Bug 1666592 - Prevent PullItemsNextInFlow() from reparenting child's NIF if NIF's parent is already this container. r=mats

We can do this because all the children in aItems are going to be moved to
this container's principal child list. It's fine to leave the child's
next-in-flow in other lists of the same parent.

Differential Revision: https://phabricator.services.mozilla.com/D92024
This commit is contained in:
Ting-Yu Lin 2020-12-11 01:05:32 +00:00
Родитель 64d2a266cd
Коммит aea8c8e06f
1 изменённых файлов: 13 добавлений и 12 удалений

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

@ -1824,9 +1824,9 @@ void nsContainerFrame::NormalizeChildLists() {
}
}
// Pull up item's next-in-flow (if any) into aItems, and reparent it to our
// next-in-flow, unless its parent is already our next-in-flow (to avoid
// leaving a hole there).
// For each item in aItems, pull up its next-in-flow (if any), and reparent it
// to our next-in-flow, unless its parent is already ourselves or our
// next-in-flow (to avoid leaving a hole there).
auto PullItemsNextInFlow = [this](const nsFrameList& aItems) {
auto* firstNIF = static_cast<nsContainerFrame*>(GetNextInFlow());
if (!firstNIF) {
@ -1835,15 +1835,16 @@ void nsContainerFrame::NormalizeChildLists() {
nsFrameList childNIFs;
nsFrameList childOCNIFs;
for (auto* child : aItems) {
auto* childNIF = child->GetNextInFlow();
if (childNIF && childNIF->GetParent() != firstNIF) {
auto* parent = childNIF->GetParent();
parent->StealFrame(childNIF);
ReparentFrame(childNIF, parent, firstNIF);
if (childNIF->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER)) {
childOCNIFs.AppendFrame(nullptr, childNIF);
} else {
childNIFs.AppendFrame(nullptr, childNIF);
if (auto* childNIF = child->GetNextInFlow()) {
if (auto* parent = childNIF->GetParent();
parent != this && parent != firstNIF) {
parent->StealFrame(childNIF);
ReparentFrame(childNIF, parent, firstNIF);
if (childNIF->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER)) {
childOCNIFs.AppendFrame(nullptr, childNIF);
} else {
childNIFs.AppendFrame(nullptr, childNIF);
}
}
}
}