Commit 33ed77d6 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Revert "Improve ChromeVox continuous read"

This reverts commit 743f4e9d.

In extended usage, this doesn't work well for long text blocks. Stopping speech, ChromeVox is immediately brought to the end of that entire block. We need timepointing from tts to help here.

TBR=dtseng@chromium.org

Change-Id: I6fe2503618fefe35d9043453c56edfa4c05e9653
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2493121Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820055}
parent 53830064
......@@ -2721,51 +2721,6 @@ TEST_F('ChromeVoxBackgroundTest', 'SwipeToScrollByPage', function() {
});
});
TEST_F('ChromeVoxBackgroundTest', 'ReadFromHereAccumulatesText', function() {
this.runWithLoadedTree(
`
<p>start</p>
<p><span>hi</span><span>there</span></p>
<p><span lang="es">hola</span><span>there</span></p>
<p>goodbye</p>
`,
async function(root) {
// Flip on language switching and fake out voices needed by the test.
localStorage['languageSwitching'] = 'true';
LocaleOutputHelper.instance.availableVoices_ =
[{lang: 'en-US'}, {lang: 'es'}];
const expectedText = [
{text: 'hi there'}, {text: 'espa\u00f1ol: hola', lang: 'es'},
{text: 'English (United States): there'}, {text: 'goodbye'}
];
await new Promise(resolve => {
// Due to the way the text accumulates, we can't use MockFeedback here
// which only executes the speech end callback when the text is
// matched.
const keepWaiting = (text, queueMode, props) => {
if (text == expectedText[0].text) {
if (expectedText[0].lang) {
assertEquals(props.lang, expectedText[0].lang);
}
expectedText.shift();
}
if (expectedText.length == 0) {
resolve();
return;
}
const callback = props['endCallback'];
if (callback) {
callback();
}
};
ChromeVox.tts.speak = keepWaiting;
doCmd('readFromHere')();
});
});
});
TEST_F('ChromeVoxBackgroundTest', 'PointerOnOffOnRepeatsNode', function() {
PointerHandler.MIN_NO_POINTER_ANCHOR_SOUND_DELAY_MS = -1;
const mockFeedback = this.createMockFeedback();
......
......@@ -680,7 +680,6 @@ CommandHandler.onCommand = function(command) {
}
} break;
case 'readFromHere':
const accumulatedText = [];
ChromeVoxState.isReadingContinuously = true;
const continueReading = function() {
if (!ChromeVoxState.isReadingContinuously ||
......@@ -689,43 +688,17 @@ CommandHandler.onCommand = function(command) {
}
const prevRange = ChromeVoxState.instance.currentRange;
const prevNode = prevRange.start.node;
const prevLocale = prevNode.detectedLanguage || prevNode.language;
const newRange = ChromeVoxState.instance.currentRange.move(
cursors.Unit.NODE, Dir.FORWARD);
const newNode = newRange.start.node;
const newLocale = newNode.detectedLanguage || newNode.language;
// Speak the accumulated text immediately if the new range is not text
// or we've crossed out of the same parent, or if the language changed.
const differentParent = newNode.parent != prevNode.parent;
if (accumulatedText.length &&
(!AutomationPredicate.text(newNode) || differentParent ||
newLocale != prevLocale)) {
const text = accumulatedText.join(' ');
accumulatedText.length = 0;
new Output()
.withString(text, prevRange.start.node)
.onSpeechEnd(continueReading)
.go();
return;
}
// Stop if we've wrapped back to the document.
if (AutomationPredicate.root(newNode)) {
const maybeDoc = newRange.start.node;
if (AutomationPredicate.root(maybeDoc)) {
ChromeVoxState.isReadingContinuously = false;
return;
}
ChromeVoxState.instance.setCurrentRange(newRange);
// Accumulate the name of text nodes. It will be read above.
if (AutomationPredicate.text(newNode)) {
accumulatedText.push(newNode.name);
continueReading();
return;
}
newRange.select();
const o = new Output()
......
......@@ -332,17 +332,10 @@ Output = class {
/**
* Output a string literal.
* @param {string} value
* @param {AutomationNode=} opt_contextNode A node to help contextualize
* |value| e.g. for locale detection.
* @return {!Output}
*/
withString(value, opt_contextNode) {
if (opt_contextNode && localStorage['languageSwitching'] === 'true') {
this.assignLocaleAndAppend_(
value, opt_contextNode, this.speechBuffer_, {annotation: []});
} else {
this.append_(this.speechBuffer_, value);
}
withString(value) {
this.append_(this.speechBuffer_, value);
this.append_(this.brailleBuffer_, value);
this.speechRulesStr_.write('withString: ' + value + '\n');
this.brailleRulesStr_.write('withString: ' + value + '\n');
......
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