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 goog.provide('AutomationUtil.Dir'); | 10 goog.provide('AutomationUtil.Dir'); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 /** | 116 /** |
117 * Given nodes a_1, ..., a_n starting at |cur| in pre order traversal, apply | 117 * Given nodes a_1, ..., a_n starting at |cur| in pre order traversal, apply |
118 * |pred| to a_i and a_(i - 1) until |pred| is satisfied. Returns a_(i - 1) or | 118 * |pred| to a_i and a_(i - 1) until |pred| is satisfied. Returns a_(i - 1) or |
119 * a_i (depending on opt_options.before) or null if no match was found. | 119 * a_i (depending on opt_options.before) or null if no match was found. |
120 * @param {AutomationNode} cur | 120 * @param {AutomationNode} cur |
121 * @param {Dir} dir | 121 * @param {Dir} dir |
122 * @param {AutomationPredicate.Binary} pred | 122 * @param {AutomationPredicate.Binary} pred |
123 * @param {{filter: (AutomationPredicate.Unary|undefined), | 123 * @param {{filter: (AutomationPredicate.Unary|undefined), |
124 * before: boolean?}=} opt_options | 124 * before: boolean?}=} opt_options |
125 * filter - Filters which candidate nodes to | 125 * filter - Filters which candidate nodes to consider. Defaults to leaf |
126 * consider. Defaults to leaf nodes only. | 126 * only. |
127 * before - True to return a_(i - | 127 * before - True to return a_(i - 1); a_i otherwise. Defaults to false. |
128 * 1); a_i otherwise. Defaults to false. | |
129 * @return {AutomationNode} | 128 * @return {AutomationNode} |
130 */ | 129 */ |
131 AutomationUtil.findNodeUntil = function(cur, dir, pred, opt_options) { | 130 AutomationUtil.findNodeUntil = function(cur, dir, pred, opt_options) { |
132 opt_options = | 131 opt_options = |
133 opt_options || {filter: AutomationPredicate.leaf, before: false}; | 132 opt_options || {filter: AutomationPredicate.leaf, before: false}; |
134 if (!opt_options.filter) | 133 if (!opt_options.filter) |
135 opt_options.filter = AutomationPredicate.leaf; | 134 opt_options.filter = AutomationPredicate.leaf; |
136 | 135 |
137 var before = null; | 136 var before = null; |
138 var after = null; | 137 var after = null; |
(...skipping 10 matching lines...) Expand all Loading... |
149 if (!satisfied) | 148 if (!satisfied) |
150 before = candidate; | 149 before = candidate; |
151 else | 150 else |
152 after = candidate; | 151 after = candidate; |
153 return satisfied; | 152 return satisfied; |
154 }); | 153 }); |
155 return opt_options.before ? before : after; | 154 return opt_options.before ? before : after; |
156 }; | 155 }; |
157 | 156 |
158 }); // goog.scope | 157 }); // goog.scope |
OLD | NEW |