Commit 7946b231 authored by Eriko Kurimoto's avatar Eriko Kurimoto Committed by Commit Bot

When menuItem is focused, menuItemCheckBox and menuItemRadio are counted.

Reference
https://chromium-review.googlesource.com/c/chromium/src/+/1158315

Bug: 821926
Change-Id: Iaf50ca97a9cceed98a915971b816ca7bdbcd515a
Reviewed-on: https://chromium-review.googlesource.com/1172307
Commit-Queue: Eriko Kurimoto <elkurin@google.com>
Reviewed-by: default avatarYuki Awano <yawano@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583960}
parent f8855f01
......@@ -468,9 +468,7 @@ Output.RULES = {
},
listMarker: {speak: `$name`},
menu: {
enter:
`$name $role
@@list_with_items($countChildren(menuItem, menuItemCheckBox, menuItemRadio))`,
enter: `$name $role `,
speak: `$name $node(activeDescendant)
$role @@list_with_items(
$countChildren(menuItem, menuItemCheckBox, menuItemRadio))
......@@ -478,20 +476,23 @@ Output.RULES = {
},
menuItem: {
speak: `$name $role $if($haspopup, @has_submenu)
@describe_index($posInSet, $setSize)
@describe_index($if($posInSet, $posInSet, $indexInParent(menuItem, menuItemCheckBox, menuItemRadio)),
$if($setSize, $setSize, $parentChildCount(menuItem, menuItemCheckBox, menuItemRadio)))
$description $state $restriction`
},
menuItemCheckBox: {
speak: `$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF))
$name $role $checked $state $restriction $description
@describe_index($posInSet, $setSize)`
@describe_index($if($posInSet, $posInSet, $indexInParent(menuItem, menuItemCheckBox, menuItemRadio)),
$if($setSize, $setSize, $parentChildCount(menuItem, menuItemCheckBox, menuItemRadio))) `
},
menuItemRadio: {
speak: `$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF))
$if($checked, @describe_radio_selected($name),
@describe_radio_unselected($name)) $state $roleDescription
$restriction
$description @describe_index($posInSet, $setSize) `
$restriction $description
@describe_index($if($posInSet, $posInSet, $indexInParent(menuItem, menuItemCheckBox, menuItemRadio)),
$if($setSize, $setSize, $parentChildCount(menuItem, menuItemCheckBox, menuItemRadio))) `
},
menuListOption: {
speak: `$name $role @describe_index($posInSet, $setSize) $state
......@@ -1221,9 +1222,17 @@ Output.prototype = {
} else if (token == 'indexInParent') {
if (node.parent) {
options.annotation.push(token);
var roles;
if (tree.firstChild) {
roles = this.createRoles_(tree);
} else {
roles = new Set();
roles.add(node.role);
}
var count = 0;
for (var i = 0, child; child = node.parent.children[i]; i++) {
if (node.role == child.role)
if (roles.has(child.role))
count++;
if (node === child)
break;
......@@ -1233,9 +1242,17 @@ Output.prototype = {
} else if (token == 'parentChildCount') {
if (node.parent) {
options.annotation.push(token);
var roles;
if (tree.firstChild) {
roles = this.createRoles_(tree);
} else {
roles = new Set();
roles.add(node.role);
}
var count = node.parent.children
.filter(function(child) {
return node.role == child.role;
return roles.has(child.role);
})
.length;
this.append_(buff, String(count));
......@@ -1480,14 +1497,11 @@ Output.prototype = {
tree.firstChild.value, node.location || undefined));
this.append_(buff, '', options);
} else if (token == 'countChildren') {
var roles = [];
var currentNode = tree.firstChild;
for (; currentNode; currentNode = currentNode.nextSibling)
roles.push(currentNode.value);
var roles = this.createRoles_(tree);
var count = node.children
.filter(function(e) {
return roles.includes(e.role);
return roles.has(e.role);
})
.length;
this.append_(buff, String(count));
......@@ -1588,6 +1602,19 @@ Output.prototype = {
}.bind(this));
},
/**
* @param {Object} tree
* @return {!Set}
* @private
*/
createRoles_: function(tree) {
var roles = new Set();
var currentNode = tree.firstChild;
for (; currentNode; currentNode = currentNode.nextSibling)
roles.add(currentNode.value);
return roles;
},
/**
* @param {!cursors.Range} range
* @param {cursors.Range} prevRange
......
......@@ -476,13 +476,13 @@ TEST_F('OutputE2ETest', 'Menu', function() {
var el = root.firstChild.firstChild;
var range = cursors.Range.fromNode(el);
var o = new Output().withSpeechAndBraille(range, null, 'navigate');
checkSpeechOutput('a|Menu item| 1 of 1 |Menu|with 3 items', [
checkSpeechOutput('a|Menu item| 1 of 3 |Menu', [
{value: 'name', start: 0, end: 1},
{value: 'role', start: 21, end: 25}], o);
checkBrailleOutput(
'a mnuitm 1/1 mnu +3',
'a mnuitm 1/3 mnu',
[{value: new Output.NodeSpan(el), start: 0, end: 12},
{value: new Output.NodeSpan(el.parent), start: 13, end: 19}],
{value: new Output.NodeSpan(el.parent), start: 13, end: 16}],
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