Commit 17fc7e48 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Improve listitem treatment in ARC++

List items in Android settings are:
1. clickable
2. have no content description
3. contain text nodes (possibly multiple)

Fixes:
1. never consider clickables as containers. ChromeVox has logic to descend into containers. For ordinary list items on the web, we usually want to treat them as containers because list items have arbitrarily nested complex structures (e.g. links, headings inside).
2. fix the computation of list item name. Previously, we only computed the name based on a tree walker that visits and stops descent into leafs or static text. Since clickables themselves are leaves, this stopped the walker from descending into the children of the list item.

Bug: b:118842617
Test: manually on ARC++ settings. Regression coverage provided by browser_tests --gtest_filter=ChromeVox*.*
Change-Id: I916c2a4187502c19d489e7c78e965523c05f6074
Reviewed-on: https://chromium-review.googlesource.com/c/1316095
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarYuki Awano <yawano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605264}
parent c3b17b57
......@@ -327,6 +327,10 @@ AutomationPredicate.container = function(node) {
if (AutomationPredicate.math(node))
return false;
// Clickables (on Android) are not containers.
if (node.clickable)
return false;
return AutomationPredicate.match({
anyRole: [
Role.GENERIC_CONTAINER, Role.DOCUMENT, Role.GROUP, Role.LIST,
......
......@@ -1519,13 +1519,22 @@ Output.prototype = {
this.format_(node, '$name', buff, ruleStr);
return;
}
if (!node.firstChild)
return;
var root = node;
var walker = new AutomationTreeWalker(node, Dir.FORWARD, {
visit: AutomationPredicate.leafOrStaticText,
leaf: AutomationPredicate.leafOrStaticText
leaf: (n) => {
// The root might be a leaf itself, but we still want to descend
// into it.
return n != root && AutomationPredicate.leafOrStaticText(n);
},
root: (r) => r == root
});
var outputStrings = [];
while (walker.next().node &&
walker.phase == AutomationTreeWalkerPhase.DESCENDANT) {
while (walker.next().node) {
if (walker.node.name)
outputStrings.push(walker.node.name);
}
......
......@@ -976,3 +976,24 @@ TEST_F('ChromeVoxOutputE2ETest', 'TextFieldObeysRoleDescription', function() {
assertEquals('circle', o.brailleOutputForTest.string_);
});
});
TEST_F('ChromeVoxOutputE2ETest', 'ARCListItem', function() {
this.runWithLoadedTree(function(root) {/*!
<div role="listitem">
<p>storage</p>
<p>128 GB</p>
</div>
*/}, function(root) {
var listitem = root.find({role: RoleType.LIST_ITEM});
Object.defineProperty(listitem, 'clickable', {
get: () => true
});
assertTrue(AutomationPredicate.leaf(listitem));
assertFalse(AutomationPredicate.container(listitem));
var o = new Output().withRichSpeechAndBraille(cursors.Range.fromNode(listitem));
assertEquals('storage 128 GB|List item|Press Search+Space to activate.',
o.speechOutputForTest.string_);
assertEquals('storage 128 GB lstitm', o.brailleOutputForTest.string_);
});
});
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