Bug 1766560: Don't ignore the first line start of a RemoteAccessible when retrieving the next line. r=morgan

The code previously returned failure for array index 0, but it did this for both movement directions.
It should only do this for eDirPrevious, since we decrement index in that case.

Differential Revision: https://phabricator.services.mozilla.com/D144785
This commit is contained in:
James Teh 2022-04-28 02:11:53 +00:00
Родитель 6743bc23ee
Коммит ff8c09efee
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -523,7 +523,8 @@ TextLeafPoint TextLeafPoint::FindLineStartSameRemoteAcc(
}
}
MOZ_ASSERT(index <= lines->Length());
if ((aDirection == eDirNext && index == lines->Length()) || index == 0) {
if ((aDirection == eDirNext && index == lines->Length()) ||
(aDirection == eDirPrevious && index == 0)) {
return TextLeafPoint();
}
// index points at the line start after mOffset.

Просмотреть файл

@ -26,6 +26,7 @@ ef gh</pre>
<p id="linksStartEnd"><a href="https://example.com/">a</a>b<a href="https://example.com/">c</a></p>
<p id="linksBreaking">a<a href="https://example.com/">b<br>c</a>d</p>
<p id="p">a<br role="presentation">b</p>
<p id="leafThenWrap" style="width: 2ch; word-break: break-word;"><span>a</span>bc</p>
`,
async function(browser, docAcc) {
for (const id of ["br", "pre"]) {
@ -157,6 +158,11 @@ ef gh</pre>
[1, 2, "b", 1, 2],
]);
testTextAtOffset(p, BOUNDARY_PARAGRAPH, [[0, 2, "ab", 0, 2]]);
const leafThenWrap = findAccessibleChildByID(docAcc, "leafThenWrap");
testTextAtOffset(leafThenWrap, BOUNDARY_LINE_START, [
[0, 1, "ab", 0, 2],
[2, 3, "c", 2, 3],
]);
},
{ chrome: true, topLevel: true, iframe: true, remoteIframe: true }
);