Commit 5b910974 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Allow live regions on web contents not hosted within webviews

Currently, ChromeVox only allows live regions on focused web content. within a WebView.

Specifically, the hosting views::WebView needs to be focused.

This change adds support for live regions to the virtual keyboard, which is hosted within an aura::Window.

R=jopalmer@chromium.org

AX-Relnotes: n/a
Change-Id: Icfef3ee2c356ddf4ee59649b8edcde9b390795b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2208821
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772535}
parent 94bd8fed
......@@ -13,6 +13,7 @@ goog.require('ChromeVoxState');
goog.scope(function() {
const AutomationNode = chrome.automation.AutomationNode;
const RoleType = chrome.automation.RoleType;
const StateType = chrome.automation.StateType;
const TreeChange = chrome.automation.TreeChange;
const TreeChangeObserverFilter = chrome.automation.TreeChangeObserverFilter;
const TreeChangeType = chrome.automation.TreeChangeType;
......@@ -70,16 +71,7 @@ LiveRegions = class {
return;
}
const currentRange = this.chromeVoxState_.currentRange;
if (!currentRange) {
return;
}
let webView = AutomationUtil.getTopLevelRoot(node);
webView = webView ? webView.parent : null;
if (!LiveRegions.announceLiveRegionsFromBackgroundTabs_ &&
currentRange.start.node.role != RoleType.DESKTOP &&
(!webView || !webView.state.focused)) {
if (this.shouldIgnoreLiveRegion_(node)) {
return;
}
......@@ -169,9 +161,11 @@ LiveRegions = class {
output.withSpeechCategory(TtsCategory.LIVE);
// Queue live regions coming from background tabs.
let webView = AutomationUtil.getTopLevelRoot(node);
webView = webView ? webView.parent : null;
const forceQueue = !webView || !webView.state.focused ||
let hostView = AutomationUtil.getTopLevelRoot(node);
hostView = hostView ? hostView.parent : null;
const currentRange = this.chromeVoxState_.currentRange;
const forceQueue = !hostView || !hostView.state.focused ||
(currentRange && currentRange.start.node.root != node.root) ||
node.containerLiveStatus == 'polite';
// Enqueue live region updates that were received at approximately
......@@ -218,6 +212,39 @@ LiveRegions = class {
this.addNodeToNodeSetRecursive_(child);
}
}
/**
* @param {!AutomationNode} node
* @return {boolean}
* @private
*/
shouldIgnoreLiveRegion_(node) {
if (LiveRegions.announceLiveRegionsFromBackgroundTabs_) {
return false;
}
const currentRange = this.chromeVoxState_.currentRange;
if (currentRange && currentRange.start.node.root == node.root) {
return false;
}
let hostView = AutomationUtil.getTopLevelRoot(node);
hostView = hostView ? hostView.parent : null;
if (!hostView) {
return true;
}
if (hostView.role == RoleType.WINDOW &&
!hostView.state[StateType.INVISIBLE]) {
return false;
}
if (hostView.state.focused) {
return false;
}
return true;
}
};
/**
......
......@@ -397,3 +397,21 @@ TEST_F('ChromeVoxLiveRegionsTest', 'TreeChangeOnIgnoredNode', function() {
.replay();
});
});
SYNC_TEST_F('ChromeVoxLiveRegionsTest', 'ShouldIgnoreLiveRegion', function() {
const liveRegions = new LiveRegions(ChromeVoxState.instance);
const mockParentNode = {};
mockParentNode.root = {role: chrome.automation.RoleType.DESKTOP};
mockParentNode.state = {};
const mockNode = {};
mockNode.role = chrome.automation.RoleType.ROOT_WEB_AREA;
mockNode.root = mockNode;
mockNode.parent = mockParentNode;
mockNode.state = {};
mockParentNode.role = chrome.automation.RoleType.WINDOW;
assertFalse(liveRegions.shouldIgnoreLiveRegion_(mockNode));
mockParentNode.state[chrome.automation.StateType.INVISIBLE] = true;
assertTrue(liveRegions.shouldIgnoreLiveRegion_(mockNode));
});
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