| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 290 |
| 291 while (root && | 291 while (root && |
| 292 root.parent && | 292 root.parent && |
| 293 root.parent.root && | 293 root.parent.root && |
| 294 root.parent.root.role != RoleType.desktop) { | 294 root.parent.root.role != RoleType.desktop) { |
| 295 root = root.parent.root; | 295 root = root.parent.root; |
| 296 } | 296 } |
| 297 return root; | 297 return root; |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 /** |
| 301 * @param {!AutomationNode} prevNode |
| 302 * @param {!AutomationNode} node |
| 303 * @return {AutomationNode} |
| 304 */ |
| 305 AutomationUtil.getLeastCommonAncestor = function(prevNode, node) { |
| 306 if (prevNode == node) |
| 307 return node; |
| 308 |
| 309 var prevAncestors = AutomationUtil.getAncestors(prevNode); |
| 310 var ancestors = AutomationUtil.getAncestors(node); |
| 311 var divergence = AutomationUtil.getDivergence(prevAncestors, ancestors); |
| 312 return ancestors[divergence - 1]; |
| 313 }; |
| 314 |
| 300 }); // goog.scope | 315 }); // goog.scope |
| OLD | NEW |