Commit 5349bb92 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

[a11y switch access] Avoid using obsolete child node as the focus node

When fetching history record, the group stored in history updates. As a
result, the focus node stored in history may not be a child of the group
anymore. However, that obsolete node is still used as the preferred
focus node. This CL fixes it. See comments under the issue for detailed
analysis.

Bug: 831407
Change-Id: I1e1553c4322408fb431b212d9e0397b95e7f50ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2482184Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818928}
parent a95531a0
......@@ -434,9 +434,23 @@ class NavigationManager {
*/
restoreFromHistory_() {
const data = this.history_.retrieve();
// |data.focus| may not be a child of |data.group| anymore since
// |data.group| updates when retrieving the history record. So |data.focus|
// should not be used as the preferred focus node.
const groupChildren = data.group.children;
var focusTarget = null;
for (var index = 0; index < groupChildren.length; ++index) {
const child = groupChildren[index];
if (child.isEquivalentTo(data.focus)) {
focusTarget = child;
break;
}
}
// retrieve() guarantees that the group is valid, but not the focus.
if (data.focus.isValidAndVisible()) {
this.setGroup_(data.group, data.focus);
if (focusTarget && focusTarget.isValidAndVisible()) {
this.setGroup_(data.group, focusTarget);
} else {
this.setGroup_(data.group);
}
......
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