diff --git a/mozilla/accessible/src/base/nsAccessibleTreeWalker.cpp b/mozilla/accessible/src/base/nsAccessibleTreeWalker.cpp index 578deca2357..582a94905a9 100755 --- a/mozilla/accessible/src/base/nsAccessibleTreeWalker.cpp +++ b/mozilla/accessible/src/base/nsAccessibleTreeWalker.cpp @@ -60,7 +60,7 @@ nsAccessibleTreeWalker::nsAccessibleTreeWalker(nsIWeakReference* aPresShell, nsI if (aWalkAnonContent) { nsCOMPtr presShell(do_QueryReferent(mWeakShell)); if (presShell) - mBindingManager = presShell->GetDocument()->GetBindingManager(); + mBindingManager = presShell->GetDocument()->BindingManager(); } MOZ_COUNT_CTOR(nsAccessibleTreeWalker); } diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index 13753e69bd7..facc5faa2c2 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -1193,7 +1193,7 @@ static void FlushSkinBindingsForWindow(nsIDOMWindowInternal* aWindow) return; // Annihilate all XBL bindings. - document->GetBindingManager()->FlushSkinBindings(); + document->BindingManager()->FlushSkinBindings(); } // XXXbsmedberg: move this to nsIWindowMediator diff --git a/mozilla/content/base/public/nsContentCID.h b/mozilla/content/base/public/nsContentCID.h index f3671227722..ae72aa0fd49 100644 --- a/mozilla/content/base/public/nsContentCID.h +++ b/mozilla/content/base/public/nsContentCID.h @@ -177,10 +177,6 @@ #define NS_XBLSERVICE_CID \ { 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } } -// {15671AF5-39F9-4c70-8CE3-72C97111B52D} -#define NS_BINDINGMANAGER_CID \ -{ 0x15671af5, 0x39f9, 0x4c70, { 0x8c, 0xe3, 0x72, 0xc9, 0x71, 0x11, 0xb5, 0x2d } } - // 3a9cd622-264d-11d4-ba06-0060b0fc76dd #define NS_DOM_IMPLEMENTATION_CID \ { 0x3a9cd622, 0x264d, 0x11d4, {0xba, 0x06, 0x00, 0x60, 0xb0, 0xfc, 0x76, 0xdd } } diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index c3de2d07ade..3b02507bb98 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -526,7 +526,7 @@ public: return mNextContentID++; } - nsIBindingManager* GetBindingManager() const + nsIBindingManager* BindingManager() const { return mBindingManager; } diff --git a/mozilla/content/base/src/Makefile.in b/mozilla/content/base/src/Makefile.in index b525518a44c..c303f8ab28a 100644 --- a/mozilla/content/base/src/Makefile.in +++ b/mozilla/content/base/src/Makefile.in @@ -142,6 +142,7 @@ INCLUDES += \ -I$(srcdir)/../../xul/content/src \ -I$(srcdir)/../../html/content/src \ -I$(srcdir)/../../base/src \ + -I$(srcdir)/../../xbl/src \ -I$(srcdir)/../../../layout/generic \ -I$(srcdir)/../../../layout/style \ -I$(srcdir)/../../../dom/src/base \ diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 08c0eee76a4..30431b09e0c 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -122,6 +122,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID); #include "nsContentCreatorFunctions.h" #include "nsIScriptContext.h" +#include "nsBindingManager.h" #include "nsICharsetAlias.h" static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID); @@ -508,24 +509,6 @@ NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument) // NOTE! nsDocument::operator new() zeroes out all members, so don't // bother initializing members to 0. -nsDocument::nsDocument() -{ - - // NOTE! nsIDocument::operator new() zeroes out all members, so don't - // bother initializing members to 0. - - // Force initialization. - mBindingManager = do_CreateInstance("@mozilla.org/xbl/binding-manager;1"); - - nsCOMPtr observer(do_QueryInterface(mBindingManager)); - if (observer) { - // The binding manager must always be the first observer of the - // document. - - mObservers.InsertElementAt(observer, 0); - } -} - nsDocument::~nsDocument() { mInDestructor = PR_TRUE; @@ -678,6 +661,15 @@ NS_IMPL_RELEASE(nsDocument) nsresult nsDocument::Init() { + // Force initialization. + nsBindingManager *bindingManager = new nsBindingManager(); + NS_ENSURE_TRUE(bindingManager, NS_ERROR_OUT_OF_MEMORY); + mBindingManager = bindingManager; + + // The binding manager must always be the first observer of the document. + // (static cast to the correct interface pointer) + mObservers.InsertElementAt(NS_STATIC_CAST(nsIDocumentObserver*, bindingManager), 0); + if (mNodeInfoManager) { return NS_ERROR_ALREADY_INITIALIZED; } @@ -2619,27 +2611,20 @@ nsDocument::RemoveBinding(nsIDOMElement* aContent, const nsAString& aURI) return rv; } - if (mBindingManager) { - nsCOMPtr content(do_QueryInterface(aContent)); - nsCOMPtr uri; - rv = NS_NewURI(getter_AddRefs(uri), aURI); - if (NS_FAILED(rv)) { - return rv; - } - return mBindingManager->RemoveLayeredBinding(content, uri); + nsCOMPtr uri; + rv = NS_NewURI(getter_AddRefs(uri), aURI); + if (NS_FAILED(rv)) { + return rv; } - return NS_ERROR_FAILURE; + nsCOMPtr content(do_QueryInterface(aContent)); + return mBindingManager->RemoveLayeredBinding(content, uri); } NS_IMETHODIMP nsDocument::LoadBindingDocument(const nsAString& aURI, nsIDOMDocument** aResult) { - if (!mBindingManager) { - return NS_ERROR_FAILURE; - } - nsCOMPtr uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), aURI, mCharacterSet.get(), @@ -2739,9 +2724,6 @@ nsDocument::GetAnonymousNodes(nsIDOMElement* aElement, nsIDOMNodeList** aResult) { *aResult = nsnull; - if (!mBindingManager) { - return NS_OK; - } nsCOMPtr content(do_QueryInterface(aElement)); return mBindingManager->GetAnonymousNodesFor(content, aResult); diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index c047971d366..244f1ccc55a 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -84,7 +84,7 @@ #include "nsIHTMLCSSStyleSheet.h" #include "nsStyleSet.h" - +#include "nsXMLEventsManager.h" #include "pldhash.h" @@ -102,7 +102,6 @@ class nsIDTD; class nsXPathDocumentTearoff; class nsIRadioVisitor; class nsIFormControl; -class nsXMLEventsManager; struct nsRadioGroupStruct; @@ -548,7 +547,7 @@ protected: return kNameSpaceID_None; }; - nsDocument(); + nsDocument() : nsIDocument() {} virtual ~nsDocument(); nsCString mReferrer; diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index e7f40d893e3..234142fd96f 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -1784,11 +1784,7 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, if (document && aDeep) { // Notify XBL- & nsIAnonymousContentCreator-generated // anonymous content that the document is changing. - nsIBindingManager* bindingManager = document->GetBindingManager(); - NS_ASSERTION(bindingManager, "No binding manager."); - if (bindingManager) { - bindingManager->ChangeDocumentFor(this, document, aDocument); - } + document->BindingManager()->ChangeDocumentFor(this, document, aDocument); nsCOMPtr domElement; QueryInterface(NS_GET_IID(nsIDOMElement), getter_AddRefs(domElement)); @@ -1930,16 +1926,12 @@ nsGenericElement::HandleDOMEvent(nsPresContext* aPresContext, } } - // determine the parent: + // check for an anonymous parent nsCOMPtr parent; - nsIBindingManager* bindingManager = nsnull; nsIDocument* ownerDoc = GetOwnerDoc(); if (ownerDoc) { - bindingManager = ownerDoc->GetBindingManager(); - } - if (bindingManager) { - // we have a binding manager -- do we have an anonymous parent? - bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); + ownerDoc->BindingManager()->GetInsertionParent(this, + getter_AddRefs(parent)); } if (!parent) { // if we didn't find an anonymous parent, use the explicit one, @@ -3184,9 +3176,8 @@ nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr) { nsIDocument *document = GetOwnerDoc(); if (document) { - nsIBindingManager* manager = document->GetBindingManager(); - if (manager) - return manager->GetBindingImplementation(this, aIID, aInstancePtr); + return document->BindingManager()->GetBindingImplementation(this, aIID, + aInstancePtr); } return NS_NOINTERFACE; @@ -3439,7 +3430,7 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, if (document) { nsCOMPtr binding; - document->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); + document->BindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(aName, aNamespaceID, PR_FALSE, aNotify); @@ -3571,7 +3562,7 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, if (document) { nsCOMPtr binding; - document->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); + document->BindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify); @@ -3657,58 +3648,56 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent) const nsIDocument *document = GetOwnerDoc(); if (document) { - nsIBindingManager* bindingManager = document->GetBindingManager(); - if (bindingManager) { - nsCOMPtr anonymousChildren; - bindingManager->GetAnonymousNodesFor(NS_CONST_CAST(nsGenericElement*, this), - getter_AddRefs(anonymousChildren)); + nsIBindingManager* bindingManager = document->BindingManager(); + nsCOMPtr anonymousChildren; + bindingManager->GetAnonymousNodesFor(NS_CONST_CAST(nsGenericElement*, this), + getter_AddRefs(anonymousChildren)); - if (anonymousChildren) { - PRUint32 length; - anonymousChildren->GetLength(&length); - if (length) { - for (index = aIndent; --index >= 0; ) fputs(" ", out); - fputs("anonymous-children<\n", out); + if (anonymousChildren) { + PRUint32 length; + anonymousChildren->GetLength(&length); + if (length) { + for (index = aIndent; --index >= 0; ) fputs(" ", out); + fputs("anonymous-children<\n", out); - for (PRUint32 i = 0; i < length; ++i) { - nsCOMPtr node; - anonymousChildren->Item(i, getter_AddRefs(node)); - nsCOMPtr child = do_QueryInterface(node); - child->List(out, aIndent + 1); - } - - for (index = aIndent; --index >= 0; ) fputs(" ", out); - fputs(">\n", out); + for (PRUint32 i = 0; i < length; ++i) { + nsCOMPtr node; + anonymousChildren->Item(i, getter_AddRefs(node)); + nsCOMPtr child = do_QueryInterface(node); + child->List(out, aIndent + 1); } + + for (index = aIndent; --index >= 0; ) fputs(" ", out); + fputs(">\n", out); } + } - PRBool hasContentList; - bindingManager->HasContentListFor(NS_CONST_CAST(nsGenericElement*, this), - &hasContentList); + PRBool hasContentList; + bindingManager->HasContentListFor(NS_CONST_CAST(nsGenericElement*, this), + &hasContentList); - if (hasContentList) { - nsCOMPtr contentList; - bindingManager->GetContentListFor(NS_CONST_CAST(nsGenericElement*, this), - getter_AddRefs(contentList)); + if (hasContentList) { + nsCOMPtr contentList; + bindingManager->GetContentListFor(NS_CONST_CAST(nsGenericElement*, this), + getter_AddRefs(contentList)); - NS_ASSERTION(contentList != nsnull, "oops, binding manager lied"); + NS_ASSERTION(contentList != nsnull, "oops, binding manager lied"); - PRUint32 length; - contentList->GetLength(&length); - if (length) { - for (index = aIndent; --index >= 0; ) fputs(" ", out); - fputs("content-list<\n", out); + PRUint32 length; + contentList->GetLength(&length); + if (length) { + for (index = aIndent; --index >= 0; ) fputs(" ", out); + fputs("content-list<\n", out); - for (PRUint32 i = 0; i < length; ++i) { - nsCOMPtr node; - contentList->Item(i, getter_AddRefs(node)); - nsCOMPtr child = do_QueryInterface(node); - child->List(out, aIndent + 1); - } - - for (index = aIndent; --index >= 0; ) fputs(" ", out); - fputs(">\n", out); + for (PRUint32 i = 0; i < length; ++i) { + nsCOMPtr node; + contentList->Item(i, getter_AddRefs(node)); + nsCOMPtr child = do_QueryInterface(node); + child->List(out, aIndent + 1); } + + for (index = aIndent; --index >= 0; ) fputs(" ", out); + fputs(">\n", out); } } } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index a1e174bf9d8..a849a0b4622 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1748,7 +1748,7 @@ nsGenericHTMLElement::SetAttrAndNotify(PRInt32 aNamespaceID, if (document) { nsCOMPtr binding; - document->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); + document->BindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) { binding->AttributeChanged(aAttribute, aNamespaceID, PR_FALSE, aNotify); } diff --git a/mozilla/content/html/document/src/Makefile.in b/mozilla/content/html/document/src/Makefile.in index e60af44ea17..e35f435575d 100644 --- a/mozilla/content/html/document/src/Makefile.in +++ b/mozilla/content/html/document/src/Makefile.in @@ -99,6 +99,7 @@ include $(topsrcdir)/config/rules.mk INCLUDES += \ -I$(srcdir)/../../../base/src \ + -I$(srcdir)/../../../events/src \ -I$(srcdir)/../../content/src \ -I$(srcdir)/../../../../layout/style \ -I$(srcdir)/../../../../dom/src/base \ diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index 87d147222a6..eaf53b59b12 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -464,7 +464,7 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement) // is our owner doc. nsIDocument* ownerDoc = GetOwnerDoc(); if (ownerDoc) { - bindingManager = ownerDoc->GetBindingManager(); + bindingManager = ownerDoc->BindingManager(); } nsCOMPtr parent; @@ -656,7 +656,7 @@ nsSVGElement::SetAttrAndNotify(PRInt32 aNamespaceID, nsIAtom* aAttribute, if (document) { nsCOMPtr binding; - document->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); + document->BindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) { binding->AttributeChanged(aAttribute, aNamespaceID, PR_FALSE, aNotify); } diff --git a/mozilla/content/svg/content/src/nsSVGGraphicElement.cpp b/mozilla/content/svg/content/src/nsSVGGraphicElement.cpp index 631b68e05e3..4c4d9bfc58f 100644 --- a/mozilla/content/svg/content/src/nsSVGGraphicElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGGraphicElement.cpp @@ -153,7 +153,7 @@ NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix **_retval) // is our owner doc. nsIDocument* ownerDoc = GetOwnerDoc(); if (ownerDoc) { - bindingManager = ownerDoc->GetBindingManager(); + bindingManager = ownerDoc->BindingManager(); } nsCOMPtr parent; @@ -233,7 +233,7 @@ NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsIDOMSVGMatrix **_retval) // is our owner doc. nsIDocument* ownerDoc = GetOwnerDoc(); if (ownerDoc) { - bindingManager = ownerDoc->GetBindingManager(); + bindingManager = ownerDoc->BindingManager(); } nsCOMPtr parent; diff --git a/mozilla/content/svg/content/src/nsSVGSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGSVGElement.cpp index d9d5b5d5a0e..ea8d3827253 100644 --- a/mozilla/content/svg/content/src/nsSVGSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGSVGElement.cpp @@ -988,7 +988,7 @@ nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix **_retval) // is our owner doc. nsIDocument* ownerDoc = GetOwnerDoc(); if (ownerDoc) { - bindingManager = ownerDoc->GetBindingManager(); + bindingManager = ownerDoc->BindingManager(); } nsCOMPtr parent; @@ -1066,7 +1066,7 @@ nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **_retval) // is our owner doc. nsIDocument* ownerDoc = GetOwnerDoc(); if (ownerDoc) { - bindingManager = ownerDoc->GetBindingManager(); + bindingManager = ownerDoc->BindingManager(); } nsCOMPtr parent; diff --git a/mozilla/content/svg/document/src/Makefile.in b/mozilla/content/svg/document/src/Makefile.in index a64805eda2e..c48ce5e5012 100644 --- a/mozilla/content/svg/document/src/Makefile.in +++ b/mozilla/content/svg/document/src/Makefile.in @@ -79,6 +79,7 @@ INCLUDES += \ -I$(srcdir)/../../../html/document/src \ -I$(srcdir)/../../../../layout/style \ -I$(srcdir)/../../../base/src \ + -I$(srcdir)/../../../events/src \ $(NULL) DEFINES += -D_IMPL_NS_LAYOUT diff --git a/mozilla/content/xbl/src/Makefile.in b/mozilla/content/xbl/src/Makefile.in index d185be80f0f..c939ddbf781 100644 --- a/mozilla/content/xbl/src/Makefile.in +++ b/mozilla/content/xbl/src/Makefile.in @@ -110,6 +110,7 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../../html/document/src \ -I$(srcdir)/../../xml/document/src \ -I$(srcdir)/../../xul/content/src \ + -I$(srcdir)/../../events/src \ -I$(srcdir)/../../../layout/style \ $(NULL) diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index c5014843280..ba851f13f46 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -41,10 +41,8 @@ #include "nsIXBLService.h" #include "nsIInputStream.h" #include "nsDoubleHashtable.h" -#include "nsInterfaceHashtable.h" #include "nsIURI.h" #include "nsIURL.h" -#include "nsURIHashKey.h" #include "nsIChannel.h" #include "nsXPIDLString.h" #include "nsIParser.h" @@ -63,8 +61,6 @@ #include "nsSupportsArray.h" #include "nsITextContent.h" #include "nsIStreamListener.h" -#include "nsIStyleRuleSupplier.h" -#include "nsStubDocumentObserver.h" #include "nsIXBLBinding.h" #include "nsIXBLDocumentInfo.h" @@ -88,6 +84,7 @@ #include "nsIScriptError.h" #include "nsIScriptContext.h" +#include "nsBindingManager.h" // ================================================================== // = nsAnonymousContentList @@ -291,155 +288,6 @@ SetOrRemoveObject(PLDHashTable& table, nsISupports* aKey, nsISupports* aValue) return NS_OK; } -//////////////////////////////////////////////////////////////////////// - -class nsBindingManager : public nsIBindingManager, - public nsIStyleRuleSupplier, - public nsStubDocumentObserver -{ - NS_DECL_ISUPPORTS - -public: - nsBindingManager(); - virtual ~nsBindingManager(); - - NS_IMETHOD GetBinding(nsIContent* aContent, nsIXBLBinding** aResult); - NS_IMETHOD SetBinding(nsIContent* aContent, nsIXBLBinding* aBinding); - - NS_IMETHOD GetInsertionParent(nsIContent* aContent, nsIContent** aResult); - NS_IMETHOD SetInsertionParent(nsIContent* aContent, nsIContent* aResult); - - NS_IMETHOD GetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS** aResult); - NS_IMETHOD SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult); - - NS_IMETHOD ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocument, - nsIDocument* aNewDocument); - - NS_IMETHOD ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** aResult); - - NS_IMETHOD GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult); - NS_IMETHOD SetContentListFor(nsIContent* aContent, nsVoidArray* aList); - NS_IMETHOD HasContentListFor(nsIContent* aContent, PRBool* aResult); - - NS_IMETHOD GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult); - NS_IMETHOD SetAnonymousNodesFor(nsIContent* aContent, nsVoidArray* aList); - - 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); - - 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 ClearAttachedQueue(); - NS_IMETHOD ProcessAttachedQueue(); - - NS_IMETHOD ExecuteDetachedHandlers(); - - NS_IMETHOD PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); - NS_IMETHOD GetXBLDocumentInfo(nsIURI* aURI, nsIXBLDocumentInfo** aResult); - NS_IMETHOD RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); - - NS_IMETHOD PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener); - 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); - - NS_IMETHOD ShouldBuildChildFrames(nsIContent* aContent, PRBool* aResult); - - // nsIStyleRuleSupplier - NS_IMETHOD WalkRules(nsStyleSet* aStyleSet, - nsIStyleRuleProcessor::EnumFunc aFunc, - RuleProcessorData* aData, - PRBool* aCutOffInheritance); - - // nsIDocumentObserver - virtual void ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - -protected: - nsresult GetXBLChildNodesInternal(nsIContent* aContent, - nsIDOMNodeList** aResult, - PRBool* aIsAnonymousContentList); - nsresult GetAnonymousNodesInternal(nsIContent* aContent, - nsIDOMNodeList** aResult, - PRBool* aIsAnonymousContentList); - - nsIContent* GetEnclosingScope(nsIContent* aContent) { - return aContent->GetBindingParent(); - } - - nsresult GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult); - -// MEMBER VARIABLES -protected: - // A mapping from nsIContent* to the nsIXBLBinding* that is - // installed on that element. - PLDHashTable mBindingTable; - - // A mapping from nsIContent* to an nsIDOMNodeList* - // (nsAnonymousContentList*). This list contains an accurate - // reflection of our *explicit* children (once intermingled with - // insertion points) in the altered DOM. - PLDHashTable mContentListTable; - - // A mapping from nsIContent* to an nsIDOMNodeList* - // (nsAnonymousContentList*). This list contains an accurate - // reflection of our *anonymous* children (if and only if they are - // intermingled with insertion points) in the altered DOM. This - // table is not used if no insertion points were defined directly - // underneath a tag in a binding. The NodeList from the - // is used instead as a performance optimization. - PLDHashTable mAnonymousNodesTable; - - // A mapping from nsIContent* to nsIContent*. The insertion parent - // is our one true parent in the transformed DOM. This gives us a - // more-or-less O(1) way of obtaining our transformed parent. - PLDHashTable mInsertionParentTable; - - // A mapping from nsIContent* to nsIXPWrappedJS* (an XPConnect - // wrapper for JS objects). For XBL bindings that implement XPIDL - // interfaces, and that get referred to from C++, this table caches - // the XPConnect wrapper for the binding. By caching it, I control - // its lifetime, and I prevent a re-wrap of the same script object - // (in the case where multiple bindings in an XBL inheritance chain - // both implement an XPIDL interface). - PLDHashTable mWrapperTable; - - // A mapping from a URL (a string) to nsIXBLDocumentInfo*. This table - // is the cache of all binding documents that have been loaded by a - // given bound document. - nsInterfaceHashtable mDocumentTable; - - // A mapping from a URL (a string) to a nsIStreamListener. This - // table is the currently loading binding docs. If they're in this - // table, they have not yet finished loading. - nsInterfaceHashtable mLoadingDocTable; - - // A queue of binding attached event handlers that are awaiting - // execution. - nsCOMPtr mAttachedStack; - PRBool mProcessingAttachedStack; -}; - // Implementation ///////////////////////////////////////////////////////////////// // Static member variable initialization @@ -558,7 +406,7 @@ nsBindingManager::ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocum binding->ChangeDocument(aOldDocument, aNewDocument); SetBinding(aContent, nsnull); if (aNewDocument) - aNewDocument->GetBindingManager()->SetBinding(aContent, binding); + aNewDocument->BindingManager()->SetBinding(aContent, binding); } // Clear out insertion parents and content lists. @@ -1439,17 +1287,3 @@ nsBindingManager::ContentRemoved(nsIDocument* aDocument, } } } - - -// Creation Routine /////////////////////////////////////////////////////////////////////// - -nsresult -NS_NewBindingManager(nsIBindingManager** aResult) -{ - *aResult = new nsBindingManager; - if (!*aResult) - return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(*aResult); - return NS_OK; -} - diff --git a/mozilla/content/xbl/src/nsBindingManager.h b/mozilla/content/xbl/src/nsBindingManager.h new file mode 100755 index 00000000000..557c7e189a7 --- /dev/null +++ b/mozilla/content/xbl/src/nsBindingManager.h @@ -0,0 +1,210 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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) + * Alec Flett + * + * 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 ***** */ + +#ifndef nsBindingManager_h_ +#define nsBindingManager_h_ + +#include "nsIBindingManager.h" +#include "nsIStyleRuleSupplier.h" +#include "nsStubDocumentObserver.h" +#include "pldhash.h" +#include "nsInterfaceHashtable.h" +#include "nsISupportsArray.h" +#include "nsURIHashKey.h" + +class nsIContent; +class nsIXBLBinding; +class nsIXPConnectWrappedJS; +class nsIAtom; +class nsIDOMNodeList; +class nsVoidArray; +class nsIDocument; +class nsIURI; +class nsIXBLDocumentInfo; +class nsIStreamListener; +class nsStyleSet; + +class nsBindingManager : public nsIBindingManager, + public nsIStyleRuleSupplier, + public nsStubDocumentObserver +{ + NS_DECL_ISUPPORTS + +public: + nsBindingManager(); + ~nsBindingManager(); + + NS_IMETHOD GetBinding(nsIContent* aContent, nsIXBLBinding** aResult); + NS_IMETHOD SetBinding(nsIContent* aContent, nsIXBLBinding* aBinding); + + NS_IMETHOD GetInsertionParent(nsIContent* aContent, nsIContent** aResult); + NS_IMETHOD SetInsertionParent(nsIContent* aContent, nsIContent* aResult); + + NS_IMETHOD GetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS** aResult); + NS_IMETHOD SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult); + + NS_IMETHOD ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocument, + nsIDocument* aNewDocument); + + NS_IMETHOD ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** aResult); + + NS_IMETHOD GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult); + NS_IMETHOD SetContentListFor(nsIContent* aContent, nsVoidArray* aList); + NS_IMETHOD HasContentListFor(nsIContent* aContent, PRBool* aResult); + + NS_IMETHOD GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult); + NS_IMETHOD SetAnonymousNodesFor(nsIContent* aContent, nsVoidArray* aList); + + 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); + + 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 ClearAttachedQueue(); + NS_IMETHOD ProcessAttachedQueue(); + + NS_IMETHOD ExecuteDetachedHandlers(); + + NS_IMETHOD PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); + NS_IMETHOD GetXBLDocumentInfo(nsIURI* aURI, nsIXBLDocumentInfo** aResult); + NS_IMETHOD RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); + + NS_IMETHOD PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener); + 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); + + NS_IMETHOD ShouldBuildChildFrames(nsIContent* aContent, PRBool* aResult); + + // nsIStyleRuleSupplier + NS_IMETHOD WalkRules(nsStyleSet* aStyleSet, + nsIStyleRuleProcessor::EnumFunc aFunc, + RuleProcessorData* aData, + PRBool* aCutOffInheritance); + + // nsIDocumentObserver + virtual void ContentAppended(nsIDocument* aDocument, + nsIContent* aContainer, + PRInt32 aNewIndexInContainer); + virtual void ContentInserted(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + virtual void ContentRemoved(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + +protected: + nsresult GetXBLChildNodesInternal(nsIContent* aContent, + nsIDOMNodeList** aResult, + PRBool* aIsAnonymousContentList); + nsresult GetAnonymousNodesInternal(nsIContent* aContent, + nsIDOMNodeList** aResult, + PRBool* aIsAnonymousContentList); + + nsIContent* GetEnclosingScope(nsIContent* aContent) { + return aContent->GetBindingParent(); + } + + nsresult GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult); + +// MEMBER VARIABLES +protected: + // A mapping from nsIContent* to the nsIXBLBinding* that is + // installed on that element. + PLDHashTable mBindingTable; + + // A mapping from nsIContent* to an nsIDOMNodeList* + // (nsAnonymousContentList*). This list contains an accurate + // reflection of our *explicit* children (once intermingled with + // insertion points) in the altered DOM. + PLDHashTable mContentListTable; + + // A mapping from nsIContent* to an nsIDOMNodeList* + // (nsAnonymousContentList*). This list contains an accurate + // reflection of our *anonymous* children (if and only if they are + // intermingled with insertion points) in the altered DOM. This + // table is not used if no insertion points were defined directly + // underneath a tag in a binding. The NodeList from the + // is used instead as a performance optimization. + PLDHashTable mAnonymousNodesTable; + + // A mapping from nsIContent* to nsIContent*. The insertion parent + // is our one true parent in the transformed DOM. This gives us a + // more-or-less O(1) way of obtaining our transformed parent. + PLDHashTable mInsertionParentTable; + + // A mapping from nsIContent* to nsIXPWrappedJS* (an XPConnect + // wrapper for JS objects). For XBL bindings that implement XPIDL + // interfaces, and that get referred to from C++, this table caches + // the XPConnect wrapper for the binding. By caching it, I control + // its lifetime, and I prevent a re-wrap of the same script object + // (in the case where multiple bindings in an XBL inheritance chain + // both implement an XPIDL interface). + PLDHashTable mWrapperTable; + + // A mapping from a URL (a string) to nsIXBLDocumentInfo*. This table + // is the cache of all binding documents that have been loaded by a + // given bound document. + nsInterfaceHashtable mDocumentTable; + + // A mapping from a URL (a string) to a nsIStreamListener. This + // table is the currently loading binding docs. If they're in this + // table, they have not yet finished loading. + nsInterfaceHashtable mLoadingDocTable; + + // A queue of binding attached event handlers that are awaiting + // execution. + nsCOMPtr mAttachedStack; + PRBool mProcessingAttachedStack; +}; + +#endif diff --git a/mozilla/content/xbl/src/nsXBLBinding.cpp b/mozilla/content/xbl/src/nsXBLBinding.cpp index edb26328a49..7dedebe29e3 100644 --- a/mozilla/content/xbl/src/nsXBLBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLBinding.cpp @@ -541,7 +541,7 @@ nsXBLBinding::GenerateAnonymousContent() if (! doc) return NS_OK; - nsIBindingManager *bindingManager = doc->GetBindingManager(); + nsIBindingManager *bindingManager = doc->BindingManager(); nsCOMPtr children; bindingManager->GetContentListFor(mBoundElement, getter_AddRefs(children)); @@ -1016,7 +1016,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen // Make sure that henceforth we don't claim that mBoundElement's children // have insertion parents in the old document. - nsIBindingManager* bindingManager = aOldDocument->GetBindingManager(); + nsIBindingManager* bindingManager = aOldDocument->BindingManager(); for (PRUint32 i = mBoundElement->GetChildCount(); i > 0; --i) { NS_ASSERTION(mBoundElement->GetChildAt(i-1), "Must have child at i for 0 <= i < GetChildCount()!"); diff --git a/mozilla/content/xbl/src/nsXBLContentSink.cpp b/mozilla/content/xbl/src/nsXBLContentSink.cpp index 06e7dc707d0..ce735354d72 100644 --- a/mozilla/content/xbl/src/nsXBLContentSink.cpp +++ b/mozilla/content/xbl/src/nsXBLContentSink.cpp @@ -411,7 +411,7 @@ nsXBLContentSink::OnOpenContainer(const PRUnichar **aAtts, return PR_TRUE; } - mDocument->GetBindingManager()->PutXBLDocumentInfo(mDocInfo); + mDocument->BindingManager()->PutXBLDocumentInfo(mDocInfo); nsIURI *uri = mDocument->GetDocumentURI(); diff --git a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp index 9ac94cd1de5..37c231cea17 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -788,8 +788,7 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement, // count to detemine our precise position within the template. nsIDocument* doc = aBoundElement->GetOwnerDoc(); nsCOMPtr binding; - doc->GetBindingManager()->GetBinding(aBoundElement, - getter_AddRefs(binding)); + doc->BindingManager()->GetBinding(aBoundElement, getter_AddRefs(binding)); nsCOMPtr currBinding = binding; nsCOMPtr anonContent; diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index 0c1204690b6..9c99addb4c0 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -389,7 +389,7 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent) } // Remove ourselves from the set of pending docs. - nsIBindingManager *bindingManager = doc->GetBindingManager(); + nsIBindingManager *bindingManager = doc->BindingManager(); nsIURI* documentURI = mBindingDocument->GetDocumentURI(); bindingManager->RemoveLoadingDocListener(documentURI); @@ -400,7 +400,7 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent) // Put our doc info in the doc table. nsCOMPtr info; - nsIBindingManager *xblDocBindingManager = mBindingDocument->GetBindingManager(); + nsIBindingManager *xblDocBindingManager = mBindingDocument->BindingManager(); xblDocBindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); xblDocBindingManager->RemoveXBLDocumentInfo(info); // Break the self-imposed cycle. if (!info) { @@ -534,7 +534,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFl if (!document) return NS_OK; - nsIBindingManager *bindingManager = document->GetBindingManager(); + nsIBindingManager *bindingManager = document->BindingManager(); nsCOMPtr binding; bindingManager->GetBinding(aContent, getter_AddRefs(binding)); @@ -649,7 +649,7 @@ nsXBLService::FlushStyleBindings(nsIContent* aContent) if (! document) return NS_OK; - nsIBindingManager *bindingManager = document->GetBindingManager(); + nsIBindingManager *bindingManager = document->BindingManager(); nsCOMPtr binding; bindingManager->GetBinding(aContent, getter_AddRefs(binding)); @@ -677,10 +677,8 @@ nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, { nsIDocument* document = aContent->GetOwnerDoc(); if (document) { - nsIBindingManager *bindingManager = document->GetBindingManager(); - - if (bindingManager) - return bindingManager->ResolveTag(aContent, aNameSpaceID, aResult); + return document->BindingManager()->ResolveTag(aContent, aNameSpaceID, + aResult); } *aNameSpaceID = aContent->GetNameSpaceID(); @@ -709,7 +707,7 @@ nsXBLService::GetXBLDocumentInfo(nsIURI* aURI, nsIContent* aBoundElement, nsIXBL // The second line of defense is the binding manager's document table. nsIDocument* boundDocument = aBoundElement->GetOwnerDoc(); if (boundDocument) - boundDocument->GetBindingManager()->GetXBLDocumentInfo(aURI, aResult); + boundDocument->BindingManager()->GetXBLDocumentInfo(aURI, aResult); } return NS_OK; } @@ -1055,7 +1053,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, NS_ENSURE_SUCCESS(rv, rv); if (aBoundDocument) { - bindingManager = aBoundDocument->GetBindingManager(); + bindingManager = aBoundDocument->BindingManager(); bindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); } @@ -1103,7 +1101,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, bindingURL, aForceSyncLoad, getter_AddRefs(document)); if (document) { - nsIBindingManager *xblDocBindingManager = document->GetBindingManager(); + nsIBindingManager *xblDocBindingManager = document->BindingManager(); xblDocBindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); if (!info) { NS_ERROR("An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?"); @@ -1198,7 +1196,7 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun // Add ourselves to the list of loading docs. nsIBindingManager *bindingManager; if (aBoundDocument) - bindingManager = aBoundDocument->GetBindingManager(); + bindingManager = aBoundDocument->BindingManager(); else bindingManager = nsnull; diff --git a/mozilla/content/xml/document/src/Makefile.in b/mozilla/content/xml/document/src/Makefile.in index 2886c77fd4b..56dacc9810e 100644 --- a/mozilla/content/xml/document/src/Makefile.in +++ b/mozilla/content/xml/document/src/Makefile.in @@ -91,6 +91,7 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../../../../layout/style \ -I$(srcdir)/../../../base/src \ -I$(srcdir)/../../../xul/content/src \ + -I$(srcdir)/../../../events/src \ -I$(srcdir)/../../../../dom/src/base \ $(NULL) diff --git a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp index 117e8abf4c1..fb005b6ce13 100644 --- a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp +++ b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp @@ -173,7 +173,7 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument) nsCOMPtr binding; nsCOMPtr rootCont = do_QueryInterface(rootElem); NS_ASSERTION(rootCont, "Element doesn't implement nsIContent"); - aDocument->GetBindingManager()->GetBindingImplementation(rootCont, + aDocument->BindingManager()->GetBindingImplementation(rootCont, NS_GET_IID(nsIObserver), (void**)getter_AddRefs(binding)); NS_ASSERTION(binding, "Prettyprint binding doesn't implement nsIObserver"); diff --git a/mozilla/content/xul/content/src/Makefile.in b/mozilla/content/xul/content/src/Makefile.in index dc45500b4a5..d77ef2b9a2c 100644 --- a/mozilla/content/xul/content/src/Makefile.in +++ b/mozilla/content/xul/content/src/Makefile.in @@ -99,6 +99,7 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../../../xml/document/src \ -I$(srcdir)/../../../../layout/style \ -I$(srcdir)/../../../html/content/src \ + -I$(srcdir)/../../../events/src \ $(NULL) DEFINES += -D_IMPL_NS_LAYOUT diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 9ce0323ec28..ab12100fc7e 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -862,11 +862,7 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, if (doc) { // Notify XBL- & nsIAnonymousContentCreator-generated // anonymous content that the document is changing. - nsIBindingManager *bindingManager = doc->GetBindingManager(); - NS_ASSERTION(bindingManager, "no binding manager"); - if (bindingManager) { - bindingManager->ChangeDocumentFor(this, doc, aDocument); - } + doc->BindingManager()->ChangeDocumentFor(this, doc, aDocument); nsCOMPtr nsDoc(do_QueryInterface(doc)); nsDoc->SetBoxObjectFor(this, nsnull); @@ -1388,7 +1384,7 @@ nsXULElement::SetAttrAndNotify(PRInt32 aNamespaceID, if (doc) { nsCOMPtr binding; - doc->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); + doc->BindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) { binding->AttributeChanged(aAttribute, aNamespaceID, PR_FALSE, aNotify); } @@ -1599,7 +1595,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify) } nsCOMPtr binding; - doc->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); + doc->BindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify); @@ -1794,58 +1790,56 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const // XXX sXBL/XBL2 issue! Owner or current document? nsIDocument* doc = GetCurrentDoc(); if (doc) { - nsIBindingManager *bindingManager = doc->GetBindingManager(); - if (bindingManager) { - nsCOMPtr anonymousChildren; - bindingManager->GetAnonymousNodesFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)), - getter_AddRefs(anonymousChildren)); + nsIBindingManager *bindingManager = doc->BindingManager(); + nsCOMPtr anonymousChildren; + bindingManager->GetAnonymousNodesFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)), + getter_AddRefs(anonymousChildren)); - if (anonymousChildren) { - PRUint32 length; - anonymousChildren->GetLength(&length); - if (length) { - rdf_Indent(out, aIndent); - fputs("anonymous-children<\n", out); + if (anonymousChildren) { + PRUint32 length; + anonymousChildren->GetLength(&length); + if (length) { + rdf_Indent(out, aIndent); + fputs("anonymous-children<\n", out); - for (PRUint32 i2 = 0; i2 < length; ++i2) { - nsCOMPtr node; - anonymousChildren->Item(i2, getter_AddRefs(node)); - nsCOMPtr child = do_QueryInterface(node); - child->List(out, aIndent + 1); - } - - rdf_Indent(out, aIndent); - fputs(">\n", out); + for (PRUint32 i2 = 0; i2 < length; ++i2) { + nsCOMPtr node; + anonymousChildren->Item(i2, getter_AddRefs(node)); + nsCOMPtr child = do_QueryInterface(node); + child->List(out, aIndent + 1); } + + rdf_Indent(out, aIndent); + fputs(">\n", out); } + } - PRBool hasContentList; - bindingManager->HasContentListFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)), - &hasContentList); + PRBool hasContentList; + bindingManager->HasContentListFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)), + &hasContentList); - if (hasContentList) { - nsCOMPtr contentList; - bindingManager->GetContentListFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)), - getter_AddRefs(contentList)); + if (hasContentList) { + nsCOMPtr contentList; + bindingManager->GetContentListFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)), + getter_AddRefs(contentList)); - NS_ASSERTION(contentList != nsnull, "oops, binding manager lied"); + NS_ASSERTION(contentList != nsnull, "oops, binding manager lied"); - PRUint32 length; - contentList->GetLength(&length); - if (length) { - rdf_Indent(out, aIndent); - fputs("content-list<\n", out); + PRUint32 length; + contentList->GetLength(&length); + if (length) { + rdf_Indent(out, aIndent); + fputs("content-list<\n", out); - for (PRUint32 i2 = 0; i2 < length; ++i2) { - nsCOMPtr node; - contentList->Item(i2, getter_AddRefs(node)); - nsCOMPtr child = do_QueryInterface(node); - child->List(out, aIndent + 1); - } - - rdf_Indent(out, aIndent); - fputs(">\n", out); + for (PRUint32 i2 = 0; i2 < length; ++i2) { + nsCOMPtr node; + contentList->Item(i2, getter_AddRefs(node)); + nsCOMPtr child = do_QueryInterface(node); + child->List(out, aIndent + 1); } + + rdf_Indent(out, aIndent); + fputs(">\n", out); } } } @@ -1977,11 +1971,9 @@ nsXULElement::HandleDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent, // XXX sXBL/XBL2 issue! Owner or current document? nsIDocument* doc = GetCurrentDoc(); if (doc) { - nsIBindingManager* bindingManager = doc->GetBindingManager(); - if (bindingManager) { - // we have a binding manager -- do we have an anonymous parent? - bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); - } + // check for an anonymous parent + doc->BindingManager()->GetInsertionParent(this, + getter_AddRefs(parent)); } if (!parent) { diff --git a/mozilla/content/xul/document/src/Makefile.in b/mozilla/content/xul/document/src/Makefile.in index b06f25f4759..b1f0f216f3e 100644 --- a/mozilla/content/xul/document/src/Makefile.in +++ b/mozilla/content/xul/document/src/Makefile.in @@ -96,6 +96,7 @@ LOCAL_INCLUDES = -I$(srcdir)/../../../base/src \ -I$(srcdir)/../../templates/src \ -I$(srcdir)/../../../../layout/style \ -I$(srcdir)/../../../xml/document/src \ + -I$(srcdir)/../../../events/src \ $(NULL) DEFINES += -D_IMPL_NS_LAYOUT diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index 2295c730071..21f0fdde094 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -1474,28 +1474,24 @@ nsXULTemplateBuilder::GetTemplateRoot(nsIContent** aResult) if (! doc) return NS_ERROR_FAILURE; - nsIBindingManager *bindingManager = doc->GetBindingManager(); + nsCOMPtr kids; + doc->BindingManager()->GetXBLChildNodesFor(mRoot, getter_AddRefs(kids)); - if (bindingManager) { - nsCOMPtr kids; - bindingManager->GetXBLChildNodesFor(mRoot, getter_AddRefs(kids)); + if (kids) { + PRUint32 length; + kids->GetLength(&length); - if (kids) { - PRUint32 length; - kids->GetLength(&length); + for (PRUint32 i = 0; i < length; ++i) { + nsCOMPtr node; + kids->Item(i, getter_AddRefs(node)); + if (! node) + continue; - for (PRUint32 i = 0; i < length; ++i) { - nsCOMPtr node; - kids->Item(i, getter_AddRefs(node)); - if (! node) - continue; + nsCOMPtr child = do_QueryInterface(node); - nsCOMPtr child = do_QueryInterface(node); - - if (IsTemplateElement(child)) { - NS_ADDREF(*aResult = child.get()); - return NS_OK; - } + if (IsTemplateElement(child)) { + NS_ADDREF(*aResult = child.get()); + return NS_OK; } } } diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index a9696cb88f0..9636d4dcc28 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -5346,11 +5346,8 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, // We must ensure that the XBL Binding is installed before we hand // back this object. - nsIBindingManager *bindingManager = doc->GetBindingManager(); - NS_ENSURE_TRUE(bindingManager, NS_ERROR_UNEXPECTED); - nsCOMPtr binding; - bindingManager->GetBinding(content, getter_AddRefs(binding)); + doc->BindingManager()->GetBinding(content, getter_AddRefs(binding)); if (binding) { // There's already a binding for this element so nothing left to diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index b75cfeb9014..06689416569 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -866,9 +866,7 @@ nsGlobalWindow::HandleDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent, // down. if (aEvent->message == NS_PAGE_UNLOAD && mDocument && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) { nsCOMPtr doc(do_QueryInterface(mDocument)); - nsIBindingManager *bindingManager = doc->GetBindingManager(); - if (bindingManager) - bindingManager->ExecuteDetachedHandlers(); + doc->BindingManager()->ExecuteDetachedHandlers(); } } diff --git a/mozilla/extensions/inspector/base/src/inDOMUtils.cpp b/mozilla/extensions/inspector/base/src/inDOMUtils.cpp index 6c07d651e35..5e6f4d034de 100644 --- a/mozilla/extensions/inspector/base/src/inDOMUtils.cpp +++ b/mozilla/extensions/inspector/base/src/inDOMUtils.cpp @@ -225,8 +225,7 @@ inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsISimpleEnumerator **_retva if (!doc1) return NS_OK; nsCOMPtr doc = do_QueryInterface(doc1); - nsIBindingManager *bindingManager = doc->GetBindingManager(); - if (!bindingManager) return NS_OK; + nsIBindingManager *bindingManager = doc->BindingManager(); nsCOMPtr content = do_QueryInterface(aElement); nsCOMPtr binding; diff --git a/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp b/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp index 485aafba2b9..78f5f9e9d3c 100644 --- a/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp +++ b/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp @@ -224,7 +224,7 @@ inLayoutUtils::GetBindingManagerFor(nsIDOMNode* aNode) aNode->GetOwnerDocument(getter_AddRefs(domdoc)); if (domdoc) { nsCOMPtr doc = do_QueryInterface(domdoc); - return doc->GetBindingManager(); + return doc->BindingManager(); } return nsnull; diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 0415bbce637..af4adc9d255 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -1686,10 +1686,7 @@ private: nsAutoEnqueueBinding::~nsAutoEnqueueBinding() { if (mBinding) { - nsIBindingManager *bm = mDocument->GetBindingManager(); - if (bm) { - bm->AddToAttachedQueue(mBinding); - } + mDocument->BindingManager()->AddToAttachedQueue(mBinding); } } @@ -4022,9 +4019,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsFrameConstructorState& aState, return NS_OK; // Binding will load asynchronously. if (binding) { - nsIBindingManager *bm = mDocument->GetBindingManager(); - if (bm) - bm->AddToAttachedQueue(binding); + mDocument->BindingManager()->AddToAttachedQueue(binding); } if (resolveStyle) { @@ -4213,12 +4208,12 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIContent* aDocElement, */ // Set up our style rule observer. - nsIBindingManager *bindingManager = mDocument->GetBindingManager(); - if (bindingManager) { - nsCOMPtr ruleSupplier(do_QueryInterface(bindingManager)); + { + nsCOMPtr ruleSupplier = + do_QueryInterface(mDocument->BindingManager()); mPresShell->StyleSet()->SetStyleRuleSupplier(ruleSupplier); } - + // --------- BUILD VIEWPORT ----------- nsIFrame* viewportFrame = nsnull; nsRefPtr viewportPseudoStyle; @@ -6066,8 +6061,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState, if (processChildren || processAnonymousChildren) { nsFrameItems childItems; if (processChildren) { - mDocument->GetBindingManager()->ShouldBuildChildFrames(aContent, - &processChildren); + mDocument->BindingManager()->ShouldBuildChildFrames(aContent, + &processChildren); if (processChildren) rv = ProcessChildren(aState, aContent, newFrame, PR_FALSE, childItems, PR_FALSE); @@ -8295,11 +8290,10 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, #ifdef MOZ_XUL if (aContainer) { - nsIBindingManager *bindingManager = mDocument->GetBindingManager(); - nsCOMPtr tag; PRInt32 namespaceID; - bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag)); + mDocument->BindingManager()->ResolveTag(aContainer, &namespaceID, + getter_AddRefs(tag)); // Just ignore tree tags, anyway we don't create any frames for them. if (tag == nsXULAtoms::treechildren || @@ -8337,7 +8331,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, document = firstAppendedChild->GetDocument(); } if (document) - bindingManager = document->GetBindingManager(); + bindingManager = document->BindingManager(); if (bindingManager) { nsCOMPtr insParent; bindingManager->GetInsertionParent(firstAppendedChild, getter_AddRefs(insParent)); @@ -8556,7 +8550,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, } // We built some new frames. Initialize any newly-constructed bindings. - mDocument->GetBindingManager()->ProcessAttachedQueue(); + mDocument->BindingManager()->ProcessAttachedQueue(); // process the current pseudo frame state if (!state.mPseudoFrames.IsEmpty()) { @@ -8883,8 +8877,8 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext, nsCOMPtr tag; PRInt32 namespaceID; - aDocument->GetBindingManager()->ResolveTag(aContainer, &namespaceID, - getter_AddRefs(tag)); + aDocument->BindingManager()->ResolveTag(aContainer, &namespaceID, + getter_AddRefs(tag)); // Just ignore tree tags, anyway we don't create any frames for them. if (tag == nsXULAtoms::treechildren || @@ -8979,7 +8973,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer, #endif } - mDocument->GetBindingManager()->ProcessAttachedQueue(); + mDocument->BindingManager()->ProcessAttachedQueue(); // otherwise this is not a child of the root element, and we // won't let it have a frame. @@ -9176,7 +9170,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer, // Now that we've created frames, run the attach queue. //XXXwaterson should we do this after we've processed pseudos, too? - mDocument->GetBindingManager()->ProcessAttachedQueue(); + mDocument->BindingManager()->ProcessAttachedQueue(); // process the current pseudo frame state if (!state.mPseudoFrames.IsEmpty()) @@ -10248,8 +10242,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, if (!primaryFrame && !reframe) { PRInt32 namespaceID; nsCOMPtr tag; - mDocument->GetBindingManager()->ResolveTag(aContent, &namespaceID, - getter_AddRefs(tag)); + mDocument->BindingManager()->ResolveTag(aContent, &namespaceID, + getter_AddRefs(tag)); if (namespaceID == kNameSpaceID_XUL && (tag == nsXULAtoms::listitem || @@ -10311,8 +10305,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, aAttribute == nsXULAtoms::menugenerated) { PRInt32 namespaceID; nsCOMPtr tag; - mDocument->GetBindingManager()->ResolveTag(aContent, &namespaceID, - getter_AddRefs(tag)); + mDocument->BindingManager()->ResolveTag(aContent, &namespaceID, + getter_AddRefs(tag)); if (namespaceID == kNameSpaceID_XUL && (tag == nsXULAtoms::menupopup || tag == nsXULAtoms::popup || @@ -11368,9 +11362,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIFrame* aParentFrame, if (!container) return NS_OK; - nsIBindingManager *bindingManager = mDocument->GetBindingManager(); - if (!bindingManager) - return NS_OK; + nsIBindingManager *bindingManager = mDocument->BindingManager(); nsCOMPtr insertionElement; if (aChildContent) { @@ -12608,7 +12600,7 @@ nsCSSFrameConstructor::CreateListBoxContent(nsPresContext* aPresContext, *aNewFrame = newFrame; if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { - mDocument->GetBindingManager()->ProcessAttachedQueue(); + mDocument->BindingManager()->ProcessAttachedQueue(); // Notify the parent frame if (aIsAppend) diff --git a/mozilla/layout/base/nsChildIterator.cpp b/mozilla/layout/base/nsChildIterator.cpp index 2b7cf835272..6d64db97306 100644 --- a/mozilla/layout/base/nsChildIterator.cpp +++ b/mozilla/layout/base/nsChildIterator.cpp @@ -58,14 +58,10 @@ ChildIterator::Init(nsIContent* aContent, if (! doc) return NS_ERROR_FAILURE; - nsIBindingManager *mgr = doc->GetBindingManager(); - if (! mgr) - return NS_ERROR_FAILURE; - // If this node has XBL children, then use them. Otherwise, just use // the vanilla content APIs. nsCOMPtr nodes; - mgr->GetXBLChildNodesFor(aContent, getter_AddRefs(nodes)); + doc->BindingManager()->GetXBLChildNodesFor(aContent, getter_AddRefs(nodes)); PRUint32 length; if (nodes) diff --git a/mozilla/layout/build/nsLayoutCID.h b/mozilla/layout/build/nsLayoutCID.h index a8b566cd8a9..a920722c718 100644 --- a/mozilla/layout/build/nsLayoutCID.h +++ b/mozilla/layout/build/nsLayoutCID.h @@ -145,10 +145,6 @@ #define NS_XBLSERVICE_CID \ { 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } } -// {15671AF5-39F9-4c70-8CE3-72C97111B52D} -#define NS_BINDINGMANAGER_CID \ -{ 0x15671af5, 0x39f9, 0x4c70, { 0x8c, 0xe3, 0x72, 0xc9, 0x71, 0x11, 0xb5, 0x2d } } - // {D750A964-2D14-484c-B3AA-8ED7823B5C7B} #define NS_BOXOBJECT_CID \ { 0xd750a964, 0x2d14, 0x484c, { 0xb3, 0xaa, 0x8e, 0xd7, 0x82, 0x3b, 0x5c, 0x7b } } diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index b55e00eb14b..800bbadb99c 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -58,7 +58,6 @@ #include "nsHTMLContentSerializer.h" #include "nsHTMLParts.h" #include "nsGenericHTMLElement.h" -#include "nsIBindingManager.h" #include "nsICSSLoader.h" #include "nsICSSParser.h" #include "nsCSSScanner.h" @@ -463,7 +462,6 @@ nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult); nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult); nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult); nsresult NS_NewXBLService(nsIXBLService** aResult); -nsresult NS_NewBindingManager(nsIBindingManager** aResult); nsresult NS_NewContentPolicy(nsIContentPolicy** aResult); nsresult NS_NewSyncLoadDOMService(nsISyncLoadDOMService** aResult); nsresult NS_NewDOMEventGroup(nsIDOMEventGroup** aResult); @@ -565,7 +563,6 @@ MAKE_CTOR(CreateXMLFragmentSink, nsIFragmentContentSink, NS_NewXML MAKE_CTOR(CreateXMLFragmentSink2, nsIFragmentContentSink, NS_NewXMLFragmentContentSink2) MAKE_CTOR(CreateSanitizingHTMLSerializer, nsIContentSerializer, NS_NewSanitizingHTMLSerializer) MAKE_CTOR(CreateXBLService, nsIXBLService, NS_NewXBLService) -MAKE_CTOR(CreateBindingManager, nsIBindingManager, NS_NewBindingManager) MAKE_CTOR(CreateContentPolicy, nsIContentPolicy, NS_NewContentPolicy) MAKE_CTOR(CreateComputedDOMStyle, nsIComputedDOMStyle, NS_NewComputedDOMStyle) #ifdef MOZ_XUL @@ -1127,11 +1124,6 @@ static const nsModuleComponentInfo gComponents[] = { "@mozilla.org/xbl;1", CreateXBLService }, - { "XBL Binding Manager", - NS_BINDINGMANAGER_CID, - "@mozilla.org/xbl/binding-manager;1", - CreateBindingManager }, - { "Content policy service", NS_CONTENTPOLICY_CID, NS_CONTENTPOLICY_CONTRACTID, diff --git a/mozilla/layout/xul/base/src/nsListBoxObject.cpp b/mozilla/layout/xul/base/src/nsListBoxObject.cpp index 1ca0cde30a5..88cbc0e7a32 100644 --- a/mozilla/layout/xul/base/src/nsListBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxObject.cpp @@ -185,7 +185,7 @@ FindBodyContent(nsIContent* aParent, nsIContent** aResult) } else { nsCOMPtr kids; - aParent->GetDocument()->GetBindingManager()->GetXBLChildNodesFor(aParent, getter_AddRefs(kids)); + aParent->GetDocument()->BindingManager()->GetXBLChildNodesFor(aParent, getter_AddRefs(kids)); if (!kids) return; PRUint32 i; diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index 907688586dd..de6085faf59 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -1298,7 +1298,7 @@ static void FlushSkinBindingsForWindow(nsIDOMWindowInternal* aWindow) return; // Annihilate all XBL bindings. - document->GetBindingManager()->FlushSkinBindings(); + document->BindingManager()->FlushSkinBindings(); } // XXXbsmedberg: move this to nsIWindowMediator