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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
index 0f3bfa353e932fe808567ee3ae1f23ed213ead99..bd3162c44450ecb48766198ab7d989850de0c7f0 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
@@ -154,6 +154,12 @@ Background = function() {
chrome.accessibilityPrivate.onAccessibilityGesture.addListener(
this.onAccessibilityGesture_);
+
+ /**
+ * @type {WeakMap<AutomationNode>}
dmazzoni 2016/10/11 17:41:18 I think it should be WeakMap<AutomationNode, Autom
David Tseng 2016/10/11 21:24:32 Yup; you're right. Done (Closure doesn't seem to c
+ * @private
+ */
+ this.focusRecoveryMap_ = new WeakMap();
};
/**
@@ -198,6 +204,13 @@ Background.GESTURE_NEXT_COMMAND_MAP = {
Background.prototype = {
__proto__: ChromeVoxState.prototype,
+ /**
+ * Maps the last node with range in a given root.
+ * @type {WeakMap<AutomationNode>}
+ */
+ get focusRecoveryMap() {
+ return this.focusRecoveryMap_;
+ },
/**
* @override
@@ -644,59 +657,15 @@ Background.prototype = {
},
/**
- * Restore the range to the last range that was *not* in the ChromeVox
- * panel. This is used when the ChromeVox Panel closes.
- * @param {function()=} opt_callback
- * @private
+ * Save the current ChromeVox range.
*/
- restoreCurrentRange_: function(opt_callback) {
- if (this.savedRange_) {
- var node = this.savedRange_.start.node;
- var containingWebView = node;
- while (containingWebView && containingWebView.role != RoleType.webView)
- containingWebView = containingWebView.parent;
-
- if (containingWebView) {
- // Focusing the webView causes a focus change event which steals focus
- // away from the saved range.
- var saved = this.savedRange_;
- var setSavedRange = function(e) {
- if (e.target.root == saved.start.node.root) {
- this.navigateToRange(saved, false);
- opt_callback && opt_callback();
- }
- node.root.removeEventListener(EventType.focus, setSavedRange, true);
- }.bind(this);
- node.root.addEventListener(EventType.focus, setSavedRange, true);
- containingWebView.focus();
- }
- this.navigateToRange(this.savedRange_);
- this.savedRange_ = null;
- }
- },
-
- /**
- * Move ChromeVox without saving any ranges.
- */
- startExcursion: function() {
- this.inExcursion_ = true;
- },
-
- /**
- * Move ChromeVox back to the last saved range.
- * @param {function()=} opt_callback Called when range has been restored.
- */
- endExcursion: function(opt_callback) {
- this.inExcursion_ = false;
- this.restoreCurrentRange_(opt_callback);
- },
+ markCurrentRange: function() {
+ if (!this.currentRange)
+ return;
- /**
- * Move ChromeVox back to the last saved range.
- */
- saveExcursion: function() {
- this.savedRange_ =
- new cursors.Range(this.currentRange_.start, this.currentRange_.end);
+ var root = AutomationUtil.getTopLevelRoot(this.currentRange.start.node);
+ if (root)
+ this.focusRecoveryMap_.set(root, this.currentRange.start.node);
dmazzoni 2016/10/11 17:41:18 Why not store and recover the whole range?
David Tseng 2016/10/11 21:24:32 Done.
},
/**

Powered by Google App Engine
This is Rietveld 408576698