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

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

Issue 2957653002: Provide feedback for multi-line selections (Closed)
Patch Set: Clarity check. Created 3 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 Processes events related to editing text and emits the 6 * @fileoverview Processes events related to editing text and emits the
7 * appropriate spoken and braille feedback. 7 * appropriate spoken and braille feedback.
8 */ 8 */
9 9
10 goog.provide('editing.TextEditHandler'); 10 goog.provide('editing.TextEditHandler');
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 return; 306 return;
307 } 307 }
308 308
309 if (cur.text == '') { 309 if (cur.text == '') {
310 // This line has no text content. Describe the DOM selection. 310 // This line has no text content. Describe the DOM selection.
311 new Output() 311 new Output()
312 .withRichSpeechAndBraille( 312 .withRichSpeechAndBraille(
313 new Range(cur.start_, cur.end_), 313 new Range(cur.start_, cur.end_),
314 new Range(prev.start_, prev.end_), Output.EventType.NAVIGATE) 314 new Range(prev.start_, prev.end_), Output.EventType.NAVIGATE)
315 .go(); 315 .go();
316 } else if (!cur.hasCollapsedSelection()) {
317 // This is a selection.
318 cvox.ChromeVox.tts.speak(cur.selectedText, cvox.QueueMode.CATEGORY_FLUSH);
dmazzoni 2017/06/23 19:50:49 Do you want to do this if there's a lot of selecte
David Tseng 2017/06/23 20:06:09 I think this is ok since |cur| will be at most a l
319 cvox.ChromeVox.tts.speak(Msgs.getMsg('selected'), cvox.QueueMode.QUEUE);
320 this.brailleCurrentRichLine_();
316 } else { 321 } else {
317 // Describe the current line. This accounts for previous/current 322 // Describe the current line. This accounts for previous/current
318 // selections and picking the line edge boundary that changed (as computed 323 // selections and picking the line edge boundary that changed (as computed
319 // above). This is also the code path for describing paste. 324 // above). This is also the code path for describing paste.
320 cvox.ChromeVox.tts.speak(cur.text, cvox.QueueMode.CATEGORY_FLUSH); 325 cvox.ChromeVox.tts.speak(cur.text, cvox.QueueMode.CATEGORY_FLUSH);
321 this.brailleCurrentRichLine_(); 326 this.brailleCurrentRichLine_();
322 } 327 }
323 328
324 // The state in EditableTextBase needs to get updated with the new line 329 // The state in EditableTextBase needs to get updated with the new line
325 // contents, so that subsequent intra-line changes get the right state 330 // contents, so that subsequent intra-line changes get the right state
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 }, 739 },
735 740
736 /** 741 /**
737 * The text content of this line. 742 * The text content of this line.
738 * @return {string} The text of this line. 743 * @return {string} The text of this line.
739 */ 744 */
740 get text() { 745 get text() {
741 return this.value_.toString(); 746 return this.value_.toString();
742 }, 747 },
743 748
749 /** @return {string} */
750 get selectedText() {
751 return this.value_.toString().substring(this.startOffset, this.endOffset);
752 },
753
754 /** @return {boolean} */
755 hasCollapsedSelection: function() {
756 return this.start_.equals(this.end_);
757 },
758
744 /** 759 /**
745 * Returns true if |otherLine| surrounds the same line as |this|. Note that 760 * Returns true if |otherLine| surrounds the same line as |this|. Note that
746 * the contents of the line might be different. 761 * the contents of the line might be different.
747 * @param {editing.EditableLine} otherLine 762 * @param {editing.EditableLine} otherLine
748 * @return {boolean} 763 * @return {boolean}
749 */ 764 */
750 isSameLine: function(otherLine) { 765 isSameLine: function(otherLine) {
751 // Equality is intentionally loose here as any of the state nodes can be 766 // Equality is intentionally loose here as any of the state nodes can be
752 // invalidated at any time. We rely upon the start/anchor of the line 767 // invalidated at any time. We rely upon the start/anchor of the line
753 // staying the same. 768 // staying the same.
(...skipping 12 matching lines...) Expand all
766 * @return {boolean} 781 * @return {boolean}
767 */ 782 */
768 isSameLineAndSelection: function(otherLine) { 783 isSameLineAndSelection: function(otherLine) {
769 return this.isSameLine(otherLine) && 784 return this.isSameLine(otherLine) &&
770 this.startOffset == otherLine.startOffset && 785 this.startOffset == otherLine.startOffset &&
771 this.endOffset == otherLine.endOffset; 786 this.endOffset == otherLine.endOffset;
772 } 787 }
773 }; 788 };
774 789
775 }); 790 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698