| OLD | NEW |
| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 * Returns an array containing ancestors of node starting at root down to node. | 141 * Returns an array containing ancestors of node starting at root down to node. |
| 142 * @param {!AutomationNode} node | 142 * @param {!AutomationNode} node |
| 143 * @return {!Array<AutomationNode>} | 143 * @return {!Array<AutomationNode>} |
| 144 */ | 144 */ |
| 145 AutomationUtil.getAncestors = function(node) { | 145 AutomationUtil.getAncestors = function(node) { |
| 146 var ret = []; | 146 var ret = []; |
| 147 var candidate = node; | 147 var candidate = node; |
| 148 while (candidate) { | 148 while (candidate) { |
| 149 ret.push(candidate); | 149 ret.push(candidate); |
| 150 | 150 |
| 151 if (!AutomationUtil.isInSameTree(candidate, candidate.parent)) | |
| 152 break; | |
| 153 | |
| 154 candidate = candidate.parent; | 151 candidate = candidate.parent; |
| 155 } | 152 } |
| 156 return ret.reverse(); | 153 return ret.reverse(); |
| 157 }; | 154 }; |
| 158 | 155 |
| 159 /** | 156 /** |
| 160 * Gets the first index where the two input arrays differ. Returns -1 if they | 157 * Gets the first index where the two input arrays differ. Returns -1 if they |
| 161 * do not. | 158 * do not. |
| 162 * @param {!Array<AutomationNode>} ancestorsA | 159 * @param {!Array<AutomationNode>} ancestorsA |
| 163 * @param {!Array<AutomationNode>} ancestorsB | 160 * @param {!Array<AutomationNode>} ancestorsB |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 * @return {boolean} | 273 * @return {boolean} |
| 277 */ | 274 */ |
| 278 AutomationUtil.isDescendantOf = function(node, ancestor) { | 275 AutomationUtil.isDescendantOf = function(node, ancestor) { |
| 279 var testNode = node; | 276 var testNode = node; |
| 280 while (testNode && testNode !== ancestor) | 277 while (testNode && testNode !== ancestor) |
| 281 testNode = testNode.parent; | 278 testNode = testNode.parent; |
| 282 return testNode === ancestor; | 279 return testNode === ancestor; |
| 283 }; | 280 }; |
| 284 | 281 |
| 285 }); // goog.scope | 282 }); // goog.scope |
| OLD | NEW |