| 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);
|
| + }
|
| }
|
| };
|
|
|
|
|