| 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 Implements support for live regions in ChromeVox Next. | 6 * @fileoverview Implements support for live regions in ChromeVox Next. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('LiveRegions'); | 9 goog.provide('LiveRegions'); |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 */ | 34 */ |
| 35 this.lastLiveRegionTime_ = new Date(0); | 35 this.lastLiveRegionTime_ = new Date(0); |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Set of nodes that have been announced as part of a live region since | 38 * Set of nodes that have been announced as part of a live region since |
| 39 * |this.lastLiveRegionTime_|, to prevent duplicate announcements. | 39 * |this.lastLiveRegionTime_|, to prevent duplicate announcements. |
| 40 * @type {!WeakSet<AutomationNode>} | 40 * @type {!WeakSet<AutomationNode>} |
| 41 * @private | 41 * @private |
| 42 */ | 42 */ |
| 43 this.liveRegionNodeSet_ = new WeakSet(); | 43 this.liveRegionNodeSet_ = new WeakSet(); |
| 44 | 44 chrome.automation.addTreeChangeObserver( |
| 45 // API only exists >= m49. Prevent us from crashing. | 45 'liveRegionTreeChanges', this.onTreeChange.bind(this)); |
| 46 try { | |
| 47 chrome.automation.addTreeChangeObserver( | |
| 48 'liveRegionTreeChanges', this.onTreeChange.bind(this)); | |
| 49 } catch (e) { | |
| 50 } | |
| 51 }; | 46 }; |
| 52 | 47 |
| 53 /** | 48 /** |
| 54 * Live region events received in fewer than this many milliseconds will | 49 * Live region events received in fewer than this many milliseconds will |
| 55 * queue, otherwise they'll be output with a category flush. | 50 * queue, otherwise they'll be output with a category flush. |
| 56 * @type {number} | 51 * @type {number} |
| 57 * @const | 52 * @const |
| 58 */ | 53 */ |
| 59 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 500; | 54 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 500; |
| 60 | 55 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return; | 149 return; |
| 155 parent = parent.parent; | 150 parent = parent.parent; |
| 156 } | 151 } |
| 157 | 152 |
| 158 this.liveRegionNodeSet_.add(node); | 153 this.liveRegionNodeSet_.add(node); |
| 159 output.go(); | 154 output.go(); |
| 160 }, | 155 }, |
| 161 }; | 156 }; |
| 162 | 157 |
| 163 }); // goog.scope | 158 }); // goog.scope |
| OLD | NEW |