Index: Source/core/html/HTMLFormControlElement.cpp |
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp |
index b1507544c8fa9a7242174c3d6d55b659a837c43c..dee236c296c9d574ea3944ba6b4a2add6f84bef9 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,35 @@ 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 |
+{ |
+ ASSERT(focused()); |
+ return shouldShowFocusRingOnMouseFocus() || !m_wasFocusedByMouse; |
+} |
+ |
+void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) |
+{ |
+ if (!event.isKeyboardEvent() || event.type() != eventNames().keydownEvent) |
+ return; |
+ if (!m_wasFocusedByMouse) |
+ return; |
+ m_wasFocusedByMouse = false; |
+ if (renderer()) |
+ renderer()->repaint(); |
+} |
+ |
+ |
short HTMLFormControlElement::tabIndex() const |
{ |
// Skip the supportsFocus check in HTMLElement. |