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 d435ab54be1b5490ca014e4eb1d8a53d2b76ee3a..1d12d9d05e93e447ea9745c8c5449f9a51b542ef 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js |
@@ -30,7 +30,6 @@ |
var Dir = constants.Dir; |
var EventType = chrome.automation.EventType; |
var RoleType = chrome.automation.RoleType; |
-var StateType = chrome.automation.StateType; |
/** |
* An Output object formats a cursors.Range into speech, braille, or both |
@@ -986,7 +985,7 @@ |
return; |
var uniqueAncestors = AutomationUtil.getUniqueAncestors(prevParent, parent); |
for (var i = 0; parent = uniqueAncestors[i]; i++) { |
- if (parent.role == RoleType.WINDOW) |
+ if (parent.role == RoleType.window) |
break; |
if (Output.ROLE_INFO_[parent.role] && |
Output.ROLE_INFO_[parent.role].outputContextFirst) { |
@@ -1052,19 +1051,20 @@ |
// All possible tokens based on prefix. |
if (prefix == '$') { |
if (token == 'value') { |
- var text = node.value || ''; |
- if (!node.state[StateType.EDITABLE] && node.name == text) |
+ var text = node.value; |
+ if (!node.state.editable && node.name == text) |
return; |
var selectedText = ''; |
- if (node.textSelStart !== undefined) { |
- options.annotation.push(new Output.SelectionSpan( |
- node.textSelStart || 0, |
- node.textSelEnd || 0)); |
- |
- selectedText = |
- node.value.substring(node.textSelStart || 0, |
- node.textSelEnd || 0); |
+ if (text !== undefined) { |
+ if (node.textSelStart !== undefined) { |
+ options.annotation.push(new Output.SelectionSpan( |
+ node.textSelStart, |
+ node.textSelEnd)); |
+ |
+ selectedText = |
+ node.value.substring(node.textSelStart, node.textSelEnd); |
+ } |
} |
options.annotation.push(token); |
if (selectedText && !this.formatOptions_.braille) { |
@@ -1078,10 +1078,10 @@ |
var earcon = node ? this.findEarcon_(node, opt_prevNode) : null; |
if (earcon) |
options.annotation.push(earcon); |
- this.append_(buff, node.name || '', options); |
+ this.append_(buff, node.name, options); |
} else if (token == 'urlFilename') { |
options.annotation.push('name'); |
- var url = node.url || ''; |
+ var url = node.url; |
var filename = ''; |
if (url.substring(0, 4) != 'data') { |
filename = |
@@ -1093,22 +1093,23 @@ |
} |
this.append_(buff, filename, options); |
} else if (token == 'nameFromNode') { |
- if (node.nameFrom == chrome.automation.NameFromType.CONTENTS) |
+ if (chrome.automation.NameFromType[node.nameFrom] == |
+ 'contents') |
return; |
options.annotation.push('name'); |
- this.append_(buff, node.name || '', options); |
+ this.append_(buff, node.name, options); |
} else if (token == 'nameOrDescendants') { |
options.annotation.push(token); |
if (node.name) |
- this.append_(buff, node.name || '', options); |
+ this.append_(buff, node.name, options); |
else |
this.format_(node, '$descendants', buff); |
} else if (token == 'description') { |
if (node.name == node.description || node.value == node.description) |
return; |
options.annotation.push(token); |
- this.append_(buff, node.description || '', options); |
+ this.append_(buff, node.description, options); |
} else if (token == 'indexInParent') { |
if (node.parent) { |
options.annotation.push(token); |
@@ -1143,25 +1144,22 @@ |
msg = 'aria_checked_false'; |
break; |
default: |
- msg = node.state[StateType.CHECKED] ? |
- 'aria_checked_true' : 'aria_checked_false'; |
+ msg = |
+ node.state.checked ? 'aria_checked_true' : 'aria_checked_false'; |
} |
this.format_(node, '@' + msg, buff); |
} else if (token == 'state') { |
- if (node.state) { |
- Object.getOwnPropertyNames(node.state).forEach(function(s) { |
- var stateInfo = Output.STATE_INFO_[s]; |
- if (stateInfo && !stateInfo.isRoleSpecific && stateInfo.on) |
+ Object.getOwnPropertyNames(node.state).forEach(function(s) { |
+ var stateInfo = Output.STATE_INFO_[s]; |
+ if (stateInfo && !stateInfo.isRoleSpecific && stateInfo.on) |
this.format_(node, '@' + stateInfo.on.msgId, buff); |
- }.bind(this)); |
- } |
+ }.bind(this)); |
} else if (token == 'find') { |
// Find takes two arguments: JSON query string and format string. |
if (tree.firstChild) { |
var jsonQuery = tree.firstChild.value; |
node = node.find( |
- /** @type {chrome.automation.FindParams}*/( |
- JSON.parse(jsonQuery))); |
+ /** @type {Object}*/(JSON.parse(jsonQuery))); |
var formatString = tree.firstChild.nextSibling; |
if (node) |
this.format_(node, formatString, buff); |
@@ -1208,7 +1206,7 @@ |
} else { |
console.error('Missing role info for ' + node.role); |
} |
- this.append_(buff, msg || '', options); |
+ this.append_(buff, msg, options); |
} else if (token == 'inputType') { |
if (!node.inputType) |
return; |
@@ -1263,8 +1261,7 @@ |
return; |
if (this.formatOptions_.speech && resolvedInfo.earconId) { |
options.annotation.push( |
- new Output.EarconAction(resolvedInfo.earconId), |
- node.location || undefined); |
+ new Output.EarconAction(resolvedInfo.earconId), node.location); |
} |
var msgId = |
this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' : |
@@ -1286,8 +1283,7 @@ |
return; |
options.annotation.push( |
- new Output.EarconAction(tree.firstChild.value, |
- node.location || undefined)); |
+ new Output.EarconAction(tree.firstChild.value, node.location)); |
this.append_(buff, '', options); |
} else if (token == 'countChildren') { |
var role = tree.firstChild.value; |
@@ -1454,7 +1450,7 @@ |
for (i = 0; i < ancestors.length - 1; i++) { |
var node = ancestors[i]; |
// Discard ancestors of deepest window. |
- if (node.role == RoleType.WINDOW) { |
+ if (node.role == RoleType.window) { |
contextFirst = []; |
rest = []; |
} |
@@ -1618,7 +1614,7 @@ |
options.annotation.push(earcon); |
var text = ''; |
- if (this.formatOptions_.braille && !node.state[StateType.EDITABLE]) { |
+ if (this.formatOptions_.braille && !node.state.editable) { |
// In braille, we almost always want to show the entire contents and |
// simply place the cursor under the SelectionSpan we set above. |
text = range.start.getText(); |
@@ -1761,7 +1757,7 @@ |
if (!s.node) |
return false; |
return s.node.display == 'inline' || |
- s.node.role == RoleType.INLINE_TEXT_BOX; |
+ s.node.role == RoleType.inlineTextBox; |
}); |
var isName = cur.hasSpan('name'); |
@@ -1812,8 +1808,7 @@ |
while (earconFinder = ancestors.pop()) { |
var info = Output.ROLE_INFO_[earconFinder.role]; |
if (info && info.earconId) { |
- return new Output.EarconAction(info.earconId, |
- node.location || undefined); |
+ return new Output.EarconAction(info.earconId, node.location); |
break; |
} |
earconFinder = earconFinder.parent; |