Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js |
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js |
index 4358b77dd6abfe1076ec29b080649a71c192a7b7..a403e971f61535ecc34ea6871777bbafb6ed896e 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js |
@@ -92,7 +92,7 @@ Output = function() { |
* @type {boolean} |
* @private |
*/ |
- this.outputContextFirst_ = localStorage['outputContextFirst'] == 'true'; |
+ this.outputContextFirst_ = false; |
}; |
/** |
@@ -106,11 +106,11 @@ Output.SPACE = ' '; |
* @const {Object<{msgId: string, |
* earconId: (string|undefined), |
* inherits: (string|undefined), |
- * ignoreAncestry: (boolean|undefined)}>} |
+ * outputContextFirst: (boolean|undefined)}>} |
* msgId: the message id of the role. |
* earconId: an optional earcon to play when encountering the role. |
* inherits: inherits rules from this role. |
- * ignoreAncestry: don't output ancestry changes when encountering this role. |
+ * outputContextFirst: where to place the context output. |
* @private |
*/ |
Output.ROLE_INFO_ = { |
@@ -119,7 +119,8 @@ Output.ROLE_INFO_ = { |
earconId: 'ALERT_NONMODAL' |
}, |
alertDialog: { |
- msgId: 'role_alertdialog' |
+ msgId: 'role_alertdialog', |
+ outputContextFirst: true |
}, |
article: { |
msgId: 'role_article', |
@@ -149,7 +150,8 @@ Output.ROLE_INFO_ = { |
inherits: 'cell' |
}, |
comboBox: { |
- msgId: 'role_combobox' |
+ msgId: 'role_combobox', |
+ earconId: 'LISTBOX' |
}, |
complementary: { |
msgId: 'role_complementary', |
@@ -168,7 +170,8 @@ Output.ROLE_INFO_ = { |
inherits: 'abstractContainer' |
}, |
dialog: { |
- msgId: 'role_dialog' |
+ msgId: 'role_dialog', |
+ outputContextFirst: true |
}, |
directory: { |
msgId: 'role_directory', |
@@ -230,7 +233,8 @@ Output.ROLE_INFO_ = { |
inherits: 'abstractContainer' |
}, |
menu: { |
- msgId: 'role_menu' |
+ msgId: 'role_menu', |
+ outputContextFirst: true |
}, |
menuBar: { |
msgId: 'role_menubar', |
@@ -268,6 +272,9 @@ Output.ROLE_INFO_ = { |
radioGroup: { |
msgId: 'role_radiogroup', |
}, |
+ rootWebArea: { |
+ outputContextFirst: true |
+ }, |
row: { |
msgId: 'role_row', |
inherits: 'abstractContainer' |
@@ -898,21 +905,24 @@ Output.prototype = { |
*/ |
go: function() { |
// Speech. |
- var queueMode = this.queueMode_; |
- this.speechBuffer_.forEach(function(buff, i, a) { |
- if (Output.forceModeForNextSpeechUtterance_ !== undefined && |
- buff.length > 0) { |
- queueMode = Output.forceModeForNextSpeechUtterance_; |
- Output.forceModeForNextSpeechUtterance_ = undefined; |
- } |
+ var queueMode = cvox.QueueMode.FLUSH; |
+ if (Output.forceModeForNextSpeechUtterance_ !== undefined) |
+ queueMode = Output.forceModeForNextSpeechUtterance_; |
+ else if (this.queueMode_ !== undefined) |
+ queueMode = this.queueMode_; |
+ |
+ if (this.speechBuffer_.length > 0) |
+ Output.forceModeForNextSpeechUtterance_ = undefined; |
+ |
+ for (var i = 0; i < this.speechBuffer_.length; i++) { |
+ var buff = this.speechBuffer_[i]; |
+ var speechProps = /** @type {Object} */( |
+ buff.getSpanInstanceOf(Output.SpeechProperties)) || {}; |
+ |
+ speechProps.category = this.speechCategory_; |
- var speechProps = {}; |
(function() { |
var scopedBuff = buff; |
- speechProps = |
- scopedBuff.getSpanInstanceOf(Output.SpeechProperties) || {}; |
- speechProps.category = this.speechCategory_; |
- |
speechProps['startCallback'] = function() { |
var actions = scopedBuff.getSpansInstanceOf(Output.Action); |
if (actions) { |
@@ -921,16 +931,15 @@ Output.prototype = { |
}); |
} |
}; |
- }.bind(this)()); |
+ }()); |
- if (this.speechEndCallback_ && i == a.length - 1) |
+ if (i == this.speechBuffer_.length - 1) |
speechProps['endCallback'] = this.speechEndCallback_; |
- else |
- speechProps['endCallback'] = null; |
+ |
cvox.ChromeVox.tts.speak( |
buff.toString(), queueMode, speechProps); |
queueMode = cvox.QueueMode.QUEUE; |
- }.bind(this)); |
+ } |
// Braille. |
if (this.brailleBuffer_.length) { |
@@ -974,6 +983,17 @@ Output.prototype = { |
if (prevRange && !prevRange.isValid()) |
prevRange = null; |
+ // Scan ancestors to get the value of |outputContextFirst|. |
+ var parent = range.start.node; |
+ while (parent && parent.root && parent.root.role != RoleType.desktop) { |
+ if (Output.ROLE_INFO_[parent.role] && |
+ Output.ROLE_INFO_[parent.role].outputContextFirst) { |
+ this.outputContextFirst_ = true; |
+ break; |
+ } |
+ parent = parent.parent; |
+ } |
+ |
if (range.isSubNode()) |
this.subNode_(range, prevRange, type, buff); |
else |
@@ -1371,11 +1391,6 @@ Output.prototype = { |
* @private |
*/ |
ancestry_: function(node, prevNode, type, buff) { |
- // Check to see if ancestry output is ignored. |
- if (Output.ROLE_INFO_[node.role] && |
- Output.ROLE_INFO_[node.role].ignoreAncestry) |
- return; |
- |
var prevUniqueAncestors = |
AutomationUtil.getUniqueAncestors(node, prevNode); |
var uniqueAncestors = AutomationUtil.getUniqueAncestors(prevNode, node); |