diff options
-rw-r--r-- | layout/base/nsCSSFrameConstructor.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
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); |