From 14bb98e17510892a5cd622d76c605f1a7fd8b247 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 07:17:52 -0400 Subject: Bug 1380749 - Retry AdjustAppendParentForAfterContent in case |parentAfterFrame| was a :first-letter frame that we deleted Tag #1375 --- layout/base/nsCSSFrameConstructor.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'layout/base/nsCSSFrameConstructor.cpp') diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 85f53a820..bc49c277b 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -7446,20 +7446,14 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, // Deal with possible :after generated content on the parent nsIFrame* parentAfterFrame; + nsContainerFrame* preAdjustedParentFrame = parentFrame; parentFrame = ::AdjustAppendParentForAfterContent(this, insertion.mContainer, parentFrame, aFirstNewContent, &parentAfterFrame); - // Create some new frames - nsFrameConstructorState state(mPresShell, - GetAbsoluteContainingBlock(parentFrame, FIXED_POS), - GetAbsoluteContainingBlock(parentFrame, ABS_POS), - GetFloatContainingBlock(parentFrame)); - state.mTreeMatchContext.InitAncestors(aContainer->AsElement()); - // See if the containing block has :first-letter style applied. bool haveFirstLetterStyle = false, haveFirstLineStyle = false; - nsContainerFrame* containingBlock = state.mFloatedItems.containingBlock; + nsContainerFrame* containingBlock = GetFloatContainingBlock(parentFrame); if (containingBlock) { haveFirstLetterStyle = HasFirstLetterStyle(containingBlock); haveFirstLineStyle = @@ -7468,10 +7462,30 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, } if (haveFirstLetterStyle) { + nsWeakFrame wf(parentAfterFrame); // Before we get going, remove the current letter frames - RemoveLetterFrames(state.mPresShell, containingBlock); + RemoveLetterFrames(mPresShell, containingBlock); + + if (parentAfterFrame && !wf) { + // Ouch, parentAfterFrame was a letter frame and we just deleted it! + // Retry AdjustAppendParentForAfterContent; fortunately this is rare. + parentFrame = + ::AdjustAppendParentForAfterContent(this, insertion.mContainer, + preAdjustedParentFrame, + aFirstNewContent, &parentAfterFrame); + if (parentFrame != preAdjustedParentFrame) { + containingBlock = GetFloatContainingBlock(parentFrame); + } + } } + // Create some new frames + nsFrameConstructorState state(mPresShell, + GetAbsoluteContainingBlock(parentFrame, FIXED_POS), + GetAbsoluteContainingBlock(parentFrame, ABS_POS), + containingBlock); + state.mTreeMatchContext.InitAncestors(aContainer->AsElement()); + nsIAtom* frameType = parentFrame->GetType(); FlattenedChildIterator iter(aContainer); -- cgit v1.2.3