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

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

Issue 2263513004: Add support for rich output inside of content editables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@editable_nav
Patch Set: Test fixes. Created 4 years, 3 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 /** 134 /**
135 * A node appropriate for making selections. 135 * A node appropriate for making selections.
136 * @return {AutomationNode} 136 * @return {AutomationNode}
137 * @private 137 * @private
138 */ 138 */
139 get selectionNode_() { 139 get selectionNode_() {
140 if (!this.node) 140 if (!this.node)
141 return null; 141 return null;
142 142
143 if (this.node.role == RoleType.inlineTextBox) 143 if (this.node.role == RoleType.inlineTextBox ||
144 this.index_ == cursors.NODE_INDEX)
144 return this.node.parent; 145 return this.node.parent;
145 146
146 return this.node; 147 return this.node;
147 }, 148 },
148 149
149 /** 150 /**
150 * An index appropriate for making selections. If this cursor has a 151 * An index appropriate for making selections. If this cursor has a
151 * cursors.NODE_INDEX index, the selection index is a node offset e.g. the 152 * cursors.NODE_INDEX index, the selection index is a node offset e.g. the
152 * index in parent. If not, the index is a character offset. 153 * index in parent. If not, the index is a character offset.
153 * @return {number} 154 * @return {number}
154 * @private 155 * @private
155 */ 156 */
156 get selectionIndex_() { 157 get selectionIndex_() {
157 var adjustedIndex = this.index_; 158 var adjustedIndex = this.index_;
158 if (this.node.role == RoleType.inlineTextBox) { 159 if (this.node.role == RoleType.inlineTextBox) {
159 if (adjustedIndex == cursors.NODE_INDEX) 160 if (adjustedIndex == cursors.NODE_INDEX)
160 adjustedIndex = 0; 161 adjustedIndex = 0;
161 162
162 var sibling = this.node.previousSibling; 163 var sibling = this.node.previousSibling;
163 while (sibling) { 164 while (sibling) {
164 adjustedIndex += sibling.name.length; 165 adjustedIndex += sibling.name.length;
165 sibling = sibling.previousSibling; 166 sibling = sibling.previousSibling;
166 } 167 }
167 } else if (this.index_ == cursors.NODE_INDEX) { 168 } else if (this.index_ == cursors.NODE_INDEX) {
168 // Indicies of this kind are buggy. Set it to 0 (different than the DOM 169 adjustedIndex = this.node.indexInParent + 1;
169 // index in parent convention).
170 adjustedIndex = 0;
171 } 170 }
172 return adjustedIndex; 171 return adjustedIndex;
173 }, 172 },
174 173
175 /** 174 /**
176 * Gets the accessible text of the node associated with this cursor. 175 * Gets the accessible text of the node associated with this cursor.
177 * 176 *
178 * @param {!AutomationNode=} opt_node Use this node rather than this cursor's 177 * @param {!AutomationNode=} opt_node Use this node rather than this cursor's
179 * node. 178 * node.
180 * @return {string} 179 * @return {string}
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 /** 604 /**
606 * Returns whether this range has valid start and end cursors. 605 * Returns whether this range has valid start and end cursors.
607 * @return {boolean} 606 * @return {boolean}
608 */ 607 */
609 isValid: function() { 608 isValid: function() {
610 return this.start.isValid() && this.end.isValid(); 609 return this.start.isValid() && this.end.isValid();
611 } 610 }
612 }; 611 };
613 612
614 }); // goog.scope 613 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698