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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js

Issue 1318683002: Make cvox2 feedback more robust when focusing a text field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock_feedback
Patch Set: EditableTextBase expects start < end Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
index 59968fc6c9b7712bb29a591f699d5e45f8c1f5bd..14a3208a94fe99a6754485283496bf6ee8e67912 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
@@ -89,6 +89,12 @@ Background = function() {
valueChanged: this.onValueChanged
};
+ /**
+ * The object that speaks changes to an editable text field.
+ * @type {?cvox.ChromeVoxEditableTextBase}
+ */
+ this.editableTextHandler_ = null;
+
chrome.automation.getDesktop(this.onGotDesktop);
// Handle messages directed to the Next background page.
@@ -471,6 +477,10 @@ Background.prototype = {
AutomationPredicate.leaf);
}
}
+
+ if (evt.target.role == RoleType.textField)
+ this.createEditableTextHandlerIfNeeded_(evt.target);
+
this.onEventDefault({target: node, type: 'focus'});
},
@@ -533,27 +543,15 @@ Background.prototype = {
this.currentRange_ = cursors.Range.fromNode(evt.target);
}
+ this.createEditableTextHandlerIfNeeded_(evt.target);
var textChangeEvent = new cvox.TextChangeEvent(
evt.target.value,
evt.target.textSelStart,
evt.target.textSelEnd,
true); // triggered by user
- if (!this.editableTextHandler ||
- evt.target != this.currentRange_.start.node) {
- this.editableTextHandler =
- new cvox.ChromeVoxEditableTextBase(
- textChangeEvent.value,
- textChangeEvent.start,
- textChangeEvent.end,
- evt.target.state['protected'],
- cvox.ChromeVox.tts);
- // Ignore the first text selection changed event which gets fired after
- // the focus event.
- return;
- }
+ this.editableTextHandler_.changed(textChangeEvent);
- this.editableTextHandler.changed(textChangeEvent);
new Output().withBraille(
this.currentRange_, null, evt.type)
.go();
@@ -745,6 +743,30 @@ Background.prototype = {
var start = text.getSpanStart(selectionSpan);
actionNode.setSelection(position - start, position - start);
}
+ },
+
+ /**
+ * Create an editable text handler for the given node if needed.
+ * @param {Object} node
+ */
+ createEditableTextHandlerIfNeeded_: function(node) {
+ if (!this.editableTextHandler_ || node != this.currentRange_.start.node) {
+ var start = node.textSelStart;
+ var end = node.textSelEnd;
+ if (start > end) {
+ var tempOffset = end;
+ end = start;
+ start = tempOffset;
+ }
+
+ this.editableTextHandler_ =
+ new cvox.ChromeVoxEditableTextBase(
+ node.value,
+ start,
+ end,
+ node.state.protected,
+ cvox.ChromeVox.tts);
+ }
}
};
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698