Index: Source/core/svg/SVGAElement.cpp |
diff --git a/Source/core/svg/SVGAElement.cpp b/Source/core/svg/SVGAElement.cpp |
index db4f473f6baefe91c83023114670b563e06c19e8..950a1fb78450c64b440d50129c95437e317e1c26 100644 |
--- a/Source/core/svg/SVGAElement.cpp |
+++ b/Source/core/svg/SVGAElement.cpp |
@@ -32,6 +32,7 @@ |
#include "core/events/KeyboardEvent.h" |
#include "core/events/MouseEvent.h" |
#include "core/events/ThreadLocalEventNames.h" |
+#include "core/frame/FrameHost.h" |
#include "core/frame/LocalFrame.h" |
#include "core/html/HTMLAnchorElement.h" |
#include "core/html/HTMLFormElement.h" |
@@ -178,11 +179,18 @@ void SVGAElement::defaultEventHandler(Event* event) |
SVGGraphicsElement::defaultEventHandler(event); |
} |
+short SVGAElement::tabIndex() const |
+{ |
+ // Skip the supportsFocus check in SVGElement. |
+ return Element::tabIndex(); |
+} |
+ |
bool SVGAElement::supportsFocus() const |
{ |
if (rendererIsEditable()) |
return SVGGraphicsElement::supportsFocus(); |
- return true; |
+ // If not a link we should still be able to focus the element if it has tabIndex. |
+ return isLink() || SVGElement::supportsFocus(); |
} |
bool SVGAElement::isURLAttribute(const Attribute& attribute) const |
@@ -192,17 +200,29 @@ bool SVGAElement::isURLAttribute(const Attribute& attribute) const |
bool SVGAElement::isMouseFocusable() const |
{ |
- return false; |
+ // 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 SVGElement::supportsFocus(); |
+ |
+ return SVGElement::isMouseFocusable(); |
} |
bool SVGAElement::isKeyboardFocusable() const |
{ |
- if (!isFocusable()) |
- return false; |
+ if (isFocusable() && Element::supportsFocus()) |
+ return SVGElement::isKeyboardFocusable(); |
- if (Page* page = document().page()) |
- return page->chrome().client().tabsToLinks(); |
- return false; |
+ if (isLink()) |
+ return document().frameHost()->chrome().client().tabsToLinks(); |
fs
2014/03/14 16:05:12
There's a slight discrepancy here with how HTML se
|
+ return SVGElement::isKeyboardFocusable(); |
+} |
+ |
+bool SVGAElement::canStartSelection() const |
+{ |
+ if (!isLink()) |
+ return SVGElement::canStartSelection(); |
+ return rendererIsEditable(); |
} |
bool SVGAElement::willRespondToMouseClickEvents() |