Copy state bits from old block parent to new before old parent is destroyed draft
authorNeerja Pancholi <npancholi@mozilla.com>
Tue, 07 Nov 2017 14:59:06 -0800
changeset 698708 95c0bd606380c94aac4dcc6fc4bc159f669a17ec
parent 698707 e44704fb0b5d82ec5557add0d5de6f9fcaf25719
child 698709 6651d9ef742454d75abc22bcb596a19d0d4a98e9
push id89334
push userbmo:npancholi@mozilla.com
push dateThu, 16 Nov 2017 00:39:30 +0000
milestone59.0a1
Copy state bits from old block parent to new before old parent is destroyed MozReview-Commit-ID: LpPFGKrVIXI ***
layout/base/nsCSSFrameConstructor.cpp
layout/generic/nsFrame.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -12421,21 +12421,21 @@ ProcessColumnSpan(nsFrameConstructorStat
     *aNewFrame = static_cast<nsContainerFrame*>(splitChildren.FirstChild());
     while (splitChildren.NotEmpty()) {
       nsContainerFrame* currChild =
           static_cast<nsContainerFrame*>(splitChildren.RemoveFirstChild());
       aState.AddChild(currChild, aFrameItems, content, styleContext, aFinalParent);
         
       if (aPositionedFrameForAbsPosContainer &&
           aPositionedFrameForAbsPosContainer == aOldParent) {
-          nsFrameList splitAbsoluteList;
-          SplitAbsoluteListForSplitBlock(currChild, aState.GetAbsoluteItems(), splitAbsoluteList);
-          nsFrameConstructorSaveState absoluteSaveState;
-          currChild->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
-          aState.OverwriteAbsoluteState(currChild, splitAbsoluteList, absoluteSaveState);
+        nsFrameList splitAbsoluteList;
+        SplitAbsoluteListForSplitBlock(currChild, aState.GetAbsoluteItems(), splitAbsoluteList);
+        nsFrameConstructorSaveState absoluteSaveState;
+        currChild->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
+        aState.OverwriteAbsoluteState(currChild, splitAbsoluteList, absoluteSaveState);
         aState.PushAbsoluteContainingBlock(currChild, currChild, absoluteSaveState);
       }
     }
   } else {
     nsFrameItems finalChildItems;
     WrapNonSpannerChildrenInColumnSets(aState, aOldParent, aChildItems,
                                        finalChildItems);
     MOZ_ASSERT(finalChildItems.NotEmpty(), "Child items cannot be empty here!");
@@ -12489,16 +12489,21 @@ nsCSSFrameConstructor::SplitBlocks(nsFra
 
       nsFrameList::
       FrameLinkEnumerator firstNonColumnSpan = FindFirstNonColumnSpan(aUnsplitChildItems);
       splitBlockChildren = aUnsplitChildItems.ExtractHead(firstNonColumnSpan);
     } else if (aNonSpannerSC) {
       splitBlock->SetStyleContextWithoutNotification(aNonSpannerSC);
     }
 
+    // xxxNeerja - Does it make sense to copy all state bits from aOldParent
+    // to all its split children?
+    if (aOldParent->Type() == LayoutFrameType::Block) {
+      splitBlock->AddStateBits(aOldParent->GetStateBits());
+    }
     MoveChildrenTo(aOldParent, splitBlock, splitBlockChildren);
     aSplitChildItems.AddChild(splitBlock);
 
     if (previousSplitBlock) {
       SetFrameIsIBSplit(previousSplitBlock, splitBlock);
     }
     previousSplitBlock = splitBlock;
   }
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -349,17 +349,21 @@ nsIFrame::GetAbsoluteContainingBlock() c
 }
 
 void
 nsIFrame::MarkAsAbsoluteContainingBlock()
 {
   MOZ_ASSERT(GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
   NS_ASSERTION(!GetProperty(AbsoluteContainingBlockProperty()),
                "Already has an abs-pos containing block property?");
-  NS_ASSERTION(!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN),
+
+  // This assertion can fail in the case of a having a multicol parent because
+  // we are copying state bits as is of the original unsplit parent to the new
+  // split parent so skip this check for multicol ancestors.
+  NS_ASSERTION(HasMulticolAncestor() || !HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN),
                "Already has NS_FRAME_HAS_ABSPOS_CHILDREN state bit?");
   AddStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN);
   SetProperty(AbsoluteContainingBlockProperty(), new nsAbsoluteContainingBlock(GetAbsoluteListID()));
 }
 
 void
 nsIFrame::MarkAsNotAbsoluteContainingBlock()
 {