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 = { ...@@ -468,9 +468,7 @@ Output.RULES = {
}, },
listMarker: {speak: `$name`}, listMarker: {speak: `$name`},
menu: { menu: {
enter: enter: `$name $role `,
`$name $role
@@list_with_items($countChildren(menuItem, menuItemCheckBox, menuItemRadio))`,
speak: `$name $node(activeDescendant) speak: `$name $node(activeDescendant)
$role @@list_with_items( $role @@list_with_items(
$countChildren(menuItem, menuItemCheckBox, menuItemRadio)) $countChildren(menuItem, menuItemCheckBox, menuItemRadio))
...@@ -478,20 +476,23 @@ Output.RULES = { ...@@ -478,20 +476,23 @@ Output.RULES = {
}, },
menuItem: { menuItem: {
speak: `$name $role $if($haspopup, @has_submenu) 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` $description $state $restriction`
}, },
menuItemCheckBox: { menuItemCheckBox: {
speak: `$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) speak: `$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF))
$name $role $checked $state $restriction $description $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: { menuItemRadio: {
speak: `$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) speak: `$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF))
$if($checked, @describe_radio_selected($name), $if($checked, @describe_radio_selected($name),
@describe_radio_unselected($name)) $state $roleDescription @describe_radio_unselected($name)) $state $roleDescription
$restriction $restriction $description
$description @describe_index($posInSet, $setSize) ` @describe_index($if($posInSet, $posInSet, $indexInParent(menuItem, menuItemCheckBox, menuItemRadio)),
$if($setSize, $setSize, $parentChildCount(menuItem, menuItemCheckBox, menuItemRadio))) `
}, },
menuListOption: { menuListOption: {
speak: `$name $role @describe_index($posInSet, $setSize) $state speak: `$name $role @describe_index($posInSet, $setSize) $state
...@@ -1221,9 +1222,17 @@ Output.prototype = { ...@@ -1221,9 +1222,17 @@ Output.prototype = {
} else if (token == 'indexInParent') { } else if (token == 'indexInParent') {
if (node.parent) { if (node.parent) {
options.annotation.push(token); options.annotation.push(token);
var roles;
if (tree.firstChild) {
roles = this.createRoles_(tree);
} else {
roles = new Set();
roles.add(node.role);
}
var count = 0; var count = 0;
for (var i = 0, child; child = node.parent.children[i]; i++) { for (var i = 0, child; child = node.parent.children[i]; i++) {
if (node.role == child.role) if (roles.has(child.role))
count++; count++;
if (node === child) if (node === child)
break; break;
...@@ -1233,9 +1242,17 @@ Output.prototype = { ...@@ -1233,9 +1242,17 @@ Output.prototype = {
} else if (token == 'parentChildCount') { } else if (token == 'parentChildCount') {
if (node.parent) { if (node.parent) {
options.annotation.push(token); 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 var count = node.parent.children
.filter(function(child) { .filter(function(child) {
return node.role == child.role; return roles.has(child.role);
}) })
.length; .length;
this.append_(buff, String(count)); this.append_(buff, String(count));
...@@ -1480,14 +1497,11 @@ Output.prototype = { ...@@ -1480,14 +1497,11 @@ 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 roles = []; var roles = this.createRoles_(tree);
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 roles.includes(e.role); return roles.has(e.role);
}) })
.length; .length;
this.append_(buff, String(count)); this.append_(buff, String(count));
...@@ -1588,6 +1602,19 @@ Output.prototype = { ...@@ -1588,6 +1602,19 @@ Output.prototype = {
}.bind(this)); }.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} range
* @param {cursors.Range} prevRange * @param {cursors.Range} prevRange
......
...@@ -476,13 +476,13 @@ TEST_F('OutputE2ETest', 'Menu', function() { ...@@ -476,13 +476,13 @@ TEST_F('OutputE2ETest', 'Menu', function() {
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|with 3 items', [ checkSpeechOutput('a|Menu item| 1 of 3 |Menu', [
{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 +3', 'a mnuitm 1/3 mnu',
[{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: 19}], {value: new Output.NodeSpan(el.parent), start: 13, end: 16}],
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