mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 654989 part 1. Allow handing out both an nsIContent and an nsStyleContext from CreateAnonymousContent. r=roc
This commit is contained in:
parent
3ba0ae6a9e
commit
7d3e2c97ad
@ -3851,7 +3851,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState,
|
||||
PendingBinding* aPendingBinding,
|
||||
nsFrameItems& aChildItems)
|
||||
{
|
||||
nsAutoTArray<nsIContent*, 4> newAnonymousItems;
|
||||
nsAutoTArray<nsIAnonymousContentCreator::ContentInfo, 4> 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<nsIContent*>& aContent)
|
||||
nsTArray<nsIAnonymousContentCreator::ContentInfo>& 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<nsIContent*, 4> anonymousItems;
|
||||
nsAutoTArray<nsIAnonymousContentCreator::ContentInfo, 4> 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()) {
|
||||
|
@ -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<nsIContent*>& aAnonContent);
|
||||
nsTArray<nsIAnonymousContentCreator::ContentInfo>& aAnonContent);
|
||||
|
||||
//MathML Mod - RBS
|
||||
#ifdef MOZ_MATHML
|
||||
|
@ -991,7 +991,7 @@ nsComboboxControlFrame::GetContentInsertionFrame() {
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComboboxControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsComboboxControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& 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
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
NS_DECL_FRAMEARENA_HELPERS
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
virtual nsIFrame* CreateFrameFor(nsIContent* aContent);
|
||||
|
@ -218,7 +218,7 @@ PRBool CapturePickerAcceptCallback(const nsAString& aAccept, void* aClosure)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFileControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
// Get the NodeInfoManager and tag necessary to create input elements
|
||||
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
|
||||
|
@ -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<nsIContent*>& aElements)
|
||||
nsGfxButtonControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
nsXPIDLString label;
|
||||
GetLabel(label);
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
NS_DECL_QUERYFRAME
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
virtual nsIFrame* CreateFrameFor(nsIContent* aContent);
|
||||
|
@ -187,7 +187,7 @@ nsIsIndexFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsIsIndexFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsIsIndexFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
// Get the node info manager (used to create hr's and input's)
|
||||
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
|
||||
|
@ -391,7 +391,7 @@ nsTextControlFrame::EnsureEditorInitialized()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsTextControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
NS_ASSERTION(mContent, "We should have a content!");
|
||||
|
||||
|
@ -121,7 +121,7 @@ public:
|
||||
}
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
|
||||
|
@ -106,7 +106,7 @@ nsHTMLScrollFrame::nsHTMLScrollFrame(nsIPresShell* aShell, nsStyleContext* aCont
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLScrollFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsHTMLScrollFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
return mInner.CreateAnonymousContent(aElements);
|
||||
}
|
||||
@ -1024,7 +1024,7 @@ nsMargin nsGfxScrollFrameInner::GetDesiredScrollbarSizes(nsBoxLayoutState* aStat
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULScrollFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsXULScrollFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
return mInner.CreateAnonymousContent(aElements);
|
||||
}
|
||||
@ -2386,7 +2386,8 @@ nsGfxScrollFrameInner::ReloadChildFrames()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsGfxScrollFrameInner::CreateAnonymousContent(
|
||||
nsTArray<nsIAnonymousContentCreator::ContentInfo>& aElements)
|
||||
{
|
||||
nsPresContext* presContext = mOuter->PresContext();
|
||||
nsIFrame* parent = mOuter->GetParent();
|
||||
|
@ -81,7 +81,8 @@ public:
|
||||
// We need this if a scrollbar frame is recreated.
|
||||
void ReloadChildFrames();
|
||||
|
||||
nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
nsresult CreateAnonymousContent(
|
||||
nsTArray<nsIAnonymousContentCreator::ContentInfo>& aElements);
|
||||
void AppendAnonymousContentTo(nsBaseContentList& aElements, PRUint32 aFilter);
|
||||
nsresult FireScrollPortEvent();
|
||||
void PostOverflowEvent();
|
||||
@ -424,7 +425,7 @@ public:
|
||||
}
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
|
||||
@ -624,7 +625,7 @@ public:
|
||||
}
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "nsQueryFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsStyleContext.h"
|
||||
|
||||
class nsIFrame;
|
||||
template <class T, class A> 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<nsStyleContext> 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<nsIContent*>& aElements)=0;
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements)=0;
|
||||
|
||||
/**
|
||||
* Appends "native" anonymous children created by CreateAnonymousContent()
|
||||
|
@ -89,7 +89,7 @@ NS_QUERYFRAME_HEAD(nsVideoFrame)
|
||||
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
||||
|
||||
nsresult
|
||||
nsVideoFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsVideoFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
nsNodeInfoManager *nodeInfoManager = GetContent()->GetCurrentDoc()->NodeInfoManager();
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
|
||||
}
|
||||
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilters);
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
#endif
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
};
|
||||
@ -171,7 +171,7 @@ nsSVGUseFrame::IsLeaf() const
|
||||
// nsIAnonymousContentCreator methods:
|
||||
|
||||
nsresult
|
||||
nsSVGUseFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsSVGUseFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
nsSVGUseElement *use = static_cast<nsSVGUseElement*>(mContent);
|
||||
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
NS_DECL_FRAMEARENA_HELPERS
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
||||
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
||||
PRUint32 aFilter);
|
||||
|
||||
@ -110,7 +110,7 @@ nsDocElementBoxFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
nsIDocument* doc = mContent->GetDocument();
|
||||
if (!doc) {
|
||||
|
Loading…
Reference in New Issue
Block a user