Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2975)

Unified Diff: chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js

Issue 955643006: Allows endCallbacks in tts to queue up speech in the speech queue and simplify speech output logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js
diff --git a/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js b/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js
index ef43b9ff3e11b70a469e7f1f1a1b1599b6dabb5f..67d027b77559865b8ba1bf3053040d72e70bf2eb 100644
--- a/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js
+++ b/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js
@@ -348,9 +348,7 @@ cvox.TtsBackground.prototype.startSpeakingNextItemInQueue_ = function() {
this.currentUtterance_ = this.utteranceQueue_.shift();
var utteranceId = this.currentUtterance_.id;
- this.currentUtterance_.properties['onEvent'] =
- this.currentUtterance_.properties['onEvent'] ||
- goog.bind(function(event) {
+ this.currentUtterance_.properties['onEvent'] = goog.bind(function(event) {
this.onTtsEvent_(event, utteranceId);
},
this);
@@ -400,10 +398,19 @@ cvox.TtsBackground.prototype.onTtsEvent_ = function(event, utteranceId) {
}
break;
case 'end':
+ // End callbacks could cause additional speech to queue up.
+ this.currentUtterance_ = null;
this.capturingTtsEventListeners_.forEach(function(listener) {
listener.onTtsEnd();
});
- // Intentionally falls through.
+ if (utterance.properties['endCallback']) {
+ try {
+ utterance.properties['endCallback']();
+ } catch (e) {
+ }
+ }
+ this.startSpeakingNextItemInQueue_();
+ break;
case 'interrupted':
this.cancelUtterance_(utterance);
this.currentUtterance_ = null;
@@ -457,7 +464,7 @@ cvox.TtsBackground.prototype.shouldCancel_ =
cvox.TtsBackground.prototype.cancelUtterance_ = function(utterance) {
if (utterance && utterance.properties['endCallback']) {
try {
- utterance.properties['endCallback']();
+ utterance.properties['endCallback'](true);
} catch (e) {
}
}
@@ -486,6 +493,7 @@ cvox.TtsBackground.prototype.stop = function() {
for (var i = 0; i < this.utteranceQueue_.length; i++) {
this.cancelUtterance_(this.utteranceQueue_[i]);
}
+
this.utteranceQueue_.length = 0;
chrome.tts.stop();

Powered by Google App Engine
This is Rietveld 408576698