Skip to content

Commit

Permalink
AX: header and footer elements should not be exposed as a contentinfo…
Browse files Browse the repository at this point in the history
… landmarks if contained within sectioning content

https://bugs.webkit.org/show_bug.cgi?id=264227
rdar://problem/117967651

Reviewed by Chris Fleizach.

As defined here:

https://w3c.github.io/html-aam/#el-footer
https://w3c.github.io/html-aam/#el-header
https://html.spec.whatwg.org/multipage/dom.html#sectioning-content

And tested by existing web platform test el-footer and el-header cases:

https://wpt.fyi/results/html-aam/roles-contextual.html

We now pass these testcases.

* LayoutTests/imported/w3c/web-platform-tests/html-aam/roles-contextual-expected.txt:
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRoleFromNode const):

Canonical link: https://commits.webkit.org/270255@main
  • Loading branch information
twilco committed Nov 6, 2023
1 parent 9b178a5 commit 46c79e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ PASS el-header-ancestorbody
PASS el-section
PASS el-a-no-href
FAIL el-aside-in-section-without-name assert_false: Computed Role: "complementary" does not match any of the acceptable role strings in ["generic", "", "none"]: <aside data-testname="el-aside-in-section-without-name" class="ex-generic">x</aside> expected false got true
FAIL el-footer assert_false: Computed Role: "contentinfo" does not match any of the acceptable role strings in ["generic", "", "none"]: <footer data-testname="el-footer" aria-label="x" class="ex-generic">x
</footer> expected false got true
FAIL el-header assert_false: Computed Role: "banner" does not match any of the acceptable role strings in ["generic", "", "none"]: <header data-testname="el-header" aria-label="x" class="ex-generic">x</header> expected false got true
PASS el-footer
PASS el-header
PASS el-section-no-name

11 changes: 6 additions & 5 deletions Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,15 +488,16 @@ AccessibilityRole AccessibilityNodeObject::determineAccessibilityRoleFromNode(Tr
if (node()->hasTagName(htmlTag))
return AccessibilityRole::Ignored;

// There should only be one banner/contentInfo per page. If header/footer are being used within an article or section
// then it should not be exposed as whole page's banner/contentInfo
if (node()->hasTagName(headerTag) && !isDescendantOfElementType({ articleTag, sectionTag }))
// There should only be one banner/contentInfo per page. If header/footer are being used within an article or section then it should not be exposed as whole page's banner/contentInfo.
// https://w3c.github.io/html-aam/#el-header
if (node()->hasTagName(headerTag) && !isDescendantOfElementType({ articleTag, asideTag, navTag, sectionTag }))
return AccessibilityRole::LandmarkBanner;

// http://webkit.org/b/190138 Footers should become contentInfo's if scoped to body (and consequently become a landmark).
// It should remain a footer if scoped to main, sectioning elements (article, section) or root sectioning element (blockquote, details, dialog, fieldset, figure, td).
// It should remain a footer if scoped to main, sectioning elements (article, aside, nav, section) or root sectioning element (blockquote, details, dialog, fieldset, figure, td).
// https://w3c.github.io/html-aam/#el-footer
if (node()->hasTagName(footerTag)) {
if (!isDescendantOfElementType({ articleTag, sectionTag, mainTag, blockquoteTag, detailsTag, fieldsetTag, figureTag, tdTag }))
if (!isDescendantOfElementType({ articleTag, asideTag, navTag, sectionTag, mainTag, blockquoteTag, detailsTag, dialogTag, fieldsetTag, figureTag, tdTag }))
return AccessibilityRole::LandmarkContentInfo;
return AccessibilityRole::Footer;
}
Expand Down

0 comments on commit 46c79e6

Please sign in to comment.