Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/common/editable_text.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/common/editable_text.js b/chrome/browser/resources/chromeos/chromevox/common/editable_text.js |
| index 5968c61f33ed7b0c2e1d73692a5bd74ba25ae4ac..f6cb988ed0f33323d3ee42d4c1095b08c75d9463 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/common/editable_text.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/common/editable_text.js |
| @@ -375,17 +375,35 @@ cvox.ChromeVoxEditableTextBase.prototype.changed = function(evt) { |
| this.start = evt.start; |
| this.end = evt.end; |
| + this.brailleCurrentLine_(); |
| +}; |
| + |
| + |
| +/** |
| + * Shows the current line on the braille display. |
| + * @private |
| + */ |
| +cvox.ChromeVoxEditableTextBase.prototype.brailleCurrentLine_ = function() { |
| if (this.brailleHandler_) { |
| - var line = this.getLine(this.getLineIndex(evt.start)); |
| - var lineStart = this.getLineStart(this.getLineIndex(evt.start)); |
| - var start = evt.start - lineStart; |
| - var end = Math.min(evt.end - lineStart, line.length); |
| + var lineIndex = this.getLineIndex(this.start); |
| + var line = this.getLine(lineIndex); |
| + // Collapsable whitespace inside the contenteditable is represented |
| + // as non-breaking spaces. This confuses braille input (which relies on |
| + // the text being added to be the same as the text in the input field). |
| + // Since the non-breaking spaces are just an artifact of how |
| + // contenteditable is implemented, normalize to normal spaces instead. |
| + if (this instanceof cvox.ChromeVoxEditableContentEditable) { |
|
David Tseng
2014/12/04 22:53:26
Does this belong in the subclass (i.e. replace val
|
| + line = line.replace(/\u00A0/g, ' '); |
| + } |
| + var lineStart = this.getLineStart(lineIndex); |
| + var start = this.start - lineStart; |
| + var end = Math.min(this.end - lineStart, line.length); |
| + console.log('Changed: ' + line + ' ' + start + ' ' + end + ' ' + lineStart); |
|
David Tseng
2014/12/04 22:53:26
Remove.
|
| this.brailleHandler_.changed(line, start, end, this.multiline, this.node, |
| - lineStart); |
| + lineStart); |
| } |
| }; |
| - |
| /** |
| * Describe a change in the selection or cursor position when the text |
| * stays the same. |
| @@ -1248,6 +1266,11 @@ cvox.ChromeVoxEditableContentEditable.prototype.changed = |
| // Take over here if we can't describe a change; assume it's a blank line. |
| if (!this.shouldDescribeChange(evt)) { |
| this.speak(cvox.ChromeVox.msgs.getMsg('text_box_blank'), true); |
| + if (this.brailleHandler_) { |
| + this.brailleHandler_.changed('' /*line*/, 0 /*start*/, 0 /*end*/, |
| + true /*multiline*/, null /*element*/, |
| + evt.start /*lineStart*/); |
| + } |
| } else { |
| goog.base(this, 'changed', evt); |
| } |