mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 08:48:07 +00:00
Speeding up retrieval of anonymous nodes by removing a redundant copy. Patched bug in
insertion point retrieval. a=ben@netscape.com
This commit is contained in:
parent
b776af02af
commit
957686ba6a
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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<nsIDOMElement> 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)
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(aContent, getter_AddRefs(binding));
|
||||
|
||||
while (binding) {
|
||||
// Get the anonymous content.
|
||||
nsCOMPtr<nsIContent> content;
|
||||
binding->GetAnonymousContent(getter_AddRefs(content));
|
||||
if (content) {
|
||||
PRInt32 childCount;
|
||||
content->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> 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<nsIXBLBinding> 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<nsIAtom> tagName = getter_AddRefs(NS_NewAtom(display));
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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<nsIDOMElement> 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)
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(aContent, getter_AddRefs(binding));
|
||||
|
||||
while (binding) {
|
||||
// Get the anonymous content.
|
||||
nsCOMPtr<nsIContent> content;
|
||||
binding->GetAnonymousContent(getter_AddRefs(content));
|
||||
if (content) {
|
||||
PRInt32 childCount;
|
||||
content->ChildCount(childCount);
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> 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<nsIXBLBinding> 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<nsIAtom> tagName = getter_AddRefs(NS_NewAtom(display));
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user