Index: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
diff --git a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
index e27a9b21a417919596fb3f24fb1126e28dc7d775..8b1f1edaeaa500df7ef422a9909ed7337bf4d37a 100644 |
--- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
+++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
@@ -40,6 +40,7 @@ |
#include "core/frame/FrameView.h" |
#include "core/html/HTMLAnchorElement.h" |
#include "core/html/HTMLDListElement.h" |
+#include "core/html/HTMLDivElement.h" |
#include "core/html/HTMLFieldSetElement.h" |
#include "core/html/HTMLFrameElementBase.h" |
#include "core/html/HTMLImageElement.h" |
@@ -461,12 +462,18 @@ AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const { |
if (!getNode()) |
return UnknownRole; |
- // HTMLAnchorElement sets isLink only when it has hrefAttr. |
- // We assume that it is also LinkRole if it has event listners even though it |
- // doesn't have hrefAttr. |
- if (getNode()->isLink() || (isHTMLAnchorElement(*getNode()) && isClickable())) |
+ // |HTMLAnchorElement| sets isLink only when it has hrefAttr. |
+ if (getNode()->isLink()) |
return LinkRole; |
+ if (isHTMLAnchorElement(*getNode())) { |
+ // We assume that an anchor element is LinkRole if it has event listners |
+ // even though it doesn't have hrefAttr. |
+ if (isClickable()) |
+ return LinkRole; |
+ return AnchorRole; |
+ } |
+ |
if (isHTMLButtonElement(*getNode())) |
return buttonRoleType(); |
@@ -660,9 +667,8 @@ AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const { |
if (isHTMLHRElement(*getNode())) |
return SplitterRole; |
- if (isFieldset()) { |
+ if (isFieldset()) |
return GroupRole; |
- } |
return UnknownRole; |
} |
@@ -980,6 +986,28 @@ bool AXNodeObject::isLink() const { |
return roleValue() == LinkRole; |
} |
+// It is not easily possible to find out if an element is the target of an |
+// in-page link. |
+// As a workaround, we check if the element is a sectioning element with an ID, |
+// or an anchor with a name. |
+bool AXNodeObject::isInPageLinkTarget() const { |
+ if (!m_node || !m_node->isElementNode()) |
+ return false; |
+ Element* element = toElement(m_node); |
+ // We exclude elements that are in the shadow DOM. |
+ if (element->containingShadowRoot()) |
+ return false; |
+ |
+ if (isHTMLAnchorElement(element)) { |
+ HTMLAnchorElement* htmlElement = toHTMLAnchorElement(element); |
+ return htmlElement->hasName() || htmlElement->hasID(); |
+ } |
+ |
+ if (element->hasID() && (isLandmarkRelated() || isHTMLDivElement(element))) |
+ return true; |
+ return false; |
+} |
+ |
bool AXNodeObject::isMenu() const { |
return roleValue() == MenuRole; |
} |