Skip to content

Commit 8ccd2ea

Browse files
Aaron LeventhalChromium LUCI CQ
authored andcommitted
[A11y] Implement minimum role from HTML-AAM
Bug: w3c/html-aam#454 Change-Id: Ia3930b068311f26f6a7e0be8bbcce53acf820bdf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5663675 Auto-Submit: Aaron Leventhal <[email protected]> Commit-Queue: Mark Schillaci <[email protected]> Commit-Queue: Aaron Leventhal <[email protected]> Reviewed-by: Mark Schillaci <[email protected]> Cr-Commit-Position: refs/heads/main@{#1320576}
1 parent f751c82 commit 8ccd2ea

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

content/browser/accessibility/dump_accessibility_tree_browsertest.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,6 +2900,10 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
29002900
RunHtmlTest(FILE_PATH_LITERAL("micro-clearfix-hack.html"));
29012901
}
29022902

2903+
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest, AccessibilityMinRole) {
2904+
RunHtmlTest(FILE_PATH_LITERAL("min-role.html"));
2905+
}
2906+
29032907
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
29042908
AccessibilityMissingRelationTargetsAddedLater) {
29052909
RunAriaTest(FILE_PATH_LITERAL("missing-relation-targets-added-later.html"));

content/test/content_test_bundle_data.filelist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4357,6 +4357,8 @@ data/accessibility/html/meter-expected-win.txt
43574357
data/accessibility/html/meter.html
43584358
data/accessibility/html/micro-clearfix-hack-expected-blink.txt
43594359
data/accessibility/html/micro-clearfix-hack.html
4360+
data/accessibility/html/min-role-expected-blink.txt
4361+
data/accessibility/html/min-role.html
43604362
data/accessibility/html/modal-dialog-and-iframes-expected-blink.txt
43614363
data/accessibility/html/modal-dialog-and-iframes.html
43624364
data/accessibility/html/modal-dialog-closed-expected-android.txt
@@ -6936,8 +6938,8 @@ data/link_rel_prefetch_disable_network.html
69366938
data/link_rel_prefetch_disable_network.html.mock-http-headers
69376939
data/link_rel_prefetch_referrer_policy.html
69386940
data/lite_js_test.mojom
6939-
data/loader/blank.html
69406941
data/loader/async_resource_handler.html
6942+
data/loader/blank.html
69416943
data/loader/change_title.js
69426944
data/loader/cors_file_origin_test.html
69436945
data/loader/cors_origin_access_list_test.html
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
rootWebArea
2+
++genericContainer ignored
3+
++++genericContainer ignored
4+
++++++group
5+
++++++++staticText name='Autofocus'
6+
++++++++++inlineTextBox name='Autofocus'
7+
++++++group
8+
++++++++staticText name='Draggable'
9+
++++++++++inlineTextBox name='Draggable'
10+
++++++genericContainer name='Tabindex=0'
11+
++++++++staticText name='Tabindex=0'
12+
++++++++++inlineTextBox name='Tabindex=0'
13+
++++++genericContainer
14+
++++++++staticText name='Tabindex=-1'
15+
++++++++++inlineTextBox name='Tabindex=-1'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<!-- Minimum role from https://github.com/w3c/html-aam/pull/454 -->
3+
<!-- autofocus gets a minimum role of group -->
4+
<div autofocus>Autofocus</div>
5+
<!-- draggable gets a minimum role of group -->
6+
<div draggable>Draggable</div>
7+
<!-- For now, tabindex does not have a minimum role. Consider having tabindex=0 using a minimum role of group -->
8+
<div tabindex="0">Tabindex=0</div>
9+
<div tabindex="-1">Tabindex=-1</div>
10+
<!-- popover targets also have a minimum role, tested in popover-api.html -->
11+

third_party/blink/renderer/modules/accessibility/ax_node_object.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,9 +1919,11 @@ ax::mojom::blink::Role AXNodeObject::RoleFromLayoutObjectOrNode() const {
19191919
}
19201920

19211921
// Minimum role:
1922-
// TODO(aleventhal) Implement all of https://github.com/w3c/html-aam/pull/454.
19231922
if (GetElement() && !GetElement()->FastHasAttribute(html_names::kRoleAttr)) {
1924-
if (IsPopup() != ax::mojom::blink::IsPopup::kNone) {
1923+
if (IsPopup() != ax::mojom::blink::IsPopup::kNone ||
1924+
GetElement()->FastHasAttribute(html_names::kAutofocusAttr) ||
1925+
GetElement()->FastHasAttribute(html_names::kDraggableAttr)) {
1926+
// TODO(accessibility) Consider for tabindex="0".
19251927
return ax::mojom::blink::Role::kGroup;
19261928
}
19271929
}

0 commit comments

Comments
 (0)