Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/tree_walker.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 A tree walker over the automation tree. 6 * @fileoverview A tree walker over the automation tree.
7 */ 7 */
8 8
9 goog.provide('AutomationTreeWalker'); 9 goog.provide('AutomationTreeWalker');
10 goog.provide('AutomationTreeWalkerPhase'); 10 goog.provide('AutomationTreeWalkerPhase');
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 this.phase != AutomationTreeWalkerPhase.OTHER) 101 this.phase != AutomationTreeWalkerPhase.OTHER)
102 return false; 102 return false;
103 103
104 if (restrictions.visit) 104 if (restrictions.visit)
105 return restrictions.visit(node); 105 return restrictions.visit(node);
106 106
107 return true; 107 return true;
108 }; 108 };
109 /** @type {AutomationPredicate.Unary} @private */ 109 /** @type {AutomationPredicate.Unary} @private */
110 this.leafPred_ = restrictions.leaf ? restrictions.leaf : 110 this.leafPred_ = restrictions.leaf ? restrictions.leaf :
111 AutomationTreeWalker.falsePredicate_; 111 AutomationTreeWalker.falsePredicate_;
112 /** @type {AutomationPredicate.Unary} @private */ 112 /** @type {AutomationPredicate.Unary} @private */
113 this.rootPred_ = restrictions.root ? restrictions.root : 113 this.rootPred_ = restrictions.root ? restrictions.root :
114 AutomationTreeWalker.falsePredicate_; 114 AutomationTreeWalker.falsePredicate_;
115 /** @const {boolean} @private */ 115 /** @const {boolean} @private */
116 this.skipInitialAncestry_ = restrictions.skipInitialAncestry || false; 116 this.skipInitialAncestry_ = restrictions.skipInitialAncestry || false;
117 /** @const {boolean} @private */ 117 /** @const {boolean} @private */
118 this.skipInitialSubtree_ = restrictions.skipInitialSubtree || false; 118 this.skipInitialSubtree_ = restrictions.skipInitialSubtree || false;
119 }; 119 };
120 120
121 /** 121 /**
122 * @param {!chrome.automation.AutomationNode} node 122 * @param {!chrome.automation.AutomationNode} node
123 * @return {boolean} 123 * @return {boolean}
124 * @private 124 * @private
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 this.node_ = searchNode.nextSibling; 187 this.node_ = searchNode.nextSibling;
188 return; 188 return;
189 } 189 }
190 190
191 // Update the phase based on the parent if needed since we may exit below. 191 // Update the phase based on the parent if needed since we may exit below.
192 if (searchNode.parent == this.initialNode_) 192 if (searchNode.parent == this.initialNode_)
193 this.phase_ = AutomationTreeWalkerPhase.OTHER; 193 this.phase_ = AutomationTreeWalkerPhase.OTHER;
194 194
195 // Exit if we encounter a root-like node and are not searching descendants 195 // Exit if we encounter a root-like node and are not searching descendants
196 // of the initial node. 196 // of the initial node.
197 if (searchNode.parent && 197 if (searchNode.parent && this.rootPred_(searchNode.parent) &&
198 this.rootPred_(searchNode.parent) &&
199 this.phase_ != AutomationTreeWalkerPhase.DESCENDANT) 198 this.phase_ != AutomationTreeWalkerPhase.DESCENDANT)
200 break; 199 break;
201 200
202 searchNode = searchNode.parent; 201 searchNode = searchNode.parent;
203 } 202 }
204 this.node_ = null; 203 this.node_ = null;
205 }, 204 },
206 205
207 /** 206 /**
208 * @param {!chrome.automation.AutomationNode} node 207 * @param {!chrome.automation.AutomationNode} node
(...skipping 10 matching lines...) Expand all
219 this.node_ = node; 218 this.node_ = node;
220 return; 219 return;
221 } 220 }
222 if (node.parent && this.backwardAncestor_ == node.parent) { 221 if (node.parent && this.backwardAncestor_ == node.parent) {
223 this.phase_ = AutomationTreeWalkerPhase.ANCESTOR; 222 this.phase_ = AutomationTreeWalkerPhase.ANCESTOR;
224 this.backwardAncestor_ = node.parent.parent || null; 223 this.backwardAncestor_ = node.parent.parent || null;
225 } 224 }
226 this.node_ = node.parent || null; 225 this.node_ = node.parent || null;
227 } 226 }
228 }; 227 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698