Index: Source/core/html/HTMLFormControlElement.cpp |
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp |
index 7bfb760dbaf5a986b63eeec1bcf343c0e35a22f6..851d9543b97f11d9a82d6daab8b7a8389132ea7b 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()); |
@@ -319,11 +320,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. |