Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(960)

Unified 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: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLFormControlElement.cpp
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp
index 08ac138310c5ce5c1f779fb581780ac7d2b0f682..bdceeda2b3af6d6d56de136df6541d9f98e9c8b7 100644
--- a/Source/core/html/HTMLFormControlElement.cpp
+++ b/Source/core/html/HTMLFormControlElement.cpp
@@ -55,6 +55,7 @@ HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc
, m_willValidate(true)
, m_isValid(true)
, m_wasChangedSinceLastFormControlChangeEvent(false)
+ , m_wasFocusedByMouse(false)
, m_hasAutofocused(false)
{
setForm(form ? form : findFormAncestor());
@@ -321,11 +322,32 @@ bool HTMLFormControlElement::isKeyboardFocusable(KeyboardEvent*) const
return isFocusable() && document()->frame();
}
-bool HTMLFormControlElement::isMouseFocusable() const
+bool HTMLFormControlElement::shouldShowFocusRingOnMouseFocus() const
{
return false;
}
+void HTMLFormControlElement::dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection direction)
+{
+ m_wasFocusedByMouse = direction == FocusDirectionMouse;
+ HTMLElement::dispatchFocusEvent(oldFocusedNode, direction);
+}
+
+bool HTMLFormControlElement::shouldHaveFocusAppearance() const
+{
+ return shouldShowFocusRingOnMouseFocus() || !m_wasFocusedByMouse;
+}
+
+void HTMLFormControlElement::willHandleKeyDownEvent()
ojan 2013/05/31 22:48:16 Could this instead be HTMLFormControlElement::defa
tkent 2013/06/02 23:52:14 It's hard because there are many "if (event->defau
+{
+ if (!m_wasFocusedByMouse)
+ return;
+ m_wasFocusedByMouse = false;
ojan 2013/05/31 22:48:16 Do you also need to handle blur and clear this boo
tkent 2013/06/02 23:52:14 It's unnecessary. The flag should be referred only
+ if (renderer())
+ renderer()->repaint();
+}
+
+
short HTMLFormControlElement::tabIndex() const
{
// Skip the supportsFocus check in HTMLElement.

Powered by Google App Engine
This is Rietveld 408576698