diff --git a/content/xbl/public/nsIXBLBinding.h b/content/xbl/public/nsIXBLBinding.h index 229c1a338218..eabd4a80f53f 100644 --- a/content/xbl/public/nsIXBLBinding.h +++ b/content/xbl/public/nsIXBLBinding.h @@ -37,6 +37,7 @@ class nsIContent; class nsIDocument; +class nsIDOMNodeList; class nsIScriptContext; class nsIXBLPrototypeBinding; @@ -101,6 +102,9 @@ public: NS_IMETHOD ImplementsInterface(REFNSIID aIID, PRBool* aResult)=0; + NS_IMETHOD GetAnonymousNodes(nsIDOMNodeList** aResult, + nsIContent** aParent, PRBool* aMultipleInsertionPoints)=0; + NS_IMETHOD ShouldBuildChildFrames(PRBool* aResult)=0; }; diff --git a/content/xbl/public/nsIXBLService.h b/content/xbl/public/nsIXBLService.h index ae82854bfeaa..619dc7e912c8 100644 --- a/content/xbl/public/nsIXBLService.h +++ b/content/xbl/public/nsIXBLService.h @@ -37,7 +37,7 @@ class nsIContent; class nsIDocument; class nsIDOMEventReceiver; -class nsISupportsArray; +class nsIDOMNodeList; class nsIXBLBinding; class nsIXBLDocumentInfo; @@ -66,7 +66,7 @@ public: // For a given element, returns a flat list of all the anonymous children that need // frames built. - NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aChildElement, + NS_IMETHOD GetContentList(nsIContent* aContent, nsIDOMNodeList** aResult, nsIContent** aChildElement, PRBool* aMultipleInsertionPoints) = 0; // Retrieves our base class (e.g., tells us what type of frame and content node to build) diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index cf1dfeff7455..0b69922c524c 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -1410,10 +1410,11 @@ NS_IMETHODIMP nsXBLBinding::GetInsertionPoint(nsIContent* aChild, nsIContent** aResult) { *aResult = nsnull; - if (!mContent) - return NS_OK; - - return mPrototypeBinding->GetInsertionPoint(mBoundElement, mContent, aChild, aResult); + if (mContent) + return mPrototypeBinding->GetInsertionPoint(mBoundElement, mContent, aChild, aResult); + else if (mNextBinding) + return mNextBinding->GetInsertionPoint(aChild, aResult); + return NS_OK; } NS_IMETHODIMP @@ -1421,10 +1422,11 @@ nsXBLBinding::GetSingleInsertionPoint(nsIContent** aResult, PRBool* aMultipleIns { *aResult = nsnull; *aMultipleInsertionPoints = PR_FALSE; - if (!mContent) - return NS_OK; - - return mPrototypeBinding->GetSingleInsertionPoint(mBoundElement, mContent, aResult, aMultipleInsertionPoints); + if (mContent) + return mPrototypeBinding->GetSingleInsertionPoint(mBoundElement, mContent, aResult, aMultipleInsertionPoints); + else if (mNextBinding) + return mNextBinding->GetSingleInsertionPoint(aResult, aMultipleInsertionPoints); + return NS_OK; } NS_IMETHODIMP @@ -1477,6 +1479,20 @@ nsXBLBinding::ImplementsInterface(REFNSIID aIID, PRBool* aResult) return NS_OK; } +NS_IMETHODIMP +nsXBLBinding::GetAnonymousNodes(nsIDOMNodeList** aResult, nsIContent** aParent, PRBool* aMultipleInsertionPoints) +{ + *aResult = nsnull; + if (mContent) { + GetSingleInsertionPoint(aParent, aMultipleInsertionPoints); + nsCOMPtr elt(do_QueryInterface(mContent)); + return elt->GetChildNodes(aResult); + } + else if (mNextBinding) + return mNextBinding->GetAnonymousNodes(aResult, aParent, aMultipleInsertionPoints); + return NS_OK; +} + NS_IMETHODIMP nsXBLBinding::ShouldBuildChildFrames(PRBool* aResult) { diff --git a/content/xbl/src/nsXBLBinding.h b/content/xbl/src/nsXBLBinding.h index f14320cad900..6413b5f85414 100644 --- a/content/xbl/src/nsXBLBinding.h +++ b/content/xbl/src/nsXBLBinding.h @@ -96,6 +96,8 @@ class nsXBLBinding: public nsIXBLBinding NS_IMETHOD ImplementsInterface(REFNSIID aIID, PRBool* aResult); + NS_IMETHOD GetAnonymousNodes(nsIDOMNodeList** aResult, nsIContent** aParent, PRBool* aMultipleInsertionPoints); + NS_IMETHOD ShouldBuildChildFrames(PRBool* aResult); public: diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index 931415042fa1..06f4295c50a3 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -55,6 +55,7 @@ #include "nsITextContent.h" #include "nsIMemory.h" #include "nsIObserverService.h" +#include "nsIDOMNodeList.h" #include "nsIXBLBinding.h" #include "nsIXBLPrototypeBinding.h" @@ -710,11 +711,10 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsAReadableString& aURL, // For a given element, returns a flat list of all the anonymous children that need // frames built. NS_IMETHODIMP -nsXBLService::GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aParent, +nsXBLService::GetContentList(nsIContent* aContent, nsIDOMNodeList** aResult, nsIContent** aParent, PRBool* aMultipleInsertionPoints) { - // Iterate over all of the bindings one by one and build up an array - // of anonymous items. + // Locate the primary binding and get the node list from its mContent parent. *aResult = nsnull; *aParent = nsnull; *aMultipleInsertionPoints = PR_FALSE; @@ -728,31 +728,8 @@ nsXBLService::GetContentList(nsIContent* aContent, nsISupportsArray** aResult, n nsCOMPtr binding; bindingManager->GetBinding(aContent, getter_AddRefs(binding)); - - while (binding) { - // Get the anonymous content. - nsCOMPtr content; - binding->GetAnonymousContent(getter_AddRefs(content)); - if (content) { - PRInt32 childCount; - content->ChildCount(childCount); - for (PRInt32 i = 0; i < childCount; i++) { - nsCOMPtr anonymousChild; - content->ChildAt(i, *getter_AddRefs(anonymousChild)); - if (!(*aResult)) - NS_NewISupportsArray(aResult); // This call addrefs the array. - - (*aResult)->AppendElement(anonymousChild); - } - - binding->GetSingleInsertionPoint(aParent, aMultipleInsertionPoints); - return NS_OK; - } - - nsCOMPtr nextBinding; - binding->GetBaseBinding(getter_AddRefs(nextBinding)); - binding = nextBinding; - } + + binding->GetAnonymousNodes(getter_AddRefs(aResult), aParent, aMultipleInsertionPoints); return NS_OK; } @@ -1030,7 +1007,7 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement, } } else if (hasBase) { - // Check for the presence of a 'extends' and 'display' attributes + // Check for the presence of 'extends' and 'display' attributes nsAutoString display, extends; child->GetAttribute(kNameSpaceID_None, kDisplayAtom, display); child->GetAttribute(kNameSpaceID_None, kExtendsAtom, extends); @@ -1038,16 +1015,13 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement, PRBool hasExtends = !extends.IsEmpty(); nsAutoString value(extends); - - PRBool prefixIsDisplay = PR_FALSE; - - if (!hasDisplay && !hasExtends) + + if (!hasExtends) protoBinding->SetHasBasePrototype(PR_FALSE); else { nsAutoString prefix; PRInt32 offset; if (hasDisplay) { - prefixIsDisplay = PR_TRUE; offset = display.FindChar(':'); if (-1 != offset) { display.Left(prefix, offset); @@ -1073,8 +1047,10 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement, if (nameSpace) { nameSpace->FindNameSpace(prefixAtom, *getter_AddRefs(tagSpace)); if (tagSpace) { - // We extend some widget/frame. We don't really have a base binding. - protoBinding->SetHasBasePrototype(PR_FALSE); + if (!hasDisplay) { + // We extend some widget/frame. We don't really have a base binding. + protoBinding->SetHasBasePrototype(PR_FALSE); + } PRInt32 nameSpaceID; tagSpace->GetNameSpaceID(nameSpaceID); nsCOMPtr tagName = getter_AddRefs(NS_NewAtom(display)); diff --git a/content/xbl/src/nsXBLService.h b/content/xbl/src/nsXBLService.h index bc77fd918701..de56b2d62e55 100644 --- a/content/xbl/src/nsXBLService.h +++ b/content/xbl/src/nsXBLService.h @@ -67,7 +67,7 @@ class nsXBLService : public nsIXBLService, public nsIObserver, public nsSupports // For a given element, returns a flat list of all the anonymous children that need // frames built. - NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aChildElement, + NS_IMETHOD GetContentList(nsIContent* aContent, nsIDOMNodeList** aResult, nsIContent** aChildElement, PRBool* aMultipleInsertionPoints); // Gets the object's base class type. diff --git a/layout/xbl/public/nsIXBLBinding.h b/layout/xbl/public/nsIXBLBinding.h index 229c1a338218..eabd4a80f53f 100644 --- a/layout/xbl/public/nsIXBLBinding.h +++ b/layout/xbl/public/nsIXBLBinding.h @@ -37,6 +37,7 @@ class nsIContent; class nsIDocument; +class nsIDOMNodeList; class nsIScriptContext; class nsIXBLPrototypeBinding; @@ -101,6 +102,9 @@ public: NS_IMETHOD ImplementsInterface(REFNSIID aIID, PRBool* aResult)=0; + NS_IMETHOD GetAnonymousNodes(nsIDOMNodeList** aResult, + nsIContent** aParent, PRBool* aMultipleInsertionPoints)=0; + NS_IMETHOD ShouldBuildChildFrames(PRBool* aResult)=0; }; diff --git a/layout/xbl/public/nsIXBLService.h b/layout/xbl/public/nsIXBLService.h index ae82854bfeaa..619dc7e912c8 100644 --- a/layout/xbl/public/nsIXBLService.h +++ b/layout/xbl/public/nsIXBLService.h @@ -37,7 +37,7 @@ class nsIContent; class nsIDocument; class nsIDOMEventReceiver; -class nsISupportsArray; +class nsIDOMNodeList; class nsIXBLBinding; class nsIXBLDocumentInfo; @@ -66,7 +66,7 @@ public: // For a given element, returns a flat list of all the anonymous children that need // frames built. - NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aChildElement, + NS_IMETHOD GetContentList(nsIContent* aContent, nsIDOMNodeList** aResult, nsIContent** aChildElement, PRBool* aMultipleInsertionPoints) = 0; // Retrieves our base class (e.g., tells us what type of frame and content node to build) diff --git a/layout/xbl/src/nsXBLBinding.cpp b/layout/xbl/src/nsXBLBinding.cpp index cf1dfeff7455..0b69922c524c 100644 --- a/layout/xbl/src/nsXBLBinding.cpp +++ b/layout/xbl/src/nsXBLBinding.cpp @@ -1410,10 +1410,11 @@ NS_IMETHODIMP nsXBLBinding::GetInsertionPoint(nsIContent* aChild, nsIContent** aResult) { *aResult = nsnull; - if (!mContent) - return NS_OK; - - return mPrototypeBinding->GetInsertionPoint(mBoundElement, mContent, aChild, aResult); + if (mContent) + return mPrototypeBinding->GetInsertionPoint(mBoundElement, mContent, aChild, aResult); + else if (mNextBinding) + return mNextBinding->GetInsertionPoint(aChild, aResult); + return NS_OK; } NS_IMETHODIMP @@ -1421,10 +1422,11 @@ nsXBLBinding::GetSingleInsertionPoint(nsIContent** aResult, PRBool* aMultipleIns { *aResult = nsnull; *aMultipleInsertionPoints = PR_FALSE; - if (!mContent) - return NS_OK; - - return mPrototypeBinding->GetSingleInsertionPoint(mBoundElement, mContent, aResult, aMultipleInsertionPoints); + if (mContent) + return mPrototypeBinding->GetSingleInsertionPoint(mBoundElement, mContent, aResult, aMultipleInsertionPoints); + else if (mNextBinding) + return mNextBinding->GetSingleInsertionPoint(aResult, aMultipleInsertionPoints); + return NS_OK; } NS_IMETHODIMP @@ -1477,6 +1479,20 @@ nsXBLBinding::ImplementsInterface(REFNSIID aIID, PRBool* aResult) return NS_OK; } +NS_IMETHODIMP +nsXBLBinding::GetAnonymousNodes(nsIDOMNodeList** aResult, nsIContent** aParent, PRBool* aMultipleInsertionPoints) +{ + *aResult = nsnull; + if (mContent) { + GetSingleInsertionPoint(aParent, aMultipleInsertionPoints); + nsCOMPtr elt(do_QueryInterface(mContent)); + return elt->GetChildNodes(aResult); + } + else if (mNextBinding) + return mNextBinding->GetAnonymousNodes(aResult, aParent, aMultipleInsertionPoints); + return NS_OK; +} + NS_IMETHODIMP nsXBLBinding::ShouldBuildChildFrames(PRBool* aResult) { diff --git a/layout/xbl/src/nsXBLBinding.h b/layout/xbl/src/nsXBLBinding.h index f14320cad900..6413b5f85414 100644 --- a/layout/xbl/src/nsXBLBinding.h +++ b/layout/xbl/src/nsXBLBinding.h @@ -96,6 +96,8 @@ class nsXBLBinding: public nsIXBLBinding NS_IMETHOD ImplementsInterface(REFNSIID aIID, PRBool* aResult); + NS_IMETHOD GetAnonymousNodes(nsIDOMNodeList** aResult, nsIContent** aParent, PRBool* aMultipleInsertionPoints); + NS_IMETHOD ShouldBuildChildFrames(PRBool* aResult); public: diff --git a/layout/xbl/src/nsXBLService.cpp b/layout/xbl/src/nsXBLService.cpp index 931415042fa1..06f4295c50a3 100644 --- a/layout/xbl/src/nsXBLService.cpp +++ b/layout/xbl/src/nsXBLService.cpp @@ -55,6 +55,7 @@ #include "nsITextContent.h" #include "nsIMemory.h" #include "nsIObserverService.h" +#include "nsIDOMNodeList.h" #include "nsIXBLBinding.h" #include "nsIXBLPrototypeBinding.h" @@ -710,11 +711,10 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsAReadableString& aURL, // For a given element, returns a flat list of all the anonymous children that need // frames built. NS_IMETHODIMP -nsXBLService::GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aParent, +nsXBLService::GetContentList(nsIContent* aContent, nsIDOMNodeList** aResult, nsIContent** aParent, PRBool* aMultipleInsertionPoints) { - // Iterate over all of the bindings one by one and build up an array - // of anonymous items. + // Locate the primary binding and get the node list from its mContent parent. *aResult = nsnull; *aParent = nsnull; *aMultipleInsertionPoints = PR_FALSE; @@ -728,31 +728,8 @@ nsXBLService::GetContentList(nsIContent* aContent, nsISupportsArray** aResult, n nsCOMPtr binding; bindingManager->GetBinding(aContent, getter_AddRefs(binding)); - - while (binding) { - // Get the anonymous content. - nsCOMPtr content; - binding->GetAnonymousContent(getter_AddRefs(content)); - if (content) { - PRInt32 childCount; - content->ChildCount(childCount); - for (PRInt32 i = 0; i < childCount; i++) { - nsCOMPtr anonymousChild; - content->ChildAt(i, *getter_AddRefs(anonymousChild)); - if (!(*aResult)) - NS_NewISupportsArray(aResult); // This call addrefs the array. - - (*aResult)->AppendElement(anonymousChild); - } - - binding->GetSingleInsertionPoint(aParent, aMultipleInsertionPoints); - return NS_OK; - } - - nsCOMPtr nextBinding; - binding->GetBaseBinding(getter_AddRefs(nextBinding)); - binding = nextBinding; - } + + binding->GetAnonymousNodes(getter_AddRefs(aResult), aParent, aMultipleInsertionPoints); return NS_OK; } @@ -1030,7 +1007,7 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement, } } else if (hasBase) { - // Check for the presence of a 'extends' and 'display' attributes + // Check for the presence of 'extends' and 'display' attributes nsAutoString display, extends; child->GetAttribute(kNameSpaceID_None, kDisplayAtom, display); child->GetAttribute(kNameSpaceID_None, kExtendsAtom, extends); @@ -1038,16 +1015,13 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement, PRBool hasExtends = !extends.IsEmpty(); nsAutoString value(extends); - - PRBool prefixIsDisplay = PR_FALSE; - - if (!hasDisplay && !hasExtends) + + if (!hasExtends) protoBinding->SetHasBasePrototype(PR_FALSE); else { nsAutoString prefix; PRInt32 offset; if (hasDisplay) { - prefixIsDisplay = PR_TRUE; offset = display.FindChar(':'); if (-1 != offset) { display.Left(prefix, offset); @@ -1073,8 +1047,10 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement, if (nameSpace) { nameSpace->FindNameSpace(prefixAtom, *getter_AddRefs(tagSpace)); if (tagSpace) { - // We extend some widget/frame. We don't really have a base binding. - protoBinding->SetHasBasePrototype(PR_FALSE); + if (!hasDisplay) { + // We extend some widget/frame. We don't really have a base binding. + protoBinding->SetHasBasePrototype(PR_FALSE); + } PRInt32 nameSpaceID; tagSpace->GetNameSpaceID(nameSpaceID); nsCOMPtr tagName = getter_AddRefs(NS_NewAtom(display)); diff --git a/layout/xbl/src/nsXBLService.h b/layout/xbl/src/nsXBLService.h index bc77fd918701..de56b2d62e55 100644 --- a/layout/xbl/src/nsXBLService.h +++ b/layout/xbl/src/nsXBLService.h @@ -67,7 +67,7 @@ class nsXBLService : public nsIXBLService, public nsIObserver, public nsSupports // For a given element, returns a flat list of all the anonymous children that need // frames built. - NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aChildElement, + NS_IMETHOD GetContentList(nsIContent* aContent, nsIDOMNodeList** aResult, nsIContent** aChildElement, PRBool* aMultipleInsertionPoints); // Gets the object's base class type.