| 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 24 matching lines...) Expand all Loading... |
| 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 |
| 45 chrome.automation.addTreeChangeObserver( | 45 // API only exists >= m49. Prevent us from crashing. |
| 46 'liveRegionTreeChanges', this.onTreeChange.bind(this)); | 46 try { |
| 47 chrome.automation.addTreeChangeObserver( |
| 48 'liveRegionTreeChanges', this.onTreeChange.bind(this)); |
| 49 } catch (e) { |
| 50 } |
| 47 }; | 51 }; |
| 48 | 52 |
| 49 /** | 53 /** |
| 50 * Live region events received in fewer than this many milliseconds will | 54 * Live region events received in fewer than this many milliseconds will |
| 51 * queue, otherwise they'll be output with a category flush. | 55 * queue, otherwise they'll be output with a category flush. |
| 52 * @type {number} | 56 * @type {number} |
| 53 * @const | 57 * @const |
| 54 */ | 58 */ |
| 55 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 500; | 59 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 500; |
| 56 | 60 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return; | 154 return; |
| 151 parent = parent.parent; | 155 parent = parent.parent; |
| 152 } | 156 } |
| 153 | 157 |
| 154 this.liveRegionNodeSet_.add(node); | 158 this.liveRegionNodeSet_.add(node); |
| 155 output.go(); | 159 output.go(); |
| 156 }, | 160 }, |
| 157 }; | 161 }; |
| 158 | 162 |
| 159 }); // goog.scope | 163 }); // goog.scope |
| OLD | NEW |