Skip to content

Commit

Permalink
AX: Fix computed role for elements: dd, details, dt, em, hgroup, opti…
Browse files Browse the repository at this point in the history
…on, s, strong

https://bugs.webkit.org/show_bug.cgi?id=271012
rdar://problem/124641956

Reviewed by Chris Fleizach.

This allows us to pass 8 more WPT subtests.

* LayoutTests/accessibility/display-contents/element-roles-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html-aam/roles-expected.txt:
* LayoutTests/platform/glib/accessibility/aria-visible-element-roles-expected.txt:
* LayoutTests/platform/glib/accessibility/display-contents/element-roles-expected.txt:
* LayoutTests/platform/glib/accessibility/lists-expected.txt:
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/html-aam/roles-expected.txt:
* LayoutTests/platform/mac-wk1/accessibility/aria-visible-element-roles-expected.txt:
* LayoutTests/platform/mac-wk1/accessibility/roles-exposed-expected.txt:
* LayoutTests/platform/mac-wk2/accessibility/aria-visible-element-roles-expected.txt:
* LayoutTests/platform/mac-wk2/accessibility/roles-exposed-expected.txt:
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRoleFromNode const):
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::initializeRoleMap):

Canonical link: https://commits.webkit.org/276240@main
  • Loading branch information
twilco committed Mar 16, 2024
1 parent a83a068 commit 8d88c73
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This test ensures elements with CSS display: contents have the correct role.

<details class="testcase" id="details"></details>
AXRole: AXGroup
computedRoleString: group
AXSubrole: AXDetails

<summary class="testcase" id="summary"></summary>
Expand All @@ -55,10 +56,12 @@ This test ensures elements with CSS display: contents have the correct role.

<dt class="testcase" id="dt"></dt>
AXRole: AXGroup
computedRoleString: term
AXSubrole: AXTerm

<dd class="testcase" id="dd"></dd>
AXRole: AXGroup
computedRoleString: definition
AXSubrole: AXDescription

<legend class="testcase" id="legend"></legend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ PASS el-article
PASS el-blockquote
PASS el-button
PASS el-code
FAIL el-dd assert_equals: <dd data-testname="el-dd" data-expectedrole="definition" class="ex">x</dd> expected "definition" but got ""
PASS el-dd
PASS el-del
FAIL el-details assert_equals: <details data-testname="el-details" data-expectedrole="group" class="ex"><summary>x</summary>x</details> expected "group" but got ""
PASS el-details
FAIL el-dfn assert_equals: <dfn data-testname="el-dfn" data-expectedrole="term" class="ex">x</dfn> expected "term" but got "definition"
FAIL el-dt assert_equals: <dt data-testname="el-dt" data-expectedrole="term" class="ex">x</dt> expected "term" but got ""
FAIL el-em assert_equals: <em data-testname="el-em" data-expectedrole="emphasis" class="ex">x</em> expected "emphasis" but got ""
PASS el-dt
PASS el-em
PASS el-fieldset
PASS el-figure
PASS el-form
Expand All @@ -73,7 +73,7 @@ PASS el-h3
PASS el-h4
PASS el-h5
PASS el-h6
FAIL el-hgroup assert_equals: <hgroup data-testname="el-hgroup" data-expectedrole="group" class="ex"><h1>x</h1></hgroup> expected "group" but got ""
PASS el-hgroup
PASS el-hr
PASS el-img
PASS el-input-button
Expand All @@ -96,14 +96,14 @@ PASS el-menu
PASS el-meter
PASS el-nav
PASS el-ol
FAIL el-option assert_equals: <option data-testname="el-option" data-expectedrole="option" class="ex">x</option> expected "option" but got ""
PASS el-option
PASS el-output
PASS el-p
PASS el-progress
FAIL el-s assert_equals: <s data-testname="el-s" data-expectedrole="deletion" class="ex">x</s> expected "deletion" but got ""
PASS el-s
PASS el-search
PASS el-select-listbox
FAIL el-strong assert_equals: <strong data-testname="el-strong" data-expectedrole="strong" class="ex">x</strong> expected "strong" but got ""
PASS el-strong
PASS el-sub
PASS el-sup
PASS el-time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ This test ensures ARIA visible elements (e.g. those with both `hidden` and `aria

<dt hidden="" aria-hidden="false" id="dt"></dt>
AXRole: AXDescriptionTerm
computedRoleString: term

<dd hidden="" aria-hidden="false" id="dd"></dd>
AXRole: AXDescriptionValue
computedRoleString: definition

<dl hidden="" aria-hidden="false" id="dl"></dl>
AXRole: AXDescriptionList
Expand Down Expand Up @@ -169,6 +171,7 @@ This test ensures ARIA visible elements (e.g. those with both `hidden` and `aria

<details hidden="" aria-hidden="false" id="details"></details>
AXRole: AXUnknown
computedRoleString: group

<summary hidden="" aria-hidden="false" id="summary"></summary>
AXRole: AXUnknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This test ensures elements with CSS display: contents have the correct role.

<details class="testcase" id="details"></details>
AXRole: AXUnknown
computedRoleString: group

<summary class="testcase" id="summary"></summary>
AXRole: AXUnknown
Expand All @@ -47,9 +48,11 @@ This test ensures elements with CSS display: contents have the correct role.

<dt class="testcase" id="dt"></dt>
AXRole: AXDescriptionTerm
computedRoleString: term

<dd class="testcase" id="dd"></dd>
AXRole: AXDescriptionValue
computedRoleString: definition

<legend class="testcase" id="legend"></legend>
AXRole: AXLabel
Expand Down
10 changes: 5 additions & 5 deletions LayoutTests/platform/glib/accessibility/lists-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ AXEnabled: 1
AXExpanded: 0
AXRequired: 0
AXChecked: 0
AXPlatformAttributes: tag:dt
AXPlatformAttributes: computed-role:term, tag:dt
------------
AXRole: AXDescriptionValue
AXParent: AXDescriptionList
Expand All @@ -202,7 +202,7 @@ AXEnabled: 1
AXExpanded: 0
AXRequired: 0
AXChecked: 0
AXPlatformAttributes: tag:dd
AXPlatformAttributes: computed-role:definition, tag:dd
------------
AXRole: AXDescriptionTerm
AXParent: AXDescriptionList
Expand All @@ -221,7 +221,7 @@ AXEnabled: 1
AXExpanded: 0
AXRequired: 0
AXChecked: 0
AXPlatformAttributes: tag:dt
AXPlatformAttributes: computed-role:term, tag:dt
------------
AXRole: AXDescriptionValue
AXParent: AXDescriptionList
Expand All @@ -240,7 +240,7 @@ AXEnabled: 1
AXExpanded: 0
AXRequired: 0
AXChecked: 0
AXPlatformAttributes: tag:dd
AXPlatformAttributes: computed-role:definition, tag:dd
------------
AXRole: AXDescriptionValue
AXParent: AXDescriptionList
Expand All @@ -259,7 +259,7 @@ AXEnabled: 1
AXExpanded: 0
AXRequired: 0
AXChecked: 0
AXPlatformAttributes: tag:dd
AXPlatformAttributes: computed-role:definition, tag:dd
------------


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ PASS el-article
PASS el-blockquote
PASS el-button
PASS el-code
FAIL el-dd assert_equals: <dd data-testname="el-dd" data-expectedrole="definition" class="ex">x</dd> expected "definition" but got ""
PASS el-dd
PASS el-del
FAIL el-details assert_equals: <details data-testname="el-details" data-expectedrole="group" class="ex"><summary>x</summary>x</details> expected "group" but got ""
PASS el-details
FAIL el-dfn assert_equals: <dfn data-testname="el-dfn" data-expectedrole="term" class="ex">x</dfn> expected "term" but got "definition"
FAIL el-dt assert_equals: <dt data-testname="el-dt" data-expectedrole="term" class="ex">x</dt> expected "term" but got ""
FAIL el-em assert_equals: <em data-testname="el-em" data-expectedrole="emphasis" class="ex">x</em> expected "emphasis" but got ""
PASS el-dt
PASS el-em
PASS el-fieldset
PASS el-figure
PASS el-form
Expand All @@ -73,7 +73,7 @@ PASS el-h3
PASS el-h4
PASS el-h5
PASS el-h6
FAIL el-hgroup assert_equals: <hgroup data-testname="el-hgroup" data-expectedrole="group" class="ex"><h1>x</h1></hgroup> expected "group" but got ""
PASS el-hgroup
PASS el-hr
PASS el-img
PASS el-input-button
Expand All @@ -96,14 +96,14 @@ PASS el-menu
PASS el-meter
PASS el-nav
PASS el-ol
FAIL el-option assert_equals: <option data-testname="el-option" data-expectedrole="option" class="ex">x</option> expected "option" but got ""
PASS el-option
PASS el-output
PASS el-p
PASS el-progress
FAIL el-s assert_equals: <s data-testname="el-s" data-expectedrole="deletion" class="ex">x</s> expected "deletion" but got ""
PASS el-s
PASS el-search
FAIL el-select-listbox assert_equals: <select data-testname="el-select-listbox" size="2" data-expectedrole="listbox" class="ex"><option>b1</option><option>b2</option></select> expected "listbox" but got "button"
FAIL el-strong assert_equals: <strong data-testname="el-strong" data-expectedrole="strong" class="ex">x</strong> expected "strong" but got ""
PASS el-strong
PASS el-sub
PASS el-sup
PASS el-time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ This test ensures ARIA visible elements (e.g. those with both `hidden` and `aria

<dt hidden="" aria-hidden="false" id="dt"></dt>
AXRole: AXGroup
computedRoleString: term
AXSubrole: AXTerm

<dd hidden="" aria-hidden="false" id="dd"></dd>
AXRole: AXGroup
computedRoleString: definition
AXSubrole: AXDescription

<dl hidden="" aria-hidden="false" id="dl"></dl>
Expand Down Expand Up @@ -192,6 +194,7 @@ This test ensures ARIA visible elements (e.g. those with both `hidden` and `aria

<details hidden="" aria-hidden="false" id="details"></details>
AXRole: AXGroup
computedRoleString: group
AXSubrole: AXDetails

<summary hidden="" aria-hidden="false" id="summary"></summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ header
AXRoleDescription: banner

hgroup
Could not get AX element.
AXRole: AXGroup
AXSubrole: AXApplicationGroup
AXRoleDescription: group

h1
AXRole: AXHeading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ This test ensures ARIA visible elements (e.g. those with both `hidden` and `aria

<dt hidden="" aria-hidden="false" id="dt"></dt>
AXRole: AXGroup
computedRoleString: term
AXSubrole: AXTerm

<dd hidden="" aria-hidden="false" id="dd"></dd>
AXRole: AXGroup
computedRoleString: definition
AXSubrole: AXDescription

<dl hidden="" aria-hidden="false" id="dl"></dl>
Expand Down Expand Up @@ -191,6 +193,7 @@ This test ensures ARIA visible elements (e.g. those with both `hidden` and `aria

<details hidden="" aria-hidden="false" id="details"></details>
AXRole: AXGroup
computedRoleString: group
AXSubrole: AXDetails

<summary hidden="" aria-hidden="false" id="summary"></summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ header
AXRoleDescription: banner

hgroup
Could not get AX element.
AXRole: AXGroup
AXSubrole: AXApplicationGroup
AXRoleDescription: group

h1
AXRole: AXHeading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ This test ensures ARIA visible elements (e.g. those with both `hidden` and `aria

<dt hidden="" aria-hidden="false" id="dt"></dt>
AXRole: AXDescriptionTerm
computedRoleString: term

<dd hidden="" aria-hidden="false" id="dd"></dd>
AXRole: AXDescriptionValue
computedRoleString: definition

<dl hidden="" aria-hidden="false" id="dl"></dl>
AXRole: AXDescriptionList
Expand Down Expand Up @@ -170,6 +172,7 @@ This test ensures ARIA visible elements (e.g. those with both `hidden` and `aria

<details hidden="" aria-hidden="false" id="details"></details>
AXRole: AXUnknown
computedRoleString: group

<summary hidden="" aria-hidden="false" id="summary"></summary>
AXRole: AXUnknown
Expand Down
8 changes: 7 additions & 1 deletion Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,16 @@ AccessibilityRole AccessibilityNodeObject::determineAccessibilityRoleFromNode(Tr

if (element->hasTagName(codeTag))
return AccessibilityRole::Code;
if (element->hasTagName(delTag))
if (element->hasTagName(delTag) || element->hasTagName(sTag))
return AccessibilityRole::Deletion;
if (element->hasTagName(insTag))
return AccessibilityRole::Insertion;
if (element->hasTagName(subTag))
return AccessibilityRole::Subscript;
if (element->hasTagName(supTag))
return AccessibilityRole::Superscript;
if (element->hasTagName(strongTag))
return AccessibilityRole::Strong;

if (element->hasTagName(kbdTag)
|| element->hasTagName(preTag)
Expand Down Expand Up @@ -508,6 +510,10 @@ AccessibilityRole AccessibilityNodeObject::determineAccessibilityRoleFromNode(Tr
return AccessibilityRole::Time;
if (element->hasTagName(hrTag))
return AccessibilityRole::HorizontalRule;
if (element->hasTagName(emTag))
return AccessibilityRole::Emphasis;
if (element->hasTagName(hgroupTag))
return AccessibilityRole::ApplicationGroup;

// If the element does not have role, but it has ARIA attributes, or accepts tab focus, accessibility should fallback to exposing it as a group.
if (supportsARIAAttributes() || canSetFocusAttribute() || element->isFocusable())
Expand Down
10 changes: 8 additions & 2 deletions Source/WebCore/accessibility/AccessibilityObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2789,9 +2789,15 @@ static void initializeRoleMap()
}

// Create specific synonyms for the computedRole which is used in WPT tests and the accessibility inspector.
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::Image), "image"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::TextArea), "textbox"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::DateTime), "textbox"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::TextArea), "textbox"_s);

gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::DescriptionListDetail), "definition"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::DescriptionListTerm), "term"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::Details), "group"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::Image), "image"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::ListBoxOption), "option"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::MenuListOption), "option"_s);
gAriaReverseRoleMap->set(enumToUnderlyingType(AccessibilityRole::Presentational), "none"_s);
}

Expand Down

0 comments on commit 8d88c73

Please sign in to comment.