From 24257a4235fa9d74ea2a7e56ef4b701797350c1e Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 6 May 2011 16:04:44 -0400 Subject: [PATCH] Bug 654989 part 2. Use the nsStyleContext handed back from CreateAnonymousContent. r=roc This asserts the parts of AddFrameConstructionItems that should never matter for anonymous content and then just copies the one-line style context get if it's needed. --- layout/base/nsCSSFrameConstructor.cpp | 31 +++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 0d8831b8c62c..043eabf266e0 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -9538,16 +9538,39 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState, nsAutoTArray anonymousItems; GetAnonymousContent(aContent, aFrame, anonymousItems); for (PRUint32 i = 0; i < anonymousItems.Length(); ++i) { + nsIContent* content = anonymousItems[i].mContent; #ifdef DEBUG nsIAnonymousContentCreator* creator = do_QueryFrame(aFrame); - NS_ASSERTION(!creator || - !creator->CreateFrameFor(anonymousItems[i].mContent), + NS_ASSERTION(!creator || !creator->CreateFrameFor(content), "If you need to use CreateFrameFor, you need to call " "CreateAnonymousFrames manually and not follow the standard " "ProcessChildren() codepath for this frame"); #endif - AddFrameConstructionItems(aState, anonymousItems[i].mContent, PR_TRUE, - aFrame, itemsToConstruct); + // Assert some things about this content + NS_ABORT_IF_FALSE(!(content->GetFlags() & + (NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME)), + "Should not be marked as needing frames"); + NS_ABORT_IF_FALSE(!content->IsElement() || + !(content->GetFlags() & ELEMENT_ALL_RESTYLE_FLAGS), + "Should have no pending restyle flags"); + NS_ABORT_IF_FALSE(!content->GetPrimaryFrame(), + "Should have no existing frame"); + NS_ABORT_IF_FALSE(!content->IsNodeOfType(nsINode::eCOMMENT) && + !content->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION), + "Why is someone creating garbage anonymous content"); + + nsRefPtr styleContext; + if (anonymousItems[i].mStyleContext) { + styleContext = anonymousItems[i].mStyleContext.forget(); + } else { + styleContext = ResolveStyleContext(aFrame, content, &aState); + } + + AddFrameConstructionItemsInternal(aState, content, aFrame, + content->Tag(), content->GetNameSpaceID(), + PR_TRUE, styleContext, + ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK, + itemsToConstruct); } if (!aFrame->IsLeaf()) {