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

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

Issue 2079073002: Make ChromeVox Next a setting in options page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: m Created 4 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 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 newNode = newNode || originalNode; 307 newNode = newNode || originalNode;
308 newIndex = goog.isDef(newIndex) ? newIndex : this.index_; 308 newIndex = goog.isDef(newIndex) ? newIndex : this.index_;
309 return new cursors.Cursor(newNode, newIndex); 309 return new cursors.Cursor(newNode, newIndex);
310 }, 310 },
311 311
312 /** 312 /**
313 * Returns whether this cursor points to a valid position. 313 * Returns whether this cursor points to a valid position.
314 * @return {boolean} 314 * @return {boolean}
315 */ 315 */
316 isValid: function() { 316 isValid: function() {
317 return !!this.node && !!this.node.root; 317 return this.node != null;
318 } 318 }
319 }; 319 };
320 320
321 /** 321 /**
322 * A cursors.Cursor that wraps from beginning to end and vice versa when moved. 322 * A cursors.Cursor that wraps from beginning to end and vice versa when moved.
323 * @constructor 323 * @constructor
324 * @param {!AutomationNode} node 324 * @param {!AutomationNode} node
325 * @param {number} index A 0-based index into this cursor node's primary 325 * @param {number} index A 0-based index into this cursor node's primary
326 * accessible name. An index of |cursors.NODE_INDEX| means the node as a whole 326 * accessible name. An index of |cursors.NODE_INDEX| means the node as a whole
327 * is pointed to and covers the case where the accessible text is empty. 327 * is pointed to and covers the case where the accessible text is empty.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 select: function() { 548 select: function() {
549 var start = this.start.node; 549 var start = this.start.node;
550 var end = this.end.node; 550 var end = this.end.node;
551 551
552 if (!start || !end) 552 if (!start || !end)
553 return; 553 return;
554 554
555 // Find the most common root. 555 // Find the most common root.
556 var uniqueAncestors = AutomationUtil.getUniqueAncestors(start, end); 556 var uniqueAncestors = AutomationUtil.getUniqueAncestors(start, end);
557 var mcr = start.root; 557 var mcr = start.root;
558 if (uniqueAncestors) 558 if (uniqueAncestors) {
559 mcr = uniqueAncestors.pop().parent.root; 559 var common = uniqueAncestors.pop().parent;
560 if (common)
561 mcr = common.root;
562 }
560 563
561 if (mcr.role == RoleType.desktop) 564 if (!mcr || mcr.role == RoleType.desktop)
562 return; 565 return;
563 566
564 if (mcr === start.root && mcr === end.root) { 567 if (mcr === start.root && mcr === end.root) {
565 start = start.role == RoleType.inlineTextBox ? start.parent : start; 568 start = start.role == RoleType.inlineTextBox ? start.parent : start;
566 end = end.role == RoleType.inlineTextBox ? end.parent : end; 569 end = end.role == RoleType.inlineTextBox ? end.parent : end;
567 570
568 if (!start || !end) 571 if (!start || !end)
569 return; 572 return;
570 573
571 chrome.automation.setDocumentSelection( 574 chrome.automation.setDocumentSelection(
(...skipping 18 matching lines...) Expand all
590 /** 593 /**
591 * Returns whether this range has valid start and end cursors. 594 * Returns whether this range has valid start and end cursors.
592 * @return {boolean} 595 * @return {boolean}
593 */ 596 */
594 isValid: function() { 597 isValid: function() {
595 return this.start.isValid() && this.end.isValid(); 598 return this.start.isValid() && this.end.isValid();
596 } 599 }
597 }; 600 };
598 601
599 }); // goog.scope 602 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698