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

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

Issue 2412433004: Recovery: Implement focus recovery across root AutomationNodes (Closed)
Patch Set: Address feedback. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js
index 0ed19e1cd74f81e2a56761d1bba745491beb58f3..be38c90df030050b5f349eaab431e293a9b427c5 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js
@@ -263,6 +263,28 @@ DesktopAutomationHandler.prototype = {
// views.
if (evt.eventFrom == '')
Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH);
+ if (!node.root)
+ return;
+
+ var root = AutomationUtil.getTopLevelRoot(node.root);
+
+ // If we're crossing out of a root, save it in case it needs recovering.
+ var prevRange = ChromeVoxState.instance.currentRange;
+ var prevNode = prevRange ? prevRange.start.node : null;
+ if (prevNode) {
+ var prevRoot = AutomationUtil.getTopLevelRoot(prevNode);
+ if (prevRoot && prevRoot !== root)
+ ChromeVoxState.instance.focusRecoveryMap.set(prevRoot, prevRange);
+ }
+
+ // If a previous node was saved for this focus, restore it.
+ var savedRange = ChromeVoxState.instance.focusRecoveryMap.get(root);
+ ChromeVoxState.instance.focusRecoveryMap.delete(root);
+ if (savedRange) {
+ ChromeVoxState.instance.navigateToRange(savedRange, false);
+ return;
+ }
+
this.onEventDefault(new chrome.automation.AutomationEvent(
EventType.focus, node, evt.eventFrom));
},
@@ -445,7 +467,7 @@ DesktopAutomationHandler.prototype = {
* @param {!AutomationEvent} evt
*/
onMenuStart: function(evt) {
- ChromeVoxState.instance.startExcursion();
+ ChromeVoxState.instance.markCurrentRange();
this.onEventDefault(evt);
},
@@ -455,7 +477,16 @@ DesktopAutomationHandler.prototype = {
*/
onMenuEnd: function(evt) {
this.onEventDefault(evt);
- ChromeVoxState.instance.endExcursion();
+
+ // This is a work around for Chrome context menus not firing a focus event
+ // after you close them.
+ chrome.automation.getFocus(function(focus) {
+ if (focus) {
+ this.onFocus(
+ new chrome.automation.AutomationEvent(
+ EventType.focus, focus, 'page'));
+ }
+ }.bind(this));
},
/**

Powered by Google App Engine
This is Rietveld 408576698