Commit d8d57b9a authored by Katie D's avatar Katie D Committed by Commit Bot

[Switch Access] Fix bug where menu had sub-groupings rendering it unusable.

In crrev.com/c/2303458 a bug was introduced which added sub-groupings
within the Switch Access menu. This seems to be related to the change
to use an EventHandler in switch_access.js which always acts on event.target,
whereas previously it sometimes did an action on one of the children
of event.target.

Although I don't fully understand the logic, reverting this one file
from that change does restore the correct behavior.

AX-Relnotes: N/A
Bug: 1109355
Change-Id: Id7feb1a2474e06a64d0b371beade6e33800d382c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2318315
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#792027}
parent 582a21e5
...@@ -65,26 +65,35 @@ class SwitchAccess { ...@@ -65,26 +65,35 @@ class SwitchAccess {
} }
// If it's not currently in the tree, listen for changes to the desktop // If it's not currently in the tree, listen for changes to the desktop
// tree. // tree.
const eventPredicate = (event) => { const onDesktopChildrenChanged = (event) => {
if (predicate(event.target)) { if (predicate(event.target)) {
return true; // If the event target is the node we're looking for, we've found it.
desktop.removeEventListener(
chrome.automation.EventType.CHILDREN_CHANGED,
onDesktopChildrenChanged, false);
foundCallback(event.target);
} else if (event.target.children.length > 0) { } else if (event.target.children.length > 0) {
// See if one of its children is the node we're looking for. // Otherwise, see if one of its children is the node we're looking for.
const treeWalker = new AutomationTreeWalker( const treeWalker = new AutomationTreeWalker(
event.target, constants.Dir.FORWARD, event.target, constants.Dir.FORWARD,
{visit: predicate, root: (node) => node == event.target}); {visit: predicate, root: (node) => node == event.target});
treeWalker.next(); treeWalker.next();
return !!treeWalker.node; if (treeWalker.node) {
} else { desktop.removeEventListener(
return false; chrome.automation.EventType.CHILDREN_CHANGED,
onDesktopChildrenChanged, false);
foundCallback(treeWalker.node);
}
} }
}; };
new EventHandler( // Note: Cannot use an EventHandler here because in some cases we want
desktop, chrome.automation.EventType.CHILDREN_CHANGED, // to run foundCallback on the event.target, and in some cases we want to
(event) => foundCallback(event.target), // run foundCallback on one of the target's children. We would need to
{listenOnce: true, predicate: eventPredicate}) // recalculate the interesting child twice to use EventHandler.
.start(); desktop.addEventListener(
chrome.automation.EventType.CHILDREN_CHANGED, onDesktopChildrenChanged,
false);
} }
/* /*
......
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