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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.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
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 ChromeVox utilities for the automation extension API. 6 * @fileoverview ChromeVox utilities for the automation extension API.
7 */ 7 */
8 8
9 goog.provide('AutomationUtil'); 9 goog.provide('AutomationUtil');
10 10
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 var ancestorsB = AutomationUtil.getAncestors(nodeB); 202 var ancestorsB = AutomationUtil.getAncestors(nodeB);
203 var divergence = AutomationUtil.getDivergence(ancestorsA, ancestorsB); 203 var divergence = AutomationUtil.getDivergence(ancestorsA, ancestorsB);
204 204
205 // Default to Dir.FORWARD. 205 // Default to Dir.FORWARD.
206 if (divergence == -1) 206 if (divergence == -1)
207 return Dir.FORWARD; 207 return Dir.FORWARD;
208 208
209 var divA = ancestorsA[divergence]; 209 var divA = ancestorsA[divergence];
210 var divB = ancestorsB[divergence]; 210 var divB = ancestorsB[divergence];
211 211
212 // One of the nodes is an ancestor of the other. Don't distinguish and just 212 // One of the nodes is an ancestor of the other. Order this relationship in
213 // consider it Dir.FORWARD. 213 // the same way dfs would. nodeA <= nodeB if nodeA is a descendant of
214 if (!divA || !divB || divA.parent === nodeB || divB.parent === nodeA) 214 // nodeB. nodeA > nodeB if nodeB is a descendant of nodeA.
215
216 if (!divA)
217 return Dir.FORWARD;
218 if (!divB)
219 return Dir.BACKWARD;
220 if (divA.parent === nodeB)
221 return Dir.BACKWARD;
222 if (divB.parent === nodeA)
215 return Dir.FORWARD; 223 return Dir.FORWARD;
216 224
217 return divA.indexInParent <= divB.indexInParent ? Dir.FORWARD : Dir.BACKWARD; 225 return divA.indexInParent <= divB.indexInParent ? Dir.FORWARD : Dir.BACKWARD;
218 }; 226 };
219 227
220 /** 228 /**
221 * Determines whether the two given nodes come from the same tree source. 229 * Determines whether the two given nodes come from the same tree source.
222 * @param {AutomationNode} a 230 * @param {AutomationNode} a
223 * @param {AutomationNode} b 231 * @param {AutomationNode} b
224 * @return {boolean} 232 * @return {boolean}
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 while (root && 312 while (root &&
305 root.parent && 313 root.parent &&
306 root.parent.root && 314 root.parent.root &&
307 root.parent.root.role != RoleType.desktop) { 315 root.parent.root.role != RoleType.desktop) {
308 root = root.parent.root; 316 root = root.parent.root;
309 } 317 }
310 return root; 318 return root;
311 }; 319 };
312 320
313 }); // goog.scope 321 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698