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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js

Issue 2601333002: Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Address lots of feedback Created 3 years, 11 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/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 1d12d9d05e93e447ea9745c8c5449f9a51b542ef..d435ab54be1b5490ca014e4eb1d8a53d2b76ee3a 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
@@ -30,6 +30,7 @@ var AutomationNode = chrome.automation.AutomationNode;
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
@@ -985,7 +986,7 @@ Output.prototype = {
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) {
@@ -1051,20 +1052,19 @@ Output.prototype = {
// All possible tokens based on prefix.
if (prefix == '$') {
if (token == 'value') {
- var text = node.value;
- if (!node.state.editable && node.name == text)
+ var text = node.value || '';
+ if (!node.state[StateType.EDITABLE] && node.name == text)
return;
var selectedText = '';
- 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);
- }
+ 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);
}
options.annotation.push(token);
if (selectedText && !this.formatOptions_.braille) {
@@ -1078,10 +1078,10 @@ Output.prototype = {
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,23 +1093,22 @@ Output.prototype = {
}
this.append_(buff, filename, options);
} else if (token == 'nameFromNode') {
- if (chrome.automation.NameFromType[node.nameFrom] ==
- 'contents')
+ if (node.nameFrom == chrome.automation.NameFromType.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);
@@ -1144,22 +1143,25 @@ Output.prototype = {
msg = 'aria_checked_false';
break;
default:
- msg =
- node.state.checked ? 'aria_checked_true' : 'aria_checked_false';
+ msg = node.state[StateType.CHECKED] ?
+ 'aria_checked_true' : 'aria_checked_false';
}
this.format_(node, '@' + msg, buff);
} else if (token == 'state') {
- Object.getOwnPropertyNames(node.state).forEach(function(s) {
- var stateInfo = Output.STATE_INFO_[s];
- if (stateInfo && !stateInfo.isRoleSpecific && stateInfo.on)
+ if (node.state) {
+ 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 {Object}*/(JSON.parse(jsonQuery)));
+ /** @type {chrome.automation.FindParams}*/(
+ JSON.parse(jsonQuery)));
var formatString = tree.firstChild.nextSibling;
if (node)
this.format_(node, formatString, buff);
@@ -1206,7 +1208,7 @@ Output.prototype = {
} 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;
@@ -1261,7 +1263,8 @@ Output.prototype = {
return;
if (this.formatOptions_.speech && resolvedInfo.earconId) {
options.annotation.push(
- new Output.EarconAction(resolvedInfo.earconId), node.location);
+ new Output.EarconAction(resolvedInfo.earconId),
+ node.location || undefined);
Dan Beam 2017/01/11 23:04:26 i'm not exactly sure why you need to do this. is
dmazzoni 2017/01/11 23:23:57 Because the externs file says that node.location c
}
var msgId =
this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' :
@@ -1283,7 +1286,8 @@ Output.prototype = {
return;
options.annotation.push(
- new Output.EarconAction(tree.firstChild.value, node.location));
+ new Output.EarconAction(tree.firstChild.value,
+ node.location || undefined));
this.append_(buff, '', options);
} else if (token == 'countChildren') {
var role = tree.firstChild.value;
@@ -1450,7 +1454,7 @@ Output.prototype = {
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 = [];
}
@@ -1614,7 +1618,7 @@ Output.prototype = {
options.annotation.push(earcon);
var text = '';
- if (this.formatOptions_.braille && !node.state.editable) {
+ if (this.formatOptions_.braille && !node.state[StateType.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();
@@ -1757,7 +1761,7 @@ Output.prototype = {
if (!s.node)
return false;
return s.node.display == 'inline' ||
- s.node.role == RoleType.inlineTextBox;
+ s.node.role == RoleType.INLINE_TEXT_BOX;
});
var isName = cur.hasSpan('name');
@@ -1808,7 +1812,8 @@ Output.prototype = {
while (earconFinder = ancestors.pop()) {
var info = Output.ROLE_INFO_[earconFinder.role];
if (info && info.earconId) {
- return new Output.EarconAction(info.earconId, node.location);
+ return new Output.EarconAction(info.earconId,
+ node.location || undefined);
break;
}
earconFinder = earconFinder.parent;

Powered by Google App Engine
This is Rietveld 408576698