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

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

Issue 2653803002: Merge to m57: Improve live region performance (Closed)
Patch Set: Created 3 years, 11 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 * live region description. 121 * live region description.
122 * @param {!AutomationNode} node The changed node. 122 * @param {!AutomationNode} node The changed node.
123 * @param {?string=} opt_prependFormatStr If set, a format string for 123 * @param {?string=} opt_prependFormatStr If set, a format string for
124 * cvox2.Output to prepend to the output. 124 * cvox2.Output to prepend to the output.
125 * @private 125 * @private
126 */ 126 */
127 outputLiveRegionChange_: function(node, opt_prependFormatStr) { 127 outputLiveRegionChange_: function(node, opt_prependFormatStr) {
128 if (node.containerLiveBusy) 128 if (node.containerLiveBusy)
129 return; 129 return;
130 130
131 if (node.containerLiveAtomic && !node.liveAtomic) { 131 var delta = new Date() - this.lastLiveRegionTime_;
132 if (node.parent) 132 if (delta > LiveRegions.LIVE_REGION_MIN_SAME_NODE_MS)
133 this.outputLiveRegionChange_(node.parent, opt_prependFormatStr); 133 this.liveRegionNodeSet_ = new WeakSet();
134
135 while (node.containerLiveAtomic && !node.liveAtomic && node.parent)
136 node = node.parent;
137
138 if (this.liveRegionNodeSet_.has(node)) {
139 this.lastLiveRegionTime_ = new Date();
134 return; 140 return;
135 } 141 }
136 142
137 // Alerts should be announced as a result of focus. 143 this.outputLiveRegionChangeForNode_(node, opt_prependFormatStr);
138 if (node.role == RoleType.alert) 144 },
139 return;
140 145
146 /**
147 * @param {!AutomationNode} node The changed node.
148 * @param {?string=} opt_prependFormatStr If set, a format string for
149 * cvox2.Output to prepend to the output.
150 * @private
151 */
152 outputLiveRegionChangeForNode_: function(node, opt_prependFormatStr) {
141 var range = cursors.Range.fromNode(node); 153 var range = cursors.Range.fromNode(node);
142 var output = new Output(); 154 var output = new Output();
143 if (opt_prependFormatStr) 155 if (opt_prependFormatStr)
144 output.format(opt_prependFormatStr); 156 output.format(opt_prependFormatStr);
145 output.withSpeech(range, range, Output.EventType.NAVIGATE); 157 output.withSpeech(range, range, Output.EventType.NAVIGATE);
146 158
147 if (!output.hasSpeech && node.liveAtomic) 159 if (!output.hasSpeech && node.liveAtomic)
148 output.format('$joinedDescendants', node); 160 output.format('$joinedDescendants', node);
149 161
150 output.withSpeechCategory(cvox.TtsCategory.LIVE); 162 output.withSpeechCategory(cvox.TtsCategory.LIVE);
(...skipping 10 matching lines...) Expand all
161 173
162 // Enqueue live region updates that were received at approximately 174 // Enqueue live region updates that were received at approximately
163 // the same time, otherwise flush previous live region updates. 175 // the same time, otherwise flush previous live region updates.
164 var queueTime = LiveRegions.LIVE_REGION_QUEUE_TIME_MS; 176 var queueTime = LiveRegions.LIVE_REGION_QUEUE_TIME_MS;
165 var delta = currentTime - this.lastLiveRegionTime_; 177 var delta = currentTime - this.lastLiveRegionTime_;
166 if (delta > queueTime && !forceQueueForBackgroundedLiveRegion) 178 if (delta > queueTime && !forceQueueForBackgroundedLiveRegion)
167 output.withQueueMode(cvox.QueueMode.CATEGORY_FLUSH); 179 output.withQueueMode(cvox.QueueMode.CATEGORY_FLUSH);
168 else 180 else
169 output.withQueueMode(cvox.QueueMode.QUEUE); 181 output.withQueueMode(cvox.QueueMode.QUEUE);
170 182
171 if (delta > LiveRegions.LIVE_REGION_MIN_SAME_NODE_MS)
172 this.liveRegionNodeSet_ = new WeakSet();
173
174 var parent = node;
175 while (parent) {
176 if (this.liveRegionNodeSet_.has(parent)) {
177 this.lastLiveRegionTime_ = currentTime;
178 return;
179 }
180 parent = parent.parent;
181 }
182
183 this.liveRegionNodeSet_.add(node); 183 this.liveRegionNodeSet_.add(node);
184 output.go(); 184 output.go();
185 this.lastLiveRegionTime_ = currentTime; 185 this.lastLiveRegionTime_ = currentTime;
186 }, 186 },
187 }; 187 };
188 188
189 }); // goog.scope 189 }); // 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