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

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

Issue 2331253002: Use category flush for focus events. (Closed)
Patch Set: fix test 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
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 Handles automation from a desktop automation node. 6 * @fileoverview Handles automation from a desktop automation node.
7 */ 7 */
8 8
9 goog.provide('DesktopAutomationHandler'); 9 goog.provide('DesktopAutomationHandler');
10 10
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 */ 169 */
170 onEventIfSelected: function(evt) { 170 onEventIfSelected: function(evt) {
171 if (evt.target.state.selected) 171 if (evt.target.state.selected)
172 this.onEventDefault(evt); 172 this.onEventDefault(evt);
173 }, 173 },
174 174
175 /** 175 /**
176 * @param {!AutomationEvent} evt 176 * @param {!AutomationEvent} evt
177 */ 177 */
178 onEventWithFlushedOutput: function(evt) { 178 onEventWithFlushedOutput: function(evt) {
179 Output.flushNextSpeechUtterance(); 179 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.FLUSH);
180 this.onEventDefault(evt); 180 this.onEventDefault(evt);
181 }, 181 },
182 182
183 /** 183 /**
184 * @param {!AutomationEvent} evt 184 * @param {!AutomationEvent} evt
185 */ 185 */
186 onHover: function(evt) { 186 onHover: function(evt) {
187 if (ChromeVoxState.instance.currentRange && 187 if (ChromeVoxState.instance.currentRange &&
188 evt.target == ChromeVoxState.instance.currentRange.start.node) 188 evt.target == ChromeVoxState.instance.currentRange.start.node)
189 return; 189 return;
190 Output.flushNextSpeechUtterance(); 190 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.FLUSH);
191 this.onEventDefault(evt); 191 this.onEventDefault(evt);
192 }, 192 },
193 193
194 /** 194 /**
195 * Makes an announcement without changing focus. 195 * Makes an announcement without changing focus.
196 * @param {!AutomationEvent} evt 196 * @param {!AutomationEvent} evt
197 */ 197 */
198 onActiveDescendantChanged: function(evt) { 198 onActiveDescendantChanged: function(evt) {
199 if (!evt.target.activeDescendant || !evt.target.state.focused) 199 if (!evt.target.activeDescendant || !evt.target.state.focused)
200 return; 200 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 this.textEditHandler_ = null; 244 this.textEditHandler_ = null;
245 245
246 var node = evt.target; 246 var node = evt.target;
247 247
248 // Discard focus events on embeddedObject and client nodes. 248 // Discard focus events on embeddedObject and client nodes.
249 if (node.role == RoleType.embeddedObject || node.role == RoleType.client) 249 if (node.role == RoleType.embeddedObject || node.role == RoleType.client)
250 return; 250 return;
251 251
252 this.createTextEditHandlerIfNeeded_(evt.target); 252 this.createTextEditHandlerIfNeeded_(evt.target);
253 253
254 // Since we queue output mostly for live regions support and there isn't a 254 // Category flush speech triggered by events with no source. This includes
255 // reliable way to know if this focus event resulted from a user's explicit 255 // views.
256 // action, only flush when the focused node is not web content. 256 if (evt.eventFrom == '')
257 if (node.root.role == RoleType.desktop) 257 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH);
258 Output.flushNextSpeechUtterance();
259
260 this.onEventDefault(new chrome.automation.AutomationEvent( 258 this.onEventDefault(new chrome.automation.AutomationEvent(
261 EventType.focus, node, evt.eventFrom)); 259 EventType.focus, node, evt.eventFrom));
262 }, 260 },
263 261
264 /** 262 /**
265 * Provides all feedback once a load complete event fires. 263 * Provides all feedback once a load complete event fires.
266 * @param {!AutomationEvent} evt 264 * @param {!AutomationEvent} evt
267 */ 265 */
268 onLoadComplete: function(evt) { 266 onLoadComplete: function(evt) {
269 // Don't process nodes inside of web content if ChromeVox Next is inactive. 267 // Don't process nodes inside of web content if ChromeVox Next is inactive.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 /** 415 /**
418 * @param {!AutomationEvent} evt 416 * @param {!AutomationEvent} evt
419 */ 417 */
420 onSelection: function(evt) { 418 onSelection: function(evt) {
421 chrome.automation.getFocus(function(focus) { 419 chrome.automation.getFocus(function(focus) {
422 // Some cases (e.g. in overview mode), require overriding the assumption 420 // Some cases (e.g. in overview mode), require overriding the assumption
423 // that focus is an ancestor of a selection target. 421 // that focus is an ancestor of a selection target.
424 var override = evt.target.role == RoleType.menuItem || 422 var override = evt.target.role == RoleType.menuItem ||
425 (evt.target.root == focus.root && 423 (evt.target.root == focus.root &&
426 focus.root.role == RoleType.desktop); 424 focus.root.role == RoleType.desktop);
427 Output.flushNextSpeechUtterance(); 425 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.FLUSH);
428 if (override || AutomationUtil.isDescendantOf(evt.target, focus)) 426 if (override || AutomationUtil.isDescendantOf(evt.target, focus))
429 this.onEventDefault(evt); 427 this.onEventDefault(evt);
430 }.bind(this)); 428 }.bind(this));
431 }, 429 },
432 430
433 /** 431 /**
434 * Provides all feedback once a menu start event fires. 432 * Provides all feedback once a menu start event fires.
435 * @param {!AutomationEvent} evt 433 * @param {!AutomationEvent} evt
436 */ 434 */
437 onMenuStart: function(evt) { 435 onMenuStart: function(evt) {
(...skipping 29 matching lines...) Expand all
467 DesktopAutomationHandler.init_ = function() { 465 DesktopAutomationHandler.init_ = function() {
468 chrome.automation.getDesktop(function(desktop) { 466 chrome.automation.getDesktop(function(desktop) {
469 ChromeVoxState.desktopAutomationHandler = 467 ChromeVoxState.desktopAutomationHandler =
470 new DesktopAutomationHandler(desktop); 468 new DesktopAutomationHandler(desktop);
471 }); 469 });
472 }; 470 };
473 471
474 DesktopAutomationHandler.init_(); 472 DesktopAutomationHandler.init_();
475 473
476 }); // goog.scope 474 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698