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

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

Issue 2649373002: Re-land: Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Fix presubmit 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 63f4ae557c62bed6977be5276fbc2c49921dfccb..45720681c6992464733303b54d62854abd3e0f93 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
@@ -1003,7 +1004,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) {
@@ -1069,20 +1070,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) {
@@ -1105,7 +1105,7 @@ Output.prototype = {
this.append_(buff, node.description || '', 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 =
@@ -1117,23 +1117,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);
@@ -1168,22 +1167,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);
@@ -1230,7 +1232,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;
@@ -1285,7 +1287,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);
}
var msgId =
this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' :
@@ -1307,7 +1310,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;
@@ -1474,7 +1478,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 = [];
}
@@ -1638,7 +1642,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();
@@ -1781,7 +1785,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');
@@ -1832,7 +1836,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