Remove nsIXBLBinding (bug 194834). r+sr=bzbarsky.
git-svn-id: svn://10.0.0.236/trunk@169873 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
9258ad13c5
commit
165fa3ff89
@ -79,7 +79,7 @@
|
||||
#include "nsMutationEvent.h"
|
||||
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIXBLService.h"
|
||||
@ -3429,8 +3429,7 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||
}
|
||||
|
||||
if (document) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
document->BindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = document->BindingManager()->GetBinding(this);
|
||||
if (binding)
|
||||
binding->AttributeChanged(aName, aNamespaceID, PR_FALSE, aNotify);
|
||||
|
||||
@ -3561,8 +3560,7 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (document) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
document->BindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = document->BindingManager()->GetBinding(this);
|
||||
if (binding)
|
||||
binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify);
|
||||
|
||||
|
||||
@ -140,6 +140,7 @@ include $(topsrcdir)/config/rules.mk
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../../base/src \
|
||||
-I$(srcdir)/../../../events/src \
|
||||
-I$(srcdir)/../../../xbl/src \
|
||||
-I$(srcdir)/../../../../layout/style \
|
||||
-I$(srcdir) \
|
||||
$(NULL)
|
||||
|
||||
@ -118,7 +118,7 @@
|
||||
#include "nsMutationEvent.h"
|
||||
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsXBLBinding.h"
|
||||
|
||||
#include "nsRuleWalker.h"
|
||||
|
||||
@ -1747,8 +1747,7 @@ nsGenericHTMLElement::SetAttrAndNotify(PRInt32 aNamespaceID,
|
||||
}
|
||||
|
||||
if (document) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
document->BindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = document->BindingManager()->GetBinding(this);
|
||||
if (binding) {
|
||||
binding->AttributeChanged(aAttribute, aNamespaceID, PR_FALSE, aNotify);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsMutationEvent.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIPresShell.h"
|
||||
@ -655,8 +655,7 @@ nsSVGElement::SetAttrAndNotify(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
||||
}
|
||||
|
||||
if (document) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
document->BindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = document->BindingManager()->GetBinding(this);
|
||||
if (binding) {
|
||||
binding->AttributeChanged(aAttribute, aNamespaceID, PR_FALSE, aNotify);
|
||||
}
|
||||
|
||||
@ -46,7 +46,6 @@ MODULE = content
|
||||
|
||||
EXPORTS = \
|
||||
nsIBindingManager.h \
|
||||
nsIXBLBinding.h \
|
||||
nsIXBLDocumentInfo.h \
|
||||
nsIXBLService.h \
|
||||
$(NULL)
|
||||
|
||||
@ -36,10 +36,10 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
||||
Private interface to the XBL Binding
|
||||
|
||||
/**
|
||||
* Private interface to the XBL Binding. This interface is currently
|
||||
* undergoing deCOMtamination and some methods are only accessible from
|
||||
* inside of gklayout.
|
||||
*/
|
||||
|
||||
#ifndef nsIBinding_Manager_h__
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIXBLBinding;
|
||||
class nsXBLBinding;
|
||||
class nsIXBLDocumentInfo;
|
||||
class nsIAtom;
|
||||
class nsIStreamListener;
|
||||
@ -58,17 +58,16 @@ class nsIXPConnectWrappedJS;
|
||||
class nsIDOMNodeList;
|
||||
class nsVoidArray;
|
||||
|
||||
// {55D70FE0-C8E5-11d3-97FB-00400553EEF0}
|
||||
#define NS_IBINDING_MANAGER_IID \
|
||||
{ 0x55d70fe0, 0xc8e5, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
{ 0x92281eaa, 0x89c4, 0x4457, { 0x8f, 0x8d, 0xca, 0x92, 0xbf, 0xbe, 0x0f, 0x50 } }
|
||||
|
||||
class nsIBindingManager : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IBINDING_MANAGER_IID)
|
||||
|
||||
NS_IMETHOD GetBinding(nsIContent* aContent, nsIXBLBinding** aResult) = 0;
|
||||
NS_IMETHOD SetBinding(nsIContent* aContent, nsIXBLBinding* aBinding) = 0;
|
||||
virtual nsXBLBinding* GetBinding(nsIContent* aContent) = 0;
|
||||
NS_IMETHOD SetBinding(nsIContent* aContent, nsXBLBinding* aBinding) = 0;
|
||||
|
||||
NS_IMETHOD GetInsertionParent(nsIContent* aContent, nsIContent** aResult)=0;
|
||||
NS_IMETHOD SetInsertionParent(nsIContent* aContent, nsIContent* aResult)=0;
|
||||
@ -140,22 +139,25 @@ public:
|
||||
* anonymous content tree. Specifically, aChild should be inserted
|
||||
* beneath aResult at the index specified by aIndex.
|
||||
*/
|
||||
NS_IMETHOD GetInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult, PRUint32* aIndex) = 0;
|
||||
virtual nsIContent* GetInsertionPoint(nsIContent* aParent,
|
||||
nsIContent* aChild,
|
||||
PRUint32* aIndex) = 0;
|
||||
|
||||
/**
|
||||
* Return the unfiltered insertion point for the specified parent
|
||||
* element. If other filtered insertion points exist,
|
||||
* aMultipleInsertionPoints will be set to true.
|
||||
*/
|
||||
NS_IMETHOD GetSingleInsertionPoint(nsIContent* aParent, nsIContent** aResult, PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints) = 0;
|
||||
virtual nsIContent* GetSingleInsertionPoint(nsIContent* aParent,
|
||||
PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints) = 0;
|
||||
|
||||
NS_IMETHOD AddLayeredBinding(nsIContent* aContent, nsIURI* aURL) = 0;
|
||||
NS_IMETHOD RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL) = 0;
|
||||
NS_IMETHOD LoadBindingDocument(nsIDocument* aDocument, nsIURI* aURL,
|
||||
nsIDocument** aResult) = 0;
|
||||
|
||||
NS_IMETHOD AddToAttachedQueue(nsIXBLBinding* aBinding)=0;
|
||||
NS_IMETHOD AddToAttachedQueue(nsXBLBinding* aBinding)=0;
|
||||
NS_IMETHOD ClearAttachedQueue()=0;
|
||||
NS_IMETHOD ProcessAttachedQueue()=0;
|
||||
|
||||
@ -169,7 +171,6 @@ public:
|
||||
NS_IMETHOD GetLoadingDocListener(nsIURI* aURL, nsIStreamListener** aResult) = 0;
|
||||
NS_IMETHOD RemoveLoadingDocListener(nsIURI* aURL) = 0;
|
||||
|
||||
NS_IMETHOD InheritsStyle(nsIContent* aContent, PRBool* aResult) = 0;
|
||||
NS_IMETHOD FlushSkinBindings() = 0;
|
||||
|
||||
NS_IMETHOD GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, void** aResult)=0;
|
||||
|
||||
@ -1,139 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Original Author: David W. Hyatt (hyatt@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
||||
Private interface to the XBL Binding
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIXBLBinding_h__
|
||||
#define nsIXBLBinding_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDOMNodeList;
|
||||
class nsIScriptContext;
|
||||
class nsXBLPrototypeBinding;
|
||||
class nsVoidArray;
|
||||
class nsIURI;
|
||||
class nsACString;
|
||||
|
||||
// {DDDBAD20-C8DF-11d3-97FB-00400553EEF0}
|
||||
#define NS_IXBLBINDING_IID \
|
||||
{ 0xdddbad20, 0xc8df, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
|
||||
class nsIXBLBinding : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IXBLBINDING_IID)
|
||||
|
||||
NS_IMETHOD GetPrototypeBinding(nsXBLPrototypeBinding** aResult)=0;
|
||||
NS_IMETHOD SetPrototypeBinding(nsXBLPrototypeBinding* aProtoBinding)=0;
|
||||
|
||||
NS_IMETHOD GetBaseBinding(nsIXBLBinding** aResult) = 0;
|
||||
NS_IMETHOD SetBaseBinding(nsIXBLBinding* aBinding) = 0;
|
||||
|
||||
NS_IMETHOD GetAnonymousContent(nsIContent** aParent) = 0;
|
||||
NS_IMETHOD SetAnonymousContent(nsIContent* aParent) = 0;
|
||||
|
||||
NS_IMETHOD GetBindingElement(nsIContent** aResult) = 0;
|
||||
NS_IMETHOD SetBindingElement(nsIContent* aElement) = 0;
|
||||
|
||||
NS_IMETHOD GetBoundElement(nsIContent** aResult) = 0;
|
||||
NS_IMETHOD SetBoundElement(nsIContent* aElement) = 0;
|
||||
|
||||
NS_IMETHOD GenerateAnonymousContent() = 0;
|
||||
NS_IMETHOD InstallEventHandlers() = 0;
|
||||
NS_IMETHOD InstallImplementation() = 0;
|
||||
|
||||
NS_IMETHOD HasStyleSheets(PRBool* aResolveStyle) = 0;
|
||||
|
||||
NS_IMETHOD GetFirstBindingWithConstructor(nsIXBLBinding** aResult)=0;
|
||||
|
||||
NS_IMETHOD GetBaseTag(PRInt32* aNameSpaceID, nsIAtom** aResult) = 0;
|
||||
|
||||
// Called when an attribute changes on a binding.
|
||||
NS_IMETHOD AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceID,
|
||||
PRBool aRemoveFlag, PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD ExecuteAttachedHandler()=0;
|
||||
NS_IMETHOD ExecuteDetachedHandler()=0;
|
||||
NS_IMETHOD UnhookEventHandlers() = 0;
|
||||
NS_IMETHOD ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocument) = 0;
|
||||
|
||||
NS_IMETHOD_(nsIURI*) BindingURI() const = 0;
|
||||
NS_IMETHOD_(nsIURI*) DocURI() const = 0;
|
||||
NS_IMETHOD GetID(nsACString& aResult) const = 0;
|
||||
|
||||
// Get the list of insertion points for aParent. The nsVoidArray is owned
|
||||
// by the binding, you should not delete it.
|
||||
NS_IMETHOD GetInsertionPointsFor(nsIContent* aParent, nsVoidArray** aResult)=0;
|
||||
|
||||
NS_IMETHOD GetInsertionPoint(nsIContent* aChild, nsIContent** aResult, PRUint32* aIndex,
|
||||
nsIContent** aDefaultContent) = 0;
|
||||
NS_IMETHOD GetSingleInsertionPoint(nsIContent** aResult, PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints, nsIContent** aDefaultContent) = 0;
|
||||
|
||||
NS_IMETHOD IsStyleBinding(PRBool* aResult) = 0;
|
||||
NS_IMETHOD SetIsStyleBinding(PRBool aIsStyle) = 0;
|
||||
|
||||
NS_IMETHOD GetRootBinding(nsIXBLBinding** aResult) = 0;
|
||||
NS_IMETHOD GetFirstStyleBinding(nsIXBLBinding** aResult) = 0;
|
||||
|
||||
NS_IMETHOD InheritsStyle(PRBool* aResult)=0;
|
||||
NS_IMETHOD WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, void* aData)=0;
|
||||
|
||||
NS_IMETHOD MarkForDeath()=0;
|
||||
NS_IMETHOD MarkedForDeath(PRBool* aResult)=0;
|
||||
|
||||
NS_IMETHOD ImplementsInterface(REFNSIID aIID, PRBool* aResult)=0;
|
||||
|
||||
NS_IMETHOD GetAnonymousNodes(nsIDOMNodeList** aResult)=0;
|
||||
|
||||
NS_IMETHOD ShouldBuildChildFrames(PRBool* aResult)=0;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewXBLBinding(nsXBLPrototypeBinding* aProtoBinding,
|
||||
nsIXBLBinding** aResult);
|
||||
|
||||
#endif // nsIXBLBinding_h__
|
||||
@ -51,14 +51,13 @@ class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDOMEventReceiver;
|
||||
class nsIDOMNodeList;
|
||||
class nsIXBLBinding;
|
||||
class nsXBLBinding;
|
||||
class nsIXBLDocumentInfo;
|
||||
class nsIURI;
|
||||
class nsIAtom;
|
||||
|
||||
// {0E7903E1-C7BB-11d3-97FB-00400553EEF0}
|
||||
#define NS_IXBLSERVICE_IID \
|
||||
{ 0xe7903e1, 0xc7bb, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
{ 0x0b2e5289, 0xe7d8, 0x41f8, { 0x85, 0xa2, 0x8a, 0x57, 0x0b, 0x25, 0xf4, 0x95 } }
|
||||
|
||||
class nsIXBLService : public nsISupports
|
||||
{
|
||||
@ -68,7 +67,7 @@ public:
|
||||
// This function loads a particular XBL file and installs all of the bindings
|
||||
// onto the element.
|
||||
NS_IMETHOD LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFlag,
|
||||
nsIXBLBinding** aBinding, PRBool* aResolveStyle) = 0;
|
||||
nsXBLBinding** aBinding, PRBool* aResolveStyle) = 0;
|
||||
|
||||
// Indicates whether or not a binding is fully loaded.
|
||||
NS_IMETHOD BindingReady(nsIContent* aBoundElement, nsIURI* aURI, PRBool* aIsReady) = 0;
|
||||
|
||||
@ -62,7 +62,8 @@
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsXBLPrototypeBinding.h"
|
||||
#include "nsIXBLDocumentInfo.h"
|
||||
#include "nsXBLInsertionPoint.h"
|
||||
|
||||
@ -299,17 +300,22 @@ NS_IMPL_ISUPPORTS3(nsBindingManager, nsIBindingManager, nsIStyleRuleSupplier, ns
|
||||
nsBindingManager::nsBindingManager(void)
|
||||
: mProcessingAttachedStack(PR_FALSE)
|
||||
{
|
||||
mBindingTable.ops = nsnull;
|
||||
mContentListTable.ops = nsnull;
|
||||
mAnonymousNodesTable.ops = nsnull;
|
||||
mInsertionParentTable.ops = nsnull;
|
||||
mWrapperTable.ops = nsnull;
|
||||
}
|
||||
|
||||
static PRBool PR_CALLBACK
|
||||
ReleaseBindings(void *aElement, void *aData)
|
||||
{
|
||||
nsXBLBinding *binding = NS_STATIC_CAST(nsXBLBinding*, aElement);
|
||||
NS_IF_RELEASE(binding);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsBindingManager::~nsBindingManager(void)
|
||||
{
|
||||
if (mBindingTable.ops)
|
||||
PL_DHashTableFinish(&mBindingTable);
|
||||
if (mContentListTable.ops)
|
||||
PL_DHashTableFinish(&mContentListTable);
|
||||
if (mAnonymousNodesTable.ops)
|
||||
@ -318,28 +324,33 @@ nsBindingManager::~nsBindingManager(void)
|
||||
PL_DHashTableFinish(&mInsertionParentTable);
|
||||
if (mWrapperTable.ops)
|
||||
PL_DHashTableFinish(&mWrapperTable);
|
||||
mAttachedStack.EnumerateForwards(ReleaseBindings, nsnull);
|
||||
}
|
||||
|
||||
nsXBLBinding*
|
||||
nsBindingManager::GetBinding(nsIContent* aContent)
|
||||
{
|
||||
if (mBindingTable.IsInitialized())
|
||||
return mBindingTable.GetWeak(aContent);
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::GetBinding(nsIContent* aContent, nsIXBLBinding** aResult)
|
||||
nsBindingManager::SetBinding(nsIContent* aContent, nsXBLBinding* aBinding)
|
||||
{
|
||||
if (mBindingTable.ops) {
|
||||
*aResult = NS_STATIC_CAST(nsIXBLBinding*,
|
||||
LookupObject(mBindingTable, aContent));
|
||||
NS_IF_ADDREF(*aResult);
|
||||
if (!mBindingTable.IsInitialized()) {
|
||||
if (!mBindingTable.Init())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::SetBinding(nsIContent* aContent, nsIXBLBinding* aBinding)
|
||||
{
|
||||
nsresult rv =
|
||||
SetOrRemoveObject(mBindingTable, aContent, aBinding);
|
||||
if (!aBinding) {
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
if (aBinding) {
|
||||
result = mBindingTable.Put(aContent, aBinding);
|
||||
} else {
|
||||
mBindingTable.Remove(aContent);
|
||||
|
||||
// The death of the bindings means the death of the JS wrapper,
|
||||
// and the flushing of our explicit and anonymous insertion point
|
||||
// lists.
|
||||
@ -348,7 +359,7 @@ nsBindingManager::SetBinding(nsIContent* aContent, nsIXBLBinding* aBinding)
|
||||
SetAnonymousNodesFor(aContent, nsnull);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return result ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -400,8 +411,7 @@ nsBindingManager::ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocum
|
||||
if (! aOldDocument)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(aContent, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent);
|
||||
if (binding) {
|
||||
binding->ChangeDocument(aOldDocument, aNewDocument);
|
||||
SetBinding(aContent, nsnull);
|
||||
@ -449,13 +459,13 @@ NS_IMETHODIMP
|
||||
nsBindingManager::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID,
|
||||
nsIAtom** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(aContent, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent);
|
||||
|
||||
if (binding) {
|
||||
binding->GetBaseTag(aNameSpaceID, aResult);
|
||||
*aResult = binding->GetBaseTag(aNameSpaceID);
|
||||
|
||||
if (*aResult) {
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@ -525,10 +535,11 @@ nsBindingManager::GetAnonymousNodesInternal(nsIContent* aContent,
|
||||
|
||||
if (!*aResult) {
|
||||
*aIsAnonymousContentList = PR_FALSE;
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(aContent, getter_AddRefs(binding));
|
||||
if (binding)
|
||||
return binding->GetAnonymousNodes(aResult);
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent);
|
||||
if (binding) {
|
||||
*aResult = binding->GetAnonymousNodes().get();
|
||||
return NS_OK;
|
||||
}
|
||||
} else
|
||||
*aIsAnonymousContentList = PR_TRUE;
|
||||
|
||||
@ -594,39 +605,25 @@ nsBindingManager::GetXBLChildNodesFor(nsIContent* aContent, nsIDOMNodeList** aRe
|
||||
return GetXBLChildNodesInternal(aContent, aResult, &dummy);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::GetInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult, PRUint32* aIndex)
|
||||
nsIContent*
|
||||
nsBindingManager::GetInsertionPoint(nsIContent* aParent, nsIContent* aChild,
|
||||
PRUint32* aIndex)
|
||||
{
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(aParent, getter_AddRefs(binding));
|
||||
|
||||
if (!binding) {
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> defContent;
|
||||
return binding->GetInsertionPoint(aChild, aResult, aIndex,
|
||||
getter_AddRefs(defContent));
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(aParent);
|
||||
return binding ? binding->GetInsertionPoint(aChild, aIndex) : nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::GetSingleInsertionPoint(nsIContent* aParent, nsIContent** aResult, PRUint32* aIndex,
|
||||
nsIContent*
|
||||
nsBindingManager::GetSingleInsertionPoint(nsIContent* aParent,
|
||||
PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints)
|
||||
{
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(aParent, getter_AddRefs(binding));
|
||||
|
||||
if (!binding) {
|
||||
*aMultipleInsertionPoints = PR_FALSE;
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(aParent);
|
||||
if (binding)
|
||||
return binding->GetSingleInsertionPoint(aIndex, aMultipleInsertionPoints);
|
||||
|
||||
nsCOMPtr<nsIContent> defContent;
|
||||
return binding->GetSingleInsertionPoint(aResult, aIndex,
|
||||
aMultipleInsertionPoints,
|
||||
getter_AddRefs(defContent));
|
||||
*aMultipleInsertionPoints = PR_FALSE;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -640,9 +637,10 @@ nsBindingManager::AddLayeredBinding(nsIContent* aContent, nsIURI* aURL)
|
||||
return rv;
|
||||
|
||||
// Load the bindings.
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
nsRefPtr<nsXBLBinding> binding;
|
||||
PRBool dummy;
|
||||
xblService->LoadBindings(aContent, aURL, PR_TRUE, getter_AddRefs(binding), &dummy);
|
||||
xblService->LoadBindings(aContent, aURL, PR_TRUE, getter_AddRefs(binding),
|
||||
&dummy);
|
||||
if (binding) {
|
||||
AddToAttachedQueue(binding);
|
||||
ProcessAttachedQueue();
|
||||
@ -654,20 +652,17 @@ nsBindingManager::AddLayeredBinding(nsIContent* aContent, nsIURI* aURL)
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL)
|
||||
{
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(aContent, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent);
|
||||
|
||||
if (!binding) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// For now we can only handle removing a binding if it's the only one
|
||||
nsCOMPtr<nsIXBLBinding> nextBinding;
|
||||
binding->GetBaseBinding(getter_AddRefs(nextBinding));
|
||||
NS_ENSURE_FALSE(nextBinding, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_FALSE(binding->GetBaseBinding(), NS_ERROR_FAILURE);
|
||||
|
||||
// Make sure that the binding has the URI that is requested to be removed
|
||||
nsIURI* bindingUri = binding->BindingURI();
|
||||
nsIURI* bindingUri = binding->PrototypeBinding()->BindingURI();
|
||||
|
||||
PRBool equalUri;
|
||||
nsresult rv = aURL->Equals(bindingUri, &equalUri);
|
||||
@ -677,9 +672,7 @@ nsBindingManager::RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL)
|
||||
}
|
||||
|
||||
// Make sure it isn't a style binding
|
||||
PRBool style;
|
||||
binding->IsStyleBinding(&style);
|
||||
if (style) {
|
||||
if (binding->IsStyleBinding()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -744,39 +737,40 @@ nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::AddToAttachedQueue(nsIXBLBinding* aBinding)
|
||||
nsBindingManager::AddToAttachedQueue(nsXBLBinding* aBinding)
|
||||
{
|
||||
if (!mAttachedStack)
|
||||
NS_NewISupportsArray(getter_AddRefs(mAttachedStack)); // This call addrefs the array.
|
||||
|
||||
mAttachedStack->AppendElement(aBinding);
|
||||
if (!mAttachedStack.AppendElement(aBinding))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(aBinding);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::ClearAttachedQueue()
|
||||
{
|
||||
if (mAttachedStack)
|
||||
mAttachedStack->Clear();
|
||||
mAttachedStack.EnumerateForwards(ReleaseBindings, nsnull);
|
||||
mAttachedStack.Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::ProcessAttachedQueue()
|
||||
{
|
||||
if (!mAttachedStack || mProcessingAttachedStack)
|
||||
if (mProcessingAttachedStack)
|
||||
return NS_OK;
|
||||
|
||||
mProcessingAttachedStack = PR_TRUE;
|
||||
|
||||
PRUint32 count;
|
||||
while (NS_SUCCEEDED(mAttachedStack->Count(&count)) && count--) {
|
||||
nsCOMPtr<nsIXBLBinding> binding = do_QueryElementAt(mAttachedStack, count);
|
||||
mAttachedStack->RemoveElementAt(count);
|
||||
PRInt32 lastItem;
|
||||
while ((lastItem = mAttachedStack.Count() - 1) >= 0) {
|
||||
nsXBLBinding *binding = NS_STATIC_CAST(nsXBLBinding*,
|
||||
mAttachedStack.FastElementAt(lastItem));
|
||||
mAttachedStack.RemoveElementAt(lastItem);
|
||||
|
||||
if (binding)
|
||||
binding->ExecuteAttachedHandler();
|
||||
NS_ASSERTION(binding, "null item in attached stack?");
|
||||
binding->ExecuteAttachedHandler();
|
||||
NS_RELEASE(binding);
|
||||
}
|
||||
|
||||
mProcessingAttachedStack = PR_FALSE;
|
||||
@ -785,11 +779,10 @@ nsBindingManager::ProcessAttachedQueue()
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PLDHashOperator)
|
||||
ExecuteDetachedHandler(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, PRUint32 aNumber, void* aClosure)
|
||||
ExecuteDetachedHandler(nsISupports *aKey,
|
||||
nsXBLBinding *aBinding, void* aClosure)
|
||||
{
|
||||
ObjectEntry* entry = NS_STATIC_CAST(ObjectEntry*, aHdr);
|
||||
nsIXBLBinding* binding = NS_STATIC_CAST(nsIXBLBinding*, entry->GetValue());
|
||||
binding->ExecuteDetachedHandler();
|
||||
aBinding->ExecuteDetachedHandler();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
@ -798,8 +791,8 @@ NS_IMETHODIMP
|
||||
nsBindingManager::ExecuteDetachedHandlers()
|
||||
{
|
||||
// Walk our hashtable of bindings.
|
||||
if (mBindingTable.ops)
|
||||
PL_DHashTableEnumerate(&mBindingTable, ExecuteDetachedHandler, nsnull);
|
||||
if (mBindingTable.IsInitialized())
|
||||
mBindingTable.EnumerateRead(ExecuteDetachedHandler, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -876,21 +869,16 @@ nsBindingManager::RemoveLoadingDocListener(nsIURI* aURL)
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PLDHashOperator)
|
||||
MarkForDeath(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, PRUint32 aNumber, void* aClosure)
|
||||
MarkForDeath(nsISupports *aKey, nsXBLBinding *aBinding, void* aClosure)
|
||||
{
|
||||
ObjectEntry* entry = NS_STATIC_CAST(ObjectEntry*, aHdr);
|
||||
nsIXBLBinding* binding = NS_STATIC_CAST(nsIXBLBinding*, entry->GetValue());
|
||||
|
||||
PRBool marked = PR_FALSE;
|
||||
binding->MarkedForDeath(&marked);
|
||||
if (marked)
|
||||
if (aBinding->MarkedForDeath())
|
||||
return PL_DHASH_NEXT; // Already marked for death.
|
||||
|
||||
nsCAutoString path;
|
||||
binding->DocURI()->GetPath(path);
|
||||
aBinding->PrototypeBinding()->DocURI()->GetPath(path);
|
||||
|
||||
if (!strncmp(path.get(), "/skin", 5))
|
||||
binding->MarkForDeath();
|
||||
aBinding->MarkForDeath();
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
@ -898,8 +886,8 @@ MarkForDeath(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, PRUint32 aNumber, void
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::FlushSkinBindings()
|
||||
{
|
||||
if (mBindingTable.ops)
|
||||
PL_DHashTableEnumerate(&mBindingTable, MarkForDeath, nsnull);
|
||||
if (mBindingTable.IsInitialized())
|
||||
mBindingTable.EnumerateRead(MarkForDeath, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -920,14 +908,11 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID,
|
||||
void** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(aContent, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent);
|
||||
if (binding) {
|
||||
PRBool supportsInterface;
|
||||
// The binding should not be asked for nsISupports
|
||||
NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)), "Asking a binding for nsISupports");
|
||||
binding->ImplementsInterface(aIID, &supportsInterface);
|
||||
if (supportsInterface) {
|
||||
if (binding->ImplementsInterface(aIID)) {
|
||||
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS;
|
||||
GetWrappedJS(aContent, getter_AddRefs(wrappedJS));
|
||||
|
||||
@ -1027,26 +1012,6 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::InheritsStyle(nsIContent* aContent, PRBool* aResult)
|
||||
{
|
||||
// Get our enclosing parent.
|
||||
*aResult = PR_TRUE;
|
||||
nsCOMPtr<nsIContent> parent = GetEnclosingScope(aContent);
|
||||
if (parent) {
|
||||
// See if the parent is our parent.
|
||||
if (aContent->GetParent() == parent) {
|
||||
// Yes. Check the binding and see if it wants to allow us
|
||||
// to inherit styles.
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(parent, getter_AddRefs(binding));
|
||||
if (binding)
|
||||
binding->InheritsStyle(aResult);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::WalkRules(nsStyleSet* aStyleSet,
|
||||
nsIStyleRuleProcessor::EnumFunc aFunc,
|
||||
@ -1063,17 +1028,14 @@ nsBindingManager::WalkRules(nsStyleSet* aStyleSet,
|
||||
nsIContent *content = aData->mContent;
|
||||
|
||||
do {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(content, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(content);
|
||||
if (binding) {
|
||||
aData->mScopedRoot = content;
|
||||
binding->WalkRules(aFunc, aData);
|
||||
// If we're not looking at our original content, allow the binding to cut
|
||||
// off style inheritance
|
||||
if (content != aData->mContent) {
|
||||
PRBool inheritsStyle = PR_TRUE;
|
||||
binding->InheritsStyle(&inheritsStyle);
|
||||
if (!inheritsStyle) {
|
||||
if (!binding->InheritsStyle()) {
|
||||
// Go no further; we're not inheriting style from anything above here
|
||||
break;
|
||||
}
|
||||
@ -1105,11 +1067,10 @@ nsBindingManager::ShouldBuildChildFrames(nsIContent* aContent, PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
GetBinding(aContent, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent);
|
||||
|
||||
if (binding)
|
||||
return binding->ShouldBuildChildFrames(aResult);
|
||||
*aResult = binding->ShouldBuildChildFrames();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1124,9 +1085,8 @@ nsBindingManager::GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChil
|
||||
return NS_OK; // It is anonymous. Don't use the insertion point, since that's only
|
||||
// for the explicit kids.
|
||||
|
||||
nsCOMPtr<nsIContent> insertionElement;
|
||||
PRUint32 index;
|
||||
GetInsertionPoint(aParent, aChild, getter_AddRefs(insertionElement), &index);
|
||||
nsIContent *insertionElement = GetInsertionPoint(aParent, aChild, &index);
|
||||
if (insertionElement != aParent) {
|
||||
// See if we nest even further in.
|
||||
nsCOMPtr<nsIContent> nestedPoint;
|
||||
|
||||
@ -45,11 +45,10 @@
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsURIHashKey.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIXBLBinding;
|
||||
class nsIXPConnectWrappedJS;
|
||||
class nsIAtom;
|
||||
class nsIDOMNodeList;
|
||||
@ -70,8 +69,8 @@ public:
|
||||
nsBindingManager();
|
||||
~nsBindingManager();
|
||||
|
||||
NS_IMETHOD GetBinding(nsIContent* aContent, nsIXBLBinding** aResult);
|
||||
NS_IMETHOD SetBinding(nsIContent* aContent, nsIXBLBinding* aBinding);
|
||||
virtual nsXBLBinding* GetBinding(nsIContent* aContent);
|
||||
NS_IMETHOD SetBinding(nsIContent* aContent, nsXBLBinding* aBinding);
|
||||
|
||||
NS_IMETHOD GetInsertionParent(nsIContent* aContent, nsIContent** aResult);
|
||||
NS_IMETHOD SetInsertionParent(nsIContent* aContent, nsIContent* aResult);
|
||||
@ -93,16 +92,18 @@ public:
|
||||
|
||||
NS_IMETHOD GetXBLChildNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult);
|
||||
|
||||
NS_IMETHOD GetInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult, PRUint32* aIndex);
|
||||
NS_IMETHOD GetSingleInsertionPoint(nsIContent* aParent, nsIContent** aResult, PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints);
|
||||
virtual nsIContent* GetInsertionPoint(nsIContent* aParent,
|
||||
nsIContent* aChild, PRUint32* aIndex);
|
||||
virtual nsIContent* GetSingleInsertionPoint(nsIContent* aParent,
|
||||
PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints);
|
||||
|
||||
NS_IMETHOD AddLayeredBinding(nsIContent* aContent, nsIURI* aURL);
|
||||
NS_IMETHOD RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL);
|
||||
NS_IMETHOD LoadBindingDocument(nsIDocument* aBoundDoc, nsIURI* aURL,
|
||||
nsIDocument** aResult);
|
||||
|
||||
NS_IMETHOD AddToAttachedQueue(nsIXBLBinding* aBinding);
|
||||
NS_IMETHOD AddToAttachedQueue(nsXBLBinding* aBinding);
|
||||
NS_IMETHOD ClearAttachedQueue();
|
||||
NS_IMETHOD ProcessAttachedQueue();
|
||||
|
||||
@ -116,7 +117,6 @@ public:
|
||||
NS_IMETHOD GetLoadingDocListener(nsIURI* aURL, nsIStreamListener** aResult);
|
||||
NS_IMETHOD RemoveLoadingDocListener(nsIURI* aURL);
|
||||
|
||||
NS_IMETHOD InheritsStyle(nsIContent* aContent, PRBool* aResult);
|
||||
NS_IMETHOD FlushSkinBindings();
|
||||
|
||||
NS_IMETHOD GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, void** aResult);
|
||||
@ -158,9 +158,9 @@ protected:
|
||||
|
||||
// MEMBER VARIABLES
|
||||
protected:
|
||||
// A mapping from nsIContent* to the nsIXBLBinding* that is
|
||||
// A mapping from nsIContent* to the nsXBLBinding* that is
|
||||
// installed on that element.
|
||||
PLDHashTable mBindingTable;
|
||||
nsRefPtrHashtable<nsISupportsHashKey,nsXBLBinding> mBindingTable;
|
||||
|
||||
// A mapping from nsIContent* to an nsIDOMNodeList*
|
||||
// (nsAnonymousContentList*). This list contains an accurate
|
||||
@ -201,9 +201,8 @@ protected:
|
||||
// table, they have not yet finished loading.
|
||||
nsInterfaceHashtable<nsURIHashKey,nsIStreamListener> mLoadingDocTable;
|
||||
|
||||
// A queue of binding attached event handlers that are awaiting
|
||||
// execution.
|
||||
nsCOMPtr<nsISupportsArray> mAttachedStack;
|
||||
// A queue of binding attached event handlers that are awaiting execution.
|
||||
nsVoidArray mAttachedStack;
|
||||
PRBool mProcessingAttachedStack;
|
||||
};
|
||||
|
||||
|
||||
@ -39,7 +39,6 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsIXBLDocumentInfo.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
@ -152,15 +151,12 @@ nsXBLJSClass::Destroy()
|
||||
|
||||
// Implementation /////////////////////////////////////////////////////////////////
|
||||
|
||||
// Implement our nsISupports methods
|
||||
NS_IMPL_ISUPPORTS1(nsXBLBinding, nsIXBLBinding)
|
||||
|
||||
// Constructors/Destructors
|
||||
nsXBLBinding::nsXBLBinding(nsXBLPrototypeBinding* aBinding)
|
||||
: mPrototypeBinding(aBinding),
|
||||
mInsertionPointTable(nsnull),
|
||||
mIsStyleBinding(PR_TRUE),
|
||||
mMarkedForDeath(PR_FALSE)
|
||||
: mPrototypeBinding(aBinding),
|
||||
mInsertionPointTable(nsnull),
|
||||
mIsStyleBinding(PR_TRUE),
|
||||
mMarkedForDeath(PR_FALSE)
|
||||
{
|
||||
NS_ASSERTION(mPrototypeBinding, "Must have a prototype binding!");
|
||||
// Grab a ref to the document info so the prototype binding won't die
|
||||
@ -175,34 +171,15 @@ nsXBLBinding::~nsXBLBinding(void)
|
||||
NS_RELEASE(info);
|
||||
}
|
||||
|
||||
// nsIXBLBinding Interface ////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetBaseBinding(nsIXBLBinding** aResult)
|
||||
{
|
||||
*aResult = mNextBinding;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::SetBaseBinding(nsIXBLBinding* aBinding)
|
||||
void
|
||||
nsXBLBinding::SetBaseBinding(nsXBLBinding* aBinding)
|
||||
{
|
||||
if (mNextBinding) {
|
||||
NS_ERROR("Base XBL binding is already defined!");
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
mNextBinding = aBinding; // Comptr handles rel/add
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetAnonymousContent(nsIContent** aResult)
|
||||
{
|
||||
*aResult = mContent;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@ -236,89 +213,35 @@ nsXBLBinding::InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElem
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::SetAnonymousContent(nsIContent* aParent)
|
||||
{
|
||||
// First cache the element.
|
||||
mContent = aParent;
|
||||
|
||||
InstallAnonymousContent(mContent, mBoundElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetPrototypeBinding(nsXBLPrototypeBinding** aResult)
|
||||
{
|
||||
*aResult = mPrototypeBinding;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::SetPrototypeBinding(nsXBLPrototypeBinding* aProtoBinding)
|
||||
{
|
||||
mPrototypeBinding = aProtoBinding;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetBindingElement(nsIContent** aResult)
|
||||
{
|
||||
*aResult = mPrototypeBinding->GetBindingElement().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::SetBindingElement(nsIContent* aElement)
|
||||
{
|
||||
mPrototypeBinding->SetBindingElement(aElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetBoundElement(nsIContent** aResult)
|
||||
{
|
||||
*aResult = mBoundElement;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::SetBoundElement(nsIContent* aElement)
|
||||
{
|
||||
mBoundElement = aElement;
|
||||
if (mNextBinding)
|
||||
mNextBinding->SetBoundElement(aElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetFirstBindingWithConstructor(nsIXBLBinding** aResult)
|
||||
nsXBLBinding*
|
||||
nsXBLBinding::GetFirstBindingWithConstructor()
|
||||
{
|
||||
*aResult = nsnull;
|
||||
if (mPrototypeBinding->GetConstructor())
|
||||
return this;
|
||||
|
||||
if (mPrototypeBinding->GetConstructor()) {
|
||||
*aResult = this;
|
||||
NS_ADDREF(*aResult);
|
||||
}
|
||||
else if (mNextBinding)
|
||||
return mNextBinding->GetFirstBindingWithConstructor(aResult);
|
||||
if (mNextBinding)
|
||||
return mNextBinding->GetFirstBindingWithConstructor();
|
||||
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::HasStyleSheets(PRBool* aResolveStyle)
|
||||
PRBool
|
||||
nsXBLBinding::HasStyleSheets() const
|
||||
{
|
||||
// Find out if we need to re-resolve style. We'll need to do this
|
||||
// if we have additional stylesheets in our binding document.
|
||||
if (mPrototypeBinding->HasStyleSheets()) {
|
||||
*aResolveStyle = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
if (mPrototypeBinding->HasStyleSheets())
|
||||
return PR_TRUE;
|
||||
|
||||
if (mNextBinding)
|
||||
return mNextBinding->HasStyleSheets(aResolveStyle);
|
||||
return NS_OK;
|
||||
return mNextBinding ? mNextBinding->HasStyleSheets() : PR_FALSE;
|
||||
}
|
||||
|
||||
struct EnumData {
|
||||
@ -346,8 +269,7 @@ BuildContentLists(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
nsIBindingManager* bm = data->mBindingManager;
|
||||
nsXBLBinding* binding = data->mBinding;
|
||||
|
||||
nsCOMPtr<nsIContent> boundElement;
|
||||
binding->GetBoundElement(getter_AddRefs(boundElement));
|
||||
nsIContent *boundElement = binding->GetBoundElement();
|
||||
|
||||
nsVoidArray* arr = NS_STATIC_CAST(nsVoidArray*, aData);
|
||||
PRInt32 count = arr->Count();
|
||||
@ -367,7 +289,7 @@ BuildContentLists(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
nsCOMPtr<nsIDOMNodeList> nodeList;
|
||||
if (parent == boundElement) {
|
||||
// We are altering anonymous nodes to accommodate insertion points.
|
||||
binding->GetAnonymousNodes(getter_AddRefs(nodeList));
|
||||
nodeList = binding->GetAnonymousNodes();
|
||||
}
|
||||
else {
|
||||
// We are altering the explicit content list of a node to accommodate insertion points.
|
||||
@ -431,9 +353,6 @@ RealizeDefaultContent(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
nsIBindingManager* bm = data->mBindingManager;
|
||||
nsXBLBinding* binding = data->mBinding;
|
||||
|
||||
nsCOMPtr<nsIContent> boundElement;
|
||||
binding->GetBoundElement(getter_AddRefs(boundElement));
|
||||
|
||||
nsVoidArray* arr = (nsVoidArray*)aData;
|
||||
PRInt32 count = arr->Count();
|
||||
|
||||
@ -494,7 +413,7 @@ ChangeDocumentForDefaultContent(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::GenerateAnonymousContent()
|
||||
{
|
||||
// Fetch the content element for this binding.
|
||||
@ -504,8 +423,9 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
if (!content) {
|
||||
// We have no anonymous content.
|
||||
if (mNextBinding)
|
||||
return mNextBinding->GenerateAnonymousContent();
|
||||
else return NS_OK;
|
||||
mNextBinding->GenerateAnonymousContent();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Find out if we're really building kids or if we're just
|
||||
@ -539,7 +459,7 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
|
||||
// XXX doc will be null if we're in the midst of paint suppression.
|
||||
if (! doc)
|
||||
return NS_OK;
|
||||
return;
|
||||
|
||||
nsIBindingManager *bindingManager = doc->BindingManager();
|
||||
|
||||
@ -570,14 +490,13 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
}
|
||||
|
||||
if (hasContent || hasInsertionPoints) {
|
||||
nsCOMPtr<nsIContent> clonedContent;
|
||||
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(content));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> clonedNode;
|
||||
domElement->CloneNode(PR_TRUE, getter_AddRefs(clonedNode));
|
||||
|
||||
clonedContent = do_QueryInterface(clonedNode);
|
||||
SetAnonymousContent(clonedContent);
|
||||
mContent = do_QueryInterface(clonedNode);
|
||||
InstallAnonymousContent(mContent, mBoundElement);
|
||||
|
||||
if (hasInsertionPoints) {
|
||||
// Now check and see if we have a single insertion point
|
||||
@ -598,12 +517,10 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
|
||||
// We need to place the children
|
||||
// at their respective insertion points.
|
||||
nsCOMPtr<nsIContent> singlePoint;
|
||||
PRUint32 index = 0;
|
||||
PRBool multiplePoints = PR_FALSE;
|
||||
nsCOMPtr<nsIContent> singleDefaultContent;
|
||||
GetSingleInsertionPoint(getter_AddRefs(singlePoint), &index,
|
||||
&multiplePoints, getter_AddRefs(singleDefaultContent));
|
||||
nsIContent *singlePoint = GetSingleInsertionPoint(&index,
|
||||
&multiplePoints);
|
||||
|
||||
if (children) {
|
||||
if (multiplePoints) {
|
||||
@ -615,10 +532,8 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
childContent = do_QueryInterface(node);
|
||||
|
||||
// Now determine the insertion point in the prototype table.
|
||||
nsCOMPtr<nsIContent> point;
|
||||
PRUint32 index;
|
||||
nsCOMPtr<nsIContent> defContent;
|
||||
GetInsertionPoint(childContent, getter_AddRefs(point), &index, getter_AddRefs(defContent));
|
||||
nsIContent *point = GetInsertionPoint(childContent, &index);
|
||||
bindingManager->SetInsertionParent(childContent, point);
|
||||
|
||||
// Find the correct nsIXBLInsertion point in our table.
|
||||
@ -648,7 +563,7 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
mContent = nsnull;
|
||||
bindingManager->SetContentListFor(mBoundElement, nsnull);
|
||||
bindingManager->SetAnonymousNodesFor(mBoundElement, nsnull);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -710,11 +625,9 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
if (mContent)
|
||||
mContent->UnsetAttr(namespaceID, name, PR_FALSE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::InstallEventHandlers()
|
||||
{
|
||||
// Don't install handlers if scripts aren't allowed.
|
||||
@ -793,11 +706,9 @@ nsXBLBinding::InstallEventHandlers()
|
||||
|
||||
if (mNextBinding)
|
||||
mNextBinding->InstallEventHandlers();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::InstallImplementation()
|
||||
{
|
||||
// Always install the base class properties first, so that
|
||||
@ -809,37 +720,34 @@ nsXBLBinding::InstallImplementation()
|
||||
// iterate through each property in the prototype's list and install the property.
|
||||
if (AllowScripts())
|
||||
mPrototypeBinding->InstallImplementation(mBoundElement);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetBaseTag(PRInt32* aNameSpaceID, nsIAtom** aResult)
|
||||
nsIAtom*
|
||||
nsXBLBinding::GetBaseTag(PRInt32* aNameSpaceID)
|
||||
{
|
||||
mPrototypeBinding->GetBaseTag(aNameSpaceID, aResult);
|
||||
if (!*aResult && mNextBinding)
|
||||
return mNextBinding->GetBaseTag(aNameSpaceID, aResult);
|
||||
return NS_OK;
|
||||
nsIAtom *tag = mPrototypeBinding->GetBaseTag(aNameSpaceID);
|
||||
if (!tag && mNextBinding)
|
||||
return mNextBinding->GetBaseTag(aNameSpaceID);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceID,
|
||||
PRBool aRemoveFlag, PRBool aNotify)
|
||||
{
|
||||
// XXX Change if we ever allow multiple bindings in a chain to contribute anonymous content
|
||||
if (!mContent) {
|
||||
if (mNextBinding)
|
||||
return mNextBinding->AttributeChanged(aAttribute, aNameSpaceID,
|
||||
aRemoveFlag, aNotify);
|
||||
return NS_OK;
|
||||
mNextBinding->AttributeChanged(aAttribute, aNameSpaceID,
|
||||
aRemoveFlag, aNotify);
|
||||
} else {
|
||||
mPrototypeBinding->AttributeChanged(aAttribute, aNameSpaceID, aRemoveFlag,
|
||||
mBoundElement, mContent, aNotify);
|
||||
}
|
||||
|
||||
mPrototypeBinding->AttributeChanged(aAttribute, aNameSpaceID, aRemoveFlag,
|
||||
mBoundElement, mContent, aNotify);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::ExecuteAttachedHandler()
|
||||
{
|
||||
if (mNextBinding)
|
||||
@ -847,11 +755,9 @@ nsXBLBinding::ExecuteAttachedHandler()
|
||||
|
||||
if (AllowScripts())
|
||||
mPrototypeBinding->BindingAttached(mBoundElement);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::ExecuteDetachedHandler()
|
||||
{
|
||||
if (AllowScripts())
|
||||
@ -859,11 +765,9 @@ nsXBLBinding::ExecuteDetachedHandler()
|
||||
|
||||
if (mNextBinding)
|
||||
mNextBinding->ExecuteDetachedHandler();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::UnhookEventHandlers()
|
||||
{
|
||||
nsXBLPrototypeHandler* handlerChain = mPrototypeBinding->GetPrototypeHandlers();
|
||||
@ -935,11 +839,9 @@ nsXBLBinding::UnhookEventHandlers()
|
||||
eventGroup);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocument)
|
||||
{
|
||||
if (aOldDocument != aNewDocument) {
|
||||
@ -964,11 +866,13 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
||||
WrapNative(jscontext, ::JS_GetGlobalObject(jscontext),
|
||||
mBoundElement, NS_GET_IID(nsISupports),
|
||||
getter_AddRefs(wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
JSObject* scriptObject = nsnull;
|
||||
rv = wrapper->GetJSObject(&scriptObject);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
// XXX Stay in sync! What if a layered binding has an
|
||||
// <interface>?!
|
||||
@ -991,8 +895,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
||||
}
|
||||
|
||||
// Update the anonymous content.
|
||||
nsCOMPtr<nsIContent> anonymous;
|
||||
GetAnonymousContent(getter_AddRefs(anonymous));
|
||||
nsIContent *anonymous = mContent;
|
||||
if (anonymous) {
|
||||
// Also kill the default content within all our insertion points.
|
||||
if (mInsertionPointTable)
|
||||
@ -1024,61 +927,33 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
||||
nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIURI*)
|
||||
nsXBLBinding::BindingURI() const
|
||||
{
|
||||
return mPrototypeBinding->BindingURI();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIURI*)
|
||||
nsXBLBinding::DocURI() const
|
||||
{
|
||||
return mPrototypeBinding->DocURI();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetID(nsACString& aResult) const
|
||||
{
|
||||
return mPrototypeBinding->GetID(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::InheritsStyle(PRBool* aResult)
|
||||
PRBool
|
||||
nsXBLBinding::InheritsStyle() const
|
||||
{
|
||||
// XXX Will have to change if we ever allow multiple bindings to contribute anonymous content.
|
||||
// Most derived binding with anonymous content determines style inheritance for now.
|
||||
|
||||
// XXX What about bindings with <content> but no kids, e.g., my treecell-text binding?
|
||||
if (mContent) {
|
||||
*aResult = mPrototypeBinding->InheritsStyle();
|
||||
return NS_OK;
|
||||
}
|
||||
if (mContent)
|
||||
return mPrototypeBinding->InheritsStyle();
|
||||
|
||||
if (mNextBinding)
|
||||
return mNextBinding->InheritsStyle(aResult);
|
||||
return mNextBinding->InheritsStyle();
|
||||
|
||||
return NS_OK;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, void* aData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mNextBinding) {
|
||||
rv = mNextBinding->WalkRules(aFunc, aData);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
if (mNextBinding)
|
||||
mNextBinding->WalkRules(aFunc, aData);
|
||||
|
||||
nsIStyleRuleProcessor *rules = mPrototypeBinding->GetRuleProcessor();
|
||||
if (rules)
|
||||
(*aFunc)(rules, aData);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Internal helper methods ////////////////////////////////////////////////////////////////
|
||||
@ -1276,63 +1151,6 @@ nsXBLBinding::GetImmediateChild(nsIAtom* aTag, nsIContent** aResult)
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXBLBinding::IsInExcludesList(nsIAtom* aTag, const nsString& aList)
|
||||
{
|
||||
nsAutoString element;
|
||||
aTag->ToString(element);
|
||||
|
||||
if (aList.EqualsLiteral("*"))
|
||||
return PR_TRUE; // match _everything_!
|
||||
|
||||
PRInt32 indx = aList.Find(element, 0);
|
||||
if (indx == -1)
|
||||
return PR_FALSE; // not in the list at all
|
||||
|
||||
// okay, now make sure it's not a substring snafu; e.g., 'ur'
|
||||
// found inside of 'blur'.
|
||||
if (indx > 0) {
|
||||
PRUnichar ch = aList[indx - 1];
|
||||
if (! nsCRT::IsAsciiSpace(ch) && ch != PRUnichar('|'))
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (indx + element.Length() < aList.Length()) {
|
||||
PRUnichar ch = aList[indx + element.Length()];
|
||||
if (! nsCRT::IsAsciiSpace(ch) && ch != PRUnichar('|'))
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::AddScriptEventListener(nsIContent* aElement, nsIAtom* aName,
|
||||
const nsString& aValue)
|
||||
{
|
||||
nsAutoString val;
|
||||
aName->ToString(val);
|
||||
|
||||
nsAutoString eventStr(NS_LITERAL_STRING("on"));
|
||||
eventStr += val;
|
||||
|
||||
nsCOMPtr<nsIAtom> eventName = do_GetAtom(eventStr);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(aElement));
|
||||
if (!receiver)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
rv = receiver->GetListenerManager(getter_AddRefs(manager));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = manager->AddScriptEventListener(receiver, eventName, aValue, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXBLBinding::GetTextData(nsIContent *aParent, nsString& aResult)
|
||||
{
|
||||
@ -1367,7 +1185,7 @@ DeleteVoidArray(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsXBLBinding::GetInsertionPointsFor(nsIContent* aParent, nsVoidArray** aResult)
|
||||
{
|
||||
if (!mInsertionPointTable) {
|
||||
@ -1389,117 +1207,94 @@ nsXBLBinding::GetInsertionPointsFor(nsIContent* aParent, nsVoidArray** aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetInsertionPoint(nsIContent* aChild, nsIContent** aResult, PRUint32* aIndex,
|
||||
nsIContent** aDefaultContent)
|
||||
nsIContent*
|
||||
nsXBLBinding::GetInsertionPoint(nsIContent* aChild, PRUint32* aIndex)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
*aDefaultContent = nsnull;
|
||||
if (mContent)
|
||||
mPrototypeBinding->GetInsertionPoint(mBoundElement, mContent, aChild, aResult, aIndex, aDefaultContent);
|
||||
else if (mNextBinding)
|
||||
return mNextBinding->GetInsertionPoint(aChild, aResult, aIndex, aDefaultContent);
|
||||
return NS_OK;
|
||||
if (mContent) {
|
||||
return mPrototypeBinding->GetInsertionPoint(mBoundElement, mContent,
|
||||
aChild, aIndex);
|
||||
}
|
||||
|
||||
if (mNextBinding)
|
||||
return mNextBinding->GetInsertionPoint(aChild, aIndex);
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetSingleInsertionPoint(nsIContent** aResult, PRUint32* aIndex, PRBool* aMultipleInsertionPoints,
|
||||
nsIContent** aDefaultContent)
|
||||
nsIContent*
|
||||
nsXBLBinding::GetSingleInsertionPoint(PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
*aDefaultContent = nsnull;
|
||||
*aMultipleInsertionPoints = PR_FALSE;
|
||||
if (mContent)
|
||||
mPrototypeBinding->GetSingleInsertionPoint(mBoundElement, mContent, aResult, aIndex,
|
||||
aMultipleInsertionPoints, aDefaultContent);
|
||||
else if (mNextBinding)
|
||||
return mNextBinding->GetSingleInsertionPoint(aResult, aIndex, aMultipleInsertionPoints, aDefaultContent);
|
||||
return NS_OK;
|
||||
if (mContent) {
|
||||
return mPrototypeBinding->GetSingleInsertionPoint(mBoundElement, mContent,
|
||||
aIndex,
|
||||
aMultipleInsertionPoints);
|
||||
}
|
||||
|
||||
if (mNextBinding)
|
||||
return mNextBinding->GetSingleInsertionPoint(aIndex,
|
||||
aMultipleInsertionPoints);
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetRootBinding(nsIXBLBinding** aResult)
|
||||
nsXBLBinding*
|
||||
nsXBLBinding::RootBinding()
|
||||
{
|
||||
if (mNextBinding)
|
||||
return mNextBinding->GetRootBinding(aResult);
|
||||
return mNextBinding->RootBinding();
|
||||
|
||||
*aResult = this;
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
return this;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetFirstStyleBinding(nsIXBLBinding** aResult)
|
||||
nsXBLBinding*
|
||||
nsXBLBinding::GetFirstStyleBinding()
|
||||
{
|
||||
if (mIsStyleBinding) {
|
||||
*aResult = this;
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (mNextBinding)
|
||||
return mNextBinding->GetFirstStyleBinding(aResult);
|
||||
if (mIsStyleBinding)
|
||||
return this;
|
||||
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
return mNextBinding ? mNextBinding->GetFirstStyleBinding() : nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXBLBinding::MarkForDeath()
|
||||
{
|
||||
mMarkedForDeath = PR_TRUE;
|
||||
ExecuteDetachedHandler();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::MarkedForDeath(PRBool* aResult)
|
||||
PRBool
|
||||
nsXBLBinding::ImplementsInterface(REFNSIID aIID) const
|
||||
{
|
||||
*aResult = mMarkedForDeath;
|
||||
return NS_OK;
|
||||
return mPrototypeBinding->ImplementsInterface(aIID) ||
|
||||
(mNextBinding && mNextBinding->ImplementsInterface(aIID));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::ImplementsInterface(REFNSIID aIID, PRBool* aResult)
|
||||
already_AddRefed<nsIDOMNodeList>
|
||||
nsXBLBinding::GetAnonymousNodes()
|
||||
{
|
||||
*aResult = mPrototypeBinding->ImplementsInterface(aIID);
|
||||
if (!*aResult && mNextBinding)
|
||||
return mNextBinding->ImplementsInterface(aIID, aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetAnonymousNodes(nsIDOMNodeList** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mContent));
|
||||
return elt->GetChildNodes(aResult);
|
||||
nsIDOMNodeList *nodeList = nsnull;
|
||||
elt->GetChildNodes(&nodeList);
|
||||
return nodeList;
|
||||
}
|
||||
else if (mNextBinding)
|
||||
return mNextBinding->GetAnonymousNodes(aResult);
|
||||
return NS_OK;
|
||||
|
||||
if (mNextBinding)
|
||||
return mNextBinding->GetAnonymousNodes();
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::ShouldBuildChildFrames(PRBool* aResult)
|
||||
PRBool
|
||||
nsXBLBinding::ShouldBuildChildFrames() const
|
||||
{
|
||||
*aResult = PR_TRUE;
|
||||
if (mContent)
|
||||
*aResult = mPrototypeBinding->ShouldBuildChildFrames();
|
||||
else if (mNextBinding)
|
||||
return mNextBinding->ShouldBuildChildFrames(aResult);
|
||||
return mPrototypeBinding->ShouldBuildChildFrames();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Creation Routine ///////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewXBLBinding(nsXBLPrototypeBinding* aBinding, nsIXBLBinding** aResult)
|
||||
{
|
||||
*aResult = new nsXBLBinding(aBinding);
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
if (mNextBinding)
|
||||
return mNextBinding->ShouldBuildChildFrames();
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
@ -37,99 +37,108 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsXBLPrototypeBinding.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
|
||||
class nsXBLPrototypeBinding;
|
||||
class nsIContent;
|
||||
class nsIAtom;
|
||||
class nsIDocument;
|
||||
class nsIScriptContext;
|
||||
class nsISupportsArray;
|
||||
class nsObjectHashtable;
|
||||
class nsIXBLService;
|
||||
class nsFixedSizeAllocator;
|
||||
class nsXBLEventHandler;
|
||||
struct JSContext;
|
||||
struct JSObject;
|
||||
|
||||
// *********************************************************************/
|
||||
// The XBLBinding class
|
||||
|
||||
class nsXBLBinding: public nsIXBLBinding
|
||||
class nsXBLBinding
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIXBLBinding
|
||||
NS_IMETHOD GetPrototypeBinding(nsXBLPrototypeBinding** aResult);
|
||||
NS_IMETHOD SetPrototypeBinding(nsXBLPrototypeBinding* aProtoBinding);
|
||||
|
||||
NS_IMETHOD GetBaseBinding(nsIXBLBinding** aResult);
|
||||
NS_IMETHOD SetBaseBinding(nsIXBLBinding* aBinding);
|
||||
|
||||
NS_IMETHOD GetAnonymousContent(nsIContent** aParent);
|
||||
NS_IMETHOD SetAnonymousContent(nsIContent* aParent);
|
||||
|
||||
NS_IMETHOD GetBindingElement(nsIContent** aResult);
|
||||
NS_IMETHOD SetBindingElement(nsIContent* aElement);
|
||||
|
||||
NS_IMETHOD GetBoundElement(nsIContent** aResult);
|
||||
NS_IMETHOD SetBoundElement(nsIContent* aElement);
|
||||
|
||||
NS_IMETHOD GenerateAnonymousContent();
|
||||
NS_IMETHOD InstallEventHandlers();
|
||||
NS_IMETHOD InstallImplementation();
|
||||
|
||||
NS_IMETHOD HasStyleSheets(PRBool* aResolveStyle);
|
||||
|
||||
NS_IMETHOD GetFirstBindingWithConstructor(nsIXBLBinding** aResult);
|
||||
|
||||
NS_IMETHOD GetBaseTag(PRInt32* aNameSpaceID, nsIAtom** aResult);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceID,
|
||||
PRBool aRemoveFlag, PRBool aNotify);
|
||||
|
||||
NS_IMETHOD ExecuteAttachedHandler();
|
||||
NS_IMETHOD ExecuteDetachedHandler();
|
||||
|
||||
NS_IMETHOD UnhookEventHandlers();
|
||||
NS_IMETHOD ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocument);
|
||||
|
||||
NS_IMETHOD_(nsIURI*) BindingURI() const;
|
||||
NS_IMETHOD_(nsIURI*) DocURI() const;
|
||||
NS_IMETHOD GetID(nsACString& aResult) const;
|
||||
|
||||
NS_IMETHOD GetInsertionPointsFor(nsIContent* aParent, nsVoidArray** aResult);
|
||||
|
||||
NS_IMETHOD GetInsertionPoint(nsIContent* aChild, nsIContent** aResult, PRUint32* aIndex, nsIContent** aDefaultContent);
|
||||
NS_IMETHOD GetSingleInsertionPoint(nsIContent** aResult, PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints, nsIContent** aDefaultContent);
|
||||
|
||||
NS_IMETHOD IsStyleBinding(PRBool* aResult) { *aResult = mIsStyleBinding; return NS_OK; };
|
||||
NS_IMETHOD SetIsStyleBinding(PRBool aIsStyle) { mIsStyleBinding = aIsStyle; return NS_OK; };
|
||||
|
||||
NS_IMETHOD GetRootBinding(nsIXBLBinding** aResult);
|
||||
NS_IMETHOD GetFirstStyleBinding(nsIXBLBinding** aResult);
|
||||
|
||||
NS_IMETHOD InheritsStyle(PRBool* aResult);
|
||||
NS_IMETHOD WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, void* aData);
|
||||
|
||||
NS_IMETHOD MarkForDeath();
|
||||
NS_IMETHOD MarkedForDeath(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD ImplementsInterface(REFNSIID aIID, PRBool* aResult);
|
||||
|
||||
NS_IMETHOD GetAnonymousNodes(nsIDOMNodeList** aResult);
|
||||
|
||||
NS_IMETHOD ShouldBuildChildFrames(PRBool* aResult);
|
||||
|
||||
public:
|
||||
nsXBLBinding(nsXBLPrototypeBinding* aProtoBinding);
|
||||
virtual ~nsXBLBinding();
|
||||
~nsXBLBinding();
|
||||
|
||||
NS_IMETHOD AddScriptEventListener(nsIContent* aElement, nsIAtom* aName, const nsString& aValue);
|
||||
/**
|
||||
* XBLBindings are refcounted. They are held onto in 3 ways:
|
||||
* 1. The binding manager's binding table holds onto all bindings that are
|
||||
* currently attached to a content node.
|
||||
* 2. Bindings hold onto their base binding. This is important since
|
||||
* the base binding itself may not be attached to anything.
|
||||
* 3. The binding manager holds an additional reference to bindings
|
||||
* which are queued to fire their constructors.
|
||||
*/
|
||||
|
||||
PRBool AllowScripts();
|
||||
nsrefcnt AddRef()
|
||||
{
|
||||
++mRefCnt;
|
||||
NS_LOG_ADDREF(this, mRefCnt, "nsXBLBinding", sizeof(nsXBLBinding));
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt Release()
|
||||
{
|
||||
--mRefCnt;
|
||||
NS_LOG_RELEASE(this, mRefCnt, "nsXBLBinding");
|
||||
if (mRefCnt == 0) {
|
||||
mRefCnt = 1;
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
nsXBLPrototypeBinding* PrototypeBinding() { return mPrototypeBinding; }
|
||||
nsIContent* GetAnonymousContent() { return mContent; }
|
||||
|
||||
nsXBLBinding* GetBaseBinding() { return mNextBinding; }
|
||||
void SetBaseBinding(nsXBLBinding *aBinding);
|
||||
|
||||
nsIContent* GetBoundElement() { return mBoundElement; }
|
||||
void SetBoundElement(nsIContent *aElement);
|
||||
|
||||
PRBool IsStyleBinding() const { return mIsStyleBinding; }
|
||||
void SetIsStyleBinding(PRBool aIsStyle) { mIsStyleBinding = aIsStyle; }
|
||||
|
||||
void MarkForDeath();
|
||||
PRBool MarkedForDeath() const { return mMarkedForDeath; }
|
||||
|
||||
PRBool HasStyleSheets() const;
|
||||
PRBool InheritsStyle() const;
|
||||
PRBool ImplementsInterface(REFNSIID aIID) const;
|
||||
PRBool ShouldBuildChildFrames() const;
|
||||
|
||||
void GenerateAnonymousContent();
|
||||
void InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElement);
|
||||
void InstallEventHandlers();
|
||||
void InstallImplementation();
|
||||
|
||||
void ExecuteAttachedHandler();
|
||||
void ExecuteDetachedHandler();
|
||||
void UnhookEventHandlers();
|
||||
|
||||
nsIAtom* GetBaseTag(PRInt32* aNameSpaceID);
|
||||
nsXBLBinding* GetFirstBindingWithConstructor();
|
||||
nsXBLBinding* RootBinding();
|
||||
nsXBLBinding* GetFirstStyleBinding();
|
||||
|
||||
// Get the list of insertion points for aParent. The nsVoidArray is owned
|
||||
// by the binding, you should not delete it.
|
||||
nsresult GetInsertionPointsFor(nsIContent* aParent, nsVoidArray** aResult);
|
||||
|
||||
nsIContent* GetInsertionPoint(nsIContent* aChild, PRUint32* aIndex);
|
||||
|
||||
nsIContent* GetSingleInsertionPoint(PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints);
|
||||
|
||||
void AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceID,
|
||||
PRBool aRemoveFlag, PRBool aNotify);
|
||||
|
||||
void ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocument);
|
||||
|
||||
void WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, void* aData);
|
||||
|
||||
already_AddRefed<nsIDOMNodeList> GetAnonymousNodes();
|
||||
|
||||
static nsresult GetTextData(nsIContent *aParent, nsString& aResult);
|
||||
|
||||
@ -144,14 +153,14 @@ protected:
|
||||
void** aClassObject);
|
||||
|
||||
void GetImmediateChild(nsIAtom* aTag, nsIContent** aResult);
|
||||
PRBool IsInExcludesList(nsIAtom* aTag, const nsString& aList);
|
||||
|
||||
PRBool AllowScripts(); // XXX make const
|
||||
|
||||
// MEMBER VARIABLES
|
||||
protected:
|
||||
nsAutoRefCnt mRefCnt;
|
||||
nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo
|
||||
nsCOMPtr<nsIContent> mContent; // Strong. Our anonymous content stays around with us.
|
||||
nsCOMPtr<nsIXBLBinding> mNextBinding; // Strong. The derived binding owns the base class bindings.
|
||||
nsRefPtr<nsXBLBinding> mNextBinding; // Strong. The derived binding owns the base class bindings.
|
||||
|
||||
nsIContent* mBoundElement; // [WEAK] We have a reference, but we don't own it.
|
||||
|
||||
|
||||
@ -458,9 +458,8 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute,
|
||||
while (xblAttr) {
|
||||
nsIContent* element = xblAttr->GetElement();
|
||||
|
||||
nsCOMPtr<nsIContent> realElement;
|
||||
realElement = LocateInstance(aChangedElement, content, aAnonymousContent,
|
||||
element);
|
||||
nsIContent *realElement = LocateInstance(aChangedElement, content,
|
||||
aAnonymousContent, element);
|
||||
|
||||
if (realElement) {
|
||||
nsIAtom* dstAttr = xblAttr->GetDstAttribute();
|
||||
@ -528,10 +527,10 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute,
|
||||
}
|
||||
|
||||
struct InsertionData {
|
||||
nsIXBLBinding* mBinding;
|
||||
nsXBLBinding* mBinding;
|
||||
nsXBLPrototypeBinding* mPrototype;
|
||||
|
||||
InsertionData(nsIXBLBinding* aBinding,
|
||||
InsertionData(nsXBLBinding* aBinding,
|
||||
nsXBLPrototypeBinding* aPrototype)
|
||||
:mBinding(aBinding), mPrototype(aPrototype) {};
|
||||
};
|
||||
@ -540,7 +539,7 @@ PRBool PR_CALLBACK InstantiateInsertionPoint(nsHashKey* aKey, void* aData, void*
|
||||
{
|
||||
nsXBLInsertionPointEntry* entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, aData);
|
||||
InsertionData* data = NS_STATIC_CAST(InsertionData*, aClosure);
|
||||
nsIXBLBinding* binding = data->mBinding;
|
||||
nsXBLBinding* binding = data->mBinding;
|
||||
nsXBLPrototypeBinding* proto = data->mPrototype;
|
||||
|
||||
// Get the insertion parent.
|
||||
@ -549,13 +548,12 @@ PRBool PR_CALLBACK InstantiateInsertionPoint(nsHashKey* aKey, void* aData, void*
|
||||
nsIContent* defContent = entry->GetDefaultContent();
|
||||
|
||||
// Locate the real content.
|
||||
nsCOMPtr<nsIContent> realContent;
|
||||
nsCOMPtr<nsIContent> instanceRoot;
|
||||
binding->GetAnonymousContent(getter_AddRefs(instanceRoot));
|
||||
nsIContent *instanceRoot = binding->GetAnonymousContent();
|
||||
nsCOMPtr<nsIContent> templRoot = proto->GetImmediateChild(nsXBLAtoms::content);
|
||||
realContent = proto->LocateInstance(nsnull, templRoot, instanceRoot, content);
|
||||
nsIContent *realContent = proto->LocateInstance(nsnull, templRoot,
|
||||
instanceRoot, content);
|
||||
if (!realContent)
|
||||
binding->GetBoundElement(getter_AddRefs(realContent));
|
||||
realContent = binding->GetBoundElement();
|
||||
|
||||
// Now that we have the real content, look it up in our table.
|
||||
nsVoidArray* points;
|
||||
@ -589,97 +587,88 @@ PRBool PR_CALLBACK InstantiateInsertionPoint(nsHashKey* aKey, void* aData, void*
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLPrototypeBinding::InstantiateInsertionPoints(nsIXBLBinding* aBinding)
|
||||
nsXBLPrototypeBinding::InstantiateInsertionPoints(nsXBLBinding* aBinding)
|
||||
{
|
||||
InsertionData data(aBinding, this);
|
||||
if (mInsertionPointTable)
|
||||
mInsertionPointTable->Enumerate(InstantiateInsertionPoint, &data);
|
||||
}
|
||||
|
||||
void
|
||||
nsIContent*
|
||||
nsXBLPrototypeBinding::GetInsertionPoint(nsIContent* aBoundElement,
|
||||
nsIContent* aCopyRoot,
|
||||
nsIContent* aChild,
|
||||
nsIContent** aResult,
|
||||
PRUint32* aIndex,
|
||||
nsIContent** aDefaultContent)
|
||||
PRUint32* aIndex)
|
||||
{
|
||||
if (mInsertionPointTable) {
|
||||
nsISupportsKey key(aChild->Tag());
|
||||
nsXBLInsertionPointEntry* entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key));
|
||||
if (!entry) {
|
||||
nsISupportsKey key2(nsXBLAtoms::children);
|
||||
entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key2));
|
||||
}
|
||||
if (!mInsertionPointTable)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIContent> realContent;
|
||||
if (entry) {
|
||||
nsIContent* content = entry->GetInsertionParent();
|
||||
*aIndex = entry->GetInsertionIndex();
|
||||
NS_IF_ADDREF(*aDefaultContent = entry->GetDefaultContent());
|
||||
nsCOMPtr<nsIContent> templContent;
|
||||
templContent = GetImmediateChild(nsXBLAtoms::content);
|
||||
realContent = LocateInstance(nsnull, templContent, aCopyRoot, content);
|
||||
}
|
||||
else {
|
||||
// We got nothin'. Bail.
|
||||
*aResult = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
if (realContent)
|
||||
*aResult = realContent;
|
||||
else
|
||||
*aResult = aBoundElement;
|
||||
|
||||
NS_IF_ADDREF(*aResult);
|
||||
nsISupportsKey key(aChild->Tag());
|
||||
nsXBLInsertionPointEntry* entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key));
|
||||
if (!entry) {
|
||||
nsISupportsKey key2(nsXBLAtoms::children);
|
||||
entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key2));
|
||||
}
|
||||
|
||||
nsIContent *realContent = nsnull;
|
||||
if (entry) {
|
||||
nsIContent* content = entry->GetInsertionParent();
|
||||
*aIndex = entry->GetInsertionIndex();
|
||||
nsCOMPtr<nsIContent> templContent;
|
||||
templContent = GetImmediateChild(nsXBLAtoms::content);
|
||||
realContent = LocateInstance(nsnull, templContent, aCopyRoot, content);
|
||||
}
|
||||
else {
|
||||
// We got nothin'. Bail.
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return realContent ? realContent : aBoundElement;
|
||||
}
|
||||
|
||||
void
|
||||
nsIContent*
|
||||
nsXBLPrototypeBinding::GetSingleInsertionPoint(nsIContent* aBoundElement,
|
||||
nsIContent* aCopyRoot,
|
||||
nsIContent** aResult,
|
||||
PRUint32* aIndex,
|
||||
PRBool* aMultipleInsertionPoints,
|
||||
nsIContent** aDefaultContent)
|
||||
PRBool* aMultipleInsertionPoints)
|
||||
{
|
||||
if (mInsertionPointTable) {
|
||||
if(mInsertionPointTable->Count() == 1) {
|
||||
nsISupportsKey key(nsXBLAtoms::children);
|
||||
nsXBLInsertionPointEntry* entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key));
|
||||
*aMultipleInsertionPoints = PR_FALSE;
|
||||
*aIndex = 0;
|
||||
|
||||
nsCOMPtr<nsIContent> realContent;
|
||||
if (entry) {
|
||||
nsIContent* content = entry->GetInsertionParent();
|
||||
*aIndex = entry->GetInsertionIndex();
|
||||
NS_IF_ADDREF(*aDefaultContent = entry->GetDefaultContent());
|
||||
nsCOMPtr<nsIContent> templContent;
|
||||
templContent = GetImmediateChild(nsXBLAtoms::content);
|
||||
realContent = LocateInstance(nsnull, templContent, aCopyRoot, content);
|
||||
}
|
||||
else {
|
||||
// The only insertion point specified was actually a filtered insertion point.
|
||||
// This means (strictly speaking) that we actually have multiple insertion
|
||||
// points: the filtered one and a generic insertion point (content that doesn't
|
||||
// match the filter will just go right underneath the bound element).
|
||||
*aMultipleInsertionPoints = PR_TRUE;
|
||||
*aResult = nsnull;
|
||||
*aIndex = 0;
|
||||
return;
|
||||
}
|
||||
if (!mInsertionPointTable)
|
||||
return nsnull;
|
||||
|
||||
*aMultipleInsertionPoints = PR_FALSE;
|
||||
if (realContent)
|
||||
*aResult = realContent;
|
||||
else
|
||||
*aResult = aBoundElement;
|
||||
|
||||
NS_IF_ADDREF(*aResult);
|
||||
}
|
||||
else
|
||||
*aMultipleInsertionPoints = PR_TRUE;
|
||||
if (mInsertionPointTable->Count() != 1) {
|
||||
*aMultipleInsertionPoints = PR_TRUE;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsISupportsKey key(nsXBLAtoms::children);
|
||||
nsXBLInsertionPointEntry* entry =
|
||||
NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key));
|
||||
|
||||
if (!entry) {
|
||||
// The only insertion point specified was actually a filtered insertion
|
||||
// point. This means (strictly speaking) that we actually have multiple
|
||||
// insertion points: the filtered one and a generic insertion point
|
||||
// (content that doesn't match the filter will just go right underneath the
|
||||
// bound element).
|
||||
|
||||
*aMultipleInsertionPoints = PR_TRUE;
|
||||
*aIndex = 0;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
*aMultipleInsertionPoints = PR_FALSE;
|
||||
*aIndex = entry->GetInsertionIndex();
|
||||
|
||||
nsCOMPtr<nsIContent> templContent;
|
||||
templContent = GetImmediateChild(nsXBLAtoms::content);
|
||||
nsIContent* content = entry->GetInsertionParent();
|
||||
nsIContent *realContent = LocateInstance(nsnull, templContent, aCopyRoot,
|
||||
content);
|
||||
|
||||
return realContent ? realContent : aBoundElement;
|
||||
}
|
||||
|
||||
void
|
||||
@ -689,19 +678,19 @@ nsXBLPrototypeBinding::SetBaseTag(PRInt32 aNamespaceID, nsIAtom* aTag)
|
||||
mBaseTag = aTag;
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLPrototypeBinding::GetBaseTag(PRInt32* aNamespaceID, nsIAtom** aResult)
|
||||
nsIAtom*
|
||||
nsXBLPrototypeBinding::GetBaseTag(PRInt32* aNamespaceID)
|
||||
{
|
||||
if (mBaseTag) {
|
||||
*aResult = mBaseTag;
|
||||
NS_ADDREF(*aResult);
|
||||
*aNamespaceID = mBaseNameSpaceID;
|
||||
return mBaseTag;
|
||||
}
|
||||
else *aResult = nsnull;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXBLPrototypeBinding::ImplementsInterface(REFNSIID aIID)
|
||||
nsXBLPrototypeBinding::ImplementsInterface(REFNSIID aIID) const
|
||||
{
|
||||
// Check our IID table.
|
||||
if (mInterfaceTable) {
|
||||
@ -749,7 +738,7 @@ nsXBLPrototypeBinding::InitClass(const nsCString& aClassName,
|
||||
scriptObject, aClassName, aClassObject);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIContent>
|
||||
nsIContent*
|
||||
nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement,
|
||||
nsIContent* aTemplRoot,
|
||||
nsIContent* aCopyRoot,
|
||||
@ -761,7 +750,6 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement,
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIContent> templParent = aTemplChild->GetParent();
|
||||
nsCOMPtr<nsIContent> copyParent;
|
||||
nsCOMPtr<nsIContent> childPoint;
|
||||
|
||||
if (aBoundElement) {
|
||||
@ -777,6 +765,7 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement,
|
||||
return nsnull;
|
||||
|
||||
nsIContent* result = nsnull;
|
||||
nsIContent *copyParent;
|
||||
|
||||
if (templParent == aTemplRoot)
|
||||
copyParent = aCopyRoot;
|
||||
@ -787,24 +776,22 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement,
|
||||
// First we have to locate this insertion point and use its index and its
|
||||
// count to detemine our precise position within the template.
|
||||
nsIDocument* doc = aBoundElement->GetOwnerDoc();
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
doc->BindingManager()->GetBinding(aBoundElement, getter_AddRefs(binding));
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> currBinding = binding;
|
||||
nsCOMPtr<nsIContent> anonContent;
|
||||
while (currBinding) {
|
||||
currBinding->GetAnonymousContent(getter_AddRefs(anonContent));
|
||||
nsXBLBinding *binding = doc->BindingManager()->GetBinding(aBoundElement);
|
||||
nsIContent *anonContent = nsnull;
|
||||
|
||||
while (binding) {
|
||||
anonContent = binding->GetAnonymousContent();
|
||||
if (anonContent)
|
||||
break;
|
||||
nsCOMPtr<nsIXBLBinding> tempBinding = currBinding;
|
||||
tempBinding->GetBaseBinding(getter_AddRefs(currBinding));
|
||||
|
||||
binding = binding->GetBaseBinding();
|
||||
}
|
||||
|
||||
nsVoidArray* points;
|
||||
if (anonContent == copyParent)
|
||||
currBinding->GetInsertionPointsFor(aBoundElement, &points);
|
||||
binding->GetInsertionPointsFor(aBoundElement, &points);
|
||||
else
|
||||
currBinding->GetInsertionPointsFor(copyParent, &points);
|
||||
binding->GetInsertionPointsFor(copyParent, &points);
|
||||
PRInt32 count = points->Count();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
// Next we have to find the real insertion point for this proto insertion
|
||||
@ -834,8 +821,6 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement,
|
||||
result = copyParent->GetChildAt(index);
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -887,11 +872,10 @@ PRBool PR_CALLBACK SetAttrs(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
PRInt32 dstNs = curr->GetDstNameSpace();
|
||||
nsIContent* element = curr->GetElement();
|
||||
|
||||
nsCOMPtr<nsIContent> realElement;
|
||||
realElement = changeData->mProto->LocateInstance(changeData->mBoundElement,
|
||||
content,
|
||||
changeData->mContent,
|
||||
element);
|
||||
nsIContent *realElement =
|
||||
changeData->mProto->LocateInstance(changeData->mBoundElement, content,
|
||||
changeData->mContent, element);
|
||||
|
||||
if (realElement) {
|
||||
realElement->SetAttr(dstNs, dst, value, PR_FALSE);
|
||||
|
||||
@ -961,7 +945,7 @@ nsXBLPrototypeBinding::GetStyleSheets()
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXBLPrototypeBinding::ShouldBuildChildFrames()
|
||||
nsXBLPrototypeBinding::ShouldBuildChildFrames() const
|
||||
{
|
||||
if (!mAttributeTable)
|
||||
return PR_TRUE;
|
||||
|
||||
@ -60,7 +60,7 @@ class nsSupportsHashtable;
|
||||
class nsIXBLService;
|
||||
class nsFixedSizeAllocator;
|
||||
class nsXBLProtoImpl;
|
||||
class nsIXBLBinding;
|
||||
class nsXBLBinding;
|
||||
|
||||
// *********************************************************************/
|
||||
// The XBLPrototypeBinding class
|
||||
@ -87,7 +87,7 @@ public:
|
||||
PRBool LoadResources();
|
||||
nsresult AddResource(nsIAtom* aResourceType, const nsAString& aSrc);
|
||||
|
||||
PRBool InheritsStyle() { return mInheritStyle; }
|
||||
PRBool InheritsStyle() const { return mInheritStyle; }
|
||||
|
||||
nsXBLPrototypeHandler* GetPrototypeHandlers() { return mPrototypeHandler; }
|
||||
void SetPrototypeHandlers(nsXBLPrototypeHandler* aHandler) { mPrototypeHandler = aHandler; }
|
||||
@ -129,23 +129,22 @@ public:
|
||||
|
||||
nsresult FlushSkinSheets();
|
||||
|
||||
void InstantiateInsertionPoints(nsIXBLBinding* aBinding);
|
||||
void InstantiateInsertionPoints(nsXBLBinding* aBinding);
|
||||
|
||||
void GetInsertionPoint(nsIContent* aBoundElement, nsIContent* aCopyRoot,
|
||||
nsIContent* aChild, nsIContent** aResult,
|
||||
PRUint32* aIndex, nsIContent** aDefaultContent);
|
||||
nsIContent* GetInsertionPoint(nsIContent* aBoundElement,
|
||||
nsIContent* aCopyRoot, nsIContent *aChild,
|
||||
PRUint32* aIndex);
|
||||
|
||||
void GetSingleInsertionPoint(nsIContent* aBoundElement,
|
||||
nsIContent* aCopyRoot, nsIContent** aResult,
|
||||
PRUint32* aIndex, PRBool* aMultiple,
|
||||
nsIContent** aDefaultContent);
|
||||
nsIContent* GetSingleInsertionPoint(nsIContent* aBoundElement,
|
||||
nsIContent* aCopyRoot,
|
||||
PRUint32* aIndex, PRBool* aMultiple);
|
||||
|
||||
void GetBaseTag(PRInt32* aNamespaceID, nsIAtom** aTag);
|
||||
nsIAtom* GetBaseTag(PRInt32* aNamespaceID);
|
||||
void SetBaseTag(PRInt32 aNamespaceID, nsIAtom* aTag);
|
||||
|
||||
PRBool ImplementsInterface(REFNSIID aIID);
|
||||
PRBool ImplementsInterface(REFNSIID aIID) const;
|
||||
|
||||
PRBool ShouldBuildChildFrames();
|
||||
PRBool ShouldBuildChildFrames() const;
|
||||
|
||||
nsresult AddResourceListener(nsIContent* aBoundElement);
|
||||
|
||||
@ -182,10 +181,10 @@ public:
|
||||
// Internal member functions
|
||||
public:
|
||||
already_AddRefed<nsIContent> GetImmediateChild(nsIAtom* aTag);
|
||||
already_AddRefed<nsIContent> LocateInstance(nsIContent* aBoundElt,
|
||||
nsIContent* aTemplRoot,
|
||||
nsIContent* aCopyRoot,
|
||||
nsIContent* aTemplChild);
|
||||
nsIContent* LocateInstance(nsIContent* aBoundElt,
|
||||
nsIContent* aTemplRoot,
|
||||
nsIContent* aCopyRoot,
|
||||
nsIContent* aTemplChild);
|
||||
|
||||
protected:
|
||||
void ConstructAttributeTable(nsIContent* aElement);
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsXBLContentSink.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsXBLPrototypeBinding.h"
|
||||
#include "nsIXBLDocumentInfo.h"
|
||||
#include "nsXBLAtoms.h"
|
||||
@ -521,7 +521,7 @@ nsXBLService::~nsXBLService(void)
|
||||
// onto the element.
|
||||
NS_IMETHODIMP
|
||||
nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFlag,
|
||||
nsIXBLBinding** aBinding, PRBool* aResolveStyle)
|
||||
nsXBLBinding** aBinding, PRBool* aResolveStyle)
|
||||
{
|
||||
*aBinding = nsnull;
|
||||
*aResolveStyle = PR_FALSE;
|
||||
@ -536,21 +536,17 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFl
|
||||
|
||||
nsIBindingManager *bindingManager = document->BindingManager();
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(aContent, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = bindingManager->GetBinding(aContent);
|
||||
if (binding && !aAugmentFlag) {
|
||||
nsCOMPtr<nsIXBLBinding> styleBinding;
|
||||
binding->GetFirstStyleBinding(getter_AddRefs(styleBinding));
|
||||
nsXBLBinding *styleBinding = binding->GetFirstStyleBinding();
|
||||
if (styleBinding) {
|
||||
PRBool marked = PR_FALSE;
|
||||
binding->MarkedForDeath(&marked);
|
||||
if (marked) {
|
||||
if (binding->MarkedForDeath()) {
|
||||
FlushStyleBindings(aContent);
|
||||
binding = nsnull;
|
||||
}
|
||||
else {
|
||||
// See if the URIs match.
|
||||
nsIURI* uri = styleBinding->BindingURI();
|
||||
nsIURI* uri = styleBinding->PrototypeBinding()->BindingURI();
|
||||
PRBool equal;
|
||||
if (NS_SUCCEEDED(uri->Equals(aURL, &equal)) && equal)
|
||||
return NS_OK;
|
||||
@ -575,8 +571,11 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFl
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIXBLBinding> newBinding;
|
||||
if (NS_FAILED(rv = GetBinding(aContent, aURL, getter_AddRefs(newBinding)))) {
|
||||
|
||||
PRBool ready;
|
||||
nsRefPtr<nsXBLBinding> newBinding;
|
||||
if (NS_FAILED(rv = GetBinding(aContent, aURL, PR_FALSE, &ready,
|
||||
getter_AddRefs(newBinding)))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -591,11 +590,11 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFl
|
||||
}
|
||||
|
||||
if (aAugmentFlag) {
|
||||
nsCOMPtr<nsIXBLBinding> baseBinding;
|
||||
nsCOMPtr<nsIXBLBinding> nextBinding = newBinding;
|
||||
nsXBLBinding *baseBinding;
|
||||
nsXBLBinding *nextBinding = newBinding;
|
||||
do {
|
||||
baseBinding = nextBinding;
|
||||
baseBinding->GetBaseBinding(getter_AddRefs(nextBinding));
|
||||
nextBinding = baseBinding->GetBaseBinding();
|
||||
baseBinding->SetIsStyleBinding(PR_FALSE);
|
||||
} while (nextBinding);
|
||||
|
||||
@ -609,9 +608,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFl
|
||||
// We loaded a style binding. It goes on the end.
|
||||
if (binding) {
|
||||
// Get the last binding that is in the append layer.
|
||||
nsCOMPtr<nsIXBLBinding> rootBinding;
|
||||
binding->GetRootBinding(getter_AddRefs(rootBinding));
|
||||
rootBinding->SetBaseBinding(newBinding);
|
||||
binding->RootBinding()->SetBaseBinding(newBinding);
|
||||
}
|
||||
else {
|
||||
// Install the binding on the content node.
|
||||
@ -632,10 +629,11 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFl
|
||||
newBinding->InstallImplementation();
|
||||
|
||||
// Figure out if we need to execute a constructor.
|
||||
newBinding->GetFirstBindingWithConstructor(aBinding);
|
||||
*aBinding = newBinding->GetFirstBindingWithConstructor();
|
||||
NS_IF_ADDREF(*aBinding);
|
||||
|
||||
// Figure out if we have any scoped sheets. If so, we do a second resolve.
|
||||
newBinding->HasStyleSheets(aResolveStyle);
|
||||
*aResolveStyle = newBinding->HasStyleSheets();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -651,12 +649,10 @@ nsXBLService::FlushStyleBindings(nsIContent* aContent)
|
||||
|
||||
nsIBindingManager *bindingManager = document->BindingManager();
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(aContent, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = bindingManager->GetBinding(aContent);
|
||||
|
||||
if (binding) {
|
||||
nsCOMPtr<nsIXBLBinding> styleBinding;
|
||||
binding->GetFirstStyleBinding(getter_AddRefs(styleBinding));
|
||||
nsXBLBinding *styleBinding = binding->GetFirstStyleBinding();
|
||||
|
||||
if (styleBinding) {
|
||||
// Clear out the script references.
|
||||
@ -828,26 +824,17 @@ nsXBLService::FlushMemory()
|
||||
|
||||
// Internal helper methods ////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult nsXBLService::GetBinding(nsIContent* aBoundElement,
|
||||
nsIURI* aURI,
|
||||
nsIXBLBinding** aResult)
|
||||
{
|
||||
PRBool dummy;
|
||||
return GetBindingInternal(aBoundElement, aURI, PR_FALSE, &dummy, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXBLService::BindingReady(nsIContent* aBoundElement,
|
||||
nsIURI* aURI,
|
||||
PRBool* aIsReady)
|
||||
{
|
||||
return GetBindingInternal(aBoundElement, aURI, PR_TRUE, aIsReady, nsnull);
|
||||
return GetBinding(aBoundElement, aURI, PR_TRUE, aIsReady, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement,
|
||||
nsIURI* aURI,
|
||||
PRBool aPeekOnly,
|
||||
PRBool* aIsReady,
|
||||
nsIXBLBinding** aResult)
|
||||
nsresult
|
||||
nsXBLService::GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
|
||||
PRBool aPeekOnly, PRBool* aIsReady,
|
||||
nsXBLBinding** aResult)
|
||||
{
|
||||
if (aResult)
|
||||
*aResult = nsnull;
|
||||
@ -905,12 +892,12 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement,
|
||||
}
|
||||
|
||||
// If our prototype already has a base, then don't check for an "extends" attribute.
|
||||
nsCOMPtr<nsIXBLBinding> baseBinding;
|
||||
nsRefPtr<nsXBLBinding> baseBinding;
|
||||
PRBool hasBase = protoBinding->HasBasePrototype();
|
||||
nsXBLPrototypeBinding* baseProto = protoBinding->GetBasePrototype();
|
||||
if (baseProto) {
|
||||
if (NS_FAILED(GetBindingInternal(aBoundElement, baseProto->BindingURI(),
|
||||
aPeekOnly, aIsReady, getter_AddRefs(baseBinding))))
|
||||
if (NS_FAILED(GetBinding(aBoundElement, baseProto->BindingURI(),
|
||||
aPeekOnly, aIsReady, getter_AddRefs(baseBinding))))
|
||||
return NS_ERROR_FAILURE; // We aren't ready yet.
|
||||
}
|
||||
else if (hasBase) {
|
||||
@ -984,12 +971,12 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement,
|
||||
doc->GetBaseURI());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (NS_FAILED(GetBindingInternal(aBoundElement, bindingURI, aPeekOnly,
|
||||
aIsReady, getter_AddRefs(baseBinding))))
|
||||
if (NS_FAILED(GetBinding(aBoundElement, bindingURI, aPeekOnly,
|
||||
aIsReady, getter_AddRefs(baseBinding))))
|
||||
return NS_ERROR_FAILURE; // Binding not yet ready or an error occurred.
|
||||
if (!aPeekOnly) {
|
||||
// Make sure to set the base prototype.
|
||||
baseBinding->GetPrototypeBinding(&baseProto);
|
||||
baseProto = baseBinding->PrototypeBinding();
|
||||
protoBinding->SetBasePrototype(baseProto);
|
||||
child->UnsetAttr(kNameSpaceID_None, nsXBLAtoms::extends, PR_FALSE);
|
||||
child->UnsetAttr(kNameSpaceID_None, nsXBLAtoms::display, PR_FALSE);
|
||||
@ -1001,9 +988,13 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement,
|
||||
*aIsReady = PR_TRUE;
|
||||
if (!aPeekOnly) {
|
||||
// Make a new binding
|
||||
NS_NewXBLBinding(protoBinding, aResult);
|
||||
nsXBLBinding *newBinding = new nsXBLBinding(protoBinding);
|
||||
NS_ENSURE_TRUE(newBinding, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (baseBinding)
|
||||
(*aResult)->SetBaseBinding(baseBinding);
|
||||
newBinding->SetBaseBinding(baseBinding);
|
||||
|
||||
NS_ADDREF(*aResult = newBinding);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
#include "jsclist.h" // nsXBLJSClass derives from JSCList
|
||||
#include "nsFixedSizeAllocator.h"
|
||||
|
||||
class nsIXBLBinding;
|
||||
class nsXBLBinding;
|
||||
class nsIXBLDocumentInfo;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
@ -68,7 +68,7 @@ class nsXBLService : public nsIXBLService,
|
||||
// This function loads a particular XBL file and installs all of the bindings
|
||||
// onto the element.
|
||||
NS_IMETHOD LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFlag,
|
||||
nsIXBLBinding** aBinding, PRBool* aResolveStyle);
|
||||
nsXBLBinding** aBinding, PRBool* aResolveStyle);
|
||||
|
||||
// Indicates whether or not a binding is fully loaded.
|
||||
NS_IMETHOD BindingReady(nsIContent* aBoundElement, nsIURI* aURI, PRBool* aIsReady);
|
||||
@ -91,12 +91,10 @@ public:
|
||||
nsXBLService();
|
||||
virtual ~nsXBLService();
|
||||
|
||||
protected:
|
||||
// This function clears out the bindings on a given content node.
|
||||
nsresult FlushStyleBindings(nsIContent* aContent);
|
||||
|
||||
// This method loads a binding doc and then builds the specific binding required.
|
||||
nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI, nsIXBLBinding** aResult);
|
||||
|
||||
// Release any memory that we can
|
||||
nsresult FlushMemory();
|
||||
|
||||
@ -109,8 +107,9 @@ public:
|
||||
|
||||
// This method loads a binding doc and then builds the specific binding required. It
|
||||
// can also peek without building.
|
||||
NS_IMETHOD GetBindingInternal(nsIContent* aBoundElement, nsIURI* aURI,
|
||||
PRBool aPeekFlag, PRBool* aIsReady, nsIXBLBinding** aResult);
|
||||
nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
|
||||
PRBool aPeekFlag, PRBool* aIsReady,
|
||||
nsXBLBinding** aResult);
|
||||
|
||||
// MEMBER VARIABLES
|
||||
public:
|
||||
|
||||
@ -65,7 +65,6 @@
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsIBindingManager.h"
|
||||
|
||||
nsresult
|
||||
|
||||
@ -100,6 +100,7 @@ LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../../../../layout/style \
|
||||
-I$(srcdir)/../../../html/content/src \
|
||||
-I$(srcdir)/../../../events/src \
|
||||
-I$(srcdir)/../../../xbl/src \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
|
||||
@ -164,6 +164,7 @@
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsXBLBinding.h"
|
||||
|
||||
/**
|
||||
* Three bits are used for XUL Element's lazy state.
|
||||
@ -1383,8 +1384,7 @@ nsXULElement::SetAttrAndNotify(PRInt32 aNamespaceID,
|
||||
}
|
||||
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
doc->BindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = doc->BindingManager()->GetBinding(this);
|
||||
if (binding) {
|
||||
binding->AttributeChanged(aAttribute, aNamespaceID, PR_FALSE, aNotify);
|
||||
}
|
||||
@ -1594,8 +1594,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
doc->BindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
nsXBLBinding *binding = doc->BindingManager()->GetBinding(this);
|
||||
if (binding)
|
||||
binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify);
|
||||
|
||||
|
||||
@ -67,7 +67,6 @@
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIStyledContent.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsIXULPrototypeCache.h"
|
||||
|
||||
@ -110,7 +110,10 @@ CPPSRCS = \
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../events
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../events \
|
||||
-I$(topsrcdir)/content/xbl/src \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
|
||||
// XBL related includes.
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIPresShell.h"
|
||||
@ -5346,10 +5346,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
// We must ensure that the XBL Binding is installed before we hand
|
||||
// back this object.
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
doc->BindingManager()->GetBinding(content, getter_AddRefs(binding));
|
||||
|
||||
if (binding) {
|
||||
if (doc->BindingManager()->GetBinding(content)) {
|
||||
// There's already a binding for this element so nothing left to
|
||||
// be done here.
|
||||
|
||||
@ -5376,6 +5373,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
|
||||
NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsRefPtr<nsXBLBinding> binding;
|
||||
xblService->LoadBindings(content, bindingURL, PR_FALSE,
|
||||
getter_AddRefs(binding), &dummy);
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIArray;
|
||||
interface nsISupportsArray;
|
||||
interface nsIDOMCharacterData;
|
||||
interface nsIDOMElement;
|
||||
@ -46,7 +46,7 @@ interface nsIDOMDocument;
|
||||
interface nsIDOMCSSStyleRule;
|
||||
interface nsIDOMNode;
|
||||
|
||||
[scriptable, uuid(FFFFD059-13D1-4ef7-ACB1-91188C6E31DD)]
|
||||
[scriptable, uuid(78fd16c2-bdfb-4b1d-8738-d536d0a8f430)]
|
||||
interface inIDOMUtils : nsISupports
|
||||
{
|
||||
// CSS utilities
|
||||
@ -62,7 +62,7 @@ interface inIDOMUtils : nsISupports
|
||||
in boolean aShowingAnonymousContent);
|
||||
|
||||
// XBL utilities
|
||||
nsISimpleEnumerator getBindingURLs(in nsIDOMElement aElement);
|
||||
nsIArray getBindingURLs(in nsIDOMElement aElement);
|
||||
|
||||
// content state utilities
|
||||
long getContentState(in nsIDOMElement aElement);
|
||||
|
||||
@ -46,8 +46,6 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
@ -210,40 +208,9 @@ inDOMUtils::GetRuleLine(nsIDOMCSSStyleRule *aRule, PRUint32 *_retval)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsISimpleEnumerator **_retval)
|
||||
inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsIArray **_retval)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> urls;
|
||||
NS_NewISupportsArray(getter_AddRefs(urls));
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
NS_NewArrayEnumerator(getter_AddRefs(e), urls);
|
||||
|
||||
*_retval = e;
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> doc1;
|
||||
aElement->GetOwnerDocument(getter_AddRefs(doc1));
|
||||
if (!doc1) return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(doc1);
|
||||
nsIBindingManager *bindingManager = doc->BindingManager();
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(content, getter_AddRefs(binding));
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> tempBinding;
|
||||
while (binding) {
|
||||
nsCAutoString uri;
|
||||
binding->BindingURI()->GetSpec(uri);
|
||||
|
||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(uri.get());
|
||||
urls->AppendElement(atom);
|
||||
|
||||
binding->GetBaseBinding(getter_AddRefs(tempBinding));
|
||||
binding = tempBinding;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return mCSSUtils->GetBindingURLs(aElement, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -174,10 +174,12 @@ XBLBindings.prototype =
|
||||
|
||||
var popup = document.getElementById("mpBindings");
|
||||
this.clearChildren(popup);
|
||||
|
||||
while (urls.hasMoreElements()) {
|
||||
var item = urls.getNext();
|
||||
var url = item.QueryInterface(Components.interfaces.nsIAtom).toString();
|
||||
|
||||
var urlCount = urls.length;
|
||||
var i;
|
||||
|
||||
for (i = 0; i < urlCount; ++i) {
|
||||
var url = urls.queryElementAt(i, Components.interfaces.nsIURI).spec;
|
||||
var menu = document.createElement("menuitem");
|
||||
menu.setAttribute("value", url);
|
||||
menu.setAttribute("label", url);
|
||||
|
||||
@ -154,6 +154,7 @@ LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../printing \
|
||||
-I$(srcdir)/../xul/base/src \
|
||||
-I$(srcdir)/../../content/events/src \
|
||||
-I$(srcdir)/../../content/xbl/src \
|
||||
-I$(srcdir)/../../view/src \
|
||||
$(NULL)
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsITheme.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -1681,7 +1681,7 @@ struct nsAutoEnqueueBinding
|
||||
|
||||
~nsAutoEnqueueBinding();
|
||||
|
||||
nsCOMPtr<nsIXBLBinding> mBinding;
|
||||
nsRefPtr<nsXBLBinding> mBinding;
|
||||
private:
|
||||
nsIDocument* mDocument;
|
||||
};
|
||||
@ -4019,13 +4019,14 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsFrameConstructorState& aState,
|
||||
// Get the XBL loader.
|
||||
nsresult rv;
|
||||
PRBool resolveStyle;
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
|
||||
nsIXBLService * xblService = GetXBLService();
|
||||
if (!xblService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = xblService->LoadBindings(aDocElement, display->mBinding, PR_FALSE, getter_AddRefs(binding), &resolveStyle);
|
||||
nsRefPtr<nsXBLBinding> binding;
|
||||
rv = xblService->LoadBindings(aDocElement, display->mBinding, PR_FALSE,
|
||||
getter_AddRefs(binding), &resolveStyle);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK; // Binding will load asynchronously.
|
||||
|
||||
@ -11387,12 +11388,16 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIFrame* aParentFrame,
|
||||
}
|
||||
|
||||
PRUint32 index;
|
||||
bindingManager->GetInsertionPoint(container, aChildContent, getter_AddRefs(insertionElement), &index);
|
||||
insertionElement = bindingManager->GetInsertionPoint(container,
|
||||
aChildContent,
|
||||
&index);
|
||||
}
|
||||
else {
|
||||
PRBool multiple;
|
||||
PRUint32 index;
|
||||
bindingManager->GetSingleInsertionPoint(container, getter_AddRefs(insertionElement), &index, &multiple);
|
||||
insertionElement = bindingManager->GetSingleInsertionPoint(container,
|
||||
&index,
|
||||
&multiple);
|
||||
if (multiple && aMultiple)
|
||||
*aMultiple = multiple; // Record the fact that filters are in use.
|
||||
}
|
||||
|
||||
@ -69,7 +69,6 @@
|
||||
#include "nsPresState.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
|
||||
@ -181,7 +181,6 @@
|
||||
#include "nsIMenuFrame.h"
|
||||
#include "nsITreeBoxObject.h"
|
||||
#endif
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsPlaceholderFrame.h"
|
||||
|
||||
// Dummy layout request
|
||||
|
||||
@ -163,6 +163,7 @@ include $(topsrcdir)/config/rules.mk
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../../content/base/src \
|
||||
-I$(srcdir)/../../content/html/content/src \
|
||||
-I$(srcdir)/../../content/xbl/src \
|
||||
$(NULL)
|
||||
|
||||
_FILES = \
|
||||
|
||||
@ -47,11 +47,12 @@ class nsIStyleRule;
|
||||
class nsIFrame;
|
||||
struct nsRect;
|
||||
class nsIContent;
|
||||
class nsIDOMElement;
|
||||
class nsIArray;
|
||||
|
||||
// 0252892b-419a-49f4-981d-4c6716099451
|
||||
#define NS_IINSPECTORCSSUTILS_IID \
|
||||
{ 0x0252892b, 0x419a, 0x49f4, \
|
||||
{0x98, 0x1d, 0x4c, 0x67, 0x16, 0x09, 0x94, 0x51 } }
|
||||
{ 0xdf2072d2, 0x57f0, 0x4c62, \
|
||||
{0xa7, 0x3f, 0xa5, 0x2f, 0xf2, 0xf0, 0x99, 0xa6 } }
|
||||
|
||||
// 7ef2f07f-6e34-410b-8336-88acd1cd16b7
|
||||
#define NS_INSPECTORCSSUTILS_CID \
|
||||
@ -79,6 +80,9 @@ public:
|
||||
// Hooks to methods that need nsStyleContext
|
||||
NS_IMETHOD GetRuleNodeForContent(nsIContent* aContent,
|
||||
nsRuleNode** aParent) = 0;
|
||||
|
||||
// Hooks to XBL
|
||||
NS_IMETHOD GetBindingURLs(nsIDOMElement *aElement, nsIArray **aResult) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIInspectorCSSUtils_h___ */
|
||||
|
||||
@ -47,6 +47,10 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsXBLPrototypeBinding.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsArray.h"
|
||||
|
||||
nsInspectorCSSUtils::nsInspectorCSSUtils()
|
||||
{
|
||||
@ -198,3 +202,31 @@ nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent,
|
||||
*aRuleNode = sContext->GetRuleNode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInspectorCSSUtils::GetBindingURLs(nsIDOMElement *aElement,
|
||||
nsIArray **aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsCOMArray<nsIURI> urls;
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
||||
NS_ASSERTION(content, "elements must implement nsIContent");
|
||||
|
||||
nsIDocument *ownerDoc = content->GetOwnerDoc();
|
||||
if (ownerDoc) {
|
||||
nsXBLBinding *binding =
|
||||
ownerDoc->BindingManager()->GetBinding(content);
|
||||
|
||||
while (binding) {
|
||||
urls.AppendObject(binding->PrototypeBinding()->BindingURI());
|
||||
binding = binding->GetBaseBinding();
|
||||
}
|
||||
}
|
||||
|
||||
nsIMutableArray *mutableResult = nsnull;
|
||||
nsresult rv = NS_NewArray(&mutableResult, urls);
|
||||
*aResult = mutableResult;
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -63,6 +63,8 @@ public:
|
||||
NS_IMETHOD AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect);
|
||||
NS_IMETHOD GetRuleNodeForContent(nsIContent* aContent,
|
||||
nsRuleNode** aRuleNode);
|
||||
NS_IMETHOD GetBindingURLs(nsIDOMElement *aElement, nsIArray **aResult);
|
||||
|
||||
static already_AddRefed<nsStyleContext>
|
||||
GetStyleContextForContent(nsIContent* aContent, nsIAtom* aPseudo,
|
||||
nsIPresShell* aPresShell);
|
||||
|
||||
@ -67,7 +67,6 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIBindingManager.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user