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

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

Issue 1181333005: Convert some ChromeVox functional getters to properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@traversal_root
Patch Set: Rebase Created 5 years, 4 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/cursors_test.extjs ('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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 982
983 /** 983 /**
984 * @param {!cursors.Range} range 984 * @param {!cursors.Range} range
985 * @param {cursors.Range} prevRange 985 * @param {cursors.Range} prevRange
986 * @param {chrome.automation.EventType|string} type 986 * @param {chrome.automation.EventType|string} type
987 * @param {!Array<cvox.Spannable>} rangeBuff 987 * @param {!Array<cvox.Spannable>} rangeBuff
988 * @private 988 * @private
989 */ 989 */
990 range_: function(range, prevRange, type, rangeBuff) { 990 range_: function(range, prevRange, type, rangeBuff) {
991 if (!prevRange) 991 if (!prevRange)
992 prevRange = cursors.Range.fromNode(range.getStart().getNode().root); 992 prevRange = cursors.Range.fromNode(range.start.node.root);
993 993
994 var cursor = range.getStart(); 994 var cursor = range.start;
995 var prevNode = prevRange.getStart().getNode(); 995 var prevNode = prevRange.start.node;
996 996
997 var formatNodeAndAncestors = function(node, prevNode) { 997 var formatNodeAndAncestors = function(node, prevNode) {
998 var buff = []; 998 var buff = [];
999 this.ancestry_(node, prevNode, type, buff); 999 this.ancestry_(node, prevNode, type, buff);
1000 this.node_(node, prevNode, type, buff); 1000 this.node_(node, prevNode, type, buff);
1001 if (this.formatOptions_.location) 1001 if (this.formatOptions_.location)
1002 this.locations_.push(node.location); 1002 this.locations_.push(node.location);
1003 return buff; 1003 return buff;
1004 }.bind(this); 1004 }.bind(this);
1005 1005
1006 while (cursor.getNode() != range.getEnd().getNode()) { 1006 while (cursor.node != range.end.node) {
1007 var node = cursor.getNode(); 1007 var node = cursor.node;
1008 rangeBuff.push.apply(rangeBuff, formatNodeAndAncestors(node, prevNode)); 1008 rangeBuff.push.apply(rangeBuff, formatNodeAndAncestors(node, prevNode));
1009 prevNode = node; 1009 prevNode = node;
1010 cursor = cursor.move(cursors.Unit.NODE, 1010 cursor = cursor.move(cursors.Unit.NODE,
1011 cursors.Movement.DIRECTIONAL, 1011 cursors.Movement.DIRECTIONAL,
1012 Dir.FORWARD); 1012 Dir.FORWARD);
1013 1013
1014 // Reached a boundary. 1014 // Reached a boundary.
1015 if (cursor.getNode() == prevNode) 1015 if (cursor.node == prevNode)
1016 break; 1016 break;
1017 } 1017 }
1018 var lastNode = range.getEnd().getNode(); 1018 var lastNode = range.end.node;
1019 rangeBuff.push.apply(rangeBuff, formatNodeAndAncestors(lastNode, prevNode)); 1019 rangeBuff.push.apply(rangeBuff, formatNodeAndAncestors(lastNode, prevNode));
1020 }, 1020 },
1021 1021
1022 /** 1022 /**
1023 * @param {!chrome.automation.AutomationNode} node 1023 * @param {!chrome.automation.AutomationNode} node
1024 * @param {!chrome.automation.AutomationNode} prevNode 1024 * @param {!chrome.automation.AutomationNode} prevNode
1025 * @param {chrome.automation.EventType|string} type 1025 * @param {chrome.automation.EventType|string} type
1026 * @param {!Array<cvox.Spannable>} buff 1026 * @param {!Array<cvox.Spannable>} buff
1027 * @param {!Object=} opt_exclude A list of attributes to exclude from 1027 * @param {!Object=} opt_exclude A list of attributes to exclude from
1028 * processing. 1028 * processing.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 * @param {!cursors.Range} range 1110 * @param {!cursors.Range} range
1111 * @param {cursors.Range} prevRange 1111 * @param {cursors.Range} prevRange
1112 * @param {chrome.automation.EventType|string} type 1112 * @param {chrome.automation.EventType|string} type
1113 * @param {!Array<cvox.Spannable>} buff 1113 * @param {!Array<cvox.Spannable>} buff
1114 * @private 1114 * @private
1115 */ 1115 */
1116 subNode_: function(range, prevRange, type, buff) { 1116 subNode_: function(range, prevRange, type, buff) {
1117 if (!prevRange) 1117 if (!prevRange)
1118 prevRange = range; 1118 prevRange = range;
1119 var dir = cursors.Range.getDirection(prevRange, range); 1119 var dir = cursors.Range.getDirection(prevRange, range);
1120 var prevNode = prevRange.getBound(dir).getNode(); 1120 var prevNode = prevRange.getBound(dir).node;
1121 this.ancestry_( 1121 this.ancestry_(
1122 range.getStart().getNode(), prevNode, type, buff, 1122 range.start.node, prevNode, type, buff,
1123 {stay: true, name: true, value: true}); 1123 {stay: true, name: true, value: true});
1124 var startIndex = range.getStart().getIndex(); 1124 var startIndex = range.start.getIndex();
1125 var endIndex = range.getEnd().getIndex(); 1125 var endIndex = range.end.getIndex();
1126 if (startIndex === endIndex) 1126 if (startIndex === endIndex)
1127 endIndex++; 1127 endIndex++;
1128 this.append_( 1128 this.append_(
1129 buff, range.getStart().getText().substring(startIndex, endIndex)); 1129 buff, range.start.getText().substring(startIndex, endIndex));
1130 }, 1130 },
1131 1131
1132 /** 1132 /**
1133 * Appends output to the |buff|. 1133 * Appends output to the |buff|.
1134 * @param {!Array<cvox.Spannable>} buff 1134 * @param {!Array<cvox.Spannable>} buff
1135 * @param {string|!cvox.Spannable} value 1135 * @param {string|!cvox.Spannable} value
1136 * @param {{isUnique: (boolean|undefined), 1136 * @param {{isUnique: (boolean|undefined),
1137 * annotation: !Array<*>}=} opt_options 1137 * annotation: !Array<*>}=} opt_options
1138 */ 1138 */
1139 append_: function(buff, value, opt_options) { 1139 append_: function(buff, value, opt_options) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1202 }
1203 1203
1204 if (currentNode != root) 1204 if (currentNode != root)
1205 throw 'Unbalanced parenthesis.'; 1205 throw 'Unbalanced parenthesis.';
1206 1206
1207 return root; 1207 return root;
1208 } 1208 }
1209 }; 1209 };
1210 1210
1211 }); // goog.scope 1211 }); // goog.scope
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors_test.extjs ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698