diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index c93e5c2da130..0d8831b8c62c 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3851,7 +3851,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState, PendingBinding* aPendingBinding, nsFrameItems& aChildItems) { - nsAutoTArray newAnonymousItems; + nsAutoTArray newAnonymousItems; nsresult rv = GetAnonymousContent(aParent, aParentFrame, newAnonymousItems); NS_ENSURE_SUCCESS(rv, rv); @@ -3868,8 +3868,9 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState, "How can that happen if we have nodes to construct frames for?"); for (PRUint32 i=0; i < count; i++) { - nsIContent* content = newAnonymousItems[i]; + nsIContent* content = newAnonymousItems[i].mContent; NS_ASSERTION(content, "null anonymous content?"); + NS_ASSERTION(!newAnonymousItems[i].mStyleContext, "Unexpected style context"); nsIFrame* newFrame = creator->CreateFrameFor(content); if (newFrame) { @@ -3889,7 +3890,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState, nsresult nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent, nsIFrame* aParentFrame, - nsTArray& aContent) + nsTArray& aContent) { nsIAnonymousContentCreator* creator = do_QueryFrame(aParentFrame); if (!creator) @@ -3901,7 +3902,7 @@ nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent, PRUint32 count = aContent.Length(); for (PRUint32 i=0; i < count; i++) { // get our child's content and set its parent to our content - nsIContent* content = aContent[i]; + nsIContent* content = aContent[i].mContent; NS_ASSERTION(content, "null anonymous content?"); // least-surprise CSS binding until we do the SVG specified @@ -9534,18 +9535,19 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState, // Create any anonymous frames we need here. This must happen before the // non-anonymous children are processed to ensure that popups are never // constructed before the popupset. - nsAutoTArray anonymousItems; + nsAutoTArray anonymousItems; GetAnonymousContent(aContent, aFrame, anonymousItems); for (PRUint32 i = 0; i < anonymousItems.Length(); ++i) { #ifdef DEBUG nsIAnonymousContentCreator* creator = do_QueryFrame(aFrame); - NS_ASSERTION(!creator || !creator->CreateFrameFor(anonymousItems[i]), + NS_ASSERTION(!creator || + !creator->CreateFrameFor(anonymousItems[i].mContent), "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], PR_TRUE, aFrame, - itemsToConstruct); + AddFrameConstructionItems(aState, anonymousItems[i].mContent, PR_TRUE, + aFrame, itemsToConstruct); } if (!aFrame->IsLeaf()) { diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 4b8e588dfb11..8c9bd0541f4f 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -53,6 +53,7 @@ #include "nsPageContentFrame.h" #include "nsCSSPseudoElements.h" #include "RestyleTracker.h" +#include "nsIAnonymousContentCreator.h" class nsIDocument; struct nsFrameItems; @@ -1267,7 +1268,7 @@ private: nsresult GetAnonymousContent(nsIContent* aParent, nsIFrame* aParentFrame, - nsTArray& aAnonContent); + nsTArray& aAnonContent); //MathML Mod - RBS #ifdef MOZ_MATHML diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 2172a4a4e1c7..f405d91b0e11 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -991,7 +991,7 @@ nsComboboxControlFrame::GetContentInsertionFrame() { } nsresult -nsComboboxControlFrame::CreateAnonymousContent(nsTArray& aElements) +nsComboboxControlFrame::CreateAnonymousContent(nsTArray& aElements) { // The frames used to display the combo box and the button used to popup the dropdown list // are created through anonymous content. The dropdown list is not created through anonymous diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index fd90c98515d3..4cc48fa9c6b7 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -98,7 +98,7 @@ public: NS_DECL_FRAMEARENA_HELPERS // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); virtual nsIFrame* CreateFrameFor(nsIContent* aContent); diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index 65c9c65a4d91..a57847ebe532 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -218,7 +218,7 @@ PRBool CapturePickerAcceptCallback(const nsAString& aAccept, void* aClosure) } nsresult -nsFileControlFrame::CreateAnonymousContent(nsTArray& aElements) +nsFileControlFrame::CreateAnonymousContent(nsTArray& aElements) { // Get the NodeInfoManager and tag necessary to create input elements nsCOMPtr doc = mContent->GetDocument(); diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index 6eb8e10ef540..599a31a92eec 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -93,7 +93,7 @@ public: // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index 1296ce4be583..64cf1575ed54 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -112,7 +112,7 @@ nsGfxButtonControlFrame::GetFrameName(nsAString& aResult) const // Create the text content used as label for the button. // The frame will be generated by the frame constructor. nsresult -nsGfxButtonControlFrame::CreateAnonymousContent(nsTArray& aElements) +nsGfxButtonControlFrame::CreateAnonymousContent(nsTArray& aElements) { nsXPIDLString label; GetLabel(label); diff --git a/layout/forms/nsGfxButtonControlFrame.h b/layout/forms/nsGfxButtonControlFrame.h index b3a464108e16..bc3cc6d1c76b 100644 --- a/layout/forms/nsGfxButtonControlFrame.h +++ b/layout/forms/nsGfxButtonControlFrame.h @@ -75,7 +75,7 @@ public: NS_DECL_QUERYFRAME // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); virtual nsIFrame* CreateFrameFor(nsIContent* aContent); diff --git a/layout/forms/nsIsIndexFrame.cpp b/layout/forms/nsIsIndexFrame.cpp index 336f80a61dac..67b3dcf1e86b 100644 --- a/layout/forms/nsIsIndexFrame.cpp +++ b/layout/forms/nsIsIndexFrame.cpp @@ -187,7 +187,7 @@ nsIsIndexFrame::SetFocus(PRBool aOn, PRBool aRepaint) } nsresult -nsIsIndexFrame::CreateAnonymousContent(nsTArray& aElements) +nsIsIndexFrame::CreateAnonymousContent(nsTArray& aElements) { // Get the node info manager (used to create hr's and input's) nsCOMPtr doc = mContent->GetDocument(); diff --git a/layout/forms/nsIsIndexFrame.h b/layout/forms/nsIsIndexFrame.h index b717c6079461..92b408c64a5e 100644 --- a/layout/forms/nsIsIndexFrame.h +++ b/layout/forms/nsIsIndexFrame.h @@ -97,7 +97,7 @@ public: void SetFocus(PRBool aOn, PRBool aRepaint); // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 20c6c00bf359..8567f82d5111 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -391,7 +391,7 @@ nsTextControlFrame::EnsureEditorInitialized() } nsresult -nsTextControlFrame::CreateAnonymousContent(nsTArray& aElements) +nsTextControlFrame::CreateAnonymousContent(nsTArray& aElements) { NS_ASSERTION(mContent, "We should have a content!"); diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index b1b18dece88b..f6e87c6f20f9 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -121,7 +121,7 @@ public: } // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index ab4d179dbb64..ccc20b475f17 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -106,7 +106,7 @@ nsHTMLScrollFrame::nsHTMLScrollFrame(nsIPresShell* aShell, nsStyleContext* aCont } nsresult -nsHTMLScrollFrame::CreateAnonymousContent(nsTArray& aElements) +nsHTMLScrollFrame::CreateAnonymousContent(nsTArray& aElements) { return mInner.CreateAnonymousContent(aElements); } @@ -1024,7 +1024,7 @@ nsMargin nsGfxScrollFrameInner::GetDesiredScrollbarSizes(nsBoxLayoutState* aStat } nsresult -nsXULScrollFrame::CreateAnonymousContent(nsTArray& aElements) +nsXULScrollFrame::CreateAnonymousContent(nsTArray& aElements) { return mInner.CreateAnonymousContent(aElements); } @@ -2386,7 +2386,8 @@ nsGfxScrollFrameInner::ReloadChildFrames() } nsresult -nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray& aElements) +nsGfxScrollFrameInner::CreateAnonymousContent( + nsTArray& aElements) { nsPresContext* presContext = mOuter->PresContext(); nsIFrame* parent = mOuter->GetParent(); diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index 01cdbc0ec4a9..bab8a5cabe8b 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -81,7 +81,8 @@ public: // We need this if a scrollbar frame is recreated. void ReloadChildFrames(); - nsresult CreateAnonymousContent(nsTArray& aElements); + nsresult CreateAnonymousContent( + nsTArray& aElements); void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); nsresult FireScrollPortEvent(); void PostOverflowEvent(); @@ -424,7 +425,7 @@ public: } // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); @@ -624,7 +625,7 @@ public: } // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); diff --git a/layout/generic/nsIAnonymousContentCreator.h b/layout/generic/nsIAnonymousContentCreator.h index 6f7d65378079..c3391ee17912 100644 --- a/layout/generic/nsIAnonymousContentCreator.h +++ b/layout/generic/nsIAnonymousContentCreator.h @@ -45,6 +45,7 @@ #include "nsQueryFrame.h" #include "nsIContent.h" +#include "nsStyleContext.h" class nsIFrame; template class nsTArray; @@ -60,6 +61,19 @@ class nsIAnonymousContentCreator public: NS_DECL_QUERYFRAME_TARGET(nsIAnonymousContentCreator) + struct ContentInfo { + ContentInfo(nsIContent* aContent) : + mContent(aContent) + {} + + ContentInfo(nsIContent* aContent, nsStyleContext* aStyleContext) : + mContent(aContent), mStyleContext(aStyleContext) + {} + + nsIContent* mContent; + nsRefPtr mStyleContext; + }; + /** * Creates "native" anonymous content and adds the created content to * the aElements array. None of the returned elements can be nsnull. @@ -69,7 +83,7 @@ public: * from CreateAnonymousContent when appropriate (i.e. before releasing * them). */ - virtual nsresult CreateAnonymousContent(nsTArray& aElements)=0; + virtual nsresult CreateAnonymousContent(nsTArray& aElements)=0; /** * Appends "native" anonymous children created by CreateAnonymousContent() diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 49a8d3598e2e..c638736970b0 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -89,7 +89,7 @@ NS_QUERYFRAME_HEAD(nsVideoFrame) NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame) nsresult -nsVideoFrame::CreateAnonymousContent(nsTArray& aElements) +nsVideoFrame::CreateAnonymousContent(nsTArray& aElements) { nsNodeInfoManager *nodeInfoManager = GetContent()->GetCurrentDoc()->NodeInfoManager(); nsCOMPtr nodeInfo; diff --git a/layout/generic/nsVideoFrame.h b/layout/generic/nsVideoFrame.h index a6584cd2dac6..83bcf3088cba 100644 --- a/layout/generic/nsVideoFrame.h +++ b/layout/generic/nsVideoFrame.h @@ -103,7 +103,7 @@ public: return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced)); } - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilters); diff --git a/layout/svg/base/src/nsSVGUseFrame.cpp b/layout/svg/base/src/nsSVGUseFrame.cpp index 110d021c27d1..04b9eec53b39 100644 --- a/layout/svg/base/src/nsSVGUseFrame.cpp +++ b/layout/svg/base/src/nsSVGUseFrame.cpp @@ -88,7 +88,7 @@ public: #endif // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); }; @@ -171,7 +171,7 @@ nsSVGUseFrame::IsLeaf() const // nsIAnonymousContentCreator methods: nsresult -nsSVGUseFrame::CreateAnonymousContent(nsTArray& aElements) +nsSVGUseFrame::CreateAnonymousContent(nsTArray& aElements) { nsSVGUseElement *use = static_cast(mContent); diff --git a/layout/xul/base/src/nsDocElementBoxFrame.cpp b/layout/xul/base/src/nsDocElementBoxFrame.cpp index 3c618df71458..866ef2ce7d80 100644 --- a/layout/xul/base/src/nsDocElementBoxFrame.cpp +++ b/layout/xul/base/src/nsDocElementBoxFrame.cpp @@ -71,7 +71,7 @@ public: NS_DECL_FRAMEARENA_HELPERS // nsIAnonymousContentCreator - virtual nsresult CreateAnonymousContent(nsTArray& aElements); + virtual nsresult CreateAnonymousContent(nsTArray& aElements); virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter); @@ -110,7 +110,7 @@ nsDocElementBoxFrame::DestroyFrom(nsIFrame* aDestructRoot) } nsresult -nsDocElementBoxFrame::CreateAnonymousContent(nsTArray& aElements) +nsDocElementBoxFrame::CreateAnonymousContent(nsTArray& aElements) { nsIDocument* doc = mContent->GetDocument(); if (!doc) {