Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp

Issue 2649953004: Updated descendant condition for header/footer AX role mapping. (Closed)
Patch Set: addressed review comment Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXNodeObject.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0aef97762c39958dba8bec31e74e345339f66cbf..31d6df8e3c53ef94a5a384d66c2f36898664f21c 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
@@ -420,14 +420,35 @@ const AXObject* AXNodeObject::inheritsPresentationalRoleFrom() const {
return 0;
}
+// There should only be one banner/contentInfo per page. If header/footer are
+// being used within an article, aside, nave, section, blockquote, details,
+// fieldset, figure, td, or main, then it should not be exposed as whole
+// page's banner/contentInfo.
+static HashSet<QualifiedName>& getLandmarkRolesNotAllowed() {
+ DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, landmarkRolesNotAllowed, ());
+ if (landmarkRolesNotAllowed.isEmpty()) {
+ landmarkRolesNotAllowed.add(articleTag);
+ landmarkRolesNotAllowed.add(asideTag);
+ landmarkRolesNotAllowed.add(navTag);
+ landmarkRolesNotAllowed.add(sectionTag);
+ landmarkRolesNotAllowed.add(blockquoteTag);
+ landmarkRolesNotAllowed.add(detailsTag);
+ landmarkRolesNotAllowed.add(fieldsetTag);
+ landmarkRolesNotAllowed.add(figureTag);
+ landmarkRolesNotAllowed.add(tdTag);
+ landmarkRolesNotAllowed.add(mainTag);
+ }
+ return landmarkRolesNotAllowed;
+}
+
bool AXNodeObject::isDescendantOfElementType(
- const HTMLQualifiedName& tagName) const {
+ HashSet<QualifiedName>& tagNames) const {
if (!getNode())
return false;
for (Element* parent = getNode()->parentElement(); parent;
parent = parent->parentElement()) {
- if (parent->hasTagName(tagName))
+ if (tagNames.contains(parent->tagQName()))
return true;
}
return false;
@@ -604,22 +625,14 @@ AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const {
// being used within an article or section then it should not be exposed as
// whole page's banner/contentInfo but as a group role.
if (getNode()->hasTagName(headerTag)) {
- if (isDescendantOfElementType(articleTag) ||
- isDescendantOfElementType(sectionTag) ||
- (getNode()->parentElement() &&
- getNode()->parentElement()->hasTagName(mainTag))) {
+ if (isDescendantOfElementType(getLandmarkRolesNotAllowed()))
return GroupRole;
- }
return BannerRole;
}
if (getNode()->hasTagName(footerTag)) {
- if (isDescendantOfElementType(articleTag) ||
- isDescendantOfElementType(sectionTag) ||
- (getNode()->parentElement() &&
- getNode()->parentElement()->hasTagName(mainTag))) {
+ if (isDescendantOfElementType(getLandmarkRolesNotAllowed()))
return GroupRole;
- }
return FooterRole;
}
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXNodeObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698