| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * @const {number} | 91 * @const {number} |
| 92 */ | 92 */ |
| 93 DesktopAutomationHandler.VMIN_VALUE_CHANGE_DELAY_MS = 500; | 93 DesktopAutomationHandler.VMIN_VALUE_CHANGE_DELAY_MS = 500; |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * Controls announcement of non-user-initiated events. | 96 * Controls announcement of non-user-initiated events. |
| 97 * @type {boolean} | 97 * @type {boolean} |
| 98 */ | 98 */ |
| 99 DesktopAutomationHandler.announceActions = false; | 99 DesktopAutomationHandler.announceActions = false; |
| 100 | 100 |
| 101 /** |
| 102 * The url of the keyboard. |
| 103 * @const {string} |
| 104 */ |
| 105 DesktopAutomationHandler.KEYBOARD_URL = |
| 106 'chrome-extension://jkghodnilhceideoidjikpgommlajknk/inputview.html'; |
| 107 |
| 101 DesktopAutomationHandler.prototype = { | 108 DesktopAutomationHandler.prototype = { |
| 102 __proto__: BaseAutomationHandler.prototype, | 109 __proto__: BaseAutomationHandler.prototype, |
| 103 | 110 |
| 104 /** @override */ | 111 /** @override */ |
| 105 willHandleEvent_: function(evt) { | 112 willHandleEvent_: function(evt) { |
| 106 return !cvox.ChromeVox.isActive; | 113 return !cvox.ChromeVox.isActive; |
| 107 }, | 114 }, |
| 108 | 115 |
| 109 /** | 116 /** |
| 110 * Provides all feedback once ChromeVox's focus changes. | 117 * Provides all feedback once ChromeVox's focus changes. |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } | 423 } |
| 417 | 424 |
| 418 // Re-target the node to the root of the editable. | 425 // Re-target the node to the root of the editable. |
| 419 var target = evt.target; | 426 var target = evt.target; |
| 420 while (target.parent && target.parent.state.editable) | 427 while (target.parent && target.parent.state.editable) |
| 421 target = target.parent; | 428 target = target.parent; |
| 422 var voxTarget = ChromeVoxState.instance.currentRange.start.node; | 429 var voxTarget = ChromeVoxState.instance.currentRange.start.node; |
| 423 while (voxTarget && voxTarget.parent && voxTarget.parent.state.editable) | 430 while (voxTarget && voxTarget.parent && voxTarget.parent.state.editable) |
| 424 voxTarget = voxTarget.parent; | 431 voxTarget = voxTarget.parent; |
| 425 | 432 |
| 426 // It is possible that ChromeVox has range over some other node | 433 // It is possible that ChromeVox has range over some other node when a text |
| 427 // when a text field is focused. | 434 // field is focused. Only allow this when focus is on a desktop node or |
| 428 if (!target.state.focused || target != voxTarget) | 435 // ChromeVox is over the keyboard. |
| 436 if (!target.state.focused || |
| 437 (target != voxTarget && target.root.role != RoleType.DESKTOP && |
| 438 voxTarget.root.url.indexOf(DesktopAutomationHandler.KEYBOARD_URL) != |
| 439 0)) |
| 429 return; | 440 return; |
| 430 | 441 |
| 431 this.createTextEditHandlerIfNeeded_(target); | 442 this.createTextEditHandlerIfNeeded_(target); |
| 432 | 443 |
| 433 // Sync the ChromeVox range to the editable, if a selection exists. | 444 // Sync the ChromeVox range to the editable, if a selection exists. |
| 434 var anchorObject = evt.target.root.anchorObject; | 445 var anchorObject = evt.target.root.anchorObject; |
| 435 var anchorOffset = evt.target.root.anchorOffset || 0; | 446 var anchorOffset = evt.target.root.anchorOffset || 0; |
| 436 var focusObject = evt.target.root.focusObject; | 447 var focusObject = evt.target.root.focusObject; |
| 437 var focusOffset = evt.target.root.focusOffset || 0; | 448 var focusOffset = evt.target.root.focusOffset || 0; |
| 438 if (anchorObject && focusObject) { | 449 if (anchorObject && focusObject) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 DesktopAutomationHandler.init_ = function() { | 590 DesktopAutomationHandler.init_ = function() { |
| 580 chrome.automation.getDesktop(function(desktop) { | 591 chrome.automation.getDesktop(function(desktop) { |
| 581 ChromeVoxState.desktopAutomationHandler = | 592 ChromeVoxState.desktopAutomationHandler = |
| 582 new DesktopAutomationHandler(desktop); | 593 new DesktopAutomationHandler(desktop); |
| 583 }); | 594 }); |
| 584 }; | 595 }; |
| 585 | 596 |
| 586 DesktopAutomationHandler.init_(); | 597 DesktopAutomationHandler.init_(); |
| 587 | 598 |
| 588 }); // goog.scope | 599 }); // goog.scope |
| OLD | NEW |