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

Unified Diff: chrome/browser/resources/chromeos/chromevox/common/editable_text.js

Issue 767683003: Braille improvements in contenteditables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Remove logspam. Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/common/editable_text_test.unitjs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..54312e0eb0e761eeafca49a99e82b91c7d1a34e5 100644
--- a/chrome/browser/resources/chromeos/chromevox/common/editable_text.js
+++ b/chrome/browser/resources/chromeos/chromevox/common/editable_text.js
@@ -375,17 +375,34 @@ 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) {
+ line = line.replace(/\u00A0/g, ' ');
+ }
+ var lineStart = this.getLineStart(lineIndex);
+ var start = this.start - lineStart;
+ var end = Math.min(this.end - lineStart, line.length);
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 +1265,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);
}
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/common/editable_text_test.unitjs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698