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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview The entry point for all ChromeVox2 related code for the 6 * @fileoverview The entry point for all ChromeVox2 related code for the
7 * background page. 7 * background page.
8 */ 8 */
9 9
10 goog.provide('Background'); 10 goog.provide('Background');
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 focus: this.onFocus, 82 focus: this.onFocus,
83 hover: this.onEventDefault, 83 hover: this.onEventDefault,
84 loadComplete: this.onLoadComplete, 84 loadComplete: this.onLoadComplete,
85 menuStart: this.onEventDefault, 85 menuStart: this.onEventDefault,
86 menuEnd: this.onEventDefault, 86 menuEnd: this.onEventDefault,
87 textChanged: this.onTextOrTextSelectionChanged, 87 textChanged: this.onTextOrTextSelectionChanged,
88 textSelectionChanged: this.onTextOrTextSelectionChanged, 88 textSelectionChanged: this.onTextOrTextSelectionChanged,
89 valueChanged: this.onValueChanged 89 valueChanged: this.onValueChanged
90 }; 90 };
91 91
92 /**
93 * The object that speaks changes to an editable text field.
94 * @type {?cvox.ChromeVoxEditableTextBase}
95 */
96 this.editableTextHandler_ = null;
97
92 chrome.automation.getDesktop(this.onGotDesktop); 98 chrome.automation.getDesktop(this.onGotDesktop);
93 99
94 // Handle messages directed to the Next background page. 100 // Handle messages directed to the Next background page.
95 cvox.ExtensionBridge.addMessageListener(function(msg, port) { 101 cvox.ExtensionBridge.addMessageListener(function(msg, port) {
96 var target = msg['target']; 102 var target = msg['target'];
97 var action = msg['action']; 103 var action = msg['action'];
98 104
99 switch (target) { 105 switch (target) {
100 case 'next': 106 case 'next':
101 if (action == 'getIsClassicEnabled') { 107 if (action == 'getIsClassicEnabled') {
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 Dir.FORWARD, 470 Dir.FORWARD,
465 AutomationPredicate.focused) || node; 471 AutomationPredicate.focused) || node;
466 472
467 // Fall back to the first leaf node in the document. 473 // Fall back to the first leaf node in the document.
468 if (node.role == RoleType.rootWebArea) { 474 if (node.role == RoleType.rootWebArea) {
469 node = AutomationUtil.findNodePost(node, 475 node = AutomationUtil.findNodePost(node,
470 Dir.FORWARD, 476 Dir.FORWARD,
471 AutomationPredicate.leaf); 477 AutomationPredicate.leaf);
472 } 478 }
473 } 479 }
480
481 if (evt.target.role == RoleType.textField)
482 this.createEditableTextHandlerIfNeeded_(evt.target);
483
474 this.onEventDefault({target: node, type: 'focus'}); 484 this.onEventDefault({target: node, type: 'focus'});
475 }, 485 },
476 486
477 /** 487 /**
478 * Provides all feedback once a load complete event fires. 488 * Provides all feedback once a load complete event fires.
479 * @param {Object} evt 489 * @param {Object} evt
480 */ 490 */
481 onLoadComplete: function(evt) { 491 onLoadComplete: function(evt) {
482 this.setupChromeVoxVariants_(evt.target.docUrl); 492 this.setupChromeVoxVariants_(evt.target.docUrl);
483 493
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return; 536 return;
527 537
528 if (!evt.target.state.focused) 538 if (!evt.target.state.focused)
529 return; 539 return;
530 540
531 if (!this.currentRange_) { 541 if (!this.currentRange_) {
532 this.onEventDefault(evt); 542 this.onEventDefault(evt);
533 this.currentRange_ = cursors.Range.fromNode(evt.target); 543 this.currentRange_ = cursors.Range.fromNode(evt.target);
534 } 544 }
535 545
546 this.createEditableTextHandlerIfNeeded_(evt.target);
536 var textChangeEvent = new cvox.TextChangeEvent( 547 var textChangeEvent = new cvox.TextChangeEvent(
537 evt.target.value, 548 evt.target.value,
538 evt.target.textSelStart, 549 evt.target.textSelStart,
539 evt.target.textSelEnd, 550 evt.target.textSelEnd,
540 true); // triggered by user 551 true); // triggered by user
541 if (!this.editableTextHandler ||
542 evt.target != this.currentRange_.start.node) {
543 this.editableTextHandler =
544 new cvox.ChromeVoxEditableTextBase(
545 textChangeEvent.value,
546 textChangeEvent.start,
547 textChangeEvent.end,
548 evt.target.state['protected'],
549 cvox.ChromeVox.tts);
550 552
551 // Ignore the first text selection changed event which gets fired after 553 this.editableTextHandler_.changed(textChangeEvent);
552 // the focus event.
553 return;
554 }
555 554
556 this.editableTextHandler.changed(textChangeEvent);
557 new Output().withBraille( 555 new Output().withBraille(
558 this.currentRange_, null, evt.type) 556 this.currentRange_, null, evt.type)
559 .go(); 557 .go();
560 }, 558 },
561 559
562 /** 560 /**
563 * Provides all feedback once a value changed event fires. 561 * Provides all feedback once a value changed event fires.
564 * @param {Object} evt 562 * @param {Object} evt
565 */ 563 */
566 onValueChanged: function(evt) { 564 onValueChanged: function(evt) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 }); 736 });
739 if (!actionNode) 737 if (!actionNode)
740 return; 738 return;
741 if (actionNode.role === RoleType.inlineTextBox) 739 if (actionNode.role === RoleType.inlineTextBox)
742 actionNode = actionNode.parent; 740 actionNode = actionNode.parent;
743 actionNode.doDefault(); 741 actionNode.doDefault();
744 if (selectionSpan) { 742 if (selectionSpan) {
745 var start = text.getSpanStart(selectionSpan); 743 var start = text.getSpanStart(selectionSpan);
746 actionNode.setSelection(position - start, position - start); 744 actionNode.setSelection(position - start, position - start);
747 } 745 }
746 },
747
748 /**
749 * Create an editable text handler for the given node if needed.
750 * @param {Object} node
751 */
752 createEditableTextHandlerIfNeeded_: function(node) {
753 if (!this.editableTextHandler_ || node != this.currentRange_.start.node) {
754 var start = node.textSelStart;
755 var end = node.textSelEnd;
756 if (start > end) {
757 var tempOffset = end;
758 end = start;
759 start = tempOffset;
760 }
761
762 this.editableTextHandler_ =
763 new cvox.ChromeVoxEditableTextBase(
764 node.value,
765 start,
766 end,
767 node.state.protected,
768 cvox.ChromeVox.tts);
769 }
748 } 770 }
749 }; 771 };
750 772
751 /** @type {Background} */ 773 /** @type {Background} */
752 global.backgroundObj = new Background(); 774 global.backgroundObj = new Background();
753 775
754 }); // goog.scope 776 }); // goog.scope
OLDNEW
« 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