Bug 1766206: TextLeafPoint: When determining whether an Accessible is at the start of a line, compare with the last continuation of the previous leaf. r=morgan

Previously, we were always comparing with the primary frame of the previous leaf.
If the previous leaf crossed lines, this meant we incorrectly reported that the following leaf started a new line even if it didn't, since the primary frame of the previous leaf was always on a different line.
Now, we use the last continuation (line) of the previous leaf.
This way, if the next leaf continues the final line of the previous leaf, they will have the same line number and so we won't incorrectly report that the next leaf starts a new line.

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

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

@ -159,7 +159,6 @@ static bool IsLocalAccAtLineStart(LocalAccessible* aAcc) {
if (!prevFrame) {
return false;
}
nsIFrame::GetLastLeaf(&prevFrame);
auto [thisBlock, thisLineFrame] = thisFrame->GetContainingBlockForLine(
/* aLockScroll */ false);
if (!thisBlock) {
@ -167,6 +166,10 @@ static bool IsLocalAccAtLineStart(LocalAccessible* aAcc) {
// play it safe and assume this is the beginning of a new line.
return true;
}
nsIFrame::GetLastLeaf(&prevFrame);
// The previous leaf might cross lines. We want to compare against the last
// line.
prevFrame = prevFrame->LastContinuation();
auto [prevBlock, prevLineFrame] = prevFrame->GetContainingBlockForLine(
/* aLockScroll */ false);
if (thisBlock != prevBlock) {

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

@ -248,6 +248,12 @@
/* returned start offset */ okIfCache,
/* returned end offset */ okIfCache);
// A line which wraps, followed by a br, followed by another line.
testTextAtOffset([ "brAfterWrapped" ], BOUNDARY_LINE_START,
[ [0, 1, "a ", 0, 2],
[2, 3, "b\n", 2, 4],
[4, 5, "c", 4, 5] ]);
SimpleTest.finish();
}
@ -366,5 +372,6 @@ two words
<span>Line 4<br/>
</span></div><!-- OK to indent again -->
<div id="displayContents">a<ul style="display: contents;"><li style="display: contents;"></li></ul>b</div>
<div id="brAfterWrapped" style="width: 10px;">a b<br>c</div>
</body>
</html>