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

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

Issue 2640283004: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js
index 7c0eb03eb6a4938f2f48b0cd88ffdfa7645bd46b..95c43aa651399b52970d058cb5251de307792d90 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js
@@ -128,16 +128,28 @@ LiveRegions.prototype = {
if (node.containerLiveBusy)
return;
- if (node.containerLiveAtomic && !node.liveAtomic) {
- if (node.parent)
- this.outputLiveRegionChange_(node.parent, opt_prependFormatStr);
+ var delta = new Date() - this.lastLiveRegionTime_;
+ if (delta > LiveRegions.LIVE_REGION_MIN_SAME_NODE_MS)
+ this.liveRegionNodeSet_ = new WeakSet();
+
+ while (node.containerLiveAtomic && !node.liveAtomic && node.parent)
+ node = node.parent;
+
+ if (this.liveRegionNodeSet_.has(node)) {
+ this.lastLiveRegionTime_ = new Date();
return;
}
- // Alerts should be announced as a result of focus.
- if (node.role == RoleType.alert)
- return;
+ this.outputLiveRegionChangeForNode_(node, opt_prependFormatStr);
+ },
+ /**
+ * @param {!AutomationNode} node The changed node.
+ * @param {?string=} opt_prependFormatStr If set, a format string for
+ * cvox2.Output to prepend to the output.
+ * @private
+ */
+ outputLiveRegionChangeForNode_: function(node, opt_prependFormatStr) {
var range = cursors.Range.fromNode(node);
var output = new Output();
if (opt_prependFormatStr)
@@ -168,18 +180,6 @@ LiveRegions.prototype = {
else
output.withQueueMode(cvox.QueueMode.QUEUE);
- if (delta > LiveRegions.LIVE_REGION_MIN_SAME_NODE_MS)
- this.liveRegionNodeSet_ = new WeakSet();
-
- var parent = node;
- while (parent) {
- if (this.liveRegionNodeSet_.has(parent)) {
- this.lastLiveRegionTime_ = currentTime;
- return;
- }
- parent = parent.parent;
- }
-
this.liveRegionNodeSet_.add(node);
output.go();
this.lastLiveRegionTime_ = currentTime;
« 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