Bug 1271392 part 2 - [css-grid] When pulling up grid item, make sure its next-in-flow (if any) is in our next-in-flow. r=dholbert

This commit is contained in:
Mats Palmgren 2016-05-18 13:49:33 +02:00
parent 6dca609754
commit a1b690d0f2

View File

@ -4928,6 +4928,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
RemoveStateBits(NS_STATE_GRID_DID_PUSH_ITEMS);
nsFrameList items;
auto nif = static_cast<nsGridContainerFrame*>(GetNextInFlow());
auto firstNIF = nif;
DebugOnly<bool> nifNeedPushedItem = false;
while (nif) {
nsFrameList nifItems;
@ -4970,6 +4971,29 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
"NS_STATE_GRID_DID_PUSH_ITEMS lied");
}
if (!items.IsEmpty()) {
// Pull up the first next-in-flow of the pulled up items too, unless its
// parent is our nif (to avoid leaving a hole there).
nsFrameList childNIFs;
nsFrameList childOCNIFs;
for (auto child : items) {
auto childNIF = child->GetNextInFlow();
if (childNIF && childNIF->GetParent() != firstNIF) {
auto parent = childNIF->GetParent();
parent->StealFrame(childNIF);
ReparentFrame(childNIF, parent, firstNIF);
if ((childNIF->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
childOCNIFs.AppendFrame(nullptr, childNIF);
} else {
childNIFs.AppendFrame(nullptr, childNIF);
}
}
}
// Merge items' NIFs into our NIF's respective overflow child lists.
firstNIF->MergeSortedOverflow(childNIFs);
firstNIF->MergeSortedExcessOverflowContainers(childOCNIFs);
}
MOZ_ASSERT(foundOwnPushedChild || !items.IsEmpty() || mDidPushItemsBitMayLie,
"NS_STATE_GRID_DID_PUSH_ITEMS lied");
::MergeSortedFrameLists(mFrames, items, GetContent());