Index: Source/core/html/HTMLAnchorElement.cpp |
diff --git a/Source/core/html/HTMLAnchorElement.cpp b/Source/core/html/HTMLAnchorElement.cpp |
index 8aa7f7eac91f6f2094d75822d3579fb6c6128a9e..ff37ea946440a3756fe90840d4b329b4f7a31883 100644 |
--- a/Source/core/html/HTMLAnchorElement.cpp |
+++ b/Source/core/html/HTMLAnchorElement.cpp |
@@ -63,6 +63,7 @@ HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc |
: HTMLElement(tagName, document) |
, m_linkRelations(0) |
, m_cachedVisitedLinkHash(0) |
+ , m_wasFocusedByMouse(false) |
{ |
ScriptWrappable::init(this); |
} |
@@ -84,12 +85,32 @@ bool HTMLAnchorElement::supportsFocus() const |
return isLink() || HTMLElement::supportsFocus(); |
} |
+bool HTMLAnchorElement::shouldHaveFocusAppearance() const |
pdr.
2014/08/10 20:21:52
This will be the third time we've copied the exact
robwu
2014/08/10 23:37:19
Yes, certainly. A template class seems like a grea
|
+{ |
+ ASSERT(focused()); |
+ return !m_wasFocusedByMouse || HTMLElement::supportsFocus(); |
+} |
+ |
+void HTMLAnchorElement::dispatchFocusEvent(Element* oldFocusedElement, FocusType type) |
+{ |
+ if (type != FocusTypePage) |
+ m_wasFocusedByMouse = type == FocusTypeMouse; |
+ HTMLElement::dispatchFocusEvent(oldFocusedElement, type); |
+} |
+ |
+void HTMLAnchorElement::willCallDefaultEventHandler(const Event& event) |
+{ |
+ if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) |
+ return; |
+ if (!m_wasFocusedByMouse) |
+ return; |
+ m_wasFocusedByMouse = false; |
+} |
+ |
bool HTMLAnchorElement::isMouseFocusable() const |
{ |
- // Links are focusable by default, but only allow links with tabindex or contenteditable to be mouse focusable. |
- // https://bugs.webkit.org/show_bug.cgi?id=26856 |
if (isLink()) |
- return HTMLElement::supportsFocus(); |
+ return supportsFocus(); |
return HTMLElement::isMouseFocusable(); |
} |