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

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

Issue 2903973002: Rich editable text implementation using spannables (Closed)
Patch Set: Text style. 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 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 /** 69 /**
70 * Represents a position within the automation tree. 70 * Represents a position within the automation tree.
71 * @constructor 71 * @constructor
72 * @param {!AutomationNode} node 72 * @param {!AutomationNode} node
73 * @param {number} index A 0-based index into this cursor node's primary 73 * @param {number} index A 0-based index into this cursor node's primary
74 * accessible name. An index of |cursors.NODE_INDEX| means the node as a whole 74 * accessible name. An index of |cursors.NODE_INDEX| means the node as a whole
75 * is pointed to and covers the case where the accessible text is empty. 75 * is pointed to and covers the case where the accessible text is empty.
76 */ 76 */
77 cursors.Cursor = function(node, index) { 77 cursors.Cursor = function(node, index) {
78 // Compensate for specific issues in Blink.
79 if (node.role == RoleType.STATIC_TEXT && node.name.length == index) {
80 // Re-interpret this case as the beginning of the next node.
dmazzoni 2017/06/07 17:30:13 Add a TODO to take affinity as an argument to Curs
81 var nextNode = AutomationUtil.findNextNode(
82 node, Dir.FORWARD, AutomationPredicate.leafOrStaticText);
83
84 // The exception is when a user types at the end of a line. In that case,
85 // staying on the current node is appropriate.
86 if (nextNode && nextNode.nextOnLine) {
87 node = nextNode;
88 index = 0;
89 }
90 } else if (node.role == RoleType.GENERIC_CONTAINER &&
91 node.state.richlyEditable &&
92 (node.firstChild && (node.firstChild.role == RoleType.LINE_BREAK ||
93 node.firstChild.role == RoleType.STATIC_TEXT))) {
94 // Re-interpret this case as pointing to the text under the div.
95 node = node.find({ role: RoleType.INLINE_TEXT_BOX }) || node;
96 }
97
78 /** @type {number} @private */ 98 /** @type {number} @private */
79 this.index_ = index; 99 this.index_ = index;
80 /** @type {Array<AutomationNode>} @private */ 100 /** @type {Array<AutomationNode>} @private */
81 this.ancestry_ = []; 101 this.ancestry_ = [];
82 var nodeWalker = node; 102 var nodeWalker = node;
83 while (nodeWalker) { 103 while (nodeWalker) {
84 this.ancestry_.push(nodeWalker); 104 this.ancestry_.push(nodeWalker);
85 nodeWalker = nodeWalker.parent; 105 nodeWalker = nodeWalker.parent;
86 if (nodeWalker && nodeWalker.role == RoleType.WINDOW) 106 if (nodeWalker && nodeWalker.role == RoleType.WINDOW)
87 break; 107 break;
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 /** 763 /**
744 * Returns whether this range has valid start and end cursors. 764 * Returns whether this range has valid start and end cursors.
745 * @return {boolean} 765 * @return {boolean}
746 */ 766 */
747 isValid: function() { 767 isValid: function() {
748 return this.start.isValid() && this.end.isValid(); 768 return this.start.isValid() && this.end.isValid();
749 } 769 }
750 }; 770 };
751 771
752 }); // goog.scope 772 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698