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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/walkers/abstract_node_walker.js

Issue 2943193002: Run clang-format on .js files in c/b/r/chromeos/chromevox (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 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 A base class for walkers that have a concept of lowest-level 6 * @fileoverview A base class for walkers that have a concept of lowest-level
7 * node. Base classes must override the stopNodeDescent method to define 7 * node. Base classes must override the stopNodeDescent method to define
8 * what a lowest-level node is. Then this walker will use those nodes as the 8 * what a lowest-level node is. Then this walker will use those nodes as the
9 * set of valid CursorSelections. 9 * set of valid CursorSelections.
10 */ 10 */
(...skipping 25 matching lines...) Expand all
36 /** 36 /**
37 * @override 37 * @override
38 */ 38 */
39 cvox.AbstractNodeWalker.prototype.next = function(sel) { 39 cvox.AbstractNodeWalker.prototype.next = function(sel) {
40 var r = sel.isReversed(); 40 var r = sel.isReversed();
41 var node = sel.end.node || document.body; 41 var node = sel.end.node || document.body;
42 if (!node) { 42 if (!node) {
43 return null; 43 return null;
44 } 44 }
45 do { 45 do {
46 node = cvox.DomUtil.directedNextLeafLikeNode(node, r, 46 node = cvox.DomUtil.directedNextLeafLikeNode(
47 goog.bind(this.stopNodeDescent, this)); 47 node, r, goog.bind(this.stopNodeDescent, this));
48 if (!node) { 48 if (!node) {
49 return null; 49 return null;
50 } 50 }
51 // and repeat all of the above until we have a node that is not empty 51 // and repeat all of the above until we have a node that is not empty
52 } while (node && !cvox.DomUtil.hasContent(node)); 52 } while (node && !cvox.DomUtil.hasContent(node));
53 53
54 return cvox.CursorSelection.fromNode(node).setReversed(r); 54 return cvox.CursorSelection.fromNode(node).setReversed(r);
55 }; 55 };
56 56
57 /** 57 /**
(...skipping 20 matching lines...) Expand all
78 if (this.wasBegin_) { 78 if (this.wasBegin_) {
79 // if body is empty, we return just the body selection 79 // if body is empty, we return just the body selection
80 return cvox.CursorSelection.fromBody().setReversed(r); 80 return cvox.CursorSelection.fromBody().setReversed(r);
81 } 81 }
82 this.wasBegin_ = true; 82 this.wasBegin_ = true;
83 } 83 }
84 84
85 var node = sel.start.node; 85 var node = sel.start.node;
86 86
87 while (node != document.body && node.parentNode && 87 while (node != document.body && node.parentNode &&
88 this.stopNodeDescent(node.parentNode)) { 88 this.stopNodeDescent(node.parentNode)) {
89 node = node.parentNode; 89 node = node.parentNode;
90 } 90 }
91 91
92 while (node && !this.stopNodeDescent(node)) { 92 while (node && !this.stopNodeDescent(node)) {
93 node = cvox.DomUtil.directedFirstChild(node, r); 93 node = cvox.DomUtil.directedFirstChild(node, r);
94 } 94 }
95 95
96 var n = cvox.CursorSelection.fromNode(node); 96 var n = cvox.CursorSelection.fromNode(node);
97 if (!cvox.DomUtil.hasContent(node)) { 97 if (!cvox.DomUtil.hasContent(node)) {
98 n = this.next(/** @type {!cvox.CursorSelection} */ 98 n = this.next(/** @type {!cvox.CursorSelection} */
99 (cvox.CursorSelection.fromNode(node)).setReversed(r)); 99 (cvox.CursorSelection.fromNode(node)).setReversed(r));
100 } 100 }
101 if (n) { 101 if (n) {
102 return n.setReversed(r); 102 return n.setReversed(r);
103 } 103 }
104 return this.begin({reversed: r}); 104 return this.begin({reversed: r});
105 }; 105 };
106 106
107 /** 107 /**
108 * Returns true if this is "a leaf node" or lower. That is, 108 * Returns true if this is "a leaf node" or lower. That is,
109 * it is at the lowest valid level or lower for this granularity. 109 * it is at the lowest valid level or lower for this granularity.
110 * RESTRICTION: true for a node => true for all child nodes 110 * RESTRICTION: true for a node => true for all child nodes
111 * RESTRICTION: true if node has no children 111 * RESTRICTION: true if node has no children
112 * @param {!Node} node The node to check. 112 * @param {!Node} node The node to check.
113 * @return {boolean} true if this is at the "leaf node" level or lower 113 * @return {boolean} true if this is at the "leaf node" level or lower
114 * for this granularity. 114 * for this granularity.
115 * @protected 115 * @protected
116 */ 116 */
117 cvox.AbstractNodeWalker.prototype.stopNodeDescent = goog.abstractMethod; 117 cvox.AbstractNodeWalker.prototype.stopNodeDescent = goog.abstractMethod;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698