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

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

Issue 1866043004: Add a nameFromNode attrib to link output rule (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 ed30ddea829facf1be1ab742cf1c0d75b3ed5878..394260db8f0c3b4780a554ec748f7cec7d96d306 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
@@ -396,14 +396,14 @@ Output.RULES = {
braille: ''
},
abstractContainer: {
- enter: '$name $role $description',
+ enter: '$nameFromNode $role $description',
leave: '@exited_container($role)'
},
alert: {
speak: '!doNotInterrupt $role $descendants'
},
alertDialog: {
- enter: '$name $role $description $descendants'
+ enter: '$nameFromNode $role $description $descendants'
},
cell: {
enter: '@column_granularity $tableCellColumnIndex'
@@ -413,14 +413,14 @@ Output.RULES = {
'$name $role $checked $description'
},
dialog: {
- enter: '$name $role $description'
+ enter: '$nameFromNode $role $description'
},
div: {
- enter: '$name',
+ enter: '$nameFromNode',
speak: '$name $description'
},
grid: {
- enter: '$name $role $description'
+ enter: '$nameFromNode $role $description'
},
heading: {
enter: '@tag_h+$hierarchicalLevel',
@@ -431,14 +431,15 @@ Output.RULES = {
speak: '$name='
},
link: {
- enter: '$name= $if($visited, @visited_link, $role)',
+ enter: '$nameFromNode $if($visited, @visited_link, $role)',
speak: '$name= $if($visited, @visited_link, $role) $description'
},
list: {
enter: '$role @@list_with_items($countChildren(listItem))'
},
listBox: {
- enter: '$name $role @@list_with_items($countChildren(listBoxOption)) ' +
+ enter: '$nameFromNode' +
+ '$role @@list_with_items($countChildren(listBoxOption)) ' +
'$description'
},
listBoxOption: {
@@ -923,9 +924,10 @@ Output.prototype = {
* @param {string|!Object} format The output format either specified as an
* output template string or a parsed output format tree.
* @param {!Array<Spannable>} buff Buffer to receive rendered output.
+ * @param {!AutomationNode=} opt_prevNode
* @private
*/
- format_: function(node, format, buff) {
+ format_: function(node, format, buff, opt_prevNode) {
var tokens = [];
var args = null;
@@ -984,10 +986,17 @@ Output.prototype = {
this.append_(buff, text, options);
} else if (token == 'name') {
options.annotation.push(token);
- var earcon = node ? this.findEarcon_(node) : null;
+ var earcon = node ? this.findEarcon_(node, opt_prevNode) : null;
if (earcon)
options.annotation.push(earcon);
this.append_(buff, node.name, options);
+ } else if (token == 'nameFromNode') {
+ if (chrome.automation.NameFromType[node.nameFrom] ==
+ 'nameFromContents')
+ return;
+
+ options.annotation.push(token);
+ this.append_(buff, node.name, options);
} else if (token == 'nameOrDescendants') {
options.annotation.push(token);
if (node.name)
@@ -1304,7 +1313,7 @@ Output.prototype = {
var roleBlock = getMergedRoleBlock(formatPrevNode.role);
if (roleBlock.leave && localStorage['useVerboseMode'] == 'true')
- this.format_(formatPrevNode, roleBlock.leave, buff);
+ this.format_(formatPrevNode, roleBlock.leave, buff, prevNode);
}
var enterOutputs = [];
@@ -1317,7 +1326,7 @@ Output.prototype = {
if (enterRole[formatNode.role])
continue;
enterRole[formatNode.role] = true;
- this.format_(formatNode, roleBlock.enter, buff);
+ this.format_(formatNode, roleBlock.enter, buff, prevNode);
}
if (formatNode.role == 'window')
break;
@@ -1341,7 +1350,7 @@ Output.prototype = {
parentRoleBlock.speak ||
eventBlock['default'].speak;
- this.format_(node, speakFormat, buff);
+ this.format_(node, speakFormat, buff, prevNode);
},
/**
@@ -1544,16 +1553,16 @@ Output.prototype = {
* @return {Output.Action}
*/
findEarcon_: function(node, opt_prevNode) {
+ if (node === opt_prevNode)
+ return null;
+
if (this.formatOptions_.speech) {
var earconFinder = node;
var ancestors;
- if (opt_prevNode) {
- // Don't include the node itself.
+ if (opt_prevNode)
ancestors = AutomationUtil.getUniqueAncestors(opt_prevNode, node);
- ancestors.pop();
- } else {
+ else
ancestors = AutomationUtil.getAncestors(node);
- }
while (earconFinder = ancestors.pop()) {
var info = Output.ROLE_INFO_[earconFinder.role];

Powered by Google App Engine
This is Rietveld 408576698