Chromium Code Reviews| 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 5053e3eaa886c2e212bf665d15b599d96c86b932..3c62ca3c6f39d1055467c271521c3721080df497 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
| @@ -408,14 +408,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>& getLandmarkRoleBlocked() { |
|
dmazzoni
2017/02/02 16:40:06
Just for consistency, either call the function get
je_julie
2017/02/03 08:32:45
I updated with getLandmarkRolesNotAllowed() and la
|
| + DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, landmarksRoleNotAllowed, ()); |
| + if (landmarksRoleNotAllowed.isEmpty()) { |
| + landmarksRoleNotAllowed.add(articleTag); |
| + landmarksRoleNotAllowed.add(asideTag); |
| + landmarksRoleNotAllowed.add(navTag); |
| + landmarksRoleNotAllowed.add(sectionTag); |
| + landmarksRoleNotAllowed.add(blockquoteTag); |
| + landmarksRoleNotAllowed.add(detailsTag); |
| + landmarksRoleNotAllowed.add(fieldsetTag); |
| + landmarksRoleNotAllowed.add(figureTag); |
| + landmarksRoleNotAllowed.add(tdTag); |
| + landmarksRoleNotAllowed.add(mainTag); |
| + } |
| + return landmarksRoleNotAllowed; |
| +} |
| + |
| 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; |
| @@ -592,22 +613,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(getLandmarkRoleBlocked())) |
| return GroupRole; |
| - } |
| return BannerRole; |
| } |
| if (getNode()->hasTagName(footerTag)) { |
| - if (isDescendantOfElementType(articleTag) || |
| - isDescendantOfElementType(sectionTag) || |
| - (getNode()->parentElement() && |
| - getNode()->parentElement()->hasTagName(mainTag))) { |
| + if (isDescendantOfElementType(getLandmarkRoleBlocked())) |
| return GroupRole; |
| - } |
| return FooterRole; |
| } |