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

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

Issue 2144593003: Merge dom node and node unit types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/i_search.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Provides output services for ChromeVox. 6 * @fileoverview Provides output services for ChromeVox.
7 */ 7 */
8 8
9 goog.provide('Output'); 9 goog.provide('Output');
10 goog.provide('Output.EventType'); 10 goog.provide('Output.EventType');
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 // Find takes two arguments: JSON query string and format string. 1075 // Find takes two arguments: JSON query string and format string.
1076 if (tree.firstChild) { 1076 if (tree.firstChild) {
1077 var jsonQuery = tree.firstChild.value; 1077 var jsonQuery = tree.firstChild.value;
1078 node = node.find( 1078 node = node.find(
1079 /** @type {Object}*/(JSON.parse(jsonQuery))); 1079 /** @type {Object}*/(JSON.parse(jsonQuery)));
1080 var formatString = tree.firstChild.nextSibling; 1080 var formatString = tree.firstChild.nextSibling;
1081 if (node) 1081 if (node)
1082 this.format_(node, formatString, buff); 1082 this.format_(node, formatString, buff);
1083 } 1083 }
1084 } else if (token == 'descendants') { 1084 } else if (token == 'descendants') {
1085 if (!node || AutomationPredicate.leaf(node)) 1085 if (!node || AutomationPredicate.leafOrStaticText(node))
1086 return; 1086 return;
1087 1087
1088 // Construct a range to the leftmost and rightmost leaves. 1088 // Construct a range to the leftmost and rightmost leaves.
1089 var leftmost = AutomationUtil.findNodePre( 1089 var leftmost = AutomationUtil.findNodePre(
1090 node, Dir.FORWARD, AutomationPredicate.leaf); 1090 node, Dir.FORWARD, AutomationPredicate.leafOrStaticText);
1091 var rightmost = AutomationUtil.findNodePre( 1091 var rightmost = AutomationUtil.findNodePre(
1092 node, Dir.BACKWARD, AutomationPredicate.leaf); 1092 node, Dir.BACKWARD, AutomationPredicate.leafOrStaticText);
1093 if (!leftmost || !rightmost) 1093 if (!leftmost || !rightmost)
1094 return; 1094 return;
1095 1095
1096 var subrange = new cursors.Range( 1096 var subrange = new cursors.Range(
1097 new cursors.Cursor(leftmost, 0), 1097 new cursors.Cursor(leftmost, cursors.NODE_INDEX),
1098 new cursors.Cursor(rightmost, 0)); 1098 new cursors.Cursor(rightmost, cursors.NODE_INDEX));
1099 var prev = null; 1099 var prev = null;
1100 if (node) 1100 if (node)
1101 prev = cursors.Range.fromNode(node); 1101 prev = cursors.Range.fromNode(node);
1102 this.range_(subrange, prev, Output.EventType.NAVIGATE, buff); 1102 this.render_(subrange, prev, Output.EventType.NAVIGATE, buff);
1103 } else if (token == 'joinedDescendants') { 1103 } else if (token == 'joinedDescendants') {
1104 var unjoined = []; 1104 var unjoined = [];
1105 this.format_(node, '$descendants', unjoined); 1105 this.format_(node, '$descendants', unjoined);
1106 this.append_(buff, unjoined.join(' '), options); 1106 this.append_(buff, unjoined.join(' '), options);
1107 } else if (token == 'role') { 1107 } else if (token == 'role') {
1108 if (localStorage['useVerboseMode'] == 'false') 1108 if (localStorage['useVerboseMode'] == 'false')
1109 return; 1109 return;
1110 1110
1111 if (this.formatOptions_.auralStyle) { 1111 if (this.formatOptions_.auralStyle) {
1112 speechProps = new Output.SpeechProperties(); 1112 speechProps = new Output.SpeechProperties();
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 if (outputContextFirst) 1304 if (outputContextFirst)
1305 this.ancestry_(node, prevNode, type, buff); 1305 this.ancestry_(node, prevNode, type, buff);
1306 this.node_(node, prevNode, type, buff); 1306 this.node_(node, prevNode, type, buff);
1307 if (!outputContextFirst) 1307 if (!outputContextFirst)
1308 this.ancestry_(node, prevNode, type, buff); 1308 this.ancestry_(node, prevNode, type, buff);
1309 if (node.location) 1309 if (node.location)
1310 this.locations_.push(node.location); 1310 this.locations_.push(node.location);
1311 return buff; 1311 return buff;
1312 }.bind(this); 1312 }.bind(this);
1313 1313
1314 while (cursor.node != range.end.node) { 1314 while (cursor.node &&
1315 range.end.node &&
1316 AutomationUtil.getDirection(cursor.node, range.end.node) ==
1317 Dir.FORWARD) {
1315 var node = cursor.node; 1318 var node = cursor.node;
1316 rangeBuff.push.apply(rangeBuff, formatNodeAndAncestors(node, prevNode)); 1319 rangeBuff.push.apply(rangeBuff, formatNodeAndAncestors(node, prevNode));
1317 prevNode = node; 1320 prevNode = node;
1318 cursor = cursor.move(cursors.Unit.NODE, 1321 cursor = cursor.move(cursors.Unit.NODE,
1319 cursors.Movement.DIRECTIONAL, 1322 cursors.Movement.DIRECTIONAL,
1320 Dir.FORWARD); 1323 Dir.FORWARD);
1321 1324
1322 // Reached a boundary. 1325 // Reached a boundary.
1323 if (cursor.node == prevNode) 1326 if (cursor.node == prevNode)
1324 break; 1327 break;
1325 } 1328 }
1326 var lastNode = range.end.node;
1327 rangeBuff.push.apply(rangeBuff, formatNodeAndAncestors(lastNode, prevNode));
1328 }, 1329 },
1329 1330
1330 /** 1331 /**
1331 * @param {!AutomationNode} node 1332 * @param {!AutomationNode} node
1332 * @param {!AutomationNode} prevNode 1333 * @param {!AutomationNode} prevNode
1333 * @param {EventType|Output.EventType} type 1334 * @param {EventType|Output.EventType} type
1334 * @param {!Array<Spannable>} buff 1335 * @param {!Array<Spannable>} buff
1335 * @private 1336 * @private
1336 */ 1337 */
1337 ancestry_: function(node, prevNode, type, buff) { 1338 ancestry_: function(node, prevNode, type, buff) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 break; 1644 break;
1644 } 1645 }
1645 earconFinder = earconFinder.parent; 1646 earconFinder = earconFinder.parent;
1646 } 1647 }
1647 } 1648 }
1648 return null; 1649 return null;
1649 } 1650 }
1650 }; 1651 };
1651 1652
1652 }); // goog.scope 1653 }); // goog.scope
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/i_search.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698