OLD | NEW |
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 goog.provide('cvox.ChromeVoxEditableTextBase'); | 5 goog.provide('cvox.ChromeVoxEditableTextBase'); |
6 goog.provide('cvox.TextChangeEvent'); | 6 goog.provide('cvox.TextChangeEvent'); |
7 goog.provide('cvox.TypingEcho'); | 7 goog.provide('cvox.TypingEcho'); |
8 | 8 |
9 goog.require('cvox.AbstractTts'); | 9 goog.require('cvox.AbstractTts'); |
10 goog.require('cvox.ChromeVox'); | 10 goog.require('cvox.ChromeVox'); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 .format({'COUNT': 1})), evt.triggeredByUser); | 345 .format({'COUNT': 1})), evt.triggeredByUser); |
346 return; | 346 return; |
347 } | 347 } |
348 if (evt.start == evt.end) { | 348 if (evt.start == evt.end) { |
349 // It's currently a cursor. | 349 // It's currently a cursor. |
350 if (this.start != this.end) { | 350 if (this.start != this.end) { |
351 // It was previously a selection, so just announce 'unselected'. | 351 // It was previously a selection, so just announce 'unselected'. |
352 this.speak(Msgs.getMsg('Unselected'), evt.triggeredByUser); | 352 this.speak(Msgs.getMsg('Unselected'), evt.triggeredByUser); |
353 } else if (this.getLineIndex(this.start) != | 353 } else if (this.getLineIndex(this.start) != |
354 this.getLineIndex(evt.start)) { | 354 this.getLineIndex(evt.start)) { |
355 // Moved to a different line; read it. | 355 this.describeLine(this.getLineIndex(evt.start), evt.triggeredByUser); |
356 var lineValue = this.getLine(this.getLineIndex(evt.start)); | |
357 if (lineValue == '') { | |
358 lineValue = Msgs.getMsg('text_box_blank'); | |
359 } else if (/^\s+$/.test(lineValue)) { | |
360 lineValue = Msgs.getMsg('text_box_whitespace'); | |
361 } | |
362 this.speak(lineValue, evt.triggeredByUser); | |
363 } else if (this.start == evt.start + 1 || | 356 } else if (this.start == evt.start + 1 || |
364 this.start == evt.start - 1) { | 357 this.start == evt.start - 1) { |
365 // Moved by one character; read it. | 358 // Moved by one character; read it. |
366 if (!cvox.ChromeVoxEditableTextBase.useIBeamCursor) { | 359 if (!cvox.ChromeVoxEditableTextBase.useIBeamCursor) { |
367 if (evt.start == this.value.length) { | 360 if (evt.start == this.value.length) { |
368 if (cvox.ChromeVox.verbosity == cvox.VERBOSITY_VERBOSE) { | 361 if (cvox.ChromeVox.verbosity == cvox.VERBOSITY_VERBOSE) { |
369 this.speak(Msgs.getMsg('end_of_text_verbose'), | 362 this.speak(Msgs.getMsg('end_of_text_verbose'), |
370 evt.triggeredByUser); | 363 evt.triggeredByUser); |
371 } else { | 364 } else { |
372 this.speak(Msgs.getMsg('end_of_text_brief'), | 365 this.speak(Msgs.getMsg('end_of_text_brief'), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } else { | 412 } else { |
420 // The selection changed but it wasn't an obvious extension of | 413 // The selection changed but it wasn't an obvious extension of |
421 // a previous selection. Just read the new selection. | 414 // a previous selection. Just read the new selection. |
422 this.speak(this.value.substr(evt.start, evt.end - evt.start), | 415 this.speak(this.value.substr(evt.start, evt.end - evt.start), |
423 evt.triggeredByUser); | 416 evt.triggeredByUser); |
424 this.speak(Msgs.getMsg('selected')); | 417 this.speak(Msgs.getMsg('selected')); |
425 } | 418 } |
426 } | 419 } |
427 }; | 420 }; |
428 | 421 |
| 422 /** |
| 423 * Describes a line given a line index and whether it was user triggered. |
| 424 * @param {number} lineIndex |
| 425 * @param {boolean} triggeredByUser |
| 426 */ |
| 427 cvox.ChromeVoxEditableTextBase.prototype.describeLine = |
| 428 function(lineIndex, triggeredByUser) { |
| 429 var lineValue = this.getLine(lineIndex); |
| 430 if (lineValue == '') { |
| 431 lineValue = Msgs.getMsg('text_box_blank'); |
| 432 } else if (/^\s+$/.test(lineValue)) { |
| 433 lineValue = Msgs.getMsg('text_box_whitespace'); |
| 434 } |
| 435 this.speak(lineValue, triggeredByUser); |
| 436 }; |
| 437 |
429 | 438 |
430 /** | 439 /** |
431 * Describe a change where the text changes. | 440 * Describe a change where the text changes. |
432 * @param {cvox.TextChangeEvent} evt The text change event. | 441 * @param {cvox.TextChangeEvent} evt The text change event. |
433 */ | 442 */ |
434 cvox.ChromeVoxEditableTextBase.prototype.describeTextChanged = function(evt) { | 443 cvox.ChromeVoxEditableTextBase.prototype.describeTextChanged = function(evt) { |
435 var personality = {}; | 444 var personality = {}; |
436 if (evt.value.length < this.value.length) { | 445 if (evt.value.length < this.value.length) { |
437 personality = cvox.AbstractTts.PERSONALITY_DELETED; | 446 personality = cvox.AbstractTts.PERSONALITY_DELETED; |
438 } | 447 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 725 |
717 /** | 726 /** |
718 * Moves the cursor backward by one paragraph. | 727 * Moves the cursor backward by one paragraph. |
719 * @return {boolean} True if the action was handled. | 728 * @return {boolean} True if the action was handled. |
720 */ | 729 */ |
721 cvox.ChromeVoxEditableTextBase.prototype.moveCursorToPreviousParagraph = | 730 cvox.ChromeVoxEditableTextBase.prototype.moveCursorToPreviousParagraph = |
722 function() { return false; }; | 731 function() { return false; }; |
723 | 732 |
724 | 733 |
725 /******************************************/ | 734 /******************************************/ |
OLD | NEW |