| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 this.lastValueChanged_ = new Date(0); | 44 this.lastValueChanged_ = new Date(0); |
| 45 | 45 |
| 46 this.addListener_(EventType.ACTIVEDESCENDANTCHANGED, | 46 this.addListener_(EventType.ACTIVEDESCENDANTCHANGED, |
| 47 this.onActiveDescendantChanged); | 47 this.onActiveDescendantChanged); |
| 48 this.addListener_(EventType.ALERT, | 48 this.addListener_(EventType.ALERT, |
| 49 this.onAlert); | 49 this.onAlert); |
| 50 this.addListener_(EventType.ARIA_ATTRIBUTE_CHANGED, | 50 this.addListener_(EventType.ARIA_ATTRIBUTE_CHANGED, |
| 51 this.onAriaAttributeChanged); | 51 this.onAriaAttributeChanged); |
| 52 this.addListener_(EventType.AUTOCORRECTION_OCCURED, | 52 this.addListener_(EventType.AUTOCORRECTION_OCCURED, |
| 53 this.onEventIfInRange); | 53 this.onEventIfInRange); |
| 54 this.addListener_(EventType.BLUR, |
| 55 this.onBlur); |
| 54 this.addListener_(EventType.CHECKED_STATE_CHANGED, | 56 this.addListener_(EventType.CHECKED_STATE_CHANGED, |
| 55 this.onCheckedStateChanged); | 57 this.onCheckedStateChanged); |
| 56 this.addListener_(EventType.CHILDREN_CHANGED, | 58 this.addListener_(EventType.CHILDREN_CHANGED, |
| 57 this.onChildrenChanged); | 59 this.onChildrenChanged); |
| 58 this.addListener_(EventType.EXPANDED_CHANGED, | 60 this.addListener_(EventType.EXPANDED_CHANGED, |
| 59 this.onEventIfInRange); | 61 this.onEventIfInRange); |
| 60 this.addListener_(EventType.FOCUS, | 62 this.addListener_(EventType.FOCUS, |
| 61 this.onFocus); | 63 this.onFocus); |
| 62 this.addListener_(EventType.HOVER, | 64 this.addListener_(EventType.HOVER, |
| 63 this.onHover); | 65 this.onHover); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 onAlert: function(evt) { | 238 onAlert: function(evt) { |
| 237 var node = evt.target; | 239 var node = evt.target; |
| 238 if (!node || !this.shouldOutput_(evt)) | 240 if (!node || !this.shouldOutput_(evt)) |
| 239 return; | 241 return; |
| 240 | 242 |
| 241 var range = cursors.Range.fromNode(node); | 243 var range = cursors.Range.fromNode(node); |
| 242 | 244 |
| 243 new Output().withSpeechAndBraille(range, null, evt.type).go(); | 245 new Output().withSpeechAndBraille(range, null, evt.type).go(); |
| 244 }, | 246 }, |
| 245 | 247 |
| 248 onBlur: function(evt) { |
| 249 // Nullify focus if it no longer exists. |
| 250 chrome.automation.getFocus(function(focus) { |
| 251 if (!focus) |
| 252 ChromeVoxState.instance.setCurrentRange(null); |
| 253 }); |
| 254 }, |
| 255 |
| 246 /** | 256 /** |
| 247 * Provides all feedback once a checked state changed event fires. | 257 * Provides all feedback once a checked state changed event fires. |
| 248 * @param {!AutomationEvent} evt | 258 * @param {!AutomationEvent} evt |
| 249 */ | 259 */ |
| 250 onCheckedStateChanged: function(evt) { | 260 onCheckedStateChanged: function(evt) { |
| 251 if (!AutomationPredicate.checkable(evt.target)) | 261 if (!AutomationPredicate.checkable(evt.target)) |
| 252 return; | 262 return; |
| 253 | 263 |
| 254 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH); | 264 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH); |
| 255 var event = new CustomAutomationEvent( | 265 var event = new CustomAutomationEvent( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 var savedRange = ChromeVoxState.instance.focusRecoveryMap.get(root); | 321 var savedRange = ChromeVoxState.instance.focusRecoveryMap.get(root); |
| 312 ChromeVoxState.instance.focusRecoveryMap.delete(root); | 322 ChromeVoxState.instance.focusRecoveryMap.delete(root); |
| 313 if (savedRange) { | 323 if (savedRange) { |
| 314 ChromeVoxState.instance.navigateToRange(savedRange, false); | 324 ChromeVoxState.instance.navigateToRange(savedRange, false); |
| 315 return; | 325 return; |
| 316 } | 326 } |
| 317 var event = new CustomAutomationEvent(EventType.FOCUS, node, evt.eventFrom); | 327 var event = new CustomAutomationEvent(EventType.FOCUS, node, evt.eventFrom); |
| 318 this.onEventDefault(event); | 328 this.onEventDefault(event); |
| 319 }, | 329 }, |
| 320 | 330 |
| 331 |
| 321 /** | 332 /** |
| 322 * Provides all feedback once a load complete event fires. | 333 * Provides all feedback once a load complete event fires. |
| 323 * @param {!AutomationEvent} evt | 334 * @param {!AutomationEvent} evt |
| 324 */ | 335 */ |
| 325 onLoadComplete: function(evt) { | 336 onLoadComplete: function(evt) { |
| 326 chrome.automation.getFocus(function(focus) { | 337 chrome.automation.getFocus(function(focus) { |
| 327 if (!focus || !AutomationUtil.isDescendantOf(focus, evt.target)) | 338 if (!focus || !AutomationUtil.isDescendantOf(focus, evt.target)) |
| 328 return; | 339 return; |
| 329 | 340 |
| 330 // Create text edit handler, if needed, now in order not to miss initial | 341 // Create text edit handler, if needed, now in order not to miss initial |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 DesktopAutomationHandler.init_ = function() { | 572 DesktopAutomationHandler.init_ = function() { |
| 562 chrome.automation.getDesktop(function(desktop) { | 573 chrome.automation.getDesktop(function(desktop) { |
| 563 ChromeVoxState.desktopAutomationHandler = | 574 ChromeVoxState.desktopAutomationHandler = |
| 564 new DesktopAutomationHandler(desktop); | 575 new DesktopAutomationHandler(desktop); |
| 565 }); | 576 }); |
| 566 }; | 577 }; |
| 567 | 578 |
| 568 DesktopAutomationHandler.init_(); | 579 DesktopAutomationHandler.init_(); |
| 569 | 580 |
| 570 }); // goog.scope | 581 }); // goog.scope |
| OLD | NEW |