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

Read offscreen nodes when speaking selected text with search+s.

The next change will follow onto this one by scrolling to the
currently spoken node if it is offscreen.

Bug: 812874
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I9ad68a2e88885ea7e94f09eb95b8b689eb9a0fd2
Reviewed-on: https://chromium-review.googlesource.com/923085Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Katie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537330}
parent 00d08cce
...@@ -83,12 +83,13 @@ function getNodeState(node) { ...@@ -83,12 +83,13 @@ function getNodeState(node) {
/** /**
* Returns true if a node should be ignored by Select-to-Speak. * Returns true if a node should be ignored by Select-to-Speak.
* @param {AutomationNode} node The node to test * @param {AutomationNode} node The node to test
* @param {boolean} includeOffscreen Whether to include offscreen nodes.
* @return {boolean} whether this node should be ignored. * @return {boolean} whether this node should be ignored.
*/ */
function shouldIgnoreNode(node) { function shouldIgnoreNode(node, includeOffscreen) {
return ( return (
!node.name || !node.location || node.state.offscreen || !node.name || !node.location || node.state.invisible ||
node.state.invisible); (node.state.offscreen && !includeOffscreen));
} }
/** /**
...@@ -113,7 +114,8 @@ function findAllMatching(node, rect, nodes) { ...@@ -113,7 +114,8 @@ function findAllMatching(node, rect, nodes) {
// Closure needs node.location check here to allow the next few // Closure needs node.location check here to allow the next few
// lines to compile. // lines to compile.
if (shouldIgnoreNode(node) || node.location === undefined) if (shouldIgnoreNode(node, /* don't include offscreen */ false) ||
node.location === undefined)
return false; return false;
if (overlaps(node.location, rect)) { if (overlaps(node.location, rect)) {
...@@ -527,7 +529,7 @@ SelectToSpeak.prototype = { ...@@ -527,7 +529,7 @@ SelectToSpeak.prototype = {
let nodes = []; let nodes = [];
let selectedNode = firstPosition.node; let selectedNode = firstPosition.node;
if (selectedNode.name && firstPosition.offset < selectedNode.name.length && if (selectedNode.name && firstPosition.offset < selectedNode.name.length &&
!shouldIgnoreNode(selectedNode)) { !shouldIgnoreNode(selectedNode, /* include offscreen */ true)) {
// Initialize to the first node in the list if it's valid and inside // Initialize to the first node in the list if it's valid and inside
// of the offset bounds. // of the offset bounds.
nodes.push(selectedNode); nodes.push(selectedNode);
...@@ -548,7 +550,7 @@ SelectToSpeak.prototype = { ...@@ -548,7 +550,7 @@ SelectToSpeak.prototype = {
selectedNode, constants.Dir.FORWARD, selectedNode, constants.Dir.FORWARD,
AutomationPredicate.leafWithText); AutomationPredicate.leafWithText);
if (selectedNode) { if (selectedNode) {
if (!shouldIgnoreNode(selectedNode)) if (!shouldIgnoreNode(selectedNode, /* include offscreen */ true))
nodes.push(selectedNode); nodes.push(selectedNode);
} else { } else {
break; break;
......
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