Bug 385354. When appending the first child of an element with :before content, we need to make sure we append after the :before frames for the element. r+sr=dbaron

This commit is contained in:
roc+@cs.cmu.edu 2007-07-18 21:25:17 -07:00
parent 4b46c408b0
commit fd80a49090

View File

@ -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);
}