diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 8ae152b0eae..7e050a7331a 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -9140,30 +9140,35 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer, nsIFrame* newFrame = frameItems.childList; if (NS_SUCCEEDED(rv) && newFrame) { NS_ASSERTION(!captionItems.childList, "leaking caption frames"); + if (!prevSibling) { + // We're inserting the new frame as the first child. See if the + // parent has a :before pseudo-element + nsIFrame* firstChild = parentFrame->GetFirstChild(nsnull); + + if (firstChild && + nsLayoutUtils::IsGeneratedContentFor(aContainer, firstChild, + nsCSSPseudoElements::before)) { + // Insert the new frames after the last continuation of the :before + prevSibling = firstChild->GetLastContinuation(); + nsIFrame* newParent = prevSibling->GetParent(); + if (newParent != parentFrame) { + nsHTMLContainerFrame::ReparentFrameViewList(state.mPresContext, + newFrame, parentFrame, + newParent); + parentFrame = newParent; + } + // We perhaps could leave this true and take the AppendFrames path + // below, but we'd have to update appendAfterFrame and it seems safer + // to force all insert-after-:before cases to take these to take the + // InsertFrames path + isAppend = PR_FALSE; + } + } + // Notify the parent frame if (isAppend) { AppendFrames(state, aContainer, parentFrame, newFrame, appendAfterFrame); - } - else { - if (!prevSibling) { - // We're inserting the new frame as the first child. See if the - // parent has a :before pseudo-element - nsIFrame* firstChild = parentFrame->GetFirstChild(nsnull); - - if (firstChild && - nsLayoutUtils::IsGeneratedContentFor(aContainer, firstChild, - nsCSSPseudoElements::before)) { - // Insert the new frames after the last continuation of the :before - prevSibling = firstChild->GetLastContinuation(); - nsIFrame* newParent = prevSibling->GetParent(); - if (newParent != parentFrame) { - nsHTMLContainerFrame::ReparentFrameViewList(state.mPresContext, - newFrame, parentFrame, - newParent); - parentFrame = newParent; - } - } - } + } else { state.mFrameManager->InsertFrames(parentFrame, nsnull, prevSibling, newFrame); }