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

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

Issue 2412433004: Recovery: Implement focus recovery across root AutomationNodes (Closed)
Patch Set: Created 4 years, 2 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // Discard focus events on embeddedObject. 256 // Discard focus events on embeddedObject.
257 if (node.role == RoleType.embeddedObject) 257 if (node.role == RoleType.embeddedObject)
258 return; 258 return;
259 259
260 this.createTextEditHandlerIfNeeded_(evt.target); 260 this.createTextEditHandlerIfNeeded_(evt.target);
261 261
262 // Category flush speech triggered by events with no source. This includes 262 // Category flush speech triggered by events with no source. This includes
263 // views. 263 // views.
264 if (evt.eventFrom == '') 264 if (evt.eventFrom == '')
265 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH); 265 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH);
266 if (!node.root)
267 return;
268
269 var root = AutomationUtil.getTopLevelRoot(node.root);
270
271 // If we're crossing out of a root, save it in case it needs recovering.
272 var prevRange = ChromeVoxState.instance.currentRange;
273 var prevNode = prevRange ? prevRange.start.node : null;
274 if (prevNode) {
275 var prevRoot = AutomationUtil.getTopLevelRoot(prevNode);
276 if (prevRoot && prevRoot !== root)
277 ChromeVoxState.instance.focusRecoveryMap.set(prevRoot, prevNode);
278 }
279
280 // If a previous node was saved for this focus, restore it.
281 var savedNode = ChromeVoxState.instance.focusRecoveryMap.get(root);
282 ChromeVoxState.instance.focusRecoveryMap.delete(root);
283 node = savedNode ? savedNode : node;
284
266 this.onEventDefault(new chrome.automation.AutomationEvent( 285 this.onEventDefault(new chrome.automation.AutomationEvent(
267 EventType.focus, node, evt.eventFrom)); 286 EventType.focus, node, evt.eventFrom));
268 }, 287 },
269 288
270 /** 289 /**
271 * Provides all feedback once a load complete event fires. 290 * Provides all feedback once a load complete event fires.
272 * @param {!AutomationEvent} evt 291 * @param {!AutomationEvent} evt
273 */ 292 */
274 onLoadComplete: function(evt) { 293 onLoadComplete: function(evt) {
275 // Don't process nodes inside of web content if ChromeVox Next is inactive. 294 // Don't process nodes inside of web content if ChromeVox Next is inactive.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 if (override || AutomationUtil.isDescendantOf(evt.target, focus)) 457 if (override || AutomationUtil.isDescendantOf(evt.target, focus))
439 this.onEventDefault(evt); 458 this.onEventDefault(evt);
440 }.bind(this)); 459 }.bind(this));
441 }, 460 },
442 461
443 /** 462 /**
444 * Provides all feedback once a menu start event fires. 463 * Provides all feedback once a menu start event fires.
445 * @param {!AutomationEvent} evt 464 * @param {!AutomationEvent} evt
446 */ 465 */
447 onMenuStart: function(evt) { 466 onMenuStart: function(evt) {
448 ChromeVoxState.instance.startExcursion(); 467 ChromeVoxState.instance.markCurrentRange();
449 this.onEventDefault(evt); 468 this.onEventDefault(evt);
450 }, 469 },
451 470
452 /** 471 /**
453 * Provides all feedback once a menu end event fires. 472 * Provides all feedback once a menu end event fires.
454 * @param {!AutomationEvent} evt 473 * @param {!AutomationEvent} evt
455 */ 474 */
456 onMenuEnd: function(evt) { 475 onMenuEnd: function(evt) {
457 this.onEventDefault(evt); 476 this.onEventDefault(evt);
458 ChromeVoxState.instance.endExcursion(); 477
478 // This is a work around for Chrome context menus not firing a focus event
479 // after you close them.
480 chrome.automation.getFocus(function(focus) {
481 if (focus) {
482 this.onFocus(
483 new chrome.automation.AutomationEvent(
484 EventType.focus, focus, 'page'));
485 }
486 }.bind(this));
459 }, 487 },
460 488
461 /** 489 /**
462 * Create an editable text handler for the given node if needed. 490 * Create an editable text handler for the given node if needed.
463 * @param {!AutomationNode} node 491 * @param {!AutomationNode} node
464 */ 492 */
465 createTextEditHandlerIfNeeded_: function(node) { 493 createTextEditHandlerIfNeeded_: function(node) {
466 if (!this.textEditHandler_ || 494 if (!this.textEditHandler_ ||
467 this.textEditHandler_.node !== node) { 495 this.textEditHandler_.node !== node) {
468 this.textEditHandler_ = editing.TextEditHandler.createForNode(node); 496 this.textEditHandler_ = editing.TextEditHandler.createForNode(node);
469 } 497 }
470 } 498 }
471 }; 499 };
472 500
473 /** 501 /**
474 * Initializes global state for DesktopAutomationHandler. 502 * Initializes global state for DesktopAutomationHandler.
475 * @private 503 * @private
476 */ 504 */
477 DesktopAutomationHandler.init_ = function() { 505 DesktopAutomationHandler.init_ = function() {
478 chrome.automation.getDesktop(function(desktop) { 506 chrome.automation.getDesktop(function(desktop) {
479 ChromeVoxState.desktopAutomationHandler = 507 ChromeVoxState.desktopAutomationHandler =
480 new DesktopAutomationHandler(desktop); 508 new DesktopAutomationHandler(desktop);
481 }); 509 });
482 }; 510 };
483 511
484 DesktopAutomationHandler.init_(); 512 DesktopAutomationHandler.init_();
485 513
486 }); // goog.scope 514 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698