Commit 8d5349e0 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fix corner cases in braille routing

- allow nodes to be clicked one beyond their text content regardless of where the node falls in the overall line
- the action node should always be the one that best fits the position as we pick the last actionable node span
- selection uses this node so selections can be made at the end of a node's text content as well

Bug: 
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I9062ec48dddeda5f85165bac4971bf858cb1ded5
Reviewed-on: https://chromium-review.googlesource.com/618291Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496504}
parent 371d628e
......@@ -636,22 +636,22 @@ Background.prototype = {
var actionNodeSpan = null;
var selectionSpan = null;
// For a routing key press one cell beyond the last displayed character, use
// the node span for the last character. This enables routing selection to
// the length of the text, which is valid.
var nodePosition = position;
if (position == text.length && position > 0)
nodePosition--;
text.getSpans(nodePosition).forEach(function(span) {
if (span instanceof Output.SelectionSpan) {
selectionSpan = span;
} else if (span instanceof Output.NodeSpan) {
if (!actionNodeSpan ||
text.getSpanLength(span) <= text.getSpanLength(actionNodeSpan)) {
actionNodeSpan = span;
}
var selSpans = text.getSpansInstanceOf(Output.SelectionSpan);
var nodeSpans = text.getSpansInstanceOf(Output.NodeSpan);
for (var i = 0, selSpan; selSpan = selSpans[i]; i++) {
if (text.getSpanStart(selSpan) <= position &&
position < text.getSpanEnd(selSpan)) {
selectionSpan = selSpan;
break;
}
});
}
for (var j = 0, nodeSpan; nodeSpan = nodeSpans[j]; j++) {
if (text.getSpanStart(nodeSpan) <= position &&
position <= text.getSpanEnd(nodeSpan))
actionNodeSpan = nodeSpan;
}
if (!actionNodeSpan)
return;
var actionNode = actionNodeSpan.node;
......@@ -660,6 +660,10 @@ Background.prototype = {
actionNode = actionNode.parent;
actionNode.doDefault();
if (actionNode.role != RoleType.STATIC_TEXT &&
actionNode.role != RoleType.TEXT_FIELD)
return;
if (!selectionSpan)
selectionSpan = actionNodeSpan;
......
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