Skip to content

Commit

Permalink
Consider text descendants of list items as UIAControl
Browse files Browse the repository at this point in the history
IsUIAControl provides a mechanism to hide repeated content
such as text items inside of containers that have their names
generated from content, e.g.  heading, link, button, etc.
List items also have the ability to generate a name from their
contents,see AXPlatformNodeWin::ComputeListItemNameAsBstr.
ComputeListItemNameAsBstr only generates a name from the direct
children of the list item and will not traverse down the tree.
Some authors will have a div nested in a list item, both causing
the list item to not generate a name, as well as not allowing this
text to be in the UIA Content/Control tree at all.

This change remedies the situation by allowing non-direct-children
descendants of list items to be in the UIA Content/Control tree.
This will not cause repeated content as List Items only consider
direct children when computing their name from contents.

Fixed: 1298100

Change-Id: I6d35a8d5eada4f4535e33c90c162b4b5959b8fb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3465819
Reviewed-by: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
Reviewed-by: Daniel Libby <dlibby@microsoft.com>
Commit-Queue: Jacques Newman <janewman@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#972500}
  • Loading branch information
janewman authored and Chromium LUCI CQ committed Feb 17, 2022
1 parent d90543a commit 92b7433
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest, AccessibilityListItemLevel) {
RunHtmlTest(FILE_PATH_LITERAL("list-item-level.html"));
}

IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
AccessibilityListItemNestedDiv) {
RunHtmlTest(FILE_PATH_LITERAL("list-item-nested-div.html"));
}

IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
AccessibilityListItemAriaSetsizeUnknown) {
RunHtmlTest(FILE_PATH_LITERAL("list-item-aria-setsize-unknown.html"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
rootWebArea
++genericContainer ignored
++++genericContainer ignored
++++++list
++++++++listItem hierarchicalLevel=1
++++++++++listMarker name='%E2%80%A2 '
++++++++++++staticText ignored name='%E2%80%A2 '
++++++++++genericContainer
++++++++++++staticText name='tic'
++++++++++++++inlineTextBox name='tic'
++++++++listItem hierarchicalLevel=1
++++++++++listMarker name='%E2%80%A2 '
++++++++++++staticText ignored name='%E2%80%A2 '
++++++++++button name='a button'
++++++++++++staticText name='a button'
++++++++++++++inlineTextBox name='a button'
++++++++listItem hierarchicalLevel=1
++++++++++listMarker name='%E2%80%A2 '
++++++++++++staticText ignored name='%E2%80%A2 '
++++++++++genericContainer
++++++++++++staticText name='tac'
++++++++++++++inlineTextBox name='tac'
++++++++listItem hierarchicalLevel=1
++++++++++listMarker name='%E2%80%A2 '
++++++++++++staticText ignored name='%E2%80%A2 '
++++++++++genericContainer
++++++++++++staticText name='toe'
++++++++++++++inlineTextBox name='toe'
++++++++listItem hierarchicalLevel=1
++++++++++listMarker name='%E2%80%A2 '
++++++++++++staticText ignored name='%E2%80%A2 '
++++++++++link name='a link'
++++++++++++staticText name='a link'
++++++++++++++inlineTextBox name='a link'
++++++list
++++++++listItem hierarchicalLevel=1
++++++++++genericContainer
++++++++++++staticText name='tic'
++++++++++++++inlineTextBox name='tic'
++++++++listItem hierarchicalLevel=1
++++++++++button name='a button'
++++++++++++staticText name='a button'
++++++++++++++inlineTextBox name='a button'
++++++++listItem hierarchicalLevel=1
++++++++++genericContainer
++++++++++++staticText name='tac'
++++++++++++++inlineTextBox name='tac'
++++++++listItem hierarchicalLevel=1
++++++++++genericContainer
++++++++++++staticText name='toe'
++++++++++++++inlineTextBox name='toe'
++++++++listItem hierarchicalLevel=1
++++++++++link name='a link'
++++++++++++staticText name='a link'
++++++++++++++inlineTextBox name='a link'
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Document
++List
++++ListItem
++++++Text Name='%E2%80%A2 ' IsControlElement=false
++++++Group IsControlElement=false
++++++++Text Name='tic'
++++ListItem
++++++Text Name='%E2%80%A2 ' IsControlElement=false
++++++Button Name='a button'
++++ListItem
++++++Text Name='%E2%80%A2 ' IsControlElement=false
++++++Group IsControlElement=false
++++++++Text Name='tac'
++++ListItem
++++++Text Name='%E2%80%A2 ' IsControlElement=false
++++++Group IsControlElement=false
++++++++Text Name='toe'
++++ListItem
++++++Text Name='%E2%80%A2 ' IsControlElement=false
++++++Hyperlink Name='a link'
++++++++Text Name='a link' IsControlElement=false
++List
++++ListItem
++++++Group IsControlElement=false
++++++++Text Name='tic'
++++ListItem
++++++Button Name='a button'
++++ListItem
++++++Group IsControlElement=false
++++++++Text Name='tac'
++++ListItem
++++++Group IsControlElement=false
++++++++Text Name='toe'
++++ListItem
++++++Hyperlink Name='a link'
++++++++Text Name='a link' IsControlElement=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++ROLE_SYSTEM_LIST READONLY
++++ROLE_SYSTEM_LISTITEM READONLY
++++++ROLE_SYSTEM_STATICTEXT name='%E2%80%A2 '
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='tic'
++++ROLE_SYSTEM_LISTITEM READONLY
++++++ROLE_SYSTEM_STATICTEXT name='%E2%80%A2 '
++++++ROLE_SYSTEM_PUSHBUTTON name='a button' FOCUSABLE
++++ROLE_SYSTEM_LISTITEM READONLY
++++++ROLE_SYSTEM_STATICTEXT name='%E2%80%A2 '
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='tac'
++++ROLE_SYSTEM_LISTITEM READONLY
++++++ROLE_SYSTEM_STATICTEXT name='%E2%80%A2 '
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='toe'
++++ROLE_SYSTEM_LISTITEM READONLY
++++++ROLE_SYSTEM_STATICTEXT name='%E2%80%A2 '
++++++ROLE_SYSTEM_LINK name='a link' FOCUSABLE
++++++++ROLE_SYSTEM_STATICTEXT name='a link'
++ROLE_SYSTEM_LIST READONLY
++++ROLE_SYSTEM_LISTITEM READONLY
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='tic'
++++ROLE_SYSTEM_LISTITEM READONLY
++++++ROLE_SYSTEM_PUSHBUTTON name='a button' FOCUSABLE
++++ROLE_SYSTEM_LISTITEM READONLY
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='tac'
++++ROLE_SYSTEM_LISTITEM READONLY
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='toe'
++++ROLE_SYSTEM_LISTITEM READONLY
++++++ROLE_SYSTEM_LINK name='a link' FOCUSABLE
++++++++ROLE_SYSTEM_STATICTEXT name='a link'
27 changes: 27 additions & 0 deletions content/test/data/accessibility/html/list-item-nested-div.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
@BLINK-ALLOW:hierarchicalLevel*
@MAC-ALLOW:AXSubrole
-->
<html>
<style type="text/css">
.inlineList li {
display: inline;
}
</style>
<body>
<ul>
<li><div>tic</div></li>
<li><button>a button</button></li>
<li><div>tac</div></li>
<li><div>toe</div></li>
<li><a href="#">a link</a></li>
</ul>
<ul class="inlineList">
<li><div>tic</div></li>
<li><button>a button</button></li>
<li><div>tac</div></li>
<li><div>toe</div></li>
<li><a href="#">a link</a></li>
</ul>
</body>
</html>
19 changes: 13 additions & 6 deletions ui/accessibility/platform/ax_platform_node_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7098,19 +7098,26 @@ bool AXPlatformNodeWin::IsUIAControl() const {
// content is not. We want to avoid reading out a button, moving to the
// next item, and then reading out the button's text child, causing the
// text to be effectively repeated.
auto* parent = FromNativeViewAccessible(GetDelegate()->GetParent());
while (parent) {
if (IsCellOrTableHeader(parent->GetRole()))
auto* ancestor = FromNativeViewAccessible(GetDelegate()->GetParent());
while (ancestor) {
if (IsCellOrTableHeader(ancestor->GetRole()))
return false;
switch (parent->GetRole()) {
switch (ancestor->GetRole()) {
case ax::mojom::Role::kListItem:
// We only want to hide in the case that the list item is able
// to have its name generated from its children.
// See |ComputeListItemNameAsBstr|. This is only possible when the
// element is a direct child of the list item, otherwise the child
// should be exposed as a UIA Control.
return ancestor !=
FromNativeViewAccessible(GetDelegate()->GetParent());
case ax::mojom::Role::kButton:
case ax::mojom::Role::kCheckBox:
case ax::mojom::Role::kGroup:
case ax::mojom::Role::kHeading:
case ax::mojom::Role::kLineBreak:
case ax::mojom::Role::kLink:
case ax::mojom::Role::kListBoxOption:
case ax::mojom::Role::kListItem:
case ax::mojom::Role::kMenuItem:
case ax::mojom::Role::kMenuItemCheckBox:
case ax::mojom::Role::kMenuItemRadio:
Expand All @@ -7128,7 +7135,7 @@ bool AXPlatformNodeWin::IsUIAControl() const {
default:
break;
}
parent = FromNativeViewAccessible(parent->GetParent());
ancestor = FromNativeViewAccessible(ancestor->GetParent());
}
} // end of text only case.

Expand Down

0 comments on commit 92b7433

Please sign in to comment.