Commit 7843b3b3 authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox: Correctly recover focus when collapsing the Panel.

This change fixes a regression that was introduced by adding in-page
link support for ChromeVox. The issue is that when the panel is
collapsed, a scrolled_to_anchor event is fired, which was causing us
to always place focus on the Panel root web area upon collapsing the
menus. To fix the issue, we ignore scrolled_to_anchor events if the
root of the target differs from the root of the current range.

Fixed: 1133548
AX-Relnotes: N/A
Change-Id: I43e99452ea27cd190bd53c62b5fb06593a5bf6b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442899
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813000}
parent be910707
...@@ -83,7 +83,7 @@ DesktopAutomationHandler = class extends BaseAutomationHandler { ...@@ -83,7 +83,7 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
EventType.SCROLL_VERTICAL_POSITION_CHANGED, EventType.SCROLL_VERTICAL_POSITION_CHANGED,
this.onScrollPositionChanged); this.onScrollPositionChanged);
// Called when a same-page link is followed or the url fragment changes. // Called when a same-page link is followed or the url fragment changes.
this.addListener_(EventType.SCROLLED_TO_ANCHOR, this.onEventDefault); this.addListener_(EventType.SCROLLED_TO_ANCHOR, this.onScrolledToAnchor);
this.addListener_(EventType.SELECTION, this.onSelection); this.addListener_(EventType.SELECTION, this.onSelection);
this.addListener_(EventType.TEXT_CHANGED, this.onEditableChanged_); this.addListener_(EventType.TEXT_CHANGED, this.onEditableChanged_);
this.addListener_( this.addListener_(
...@@ -548,6 +548,29 @@ DesktopAutomationHandler = class extends BaseAutomationHandler { ...@@ -548,6 +548,29 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
}.bind(this)); }.bind(this));
} }
/**
* Provides all feedback once a scrolled to anchor event fires.
* @param {!ChromeVoxEvent} evt
*/
onScrolledToAnchor(evt) {
if (!evt.target) {
return;
}
if (ChromeVoxState.instance.currentRange) {
const target = evt.target;
const current = ChromeVoxState.instance.currentRange.start.node;
if (AutomationUtil.getTopLevelRoot(current) !=
AutomationUtil.getTopLevelRoot(target)) {
// Ignore this event if the root of the target differs from that of the
// current range.
return;
}
}
this.onEventDefault(evt);
}
/** /**
* Create an editable text handler for the given node if needed. * Create an editable text handler for the given node if needed.
* @param {!AutomationNode} node * @param {!AutomationNode} node
......
...@@ -1112,7 +1112,7 @@ Panel = class { ...@@ -1112,7 +1112,7 @@ Panel = class {
desktop.addEventListener( desktop.addEventListener(
chrome.automation.EventType.FOCUS, onFocus, true); chrome.automation.EventType.FOCUS, onFocus, true);
// Make sure all menus are cleared to avoid bogous output when we re-open. // Make sure all menus are cleared to avoid bogus output when we re-open.
Panel.clearMenus(); Panel.clearMenus();
// Ensure annotations input is cleared. // Ensure annotations input is cleared.
......
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