Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
index 9fc7f3ad1386d867855c3066405c77ea29c39ab3..fe3320ec928ad64eabbf87ef0ed4d3256b56e7b7 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
@@ -115,44 +115,22 @@ AutomationUtil.findNextNode = function(cur, dir, pred, opt_restrictions) { |
/** |
* Given nodes a_1, ..., a_n starting at |cur| in pre order traversal, apply |
* |pred| to a_i and a_(i - 1) until |pred| is satisfied. Returns a_(i - 1) or |
- * a_i (depending on opt_options.before) or null if no match was found. |
+ * a_i (depending on opt_before) or null if no match was found. |
* @param {!AutomationNode} cur |
* @param {Dir} dir |
* @param {AutomationPredicate.Binary} pred |
- * @param {{filter: (AutomationPredicate.Unary|undefined), |
- * before: boolean?}=} opt_options |
- * filter - Filters which candidate nodes to consider. Defaults to leaf |
- * only. |
- * before - True to return a_(i - 1); a_i otherwise. Defaults to false. |
+ * @param {boolean=} opt_before True to return a_(i - 1); a_i otherwise. |
+ * Defaults to false. |
* @return {AutomationNode} |
*/ |
-AutomationUtil.findNodeUntil = function(cur, dir, pred, opt_options) { |
- opt_options = |
- opt_options || {filter: AutomationPredicate.leaf, before: false}; |
- if (!opt_options.filter) |
- opt_options.filter = AutomationPredicate.leaf; |
- |
- var before = null; |
- var after = null; |
- var prev = cur; |
- AutomationUtil.findNextNode(cur, |
- dir, |
- function(candidate) { |
- if (!opt_options.filter(candidate)) |
- return false; |
- |
- var satisfied = pred(prev, candidate); |
- |
- prev = candidate; |
- if (!satisfied) |
- before = candidate; |
- else |
- after = candidate; |
- return satisfied; |
- }, |
- {leaf: AutomationPredicate.leaf, skipInitialSubtree: true}); |
- |
- return opt_options.before ? before : after; |
+AutomationUtil.findNodeUntil = function(cur, dir, pred, opt_before) { |
+ var before = cur; |
+ var after = before; |
+ do { |
+ before = after; |
+ after = AutomationUtil.findNextNode(before, dir, AutomationPredicate.leaf); |
+ } while (after && !pred(before, after)); |
+ return opt_before ? before : after; |
}; |
/** |