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

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

Issue 1622803002: Cleanup AutomationUtil.findNodeUntil, fix wrapping when moving by line, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 Classes related to cursors that point to and select parts of 6 * @fileoverview Classes related to cursors that point to and select parts of
7 * the automation tree. 7 * the automation tree.
8 */ 8 */
9 9
10 goog.provide('cursors.Cursor'); 10 goog.provide('cursors.Cursor');
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 newNode, dir, pred) || this.node_; 229 newNode, dir, pred) || this.node_;
230 newIndex = cursors.NODE_INDEX; 230 newIndex = cursors.NODE_INDEX;
231 break; 231 break;
232 } 232 }
233 break; 233 break;
234 case Unit.LINE: 234 case Unit.LINE:
235 newIndex = 0; 235 newIndex = 0;
236 switch (movement) { 236 switch (movement) {
237 case Movement.BOUND: 237 case Movement.BOUND:
238 newNode = AutomationUtil.findNodeUntil(newNode, dir, 238 newNode = AutomationUtil.findNodeUntil(newNode, dir,
239 AutomationPredicate.linebreak, {before: true}); 239 AutomationPredicate.linebreak, true);
240 newNode = newNode || this.node_; 240 newNode = newNode || this.node_;
241 newIndex = 241 newIndex =
242 dir == Dir.FORWARD ? this.getText(newNode).length : 0; 242 dir == Dir.FORWARD ? this.getText(newNode).length : 0;
243 break; 243 break;
244 case Movement.DIRECTIONAL: 244 case Movement.DIRECTIONAL:
245 newNode = AutomationUtil.findNodeUntil( 245 newNode = AutomationUtil.findNodeUntil(
246 newNode, dir, AutomationPredicate.linebreak); 246 newNode, dir, AutomationPredicate.linebreak);
247 break; 247 break;
248 } 248 }
249 break; 249 break;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 cursors.WrappingCursor.prototype = { 282 cursors.WrappingCursor.prototype = {
283 __proto__: cursors.Cursor.prototype, 283 __proto__: cursors.Cursor.prototype,
284 284
285 /** @override */ 285 /** @override */
286 move: function(unit, movement, dir) { 286 move: function(unit, movement, dir) {
287 var result = cursors.Cursor.prototype.move.call(this, unit, movement, dir); 287 var result = cursors.Cursor.prototype.move.call(this, unit, movement, dir);
288 if (movement == Movement.DIRECTIONAL && result.equals(this)) { 288 if (movement == Movement.DIRECTIONAL && result.equals(this)) {
289 var pred = unit == Unit.DOM_NODE ? 289 var pred = unit == Unit.DOM_NODE ?
290 AutomationPredicate.leafDomNode : AutomationPredicate.leaf; 290 AutomationPredicate.leafDomNode : AutomationPredicate.leaf;
291 var root = this.node; 291 var endpoint = this.node;
292 while (!AutomationUtil.isTraversalRoot(root) && root.parent) 292 while (!AutomationUtil.isTraversalRoot(endpoint) && endpoint.parent)
293 root = root.parent; 293 endpoint = endpoint.parent;
294 var wrappedNode = AutomationUtil.findNodePre(root, dir, pred); 294 if (dir == Dir.BACKWARD) {
295 while (endpoint.lastChild)
296 endpoint = endpoint.lastChild;
297 }
298 var wrappedNode = endpoint;
299 if (!pred(wrappedNode))
300 wrappedNode = AutomationUtil.findNextNode(endpoint, dir, pred);
301
295 if (wrappedNode) { 302 if (wrappedNode) {
296 cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP); 303 cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP);
297 return new cursors.WrappingCursor(wrappedNode, cursors.NODE_INDEX); 304 return new cursors.WrappingCursor(wrappedNode, cursors.NODE_INDEX);
298 } 305 }
299 } 306 }
300 return new cursors.WrappingCursor(result.node, result.index); 307 return new cursors.WrappingCursor(result.node, result.index);
301 } 308 }
302 }; 309 };
303 310
304 /** 311 /**
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 * Returns true if this range has either cursor end on web content. 453 * Returns true if this range has either cursor end on web content.
447 * @return {boolean} 454 * @return {boolean}
448 */ 455 */
449 isWebRange: function() { 456 isWebRange: function() {
450 return this.start.node.root.role != RoleType.desktop || 457 return this.start.node.root.role != RoleType.desktop ||
451 this.end.node.root.role != RoleType.desktop; 458 this.end.node.root.role != RoleType.desktop;
452 } 459 }
453 }; 460 };
454 461
455 }); // goog.scope 462 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698