OLD | NEW |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 for (var func in this) { | 71 for (var func in this) { |
72 if (typeof(this[func]) == 'function') | 72 if (typeof(this[func]) == 'function') |
73 this[func] = this[func].bind(this); | 73 this[func] = this[func].bind(this); |
74 } | 74 } |
75 | 75 |
76 /** | 76 /** |
77 * Maps an automation event to its listener. | 77 * Maps an automation event to its listener. |
78 * @type {!Object<EventType, function(Object) : void>} | 78 * @type {!Object<EventType, function(Object) : void>} |
79 */ | 79 */ |
80 this.listeners_ = { | 80 this.listeners_ = { |
81 alert: this.onEventDefault, | 81 alert: this.onAlert, |
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 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 evt.type == 'focus' && | 447 evt.type == 'focus' && |
448 this.currentRange_.equals(prevRange)) | 448 this.currentRange_.equals(prevRange)) |
449 return; | 449 return; |
450 | 450 |
451 new Output().withSpeechAndBraille( | 451 new Output().withSpeechAndBraille( |
452 this.currentRange_, prevRange, evt.type) | 452 this.currentRange_, prevRange, evt.type) |
453 .go(); | 453 .go(); |
454 }, | 454 }, |
455 | 455 |
456 /** | 456 /** |
| 457 * Makes an announcement without changing focus. |
| 458 * @param {Object} evt |
| 459 */ |
| 460 onAlert: function(evt) { |
| 461 var node = evt.target; |
| 462 if (!node) |
| 463 return; |
| 464 |
| 465 // Don't process nodes inside of web content if ChromeVox Next is inactive. |
| 466 if (node.root.role != RoleType.desktop && |
| 467 this.mode_ === ChromeVoxMode.CLASSIC) { |
| 468 return; |
| 469 } |
| 470 |
| 471 var range = cursors.Range.fromNode(node); |
| 472 |
| 473 new Output().withSpeechAndBraille(range, null, evt.type).go(); |
| 474 }, |
| 475 |
| 476 /** |
457 * Provides all feedback once a focus event fires. | 477 * Provides all feedback once a focus event fires. |
458 * @param {Object} evt | 478 * @param {Object} evt |
459 */ | 479 */ |
460 onFocus: function(evt) { | 480 onFocus: function(evt) { |
461 // Invalidate any previous editable text handler state. | 481 // Invalidate any previous editable text handler state. |
462 this.editableTextHandler = null; | 482 this.editableTextHandler = null; |
463 | 483 |
464 var node = evt.target; | 484 var node = evt.target; |
465 | 485 |
466 // It almost never makes sense to place focus directly on a rootWebArea. | 486 // It almost never makes sense to place focus directly on a rootWebArea. |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 node.state.protected, | 790 node.state.protected, |
771 cvox.ChromeVox.tts); | 791 cvox.ChromeVox.tts); |
772 } | 792 } |
773 } | 793 } |
774 }; | 794 }; |
775 | 795 |
776 /** @type {Background} */ | 796 /** @type {Background} */ |
777 global.backgroundObj = new Background(); | 797 global.backgroundObj = new Background(); |
778 | 798 |
779 }); // goog.scope | 799 }); // goog.scope |
OLD | NEW |