Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js

Issue 2332103003: Define a minimum delay time for processing live regions on the same node. (Closed)
Patch Set: Change min same node ms to 20 ms. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 /** 48 /**
49 * Live region events received in fewer than this many milliseconds will 49 * Live region events received in fewer than this many milliseconds will
50 * queue, otherwise they'll be output with a category flush. 50 * queue, otherwise they'll be output with a category flush.
51 * @type {number} 51 * @type {number}
52 * @const 52 * @const
53 */ 53 */
54 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 500; 54 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 500;
55 55
56 /** 56 /**
57 * Live region events received on the same node in fewer than this many
58 * milliseconds will be dropped to avoid a stream of constant chatter.
59 * @type {number}
60 * @const
61 */
62 LiveRegions.LIVE_REGION_MIN_SAME_NODE_MS = 20;
63
64 /**
57 * Whether live regions from background tabs should be announced or not. 65 * Whether live regions from background tabs should be announced or not.
58 * @type {boolean} 66 * @type {boolean}
59 * @private 67 * @private
60 */ 68 */
61 LiveRegions.announceLiveRegionsFromBackgroundTabs_ = true; 69 LiveRegions.announceLiveRegionsFromBackgroundTabs_ = true;
62 70
63 LiveRegions.prototype = { 71 LiveRegions.prototype = {
64 /** 72 /**
65 * Called when the automation tree is changed. 73 * Called when the automation tree is changed.
66 * @param {TreeChange} treeChange 74 * @param {TreeChange} treeChange
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 136
129 output.withSpeechCategory(cvox.TtsCategory.LIVE); 137 output.withSpeechCategory(cvox.TtsCategory.LIVE);
130 138
131 if (!output.hasSpeech) 139 if (!output.hasSpeech)
132 return; 140 return;
133 141
134 // Enqueue live region updates that were received at approximately 142 // Enqueue live region updates that were received at approximately
135 // the same time, otherwise flush previous live region updates. 143 // the same time, otherwise flush previous live region updates.
136 var currentTime = new Date(); 144 var currentTime = new Date();
137 var queueTime = LiveRegions.LIVE_REGION_QUEUE_TIME_MS; 145 var queueTime = LiveRegions.LIVE_REGION_QUEUE_TIME_MS;
138 if (currentTime - this.lastLiveRegionTime_ > queueTime) { 146 var delta = currentTime - this.lastLiveRegionTime_;
139 this.liveRegionNodeSet_ = new WeakSet(); 147 if (delta > queueTime) {
140 output.withQueueMode(cvox.QueueMode.CATEGORY_FLUSH); 148 output.withQueueMode(cvox.QueueMode.CATEGORY_FLUSH);
141 this.lastLiveRegionTime_ = currentTime; 149 this.lastLiveRegionTime_ = currentTime;
142 } else { 150 } else {
143 output.withQueueMode(cvox.QueueMode.QUEUE); 151 output.withQueueMode(cvox.QueueMode.QUEUE);
144 } 152 }
145 153
154 if (delta > LiveRegions.LIVE_REGION_MIN_SAME_NODE_MS)
155 this.liveRegionNodeSet_ = new WeakSet();
156
146 var parent = node; 157 var parent = node;
147 while (parent) { 158 while (parent) {
148 if (this.liveRegionNodeSet_.has(parent)) 159 if (this.liveRegionNodeSet_.has(parent))
149 return; 160 return;
150 parent = parent.parent; 161 parent = parent.parent;
151 } 162 }
152 163
153 this.liveRegionNodeSet_.add(node); 164 this.liveRegionNodeSet_.add(node);
154 output.go(); 165 output.go();
155 }, 166 },
156 }; 167 };
157 168
158 }); // goog.scope 169 }); // goog.scope
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698