Skip to content

Commit

Permalink
Assign generic role to aside tag within the sectioning content elements
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=235065
rdar://problem/87391915

Reviewed by Tyler Wilcock.

This change assigns a generic ARIA role to <aside> elements when they are nested
within <aside>, <article>, <section>, or <nav> elements, aligning with the spec
(https://w3c.github.io/html-aam/#el-aside).
This follows the discussion in w3c/html-aam#512

Additionally, it introduces a check to return LandmarkComplementary when an <aside>
tag has an explicit accessible name.

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

Canonical link: https://commits.webkit.org/270509@main
  • Loading branch information
Joone Hur authored and twilco committed Nov 10, 2023
1 parent b848c9c commit 47f7dec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Expand Up @@ -12,15 +12,17 @@ x
x
x
x
x

PASS el-a
PASS el-aside-in-section-with-name
PASS el-aside-in-section-with-role
PASS el-aside-ancestorbodymain
PASS el-footer-ancestorbody
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
PASS el-aside-in-section-without-name
PASS el-footer
PASS el-header
PASS el-section-no-name
Expand Down
Expand Up @@ -25,6 +25,7 @@
<nav>
<aside data-testname="el-aside-in-section-with-name" data-expectedrole="complementary" aria-label="x" class="ex">x</aside>
<aside data-testname="el-aside-in-section-without-name" class="ex-generic">x</aside>
<aside data-testname="el-aside-in-section-with-role" data-expectedrole="complementary" class="ex" role="complementary">x</aside>
</nav>
<aside data-testname="el-aside-ancestorbodymain" data-expectedrole="complementary" class="ex">x</aside>

Expand All @@ -51,4 +52,4 @@
</script>

</body>
</html>
</html>
14 changes: 13 additions & 1 deletion Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Expand Up @@ -440,8 +440,20 @@ AccessibilityRole AccessibilityNodeObject::determineAccessibilityRoleFromNode(Tr
return AccessibilityRole::LandmarkMain;
if (node()->hasTagName(navTag))
return AccessibilityRole::LandmarkNavigation;
if (node()->hasTagName(asideTag))
if (node()->hasTagName(asideTag)) {
if (ariaRoleAttribute() == AccessibilityRole::LandmarkComplementary)
return AccessibilityRole::LandmarkComplementary;
// The aside element should not assume the complementary role when nested
// within the sectioning content elements.
// https://w3c.github.io/html-aam/#el-aside
if (isDescendantOfElementType({ asideTag, articleTag, sectionTag, navTag })) {
// Return LandmarkComplementary if the aside element has an accessible name.
if (hasAttribute(aria_labelAttr) || hasAttribute(aria_labelledbyAttr) || hasAttribute(aria_descriptionAttr) || hasAttribute(aria_describedbyAttr))
return AccessibilityRole::LandmarkComplementary;
return AccessibilityRole::Generic;
}
return AccessibilityRole::LandmarkComplementary;
}
if (node()->hasTagName(searchTag))
return AccessibilityRole::LandmarkSearch;

Expand Down

0 comments on commit 47f7dec

Please sign in to comment.