Chromium Code Reviews

Side by Side Diff: Source/core/html/HTMLFormControlElement.cpp

Issue 16194013: Mouse press should focus on any types of form controls. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase, common->default, etc. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 37 matching lines...)
48 , m_disabled(false) 48 , m_disabled(false)
49 , m_isReadOnly(false) 49 , m_isReadOnly(false)
50 , m_isRequired(false) 50 , m_isRequired(false)
51 , m_valueMatchesRenderer(false) 51 , m_valueMatchesRenderer(false)
52 , m_ancestorDisabledState(AncestorDisabledStateUnknown) 52 , m_ancestorDisabledState(AncestorDisabledStateUnknown)
53 , m_dataListAncestorState(Unknown) 53 , m_dataListAncestorState(Unknown)
54 , m_willValidateInitialized(false) 54 , m_willValidateInitialized(false)
55 , m_willValidate(true) 55 , m_willValidate(true)
56 , m_isValid(true) 56 , m_isValid(true)
57 , m_wasChangedSinceLastFormControlChangeEvent(false) 57 , m_wasChangedSinceLastFormControlChangeEvent(false)
58 , m_wasFocusedByMouse(false)
58 , m_hasAutofocused(false) 59 , m_hasAutofocused(false)
59 { 60 {
60 setForm(form ? form : findFormAncestor()); 61 setForm(form ? form : findFormAncestor());
61 setHasCustomStyleCallbacks(); 62 setHasCustomStyleCallbacks();
62 } 63 }
63 64
64 HTMLFormControlElement::~HTMLFormControlElement() 65 HTMLFormControlElement::~HTMLFormControlElement()
65 { 66 {
66 } 67 }
67 68
(...skipping 246 matching lines...)
314 // HTMLElement::isFocusable handles visibility and calls suportsFocus which 315 // HTMLElement::isFocusable handles visibility and calls suportsFocus which
315 // will cover the disabled case. 316 // will cover the disabled case.
316 return HTMLElement::isFocusable(); 317 return HTMLElement::isFocusable();
317 } 318 }
318 319
319 bool HTMLFormControlElement::isKeyboardFocusable(KeyboardEvent*) const 320 bool HTMLFormControlElement::isKeyboardFocusable(KeyboardEvent*) const
320 { 321 {
321 return isFocusable() && document()->frame(); 322 return isFocusable() && document()->frame();
322 } 323 }
323 324
324 bool HTMLFormControlElement::isMouseFocusable() const 325 bool HTMLFormControlElement::shouldShowFocusRingOnMouseFocus() const
325 { 326 {
326 return false; 327 return false;
327 } 328 }
328 329
330 void HTMLFormControlElement::dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection direction)
331 {
332 m_wasFocusedByMouse = direction == FocusDirectionMouse;
333 HTMLElement::dispatchFocusEvent(oldFocusedNode, direction);
334 }
335
336 bool HTMLFormControlElement::shouldHaveFocusAppearance() const
337 {
338 ASSERT(focused());
339 return shouldShowFocusRingOnMouseFocus() || !m_wasFocusedByMouse;
340 }
341
342 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event)
343 {
344 if (!event.isKeyboardEvent() || event.type() != eventNames().keydownEvent)
345 return;
346 if (!m_wasFocusedByMouse)
347 return;
348 m_wasFocusedByMouse = false;
349 if (renderer())
350 renderer()->repaint();
351 }
352
353
329 short HTMLFormControlElement::tabIndex() const 354 short HTMLFormControlElement::tabIndex() const
330 { 355 {
331 // Skip the supportsFocus check in HTMLElement. 356 // Skip the supportsFocus check in HTMLElement.
332 return Element::tabIndex(); 357 return Element::tabIndex();
333 } 358 }
334 359
335 bool HTMLFormControlElement::recalcWillValidate() const 360 bool HTMLFormControlElement::recalcWillValidate() const
336 { 361 {
337 if (m_dataListAncestorState == Unknown) { 362 if (m_dataListAncestorState == Unknown) {
338 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancest or->parentNode()) { 363 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancest or->parentNode()) {
(...skipping 134 matching lines...)
473 } 498 }
474 499
475 void HTMLFormControlElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInf o) const 500 void HTMLFormControlElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInf o) const
476 { 501 {
477 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 502 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
478 LabelableElement::reportMemoryUsage(memoryObjectInfo); 503 LabelableElement::reportMemoryUsage(memoryObjectInfo);
479 info.addMember(m_validationMessage, "validationMessage"); 504 info.addMember(m_validationMessage, "validationMessage");
480 } 505 }
481 506
482 } // namespace Webcore 507 } // namespace Webcore
OLDNEW

Powered by Google App Engine