| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Maps an automation event to its listener. | 58 * Maps an automation event to its listener. |
| 59 * @type {!Object<EventType, function(Object) : void>} | 59 * @type {!Object<EventType, function(Object) : void>} |
| 60 */ | 60 */ |
| 61 this.listeners_ = { | 61 this.listeners_ = { |
| 62 alert: this.onEventDefault, | 62 alert: this.onEventDefault, |
| 63 focus: this.onEventDefault, | 63 focus: this.onEventDefault, |
| 64 hover: this.onEventDefault, | 64 hover: this.onEventDefault, |
| 65 loadComplete: this.onLoadComplete, |
| 65 menuStart: this.onEventDefault, | 66 menuStart: this.onEventDefault, |
| 66 menuEnd: this.onEventDefault, | 67 menuEnd: this.onEventDefault, |
| 67 menuListValueChanged: this.onEventDefault, | 68 menuListValueChanged: this.onEventDefault, |
| 68 loadComplete: this.onLoadComplete, | |
| 69 textChanged: this.onTextOrTextSelectionChanged, | 69 textChanged: this.onTextOrTextSelectionChanged, |
| 70 textSelectionChanged: this.onTextOrTextSelectionChanged, | 70 textSelectionChanged: this.onTextOrTextSelectionChanged, |
| 71 valueChanged: this.onEventDefault | 71 valueChanged: this.onValueChanged |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // Register listeners for ... | 74 // Register listeners for ... |
| 75 // Desktop. | 75 // Desktop. |
| 76 chrome.automation.getDesktop(this.onGotDesktop); | 76 chrome.automation.getDesktop(this.onGotDesktop); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 Background.prototype = { | 79 Background.prototype = { |
| 80 /** | 80 /** |
| 81 * Handles all setup once a new automation tree appears. | 81 * Handles all setup once a new automation tree appears. |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 cvox.ChromeVox.tts); | 313 cvox.ChromeVox.tts); |
| 314 } | 314 } |
| 315 | 315 |
| 316 this.editableTextHandler.changed(textChangeEvent); | 316 this.editableTextHandler.changed(textChangeEvent); |
| 317 new Output().withBraille( | 317 new Output().withBraille( |
| 318 this.currentRange_, null, evt.type) | 318 this.currentRange_, null, evt.type) |
| 319 .go(); | 319 .go(); |
| 320 }, | 320 }, |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * Provides all feedback once a value changed event fires. |
| 324 * @param {Object} evt |
| 325 */ |
| 326 onValueChanged: function(evt) { |
| 327 // Don't process nodes inside of web content if ChromeVox Next is inactive. |
| 328 if (evt.target.root.role != chrome.automation.RoleType.desktop && |
| 329 !this.active_) |
| 330 return; |
| 331 |
| 332 if (!evt.target.state.focused) |
| 333 return; |
| 334 |
| 335 // Value change events fire on web text fields and text areas when pressing |
| 336 // enter; suppress them. |
| 337 if (!this.currentRange_ || |
| 338 evt.target.role != chrome.automation.RoleType.textField) { |
| 339 this.onEventDefault(evt); |
| 340 this.currentRange_ = cursors.Range.fromNode(evt.target); |
| 341 } |
| 342 }, |
| 343 |
| 344 /** |
| 323 * Called when the automation tree is changed. | 345 * Called when the automation tree is changed. |
| 324 * @param {chrome.automation.TreeChange} treeChange | 346 * @param {chrome.automation.TreeChange} treeChange |
| 325 */ | 347 */ |
| 326 onTreeChange: function(treeChange) { | 348 onTreeChange: function(treeChange) { |
| 327 var node = treeChange.target; | 349 var node = treeChange.target; |
| 328 if (!node.containerLiveStatus) | 350 if (!node.containerLiveStatus) |
| 329 return; | 351 return; |
| 330 | 352 |
| 331 if (node.containerLiveRelevant.indexOf('additions') >= 0 && | 353 if (node.containerLiveRelevant.indexOf('additions') >= 0 && |
| 332 treeChange.type == 'nodeCreated') | 354 treeChange.type == 'nodeCreated') |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 }.bind(this)); | 435 }.bind(this)); |
| 414 } | 436 } |
| 415 }.bind(this)); | 437 }.bind(this)); |
| 416 } | 438 } |
| 417 }; | 439 }; |
| 418 | 440 |
| 419 /** @type {Background} */ | 441 /** @type {Background} */ |
| 420 global.backgroundObj = new Background(); | 442 global.backgroundObj = new Background(); |
| 421 | 443 |
| 422 }); // goog.scope | 444 }); // goog.scope |
| OLD | NEW |