Commit 3a747541 authored by Alice Boxhall's avatar Alice Boxhall Committed by Commit Bot

AXObject::AddHiddenChildren() is redundant.

Since we moved to primarily walking the DOM tree, we are automatically
getting aria-hidden=false elements in the tree, so we don't need to
specially add them.

Change-Id: Id44b451dc47e3baa301258254d89edb7a2bbe14e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545846Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Alice Boxhall <aboxhall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829026}
parent b2fd68e9
......@@ -2,4 +2,5 @@ android.webkit.WebView focusable focused scrollable
++android.view.View name='blockDisplay'
++android.view.View name='blockDisplay Hiddenfalse'
++android.view.View invisible
++android.view.View focusable invisible name='blockDisplay Hiddentruefocusable'
\ No newline at end of file
++android.view.View focusable invisible name='blockDisplay Hiddentruefocusable'
++android.view.View role_description='heading 1' heading invisible name='noneDisplayParent Hiddenfalse'
......@@ -5,3 +5,4 @@
++++[static] name='blockDisplay Hiddenfalse'
++[section] hidden:true
++[section] name='blockDisplay Hiddentruefocusable' hidden:true
++[heading] name='noneDisplayParent Hiddenfalse' hidden:true
......@@ -13,4 +13,6 @@ rootWebArea isLineBreakingObject=true
++++++++++inlineTextBox name='blockDisplay Hiddenfalse'
++++++genericContainer invisible
++++++genericContainer invisible name='blockDisplay Hiddentruefocusable' isLineBreakingObject=true
++++++++staticText ignored invisible name='blockDisplay Hiddentruefocusable'
\ No newline at end of file
++++++++staticText ignored invisible name='blockDisplay Hiddentruefocusable'
++++++genericContainer ignored invisible
++++++++heading invisible name='noneDisplayParent Hiddenfalse'
......@@ -4,4 +4,5 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_SECTION
++++ROLE_SYSTEM_STATICTEXT name='blockDisplay Hiddenfalse'
++IA2_ROLE_SECTION INVISIBLE hidden:true
++IA2_ROLE_SECTION name='blockDisplay Hiddentruefocusable' INVISIBLE FOCUSABLE hidden:true
\ No newline at end of file
++IA2_ROLE_SECTION name='blockDisplay Hiddentruefocusable' INVISIBLE FOCUSABLE hidden:true
++IA2_ROLE_HEADING name='noneDisplayParent Hiddenfalse' INVISIBLE hidden:true
......@@ -14,6 +14,7 @@
#blockDisplayAriaHiddenFalse {display: block;}
#noneDisplayAriaHiddenFalse {display: none;}
#blockDisplayAriaHiddenTrueFocusable {display: block;}
#noneDisplayParent {display: none;}
</style>
</head>
<body>
......@@ -24,5 +25,6 @@
<div id="blockDisplayAriaHiddenFalse" aria-hidden="false">blockDisplay Hiddenfalse</div>
<div id="noneDisplayAriaHiddenFalse" aria-hidden="false">noneDisplay Hiddenfalse</div>
<div id="blockDisplayAriaHiddenTrueFocusable" aria-hidden="true" tabindex="-1">blockDisplay Hiddentruefocusable</div>
<div id="noneDisplayParent"><h1 aria-hidden="false">noneDisplayParent Hiddenfalse</h1></div>
</body>
</html>
......@@ -3213,59 +3213,6 @@ void AXNodeObject::AddValidationMessageChild() {
children_.push_back(ax_object);
}
// Hidden children are those that are not laid out or visible, but are
// specifically marked as aria-hidden=false,
// meaning that they should be exposed to the AX hierarchy.
void AXNodeObject::AddHiddenChildren() {
Node* node = this->GetNode();
if (!node)
return;
// First do a quick run through to determine if we have any hidden nodes (most
// often we will not). If we do have hidden nodes, we need to determine where
// to insert them so they match DOM order as close as possible.
bool should_insert_hidden_nodes = false;
for (Node& child : NodeTraversal::ChildrenOf(*node)) {
if (!child.GetLayoutObject() && IsNodeAriaVisible(&child)) {
should_insert_hidden_nodes = true;
break;
}
}
if (!should_insert_hidden_nodes)
return;
// Iterate through all of the children, including those that may have already
// been added, and try to insert hidden nodes in the correct place in the DOM
// order.
unsigned insertion_index = 0;
for (Node& child : NodeTraversal::ChildrenOf(*node)) {
if (child.GetLayoutObject()) {
// Find out where the last layout sibling is located within children_.
if (AXObject* child_object =
AXObjectCache().Get(child.GetLayoutObject())) {
if (!child_object->AccessibilityIsIncludedInTree()) {
const auto& children = child_object->ChildrenIncludingIgnored();
child_object = children.size() ? children.back().Get() : nullptr;
}
if (child_object)
insertion_index = children_.Find(child_object) + 1;
continue;
}
}
if (!IsNodeAriaVisible(&child))
continue;
unsigned previous_size = children_.size();
if (insertion_index > previous_size)
insertion_index = previous_size;
InsertChild(AXObjectCache().GetOrCreate(&child), insertion_index);
insertion_index += (children_.size() - previous_size);
}
}
void AXNodeObject::AddImageMapChildren() {
LayoutBoxModelObject* css_box = GetLayoutBoxModelObject();
if (!css_box || !css_box->IsLayoutImage())
......@@ -3399,7 +3346,6 @@ void AXNodeObject::AddChildren() {
}
}
AddHiddenChildren();
AddPopupChildren();
AddRemoteSVGChildren();
AddImageMapChildren();
......
......@@ -24,5 +24,18 @@ test((t) => {
</script>
<div id="hidden-container" style="display: none">
<h2 aria-hidden="false">h2</h2>
</div>
<script>
test((t) => {
var hiddenContainer = accessibilityController.accessibleElementById("hidden-container");
assert_true(hiddenContainer.isIgnored);
assert_equals(hiddenContainer.childrenCount, 1);
var ariaVisibleH2 = hiddenContainer.childAtIndex(0);
assert_false(ariaVisibleH2.isIgnored);
}, "Elements with aria-hidden=false inside a non-rendered element should be exposed in the accessibility tree, and not ignored");
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment