Commit 1b5a44ba authored by Eriko Kurimoto's avatar Eriko Kurimoto Committed by Commit Bot

When menu is focused, menuItemCheckBox and menuItemRadio are counted.

Bug: 821926
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ie1a0d74985a7fb689ff0d47ba9404fd15803f0f8
Reviewed-on: https://chromium-review.googlesource.com/1158315Reviewed-by: default avatarYuki Awano <yawano@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Eriko Kurimoto <elkurin@google.com>
Cr-Commit-Position: refs/heads/master@{#582084}
parent b77692bf
...@@ -468,9 +468,12 @@ Output.RULES = { ...@@ -468,9 +468,12 @@ Output.RULES = {
}, },
listMarker: {speak: `$name`}, listMarker: {speak: `$name`},
menu: { menu: {
enter: `$name $role`, enter:
`$name $role
@@list_with_items($countChildren(menuItem, menuItemCheckBox, menuItemRadio))`,
speak: `$name $node(activeDescendant) speak: `$name $node(activeDescendant)
$role @@list_with_items($countChildren(menuItem)) $role @@list_with_items(
$countChildren(menuItem, menuItemCheckBox, menuItemRadio))
$description $state $restriction` $description $state $restriction`
}, },
menuItem: { menuItem: {
...@@ -1476,10 +1479,14 @@ Output.prototype = { ...@@ -1476,10 +1479,14 @@ Output.prototype = {
tree.firstChild.value, node.location || undefined)); tree.firstChild.value, node.location || undefined));
this.append_(buff, '', options); this.append_(buff, '', options);
} else if (token == 'countChildren') { } else if (token == 'countChildren') {
var role = tree.firstChild.value; var roles = [];
var currentNode = tree.firstChild;
for (; currentNode; currentNode = currentNode.nextSibling)
roles.push(currentNode.value);
var count = node.children var count = node.children
.filter(function(e) { .filter(function(e) {
return e.role == role; return roles.includes(e.role);
}) })
.length; .length;
this.append_(buff, String(count)); this.append_(buff, String(count));
......
...@@ -468,19 +468,21 @@ TEST_F('OutputE2ETest', 'Menu', function() { ...@@ -468,19 +468,21 @@ TEST_F('OutputE2ETest', 'Menu', function() {
this.runWithLoadedTree(function() {/*! this.runWithLoadedTree(function() {/*!
<div role="menu"> <div role="menu">
<div role="menuitem">a</div> <div role="menuitem">a</div>
<div role="menuitemcheckbox">b</div>
<div role="menuitemradio">c</div>
</div> </div>
*/}, */},
function(root) { function(root) {
var el = root.firstChild.firstChild; var el = root.firstChild.firstChild;
var range = cursors.Range.fromNode(el); var range = cursors.Range.fromNode(el);
var o = new Output().withSpeechAndBraille(range, null, 'navigate'); var o = new Output().withSpeechAndBraille(range, null, 'navigate');
checkSpeechOutput('a|Menu item| 1 of 1 |Menu', [ checkSpeechOutput('a|Menu item| 1 of 1 |Menu|with 3 items', [
{value: 'name', start: 0, end: 1}, {value: 'name', start: 0, end: 1},
{value: 'role', start: 21, end: 25}], o); {value: 'role', start: 21, end: 25}], o);
checkBrailleOutput( checkBrailleOutput(
'a mnuitm 1/1 mnu', 'a mnuitm 1/1 mnu +3',
[{value: new Output.NodeSpan(el), start: 0, end: 12}, [{value: new Output.NodeSpan(el), start: 0, end: 12},
{value: new Output.NodeSpan(el.parent), start: 13, end: 16}], {value: new Output.NodeSpan(el.parent), start: 13, end: 19}],
o); o);
}); });
}); });
......
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