Commit a740f7ec authored by dtseng's avatar dtseng Committed by Commit bot

Fix issues with sending tts queue lots of utterances

- $descendants for div's can be very expensive. For example, in Gmail, there is a focusable div that wraps almost the entire contents of the page. We end up generating Output for everything under the div and lag significantly when focus lands here.
Fix this by only taking the text content of divs as one large string.  $descendants had all output including rich formatting.
- live region output on alerts causes double output (and similar lag). For example, pressing '?' in Gmail triggers hundreds of runs inside of LiveRegion.
Fix this by ignoring live regions set on alert nodes.

TEST=navigate in Gmail.
BUG=672955
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2563173002
Cr-Commit-Position: refs/heads/master@{#437925}
parent 67aaccae
...@@ -997,7 +997,7 @@ TEST_F('BackgroundTest', 'ContentEditableJumpSyncsRange', function() { ...@@ -997,7 +997,7 @@ TEST_F('BackgroundTest', 'ContentEditableJumpSyncsRange', function() {
}; };
mockFeedback.call(doCmd('nextEditText')) mockFeedback.call(doCmd('nextEditText'))
.expectSpeech('Top News') .expectSpeech('Top News Most Popular Sports')
.call(doCmd('nextHeading')) .call(doCmd('nextHeading'))
.expectSpeech('Top News') .expectSpeech('Top News')
.call(assertRangeHasText('Top News')) .call(assertRangeHasText('Top News'))
......
...@@ -134,6 +134,10 @@ LiveRegions.prototype = { ...@@ -134,6 +134,10 @@ LiveRegions.prototype = {
return; return;
} }
// Alerts should be announced as a result of focus.
if (node.role == RoleType.alert)
return;
var range = cursors.Range.fromNode(node); var range = cursors.Range.fromNode(node);
var output = new Output(); var output = new Output();
if (opt_prependFormatStr) if (opt_prependFormatStr)
......
...@@ -109,9 +109,7 @@ TEST_F('LiveRegionsTest', 'LiveRegionChangeAtomic', function() { ...@@ -109,9 +109,7 @@ TEST_F('LiveRegionsTest', 'LiveRegionChangeAtomic', function() {
function(rootNode) { function(rootNode) {
var go = rootNode.find({ role: RoleType.button }); var go = rootNode.find({ role: RoleType.button });
mockFeedback.call(go.doDefault.bind(go)) mockFeedback.call(go.doDefault.bind(go))
.expectCategoryFlushSpeech('Alpha') .expectCategoryFlushSpeech('Alpha Bravo Charlie')
.expectQueuedSpeech('Bravo')
.expectQueuedSpeech('Charlie');
mockFeedback.replay(); mockFeedback.replay();
}); });
}); });
......
...@@ -397,11 +397,12 @@ Output.RULES = { ...@@ -397,11 +397,12 @@ Output.RULES = {
leave: '@exited_container($role)' leave: '@exited_container($role)'
}, },
alert: { alert: {
speak: '$earcon(ALERT_NONMODAL) $role $descendants $state' enter: '$name $role $state',
speak: '$earcon(ALERT_NONMODAL) $role $nameOrTextContent $state'
}, },
alertDialog: { alertDialog: {
enter: '$earcon(ALERT_MODAL) $name $state', enter: '$earcon(ALERT_MODAL) $name $state',
speak: '$earcon(ALERT_MODAL) $name $descendants $state $role' speak: '$earcon(ALERT_MODAL) $name $nameOrTextContent $state $role'
}, },
cell: { cell: {
enter: '@cell_summary($tableCellRowIndex, $tableCellColumnIndex) ' + enter: '@cell_summary($tableCellRowIndex, $tableCellColumnIndex) ' +
...@@ -524,7 +525,7 @@ Output.RULES = { ...@@ -524,7 +525,7 @@ Output.RULES = {
enter: '$node(tableRowHeader)' enter: '$node(tableRowHeader)'
}, },
rowHeader: { rowHeader: {
speak: '$descendants $state' speak: '$nameOrTextContent $state'
}, },
slider: { slider: {
speak: '$earcon(SLIDER) @describe_slider($value, $name) $description ' + speak: '$earcon(SLIDER) @describe_slider($value, $name) $description ' +
...@@ -547,7 +548,7 @@ Output.RULES = { ...@@ -547,7 +548,7 @@ Output.RULES = {
'$node(tableHeader)' '$node(tableHeader)'
}, },
tableHeaderContainer: { tableHeaderContainer: {
speak: '$descendants $state $description' speak: '$nameOrTextContent $state $description'
}, },
textField: { textField: {
speak: '$name $value $if($multiline, @tag_textarea, $if(' + speak: '$name $value $if($multiline, @tag_textarea, $if(' +
...@@ -601,7 +602,7 @@ Output.RULES = { ...@@ -601,7 +602,7 @@ Output.RULES = {
alert: { alert: {
default: { default: {
speak: '$earcon(ALERT_NONMODAL) @role_alert ' + speak: '$earcon(ALERT_NONMODAL) @role_alert ' +
'$if($name, $name, $descendants) $description' '$nameOrTextContent $description'
} }
} }
}; };
...@@ -1236,11 +1237,14 @@ Output.prototype = { ...@@ -1236,11 +1237,14 @@ Output.prototype = {
Dir.FORWARD, Dir.FORWARD,
{visit: AutomationPredicate.leafOrStaticText, {visit: AutomationPredicate.leafOrStaticText,
leaf: AutomationPredicate.leafOrStaticText}); leaf: AutomationPredicate.leafOrStaticText});
var outputStrings = [];
while (walker.next().node && while (walker.next().node &&
walker.phase == AutomationTreeWalkerPhase.DESCENDANT) { walker.phase == AutomationTreeWalkerPhase.DESCENDANT) {
if (walker.node.name) if (walker.node.name)
this.append_(buff, walker.node.name, options); outputStrings.push(walker.node.name);
} }
var joinedOutput = outputStrings.join(' ');
this.append_(buff, joinedOutput, options);
} }
} else if (node[token] !== undefined) { } else if (node[token] !== undefined) {
options.annotation.push(token); options.annotation.push(token);
......
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