Commit 0806cebf authored by David Tseng's avatar David Tseng Committed by Commit Bot

Treat lines that cover all of a node's text similarly to an object

Currently, line ranges use a slightly different output path when they
- have start/end on the same node
 - cover the node's text i.e. are not index -1 (node
index)

This change makes it so that we don't consider the range less than a node or use
the |subNode| output path if the range surrounds the entire node's text.

Test: navigate by lines (Search+up/down) over checkboxes. Output should be the
same as Search+Left/Right.

chromevox_tests --gtest_filter=Background*.* cover caret navigation and ensuring
they still work.

Bug: 784693
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I0404e11e326116e21afc2c9131a2ceeedf21e37c
Reviewed-on: https://chromium-review.googlesource.com/798370Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521026}
parent 61914cbf
......@@ -1312,3 +1312,33 @@ TEST_F('BackgroundTest', 'BusyHeading', function() {
.replay();
});
});
TEST_F('BackgroundTest', 'NodeVsSubnode', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(function(root) {/*!
<a href="#">test</a>
*/}, function(root) {
var link = root.find({role: RoleType.LINK});
function outputLinkRange(start, end) {
return function() {
new Output().withSpeech(new cursors.Range(new cursors.Cursor(link, start),
new cursors.Cursor(link, end))).go();
};
}
mockFeedback.call(outputLinkRange(0, 0))
.expectSpeech('test', 'Link')
.call(outputLinkRange(0, 1))
.expectSpeech('t')
.call(outputLinkRange(1, 1))
.expectSpeech('test', 'Link')
.call(outputLinkRange(1, 2))
.expectSpeech('e')
.call(outputLinkRange(1, 3))
.expectNextSpeechUtteranceIsNot('Link')
.expectSpeech('es')
.call(outputLinkRange(0, 4))
.expectSpeech('test', 'Link')
.replay();
});
});
......@@ -666,12 +666,15 @@ cursors.Range.prototype = {
},
/**
* Returns true if this range covers a single node's text content or less.
* Returns true if this range covers less than a node.
* @return {boolean}
*/
isSubNode: function() {
return this.start.node === this.end.node && this.start.index > -1 &&
this.end.index > -1;
var startIndex = this.start.index;
var endIndex = this.end.index;
return this.start.node === this.end.node && startIndex != -1 &&
endIndex != -1 && startIndex != endIndex &&
(startIndex != 0 || endIndex != this.start.getText().length);
},
/**
......
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