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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 DesktopAutomationHandler.init_ = function() { | 571 DesktopAutomationHandler.init_ = function() { |
562 chrome.automation.getDesktop(function(desktop) { | 572 chrome.automation.getDesktop(function(desktop) { |
563 ChromeVoxState.desktopAutomationHandler = | 573 ChromeVoxState.desktopAutomationHandler = |
564 new DesktopAutomationHandler(desktop); | 574 new DesktopAutomationHandler(desktop); |
565 }); | 575 }); |
566 }; | 576 }; |
567 | 577 |
568 DesktopAutomationHandler.init_(); | 578 DesktopAutomationHandler.init_(); |
569 | 579 |
570 }); // goog.scope | 580 }); // goog.scope |
OLD | NEW |