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

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

Issue 2649373002: Re-land: Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Fix presubmit 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
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
11 goog.require('ChromeVoxState'); 11 goog.require('ChromeVoxState');
12 12
13 goog.scope(function() { 13 goog.scope(function() {
14 var AutomationNode = chrome.automation.AutomationNode; 14 var AutomationNode = chrome.automation.AutomationNode;
15 var RoleType = chrome.automation.RoleType; 15 var RoleType = chrome.automation.RoleType;
16 var TreeChange = chrome.automation.TreeChange; 16 var TreeChange = chrome.automation.TreeChange;
17 var TreeChangeObserverFilter = chrome.automation.TreeChangeObserverFilter;
17 18
18 /** 19 /**
19 * ChromeVox2 live region handler. 20 * ChromeVox2 live region handler.
20 * @param {!ChromeVoxState} chromeVoxState The ChromeVox state object, 21 * @param {!ChromeVoxState} chromeVoxState The ChromeVox state object,
21 * keeping track of the current mode and current range. 22 * keeping track of the current mode and current range.
22 * @constructor 23 * @constructor
23 */ 24 */
24 LiveRegions = function(chromeVoxState) { 25 LiveRegions = function(chromeVoxState) {
25 /** 26 /**
26 * @type {!ChromeVoxState} 27 * @type {!ChromeVoxState}
27 * @private 28 * @private
28 */ 29 */
29 this.chromeVoxState_ = chromeVoxState; 30 this.chromeVoxState_ = chromeVoxState;
30 31
31 /** 32 /**
32 * The time the last live region event was output. 33 * The time the last live region event was output.
33 * @type {!Date} 34 * @type {!Date}
34 * @private 35 * @private
35 */ 36 */
36 this.lastLiveRegionTime_ = new Date(0); 37 this.lastLiveRegionTime_ = new Date(0);
37 38
38 /** 39 /**
39 * Set of nodes that have been announced as part of a live region since 40 * Set of nodes that have been announced as part of a live region since
40 * |this.lastLiveRegionTime_|, to prevent duplicate announcements. 41 * |this.lastLiveRegionTime_|, to prevent duplicate announcements.
41 * @type {!WeakSet<AutomationNode>} 42 * @type {!WeakSet<AutomationNode>}
42 * @private 43 * @private
43 */ 44 */
44 this.liveRegionNodeSet_ = new WeakSet(); 45 this.liveRegionNodeSet_ = new WeakSet();
45 chrome.automation.addTreeChangeObserver( 46 chrome.automation.addTreeChangeObserver(
46 'liveRegionTreeChanges', this.onTreeChange.bind(this)); 47 TreeChangeObserverFilter.LIVE_REGION_TREE_CHANGES,
48 this.onTreeChange.bind(this));
47 }; 49 };
48 50
49 /** 51 /**
50 * Live region events received in fewer than this many milliseconds will 52 * Live region events received in fewer than this many milliseconds will
51 * queue, otherwise they'll be output with a category flush. 53 * queue, otherwise they'll be output with a category flush.
52 * @type {number} 54 * @type {number}
53 * @const 55 * @const
54 */ 56 */
55 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 5000; 57 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 5000;
56 58
(...skipping 27 matching lines...) Expand all
84 86
85 if (mode === ChromeVoxMode.CLASSIC || !cvox.ChromeVox.isActive) 87 if (mode === ChromeVoxMode.CLASSIC || !cvox.ChromeVox.isActive)
86 return; 88 return;
87 89
88 if (!currentRange) 90 if (!currentRange)
89 return; 91 return;
90 92
91 var webView = AutomationUtil.getTopLevelRoot(node); 93 var webView = AutomationUtil.getTopLevelRoot(node);
92 webView = webView ? webView.parent : null; 94 webView = webView ? webView.parent : null;
93 if (!LiveRegions.announceLiveRegionsFromBackgroundTabs_ && 95 if (!LiveRegions.announceLiveRegionsFromBackgroundTabs_ &&
94 currentRange.start.node.role != RoleType.desktop && 96 currentRange.start.node.role != RoleType.DESKTOP &&
95 (!webView || !webView.state.focused)) { 97 (!webView || !webView.state.focused)) {
96 return; 98 return;
97 } 99 }
98 100
99 var type = treeChange.type; 101 var type = treeChange.type;
100 var relevant = node.containerLiveRelevant; 102 var relevant = node.containerLiveRelevant;
101 var additions = relevant.indexOf('additions') >= 0; 103 var additions = relevant.indexOf('additions') >= 0;
102 var text = relevant.indexOf('text') >= 0; 104 var text = relevant.indexOf('text') >= 0;
103 var removals = relevant.indexOf('removals') >= 0; 105 var removals = relevant.indexOf('removals') >= 0;
104 var all = relevant.indexOf('all') >= 0; 106 var all = relevant.indexOf('all') >= 0;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 else 182 else
181 output.withQueueMode(cvox.QueueMode.QUEUE); 183 output.withQueueMode(cvox.QueueMode.QUEUE);
182 184
183 this.liveRegionNodeSet_.add(node); 185 this.liveRegionNodeSet_.add(node);
184 output.go(); 186 output.go();
185 this.lastLiveRegionTime_ = currentTime; 187 this.lastLiveRegionTime_ = currentTime;
186 }, 188 },
187 }; 189 };
188 190
189 }); // goog.scope 191 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698