Commit 8506399f authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

[Switch Access] Respond to locationChanged events

Bug: 1023035
Change-Id: Ie227ad87af4bba0cdb6f864e609b8b4103a2d603
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001412
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732726}
parent 07b113c5
...@@ -120,6 +120,13 @@ class NavigationManager { ...@@ -120,6 +120,13 @@ class NavigationManager {
this.setNode_(this.node_.next); this.setNode_(this.node_.next);
} }
/**
* Updates the focus ring locations in response to an automation event.
*/
refreshFocusRings() {
this.focusRingManager_.setFocusNodes(this.node_, this.group_);
}
/** /**
* Selects the current node. * Selects the current node.
*/ */
......
...@@ -20,6 +20,9 @@ class NodeWrapper extends SAChildNode { ...@@ -20,6 +20,9 @@ class NodeWrapper extends SAChildNode {
/** @private {boolean} */ /** @private {boolean} */
this.isGroup_ = SwitchAccessPredicate.isGroup(this.baseNode_, parent); this.isGroup_ = SwitchAccessPredicate.isGroup(this.baseNode_, parent);
/** @private {function(chrome.automation.AutomationEvent)} */
this.locationChangedHandler_ = SwitchAccess.refreshFocusRings;
} }
// ================= Getters and setters ================= // ================= Getters and setters =================
...@@ -117,6 +120,20 @@ class NodeWrapper extends SAChildNode { ...@@ -117,6 +120,20 @@ class NodeWrapper extends SAChildNode {
return SwitchAccessPredicate.isVisible(this.baseNode_); return SwitchAccessPredicate.isVisible(this.baseNode_);
} }
/** @override */
onFocus() {
this.baseNode_.addEventListener(
chrome.automation.EventType.LOCATION_CHANGED,
this.locationChangedHandler_, false /* is_capture */);
}
/** @override */
onUnfocus() {
this.baseNode_.removeEventListener(
chrome.automation.EventType.LOCATION_CHANGED,
this.locationChangedHandler_, false /* is_capture */);
}
/** @override */ /** @override */
performAction(action) { performAction(action) {
let ancestor; let ancestor;
...@@ -191,6 +208,9 @@ class RootNodeWrapper extends SARootNode { ...@@ -191,6 +208,9 @@ class RootNodeWrapper extends SARootNode {
/** @private {!AutomationNode} */ /** @private {!AutomationNode} */
this.baseNode_ = baseNode; this.baseNode_ = baseNode;
/** @private {function(chrome.automation.AutomationEvent)} */
this.locationChangedHandler_ = SwitchAccess.refreshFocusRings;
} }
// ================= Getters and setters ================= // ================= Getters and setters =================
...@@ -234,6 +254,20 @@ class RootNodeWrapper extends SARootNode { ...@@ -234,6 +254,20 @@ class RootNodeWrapper extends SARootNode {
return !!this.baseNode_.role && super.isValidGroup(); return !!this.baseNode_.role && super.isValidGroup();
} }
/** @override */
onFocus() {
this.baseNode_.addEventListener(
chrome.automation.EventType.LOCATION_CHANGED,
this.locationChangedHandler_, false /* is_capture */);
}
/** @override */
onUnfocus() {
this.baseNode_.removeEventListener(
chrome.automation.EventType.LOCATION_CHANGED,
this.locationChangedHandler_, false /* is_capture */);
}
// ================= Static methods ================= // ================= Static methods =================
/** /**
......
...@@ -341,4 +341,11 @@ class SwitchAccess { ...@@ -341,4 +341,11 @@ class SwitchAccess {
return this.navigationManager_.getTreeForDebugging(wholeTree); return this.navigationManager_.getTreeForDebugging(wholeTree);
} }
} }
static refreshFocusRings() {
const switchAccess = SwitchAccess.get();
if (switchAccess.navigationManager_) {
switchAccess.navigationManager_.refreshFocusRings();
}
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment