| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 Handles automation from a desktop automation node. | 6 * @fileoverview Handles automation from a desktop automation node. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('DesktopAutomationHandler'); | 9 goog.provide('DesktopAutomationHandler'); |
| 10 | 10 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 274 |
| 275 this.onActiveDescendantChanged(evt); | 275 this.onActiveDescendantChanged(evt); |
| 276 }, | 276 }, |
| 277 | 277 |
| 278 /** | 278 /** |
| 279 * Provides all feedback once a focus event fires. | 279 * Provides all feedback once a focus event fires. |
| 280 * @param {!AutomationEvent} evt | 280 * @param {!AutomationEvent} evt |
| 281 */ | 281 */ |
| 282 onFocus: function(evt) { | 282 onFocus: function(evt) { |
| 283 // Invalidate any previous editable text handler state. | 283 // Invalidate any previous editable text handler state. |
| 284 this.textEditHandler_ = null; | 284 if (this.textEditHandler_) { |
| 285 this.textEditHandler_.invalidate(); |
| 286 this.textEditHandler_ = null; |
| 287 } |
| 285 | 288 |
| 286 var node = evt.target; | 289 var node = evt.target; |
| 287 | 290 |
| 288 // Discard focus events on embeddedObject. | 291 // Discard focus events on embeddedObject. |
| 289 if (node.role == RoleType.EMBEDDED_OBJECT) | 292 if (node.role == RoleType.EMBEDDED_OBJECT) |
| 290 return; | 293 return; |
| 291 | 294 |
| 292 this.createTextEditHandlerIfNeeded_(evt.target); | 295 this.createTextEditHandlerIfNeeded_(evt.target); |
| 293 | 296 |
| 294 // Category flush speech triggered by events with no source. This includes | 297 // Category flush speech triggered by events with no source. This includes |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 new Output().withLocation(currentRange, null, evt.type).go(); | 476 new Output().withLocation(currentRange, null, evt.type).go(); |
| 474 }, | 477 }, |
| 475 | 478 |
| 476 /** | 479 /** |
| 477 * @param {!AutomationEvent} evt | 480 * @param {!AutomationEvent} evt |
| 478 */ | 481 */ |
| 479 onSelection: function(evt) { | 482 onSelection: function(evt) { |
| 480 // Invalidate any previous editable text handler state since some nodes, | 483 // Invalidate any previous editable text handler state since some nodes, |
| 481 // like menuitems, can receive selection while focus remains on an editable | 484 // like menuitems, can receive selection while focus remains on an editable |
| 482 // leading to braille output routing to the editable. | 485 // leading to braille output routing to the editable. |
| 483 this.textEditHandler_ = null; | 486 if (this.textEditHandler_) { |
| 487 this.textEditHandler_.invalidate(); |
| 488 this.textEditHandler_ = null; |
| 489 } |
| 484 | 490 |
| 485 chrome.automation.getFocus(function(focus) { | 491 chrome.automation.getFocus(function(focus) { |
| 486 // Desktop tabs get "selection" when there's a focused webview during tab | 492 // Desktop tabs get "selection" when there's a focused webview during tab |
| 487 // switching. | 493 // switching. |
| 488 if (focus.role == RoleType.WEB_VIEW && evt.target.role == RoleType.TAB) { | 494 if (focus.role == RoleType.WEB_VIEW && evt.target.role == RoleType.TAB) { |
| 489 ChromeVoxState.instance.setCurrentRange( | 495 ChromeVoxState.instance.setCurrentRange( |
| 490 cursors.Range.fromNode(focus.firstChild)); | 496 cursors.Range.fromNode(focus.firstChild)); |
| 491 return; | 497 return; |
| 492 } | 498 } |
| 493 | 499 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 }.bind(this)); | 534 }.bind(this)); |
| 529 }, | 535 }, |
| 530 | 536 |
| 531 /** | 537 /** |
| 532 * Create an editable text handler for the given node if needed. | 538 * Create an editable text handler for the given node if needed. |
| 533 * @param {!AutomationNode} node | 539 * @param {!AutomationNode} node |
| 534 */ | 540 */ |
| 535 createTextEditHandlerIfNeeded_: function(node) { | 541 createTextEditHandlerIfNeeded_: function(node) { |
| 536 if (!this.textEditHandler_ || | 542 if (!this.textEditHandler_ || |
| 537 this.textEditHandler_.node !== node) { | 543 this.textEditHandler_.node !== node) { |
| 544 if (this.textEditHandler_) |
| 545 this.textEditHandler_.invalidate(); |
| 546 |
| 538 this.textEditHandler_ = editing.TextEditHandler.createForNode(node); | 547 this.textEditHandler_ = editing.TextEditHandler.createForNode(node); |
| 539 } | 548 } |
| 540 }, | 549 }, |
| 541 | 550 |
| 542 /** | 551 /** |
| 543 * Once an event handler updates ChromeVox's range based on |evt| | 552 * Once an event handler updates ChromeVox's range based on |evt| |
| 544 * which updates mode, returns whether |evt| should be outputted. | 553 * which updates mode, returns whether |evt| should be outputted. |
| 545 * @return {boolean} | 554 * @return {boolean} |
| 546 */ | 555 */ |
| 547 shouldOutput_: function(evt) { | 556 shouldOutput_: function(evt) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 561 DesktopAutomationHandler.init_ = function() { | 570 DesktopAutomationHandler.init_ = function() { |
| 562 chrome.automation.getDesktop(function(desktop) { | 571 chrome.automation.getDesktop(function(desktop) { |
| 563 ChromeVoxState.desktopAutomationHandler = | 572 ChromeVoxState.desktopAutomationHandler = |
| 564 new DesktopAutomationHandler(desktop); | 573 new DesktopAutomationHandler(desktop); |
| 565 }); | 574 }); |
| 566 }; | 575 }; |
| 567 | 576 |
| 568 DesktopAutomationHandler.init_(); | 577 DesktopAutomationHandler.init_(); |
| 569 | 578 |
| 570 }); // goog.scope | 579 }); // goog.scope |
| OLD | NEW |