--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -485,30 +485,40 @@ AnyKidsNeedBlockParent(nsIFrame *aFrameL
}
return nullptr;
}
// Reparent a frame into a wrapper frame that is a child of its old parent.
static void
ReparentFrame(RestyleManager* aRestyleManager,
nsContainerFrame* aNewParentFrame,
- nsIFrame* aFrame)
+ nsIFrame* aFrame,
+ bool aForceStyleReparent)
{
aFrame->SetParent(aNewParentFrame);
- aRestyleManager->ReparentStyleContext(aFrame);
+ // We reparent frames for two reasons: to put them inside ::first-line, and to
+ // put them inside some wrapper anonymous boxes.
+ //
+ // The latter shouldn't affect any styles in practice, so only needs style
+ // context reparenting in the Gecko backend, to make our style context tree
+ // assertions happy. The former passes aForceStyleReparent == true.
+ if (aForceStyleReparent || aRestyleManager->IsGecko()) {
+ aRestyleManager->ReparentStyleContext(aFrame);
+ }
}
static void
ReparentFrames(nsCSSFrameConstructor* aFrameConstructor,
nsContainerFrame* aNewParentFrame,
- const nsFrameList& aFrameList)
+ const nsFrameList& aFrameList,
+ bool aForceStyleReparent)
{
RestyleManager* restyleManager = aFrameConstructor->RestyleManager();
- for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
- ReparentFrame(restyleManager, aNewParentFrame, e.get());
+ for (nsIFrame* f : aFrameList) {
+ ReparentFrame(restyleManager, aNewParentFrame, f, aForceStyleReparent);
}
}
//----------------------------------------------------------------------
//
// When inline frames get weird and have block frames in them, we
// annotate them to help us respond to incremental content changes
// more easily.
@@ -5252,17 +5262,17 @@ nsCSSFrameConstructor::FlushAccumulatedB
// then, create a block frame that will wrap the child frames. Make it a
// MathML frame so that Get(Absolute/Float)ContainingBlockFor know that this
// is not a suitable block.
nsContainerFrame* blockFrame =
NS_NewMathMLmathBlockFrame(mPresShell, blockContext);
blockFrame->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS);
InitAndRestoreFrame(aState, aContent, aParentFrame, blockFrame);
- ReparentFrames(this, blockFrame, aBlockItems);
+ ReparentFrames(this, blockFrame, aBlockItems, false);
// abs-pos and floats are disabled in MathML children so we don't have to
// worry about messing up those.
blockFrame->SetInitialChildList(kPrincipalList, aBlockItems);
NS_ASSERTION(aBlockItems.IsEmpty(), "What happened?");
aBlockItems.Clear();
aNewItems.AddChild(blockFrame);
}
@@ -11355,17 +11365,17 @@ nsCSSFrameConstructor::ProcessChildren(n
nsBlockFrame* blockFrame = NS_NewBlockFrame(mPresShell, blockSC);
// We might, in theory, want to set NS_BLOCK_FLOAT_MGR and
// NS_BLOCK_MARGIN_ROOT, but I think it's a bad idea given that
// a real block placed here wouldn't get those set on it.
InitAndRestoreFrame(aState, aContent, aFrame, blockFrame, false);
NS_ASSERTION(!blockFrame->HasView(), "need to do view reparenting");
- ReparentFrames(this, blockFrame, aFrameItems);
+ ReparentFrames(this, blockFrame, aFrameItems, false);
blockFrame->SetInitialChildList(kPrincipalList, aFrameItems);
NS_ASSERTION(aFrameItems.IsEmpty(), "How did that happen?");
aFrameItems.Clear();
aFrameItems.AddChild(blockFrame);
aFrame->AddStateBits(NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK);
}
@@ -11425,17 +11435,17 @@ nsCSSFrameConstructor::WrapFramesInFirst
// subsequent children; insert lineFrame into aFrameItems.
aFrameItems.InsertFrame(nullptr, nullptr, aLineFrame);
NS_ASSERTION(aLineFrame->StyleContext() == firstLineStyle,
"Bogus style context on line frame");
}
// Give the inline frames to the lineFrame <b>after</b> reparenting them
- ReparentFrames(this, aLineFrame, firstLineChildren);
+ ReparentFrames(this, aLineFrame, firstLineChildren, true);
if (aLineFrame->PrincipalChildList().IsEmpty() &&
(aLineFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
aLineFrame->SetInitialChildList(kPrincipalList, firstLineChildren);
} else {
AppendFrames(aLineFrame, kPrincipalList, firstLineChildren);
}
}