Bug 1427635: Fix DoCompareTreePosition frame tree version with null aCommonAncestor. r=xidorn

It doesn't fill the ancestors of the first frame if aCommonAncestor is
null, which means that we get garbage afterwards.

MANUAL PUSH: Relanding of old patch.
This commit is contained in:
Emilio Cobos Álvarez 2022-07-19 11:50:43 +02:00
Родитель 2fbf04543f
Коммит 5aa53ad4fb
1 изменённых файлов: 5 добавлений и 2 удалений

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

@ -1291,8 +1291,11 @@ int32_t nsLayoutUtils::DoCompareTreePosition(
}
AutoTArray<nsIFrame*, 20> frame1Ancestors;
if (aCommonAncestor &&
!FillAncestors(aFrame1, aCommonAncestor, &frame1Ancestors)) {
// Note that the order of the condition is important. We need to fill the
// ancestors even if aCommonAncestor is null, otherwise the code below makes
// no sense.
if (!FillAncestors(aFrame1, aCommonAncestor, &frame1Ancestors) &&
aCommonAncestor) {
// We reached the root of the frame tree ... if aCommonAncestor was set,
// it is wrong
return DoCompareTreePosition(aFrame1, aFrame2, aIf1Ancestor, aIf2Ancestor,