| 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 16 matching lines...) Expand all Loading... |
| 27 * @param {AutomationNode} cur Node to begin the search from. | 27 * @param {AutomationNode} cur Node to begin the search from. |
| 28 * @param {Dir} dir | 28 * @param {Dir} dir |
| 29 * @param {AutomationPredicate.Unary} pred A predicate to apply | 29 * @param {AutomationPredicate.Unary} pred A predicate to apply |
| 30 * to a candidate node. | 30 * to a candidate node. |
| 31 * @return {AutomationNode} | 31 * @return {AutomationNode} |
| 32 */ | 32 */ |
| 33 AutomationUtil.findNodePre = function(cur, dir, pred) { | 33 AutomationUtil.findNodePre = function(cur, dir, pred) { |
| 34 if (!cur) | 34 if (!cur) |
| 35 return null; | 35 return null; |
| 36 | 36 |
| 37 if (pred(cur)) | 37 if (pred(cur) && !AutomationPredicate.shouldIgnoreNode(cur)) |
| 38 return cur; | 38 return cur; |
| 39 | 39 |
| 40 var child = dir == Dir.BACKWARD ? cur.lastChild : cur.firstChild; | 40 var child = dir == Dir.BACKWARD ? cur.lastChild : cur.firstChild; |
| 41 while (child) { | 41 while (child) { |
| 42 var ret = AutomationUtil.findNodePre(child, dir, pred); | 42 var ret = AutomationUtil.findNodePre(child, dir, pred); |
| 43 if (ret) | 43 if (ret) |
| 44 return ret; | 44 return ret; |
| 45 child = dir == Dir.BACKWARD ? | 45 child = dir == Dir.BACKWARD ? |
| 46 child.previousSibling : child.nextSibling; | 46 child.previousSibling : child.nextSibling; |
| 47 } | 47 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 62 | 62 |
| 63 var child = dir == Dir.BACKWARD ? cur.lastChild : cur.firstChild; | 63 var child = dir == Dir.BACKWARD ? cur.lastChild : cur.firstChild; |
| 64 while (child) { | 64 while (child) { |
| 65 var ret = AutomationUtil.findNodePost(child, dir, pred); | 65 var ret = AutomationUtil.findNodePost(child, dir, pred); |
| 66 if (ret) | 66 if (ret) |
| 67 return ret; | 67 return ret; |
| 68 child = dir == Dir.BACKWARD ? | 68 child = dir == Dir.BACKWARD ? |
| 69 child.previousSibling : child.nextSibling; | 69 child.previousSibling : child.nextSibling; |
| 70 } | 70 } |
| 71 | 71 |
| 72 if (pred(cur)) | 72 if (pred(cur) && !AutomationPredicate.shouldIgnoreNode(cur)) |
| 73 return cur; | 73 return cur; |
| 74 | 74 |
| 75 return null; | 75 return null; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Find the next node in the given direction in depth first order. | 79 * Find the next node in the given direction in depth first order. |
| 80 * | 80 * |
| 81 * Let D be the dfs linearization of |cur.root|. Then, let F be the list after | 81 * Let D be the dfs linearization of |cur.root|. Then, let F be the list after |
| 82 * applying |pred| as a filter to D. This method will return the directed next | 82 * applying |pred| as a filter to D. This method will return the directed next |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 child = child.nextSibling; | 285 child = child.nextSibling; |
| 286 } | 286 } |
| 287 | 287 |
| 288 if (point.x <= (loc.left + loc.width) && point.x >= loc.left && | 288 if (point.x <= (loc.left + loc.width) && point.x >= loc.left && |
| 289 point.y <= (loc.top + loc.height) && point.y >= loc.top) | 289 point.y <= (loc.top + loc.height) && point.y >= loc.top) |
| 290 return node; | 290 return node; |
| 291 return null; | 291 return null; |
| 292 }; | 292 }; |
| 293 | 293 |
| 294 }); // goog.scope | 294 }); // goog.scope |
| OLD | NEW |