Bug 1343078 part 5. Change the restyle manager to handle style contexts with no parent in ReparentStyleContext (by doing nothing with them). r?dbaron
MozReview-Commit-ID: 9a89RV8mKYn
--- a/layout/base/GeckoRestyleManager.cpp
+++ b/layout/base/GeckoRestyleManager.cpp
@@ -861,23 +861,16 @@ GeckoRestyleManager::ReparentStyleContex
nsIFrame* providerChild = nullptr;
if (isChild) {
ReparentStyleContext(providerFrame);
// Get the style context again after ReparentStyleContext() which might have
// changed it.
newParentContext = providerFrame->StyleContext();
providerChild = providerFrame;
}
- NS_ASSERTION(newParentContext, "Reparenting something that has no usable"
- " parent? Shouldn't happen!");
- // XXX need to do something here to produce the correct style context for
- // an IB split whose first inline part is inside a first-line frame.
- // Currently the first IB anonymous block's style context takes the first
- // part's style context as parent, which is wrong since first-line style
- // should not apply to the anonymous block.
#ifdef DEBUG
{
// Check that our assumption that continuations of the same
// pseudo-type and with the same style context parent have the
// same style context is valid before the reresolution. (We need
// to check the pseudo-type and style context parent because of
// :first-letter and :first-line, where we create styled and
@@ -893,16 +886,38 @@ GeckoRestyleManager::ReparentStyleContex
nextContinuationContext->GetPseudo() ||
oldContext->GetParent() !=
nextContinuationContext->GetParent(),
"continuations should have the same style context");
}
}
#endif
+ if (!newParentContext && !oldContext->GetParent()) {
+ // No need to do anything here.
+#ifdef DEBUG
+ // Make sure we have no children, so we really know there is nothing to do.
+ nsIFrame::ChildListIterator lists(aFrame);
+ for (; !lists.IsDone(); lists.Next()) {
+ MOZ_ASSERT(lists.CurrentList().IsEmpty(),
+ "Failing to reparent style context for child of "
+ "non-inheriting anon box");
+ }
+#endif // DEBUG
+ return NS_OK;
+ }
+
+ NS_ASSERTION(newParentContext, "Reparenting something that has no usable"
+ " parent? Shouldn't happen!");
+ // XXX need to do something here to produce the correct style context for
+ // an IB split whose first inline part is inside a first-line frame.
+ // Currently the first IB anonymous block's style context takes the first
+ // part's style context as parent, which is wrong since first-line style
+ // should not apply to the anonymous block.
+
nsIFrame* prevContinuation =
GetPrevContinuationWithPossiblySameStyle(aFrame);
nsStyleContext* prevContinuationContext;
bool copyFromContinuation =
prevContinuation &&
(prevContinuationContext = prevContinuation->StyleContext())
->GetPseudo() == oldContext->GetPseudo() &&
prevContinuationContext->GetParent() == newParentContext;