| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 root: undefined, | 96 root: undefined, |
| 97 visit: undefined, | 97 visit: undefined, |
| 98 skipInitialSubtree: !AutomationPredicate.container(cur)}; | 98 skipInitialSubtree: !AutomationPredicate.container(cur)}; |
| 99 restrictions.leaf = opt_restrictions.leaf || function(node) { | 99 restrictions.leaf = opt_restrictions.leaf || function(node) { |
| 100 // Treat nodes matched by |pred| as leaves except for containers. | 100 // Treat nodes matched by |pred| as leaves except for containers. |
| 101 return !AutomationPredicate.container(node) && pred(node); | 101 return !AutomationPredicate.container(node) && pred(node); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 restrictions.root = opt_restrictions.root || AutomationUtil.isTraversalRoot; | 104 restrictions.root = opt_restrictions.root || AutomationUtil.isTraversalRoot; |
| 105 restrictions.skipInitialSubtree = opt_restrictions.skipInitialSubtree; | 105 restrictions.skipInitialSubtree = opt_restrictions.skipInitialSubtree; |
| 106 restrictions.skipInitialAncestry = opt_restrictions.skipInitialAncestry; |
| 106 | 107 |
| 107 restrictions.visit = function(node) { | 108 restrictions.visit = function(node) { |
| 108 if (pred(node) && !AutomationPredicate.shouldIgnoreLeaf(node)) | 109 if (pred(node) && !AutomationPredicate.shouldIgnoreLeaf(node)) |
| 109 return true; | 110 return true; |
| 110 if (AutomationPredicate.container(node)) | 111 if (AutomationPredicate.container(node)) |
| 111 return true; | 112 return true; |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 var walker = new AutomationTreeWalker(cur, dir, restrictions); | 115 var walker = new AutomationTreeWalker(cur, dir, restrictions); |
| 115 return walker.next().node; | 116 return walker.next().node; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 * @return {boolean} | 276 * @return {boolean} |
| 276 */ | 277 */ |
| 277 AutomationUtil.isDescendantOf = function(node, ancestor) { | 278 AutomationUtil.isDescendantOf = function(node, ancestor) { |
| 278 var testNode = node; | 279 var testNode = node; |
| 279 while (testNode && testNode !== ancestor) | 280 while (testNode && testNode !== ancestor) |
| 280 testNode = testNode.parent; | 281 testNode = testNode.parent; |
| 281 return testNode === ancestor; | 282 return testNode === ancestor; |
| 282 }; | 283 }; |
| 283 | 284 |
| 284 }); // goog.scope | 285 }); // goog.scope |
| OLD | NEW |