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

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: Created 5 years, 4 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
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 ebf1edca6e2e73fd595ca8137fce54584440b7d6..fcd5986f627e726527d68940f040185c004a5baf 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
@@ -90,6 +90,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.
@@ -469,6 +475,11 @@ Background.prototype = {
AutomationPredicate.leaf);
}
}
+
+ if (evt.target.role == 'textField' || evt.target.role == 'textBox') {
Peter Lundblad 2015/08/26 16:56:13 Use chrome.automation.RoleType. no braces around o
dmazzoni 2015/08/26 18:18:23 Done.
+ this.createEditableTextHandlerIfNeeded_(evt.target);
+ }
+
this.onEventDefault({target: node, type: 'focus'});
},
@@ -531,23 +542,13 @@ 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);
- }
-
- this.editableTextHandler.changed(textChangeEvent);
+ this.editableTextHandler_.changed(textChangeEvent);
new Output().withBraille(
this.currentRange_, null, evt.type)
.go();
@@ -739,6 +740,22 @@ 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) {
+ this.editableTextHandler_ =
+ new cvox.ChromeVoxEditableTextBase(
+ node.value,
+ node.textSelStart,
+ node.textSelEnd,
+ node.state['protected'],
Peter Lundblad 2015/08/26 16:56:13 Why do you use square brackets around 'protected'
dmazzoni 2015/08/26 18:18:23 I was thinking of it as a set/map. Changed to node
+ cvox.ChromeVox.tts);
+ }
}
};

Powered by Google App Engine
This is Rietveld 408576698