diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 260c215d0ef..6f8d8bdf164 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -59,6 +59,7 @@ class nsIChannel; class nsIPrincipal; class nsIDOMDocument; class nsIDOMDocumentType; +class nsIBindingManager; // IID for the nsIDocument interface #define NS_IDOCUMENT_IID \ @@ -327,6 +328,8 @@ public: NS_IMETHOD FlushPendingNotifications() = 0; NS_IMETHOD GetAndIncrementContentID(PRInt32* aID) = 0; + + NS_IMETHOD GetBindingManager(nsIBindingManager** aResult) = 0; }; diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 6db30dc52f2..53694175d44 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -3277,6 +3277,21 @@ nsDocument::GetAndIncrementContentID(PRInt32* aID) return NS_OK; } +NS_IMETHODIMP +nsDocument::GetBindingManager(nsIBindingManager** aResult) +{ + nsresult rv; + if (!mBindingManager) { + mBindingManager = do_CreateInstance("component://netscape/xbl/binding-manager", &rv); + if (NS_FAILED(rv)) + return NS_ERROR_FAILURE; + } + + *aResult = mBindingManager; + NS_IF_ADDREF(*aResult); + return NS_OK; +} + NS_IMETHODIMP nsDocument::GetModCount(PRInt32 *outModCount) diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 3f711b2ff8d..bef0fb14832 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -40,6 +40,7 @@ #include "nsIContent.h" #include "nsGenericDOMNodeList.h" #include "nsIPrincipal.h" +#include "nsIBindingManager.h" class nsIEventListenerManager; class nsDOMStyleSheetList; @@ -330,6 +331,7 @@ public: NS_IMETHOD FlushPendingNotifications(); NS_IMETHOD GetAndIncrementContentID(PRInt32* aID); + NS_IMETHOD GetBindingManager(nsIBindingManager** aResult); public: @@ -470,7 +472,8 @@ protected: // disk file members nsFileSpec* mFileSpec; PRInt32 mModCount; - + + nsCOMPtr mBindingManager; }; #endif /* nsDocument_h___ */ diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 374f588d681..b1b4c24f24d 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -47,8 +47,6 @@ #include "nsIPresShell.h" #include "nsIFormControlFrame.h" #include "nsIFrame.h" -#include "nsIBindableContent.h" -#include "nsIXBLBinding.h" #include "nsIEventStateManager.h" #include "nsISizeOfHandler.h" #include "nsIServiceManager.h" @@ -73,8 +71,7 @@ class nsHTMLInputElement : public nsIDOMHTMLInputElement, public nsIDOMNSHTMLInputElement, public nsIJSScriptObject, public nsIHTMLContent, - public nsIFormControl, - public nsIBindableContent + public nsIFormControl { public: nsHTMLInputElement(nsIAtom* aTag); @@ -145,11 +142,6 @@ public: NS_IMETHOD GetType(PRInt32* aType); NS_IMETHOD Init() { return NS_OK; } - // nsIBindableContent - NS_IMETHOD SetBinding(nsIXBLBinding* aBinding); - NS_IMETHOD GetBinding(nsIXBLBinding** aResult); - NS_IMETHOD GetBaseTag(nsIAtom** aResult); - // Helper method NS_IMETHOD SetPresStateChecked(nsIHTMLContent * aHTMLContent, nsIStatefulFrame::StateType aStateType, @@ -165,7 +157,6 @@ protected: PRInt32 mType; PRBool mSkipFocusEvent; nsCOMPtr mControllers; - nsCOMPtr mBinding; PRBool IsImage() const { @@ -232,11 +223,6 @@ nsHTMLInputElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - else if (aIID.Equals(NS_GET_IID(nsIBindableContent))) { - *aInstancePtr = (void*)(nsIBindableContent*) this; - NS_ADDREF_THIS(); - return NS_OK; - } return NS_NOINTERFACE; } @@ -632,30 +618,6 @@ nsHTMLInputElement::RemoveFocus(nsIPresContext* aPresContext) return NS_OK; } -NS_IMETHODIMP -nsHTMLInputElement::SetBinding(nsIXBLBinding* aBinding) -{ - mBinding = aBinding; // COMPtr does addref - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLInputElement::GetBinding(nsIXBLBinding** aResult) -{ - *aResult = mBinding; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLInputElement::GetBaseTag(nsIAtom** aResult) -{ - if (mBinding) - return mBinding->GetBaseTag(aResult); - else - return NS_OK; -} - NS_IMETHODIMP nsHTMLInputElement::Select() { diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index 1efa4853724..3caf7296558 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -42,8 +42,6 @@ #include "nsIPresContext.h" #include "nsIHTMLAttributes.h" #include "nsIFormControlFrame.h" -#include "nsIBindableContent.h" -#include "nsIXBLBinding.h" #include "nsIEventStateManager.h" #include "nsISizeOfHandler.h" #include "nsLinebreakConverter.h" @@ -58,8 +56,7 @@ class nsHTMLTextAreaElement : public nsIDOMHTMLTextAreaElement, public nsIDOMNSHTMLTextAreaElement, public nsIJSScriptObject, public nsIHTMLContent, - public nsIFormControl, - public nsIBindableContent + public nsIFormControl { public: nsHTMLTextAreaElement(nsIAtom* aTag); @@ -119,16 +116,10 @@ public: NS_IMETHOD GetType(PRInt32* aType); NS_IMETHOD Init() { return NS_OK; } - // nsIBindableContent - NS_IMETHOD SetBinding(nsIXBLBinding* aBinding); - NS_IMETHOD GetBinding(nsIXBLBinding** aResult); - NS_IMETHOD GetBaseTag(nsIAtom** aResult); - protected: nsGenericHTMLContainerFormElement mInner; nsIForm* mForm; nsCOMPtr mControllers; - nsCOMPtr mBinding; }; nsresult @@ -183,11 +174,6 @@ nsHTMLTextAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - else if (aIID.Equals(NS_GET_IID(nsIBindableContent))) { - *aInstancePtr = (void*)(nsIBindableContent*) this; - NS_ADDREF_THIS(); - return NS_OK; - } return NS_NOINTERFACE; } @@ -305,30 +291,6 @@ nsHTMLTextAreaElement::RemoveFocus(nsIPresContext* aPresContext) return NS_OK; } -NS_IMETHODIMP -nsHTMLTextAreaElement::SetBinding(nsIXBLBinding* aBinding) -{ - mBinding = aBinding; // COMPtr does addref - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLTextAreaElement::GetBinding(nsIXBLBinding** aResult) -{ - *aResult = mBinding; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLTextAreaElement::GetBaseTag(nsIAtom** aResult) -{ - if (mBinding) - return mBinding->GetBaseTag(aResult); - else - return NS_OK; -} - NS_IMETHODIMP nsHTMLTextAreaElement::Select() { diff --git a/mozilla/content/xbl/public/Makefile.in b/mozilla/content/xbl/public/Makefile.in index 9443b6cfbc0..4ba3fc912b9 100644 --- a/mozilla/content/xbl/public/Makefile.in +++ b/mozilla/content/xbl/public/Makefile.in @@ -29,7 +29,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = layout EXPORTS = \ - nsIBindableContent.h \ + nsIBindingManager.h \ nsIXBLBinding.h \ nsIXBLService.h \ $(NULL) diff --git a/mozilla/content/xbl/public/Manifest b/mozilla/content/xbl/public/Manifest index 27419e80757..325a8328aa4 100644 --- a/mozilla/content/xbl/public/Manifest +++ b/mozilla/content/xbl/public/Manifest @@ -1,4 +1,4 @@ -nsIBindableContent.h +nsIBindingManager.h nsIXBLBinding.h nsIXBLService.h diff --git a/mozilla/content/xbl/public/makefile.win b/mozilla/content/xbl/public/makefile.win index aa17490316a..26058a00eba 100644 --- a/mozilla/content/xbl/public/makefile.win +++ b/mozilla/content/xbl/public/makefile.win @@ -22,7 +22,7 @@ DEPTH=..\..\.. EXPORTS = \ - nsIBindableContent.h \ + nsIBindingManager.h \ nsIXBLBinding.h \ nsIXBLService.h \ $(NULL) diff --git a/mozilla/layout/xbl/public/nsIBindableContent.h b/mozilla/content/xbl/public/nsIBindingManager.h similarity index 71% rename from mozilla/layout/xbl/public/nsIBindableContent.h rename to mozilla/content/xbl/public/nsIBindingManager.h index c049754daeb..4c4b87fab30 100644 --- a/mozilla/layout/xbl/public/nsIBindableContent.h +++ b/mozilla/content/xbl/public/nsIBindingManager.h @@ -28,8 +28,8 @@ */ -#ifndef nsIBINDABLE_CONTENT_h__ -#define nsIBINDABLE_CONTENT_h__ +#ifndef nsIBinding_Manager_h__ +#define nsIBinding_Manager_h__ #include "nsString.h" #include "nsISupports.h" @@ -39,18 +39,18 @@ class nsIXBLBinding; class nsIAtom; // {55D70FE0-C8E5-11d3-97FB-00400553EEF0} -#define NS_IBINDABLE_CONTENT_IID \ +#define NS_IBINDING_MANAGER_IID \ { 0x55d70fe0, 0xc8e5, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } } -class nsIBindableContent : public nsISupports +class nsIBindingManager : public nsISupports { public: - static const nsIID& GetIID() { static nsIID iid = NS_IBINDABLE_CONTENT_IID; return iid; } + static const nsIID& GetIID() { static nsIID iid = NS_IBINDING_MANAGER_IID; return iid; } - NS_IMETHOD SetBinding(nsIXBLBinding* aBinding) = 0; - NS_IMETHOD GetBinding(nsIXBLBinding** aResult) = 0; + NS_IMETHOD GetBinding(nsIContent* aContent, nsIXBLBinding** aResult) = 0; + NS_IMETHOD SetBinding(nsIContent* aContent, nsIXBLBinding* aBinding) = 0; - NS_IMETHOD GetBaseTag(nsIAtom** aResult) = 0; + NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult) = 0; }; -#endif // nsIBINDABLE_CONTENT_h__ +#endif // nsIBinding_Manager_h__ diff --git a/mozilla/content/xbl/public/nsIXBLService.h b/mozilla/content/xbl/public/nsIXBLService.h index e6222a52035..6a4881bd86e 100644 --- a/mozilla/content/xbl/public/nsIXBLService.h +++ b/mozilla/content/xbl/public/nsIXBLService.h @@ -61,7 +61,7 @@ public: NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aChildElement) = 0; // Retrieves our base class (e.g., tells us what type of frame and content node to build) - NS_IMETHOD GetBaseTag(nsIContent* aContent, nsIAtom** aResult) = 0; + NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult) = 0; }; diff --git a/mozilla/content/xbl/src/Makefile.in b/mozilla/content/xbl/src/Makefile.in index 828ed62cf84..0a7689c0b7d 100644 --- a/mozilla/content/xbl/src/Makefile.in +++ b/mozilla/content/xbl/src/Makefile.in @@ -33,6 +33,7 @@ CPPSRCS = \ nsXBLBinding.cpp \ nsXBLEventHandler.cpp \ nsXBLService.cpp \ + nsBindingManager.cpp \ $(NULL) include $(topsrcdir)/config/config.mk diff --git a/mozilla/content/xbl/src/makefile.win b/mozilla/content/xbl/src/makefile.win index 7119c72058d..ca18d987b37 100644 --- a/mozilla/content/xbl/src/makefile.win +++ b/mozilla/content/xbl/src/makefile.win @@ -30,12 +30,15 @@ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN CPPSRCS= \ nsXBLBinding.cpp \ nsXBLService.cpp \ + nsXBLEventHandler.cpp \ + nsBindingManager.cpp \ $(NULL) CPP_OBJS= \ .\$(OBJDIR)\nsXBLBinding.obj \ .\$(OBJDIR)\nsXBLEventHandler.obj \ .\$(OBJDIR)\nsXBLService.obj \ + .\$(OBJDIR)\nsBindingManager.obj \ $(NULL) EXPORTS = \ diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index 27473b519d6..7ca29d0b6d7 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -37,7 +37,6 @@ #include "plstr.h" #include "nsIContent.h" #include "nsIDOMElement.h" -#include "nsIBindableContent.h" #include "nsIDocument.h" #include "nsIXMLContentSink.h" #include "nsLayoutCID.h" @@ -129,7 +128,7 @@ class nsXBLService: public nsIXBLService NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aChildElement); // Gets the object's base class type. - NS_IMETHOD GetBaseTag(nsIContent* aContent, nsIAtom** aResult); + NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult); public: nsXBLService(); @@ -240,12 +239,13 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL) { nsresult rv; - nsCOMPtr bindableContent(do_QueryInterface(aContent)); - if (!bindableContent) - return NS_ERROR_FAILURE; - + nsCOMPtr document; + aContent->GetDocument(*getter_AddRefs(document)); + nsCOMPtr bindingManager; + document->GetBindingManager(getter_AddRefs(bindingManager)); + nsCOMPtr binding; - bindableContent->GetBinding(getter_AddRefs(binding)); + bindingManager->GetBinding(aContent, getter_AddRefs(binding)); if (binding) { nsAutoString bindingURI; binding->GetBindingURI(bindingURI); @@ -269,7 +269,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL) } // Install the binding on the content node. - bindableContent->SetBinding(binding); + bindingManager->SetBinding(aContent, binding); // Tell the binding to build the anonymous content. binding->GenerateAnonymousContent(aContent); @@ -292,12 +292,15 @@ nsXBLService::GetContentList(nsIContent* aContent, nsISupportsArray** aResult, n // of anonymous items. *aResult = nsnull; *aParent = nsnull; - nsCOMPtr bindable = do_QueryInterface(aContent); - if (!bindable) - return NS_ERROR_FAILURE; + nsCOMPtr document; + aContent->GetDocument(*getter_AddRefs(document)); + nsCOMPtr bindingManager; + document->GetBindingManager(getter_AddRefs(bindingManager)); + nsCOMPtr binding; - bindable->GetBinding(getter_AddRefs(binding)); + bindingManager->GetBinding(aContent, getter_AddRefs(binding)); + while (binding) { // Get the anonymous content. nsCOMPtr content; @@ -328,13 +331,14 @@ nsXBLService::GetContentList(nsIContent* aContent, nsISupportsArray** aResult, n NS_IMETHODIMP nsXBLService::FlushBindings(nsIContent* aContent) { - nsCOMPtr bindable(do_QueryInterface(aContent)); - if (!bindable) - return NS_ERROR_FAILURE; - - // Get the original binding. + nsCOMPtr document; + aContent->GetDocument(*getter_AddRefs(document)); + nsCOMPtr bindingManager; + document->GetBindingManager(getter_AddRefs(bindingManager)); + nsCOMPtr binding; - bindable->GetBinding(getter_AddRefs(binding)); + bindingManager->GetBinding(aContent, getter_AddRefs(binding)); + if (binding) { // Clear out the script references. nsCOMPtr document; @@ -342,7 +346,8 @@ nsXBLService::FlushBindings(nsIContent* aContent) binding->ChangeDocument(document, nsnull); } - bindable->SetBinding(nsnull); // Flush old bindings + bindingManager->SetBinding(aContent, nsnull); // Flush old bindings + return NS_OK; } @@ -355,14 +360,20 @@ nsXBLService::FlushBindingDocuments() } NS_IMETHODIMP -nsXBLService::GetBaseTag(nsIContent* aContent, nsIAtom** aResult) +nsXBLService::ResolveTag(nsIContent* aContent, nsIAtom** aResult) { - *aResult = nsnull; - nsCOMPtr bindable(do_QueryInterface(aContent)); - if (!bindable) - return NS_ERROR_FAILURE; + nsCOMPtr document; + aContent->GetDocument(*getter_AddRefs(document)); + if (document) { + nsCOMPtr bindingManager; + document->GetBindingManager(getter_AddRefs(bindingManager)); + + if (bindingManager) + return bindingManager->ResolveTag(aContent, aResult); + } - return bindable->GetBaseTag(aResult); + aContent->GetTag(*aResult); // Addref happens here. + return NS_OK; } // Internal helper methods //////////////////////////////////////////////////////////////// diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp index 078e985a18f..529092e2f36 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.cpp +++ b/mozilla/content/xml/content/src/nsXMLElement.cpp @@ -111,12 +111,6 @@ nsXMLElement::QueryInterface(REFNSIID aIID, NS_ADDREF_THIS(); return NS_OK; } - else if (aIID.Equals(NS_GET_IID(nsIBindableContent))) { - nsIBindableContent* tmp = this; - *aInstancePtr = (void*) tmp; - NS_ADDREF_THIS(); - return NS_OK; - } return NS_NOINTERFACE; } @@ -478,27 +472,3 @@ nsXMLElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMETHODIMP -nsXMLElement::SetBinding(nsIXBLBinding* aBinding) -{ - mBinding = aBinding; // nsCOMPtr handles addrefing. - return NS_OK; -} - -NS_IMETHODIMP -nsXMLElement::GetBinding(nsIXBLBinding** aResult) -{ - *aResult = mBinding.get(); - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -NS_IMETHODIMP -nsXMLElement::GetBaseTag(nsIAtom** aResult) -{ - if (mBinding) - return mBinding->GetBaseTag(aResult); - else - return NS_OK; -} - diff --git a/mozilla/content/xml/content/src/nsXMLElement.h b/mozilla/content/xml/content/src/nsXMLElement.h index cbc3f7b8055..5831418dec3 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.h +++ b/mozilla/content/xml/content/src/nsXMLElement.h @@ -24,14 +24,12 @@ #define nsXMLElement_h___ #include "nsCOMPtr.h" -#include "nsIXBLBinding.h" #include "nsIDOMElement.h" #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIXMLContent.h" #include "nsIJSScriptObject.h" #include "nsGenericXMLElement.h" -#include "nsIBindableContent.h" class nsIDocument; class nsIAtom; @@ -42,7 +40,6 @@ class nsIWebShell; class nsXMLElement : public nsIDOMElement, public nsIXMLContent, - public nsIBindableContent, public nsIJSScriptObject { public: @@ -209,11 +206,6 @@ public: } NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell); - // nsIBindableContent - NS_IMETHOD SetBinding(nsIXBLBinding* aBinding); - NS_IMETHOD GetBinding(nsIXBLBinding** aResult); - NS_IMETHOD GetBaseTag(nsIAtom** aResult); - // nsIJSScriptObject virtual PRBool AddProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp) { return mInner.AddProperty(aContext, aObj, aID, aVp); @@ -245,7 +237,6 @@ protected: nsGenericXMLElement mInner; PRBool mIsLink; PRUint32 mContentID; - nsCOMPtr mBinding; }; #endif // nsXMLElement_h___ diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 63c8930ecda..cce55ac6718 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -5358,9 +5358,9 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, xblService->LoadBindings(aContent, ui->mBehavior); nsCOMPtr baseTag; - xblService->GetBaseTag(aContent, getter_AddRefs(baseTag)); + xblService->ResolveTag(aContent, getter_AddRefs(baseTag)); - if (baseTag) { + if (baseTag.get() != aTag) { // Construct the frame using the XBL base tag. return ConstructXULFrame( aPresShell, aPresContext, @@ -6309,6 +6309,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell, ProcessChildren(aPresShell, aPresContext, aState, aContent, scrolledFrame, PR_FALSE, childItems, PR_TRUE); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + childItems); + // Set the scrolled frame's initial child lists scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { @@ -6369,6 +6374,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell, ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, PR_TRUE); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + childItems); + // Set the frame's initial child list(s) newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (aState.mAbsoluteItems.childList) { @@ -6416,6 +6426,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell, ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, PR_TRUE); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + childItems); + // Set the frame's initial child list(s) newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (aState.mFloatedItems.childList) { @@ -6470,6 +6485,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell, ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, isBlockFrame); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + childItems); + // Set the frame's initial child list newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (aState.mAbsoluteItems.childList) { @@ -6999,6 +7019,9 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, if (processChildren) { rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, PR_FALSE); + + CreateAnonymousFrames(aPresShell, aPresContext, aTag, aState, aContent, newFrame, + childItems); } // Set the frame's initial child list @@ -7108,6 +7131,9 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsIPresShell* aPresShell, if (processChildren) { rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, PR_FALSE); + + CreateAnonymousFrames(aPresShell, aPresContext, aTag, aState, aContent, newFrame, + childItems); } // Set the frame's initial child list @@ -11815,6 +11841,11 @@ nsCSSFrameConstructor::ConstructBlock(nsIPresShell* aPresShell, nsresult rv = ProcessBlockChildren(aPresShell, aPresContext, aState, aContent, aNewFrame, PR_TRUE, childItems, PR_TRUE); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, aNewFrame, + childItems); + // Set the frame's initial child list aNewFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); @@ -11994,6 +12025,11 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, aNewFrame, PR_TRUE, childItems, &kidsAllInline); if (kidsAllInline) { // Set the inline frame's initial child list + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, aNewFrame, + childItems); + aNewFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); *aNewBlockFrame = nsnull; *aNextInlineFrame = nsnull; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index e1cd0aa1119..206444018ee 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -2156,6 +2156,7 @@ NS_IMETHODIMP PresShell::AppendReflowCommand(nsIReflowCommand* aReflowCommand) { #ifdef DEBUG + //printf("gShellCounter: %d\n", gShellCounter++); if (mInVerifyReflow) { return NS_OK; } diff --git a/mozilla/layout/base/public/nsIDocument.h b/mozilla/layout/base/public/nsIDocument.h index 260c215d0ef..6f8d8bdf164 100644 --- a/mozilla/layout/base/public/nsIDocument.h +++ b/mozilla/layout/base/public/nsIDocument.h @@ -59,6 +59,7 @@ class nsIChannel; class nsIPrincipal; class nsIDOMDocument; class nsIDOMDocumentType; +class nsIBindingManager; // IID for the nsIDocument interface #define NS_IDOCUMENT_IID \ @@ -327,6 +328,8 @@ public: NS_IMETHOD FlushPendingNotifications() = 0; NS_IMETHOD GetAndIncrementContentID(PRInt32* aID) = 0; + + NS_IMETHOD GetBindingManager(nsIBindingManager** aResult) = 0; }; diff --git a/mozilla/layout/base/src/nsDocument.cpp b/mozilla/layout/base/src/nsDocument.cpp index 6db30dc52f2..53694175d44 100644 --- a/mozilla/layout/base/src/nsDocument.cpp +++ b/mozilla/layout/base/src/nsDocument.cpp @@ -3277,6 +3277,21 @@ nsDocument::GetAndIncrementContentID(PRInt32* aID) return NS_OK; } +NS_IMETHODIMP +nsDocument::GetBindingManager(nsIBindingManager** aResult) +{ + nsresult rv; + if (!mBindingManager) { + mBindingManager = do_CreateInstance("component://netscape/xbl/binding-manager", &rv); + if (NS_FAILED(rv)) + return NS_ERROR_FAILURE; + } + + *aResult = mBindingManager; + NS_IF_ADDREF(*aResult); + return NS_OK; +} + NS_IMETHODIMP nsDocument::GetModCount(PRInt32 *outModCount) diff --git a/mozilla/layout/base/src/nsDocument.h b/mozilla/layout/base/src/nsDocument.h index 3f711b2ff8d..bef0fb14832 100644 --- a/mozilla/layout/base/src/nsDocument.h +++ b/mozilla/layout/base/src/nsDocument.h @@ -40,6 +40,7 @@ #include "nsIContent.h" #include "nsGenericDOMNodeList.h" #include "nsIPrincipal.h" +#include "nsIBindingManager.h" class nsIEventListenerManager; class nsDOMStyleSheetList; @@ -330,6 +331,7 @@ public: NS_IMETHOD FlushPendingNotifications(); NS_IMETHOD GetAndIncrementContentID(PRInt32* aID); + NS_IMETHOD GetBindingManager(nsIBindingManager** aResult); public: @@ -470,7 +472,8 @@ protected: // disk file members nsFileSpec* mFileSpec; PRInt32 mModCount; - + + nsCOMPtr mBindingManager; }; #endif /* nsDocument_h___ */ diff --git a/mozilla/layout/build/nsLayoutCID.h b/mozilla/layout/build/nsLayoutCID.h index 32ee510f394..7cfdb387b14 100644 --- a/mozilla/layout/build/nsLayoutCID.h +++ b/mozilla/layout/build/nsLayoutCID.h @@ -147,6 +147,10 @@ #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 } } + // {8775CA39-4072-4cc0-92D3-A7C2B820089C} #define NS_AUTOCOPYSERVICE_CID \ { 0x8775ca39, 0x4072, 0x4cc0, { 0x92, 0xd3, 0xa7, 0xc2, 0xb8, 0x20, 0x8, 0x9c } } diff --git a/mozilla/layout/build/nsLayoutFactory.cpp b/mozilla/layout/build/nsLayoutFactory.cpp index 98f413633df..d84174b6edd 100644 --- a/mozilla/layout/build/nsLayoutFactory.cpp +++ b/mozilla/layout/build/nsLayoutFactory.cpp @@ -54,6 +54,7 @@ #include "nsIFrameSelection.h" #include "nsIXBLService.h" +#include "nsIBindingManager.h" #include "nsIAutoCopy.h" @@ -94,6 +95,7 @@ static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kTextEncoderCID, NS_TEXT_ENCODER_CID); static NS_DEFINE_CID(kXBLServiceCID, NS_XBLSERVICE_CID); +static NS_DEFINE_CID(kBindingManagerCID, NS_BINDINGMANAGER_CID); static NS_DEFINE_CID(kAutoCopyServiceCID, NS_AUTOCOPYSERVICE_CID); @@ -116,6 +118,7 @@ extern nsresult NS_NewHTMLEncoder(nsIDocumentEncoder** aResult); extern nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult); extern nsresult NS_NewXBLService(nsIXBLService** aResult); +extern nsresult NS_NewBindingManager(nsIBindingManager** aResult); extern nsresult NS_NewAutoCopyService(nsIAutoCopyService** aResult); @@ -366,6 +369,13 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter, return res; } } + else if (mClassID.Equals(kBindingManagerCID)) { + res = NS_NewBindingManager((nsIBindingManager**) &inst); + if (NS_FAILED(res)) { + LOG_NEW_FAILURE("NS_NewBindingManager", res); + return res; + } + } else if (mClassID.Equals(kAutoCopyServiceCID)) { res = NS_NewAutoCopyService((nsIAutoCopyService**) &inst); if (NS_FAILED(res)) { diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index c67e66ace32..de334f9eba6 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -349,6 +349,8 @@ static Components gComponents[] = { NS_DOC_ENCODER_PROGID_BASE "text/xif", }, { "XBL Service", NS_XBLSERVICE_CID, "component://netscape/xbl" }, + { "XBL Binding Manager", NS_BINDINGMANAGER_CID, "component://netscape/xbl/binding-manager" }, + { "AutoCopy Service", NS_AUTOCOPYSERVICE_CID, "component://netscape/autocopy" }, }; #define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0])) diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index e1cd0aa1119..206444018ee 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -2156,6 +2156,7 @@ NS_IMETHODIMP PresShell::AppendReflowCommand(nsIReflowCommand* aReflowCommand) { #ifdef DEBUG + //printf("gShellCounter: %d\n", gShellCounter++); if (mInVerifyReflow) { return NS_OK; } diff --git a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp index 374f588d681..b1b4c24f24d 100644 --- a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp @@ -47,8 +47,6 @@ #include "nsIPresShell.h" #include "nsIFormControlFrame.h" #include "nsIFrame.h" -#include "nsIBindableContent.h" -#include "nsIXBLBinding.h" #include "nsIEventStateManager.h" #include "nsISizeOfHandler.h" #include "nsIServiceManager.h" @@ -73,8 +71,7 @@ class nsHTMLInputElement : public nsIDOMHTMLInputElement, public nsIDOMNSHTMLInputElement, public nsIJSScriptObject, public nsIHTMLContent, - public nsIFormControl, - public nsIBindableContent + public nsIFormControl { public: nsHTMLInputElement(nsIAtom* aTag); @@ -145,11 +142,6 @@ public: NS_IMETHOD GetType(PRInt32* aType); NS_IMETHOD Init() { return NS_OK; } - // nsIBindableContent - NS_IMETHOD SetBinding(nsIXBLBinding* aBinding); - NS_IMETHOD GetBinding(nsIXBLBinding** aResult); - NS_IMETHOD GetBaseTag(nsIAtom** aResult); - // Helper method NS_IMETHOD SetPresStateChecked(nsIHTMLContent * aHTMLContent, nsIStatefulFrame::StateType aStateType, @@ -165,7 +157,6 @@ protected: PRInt32 mType; PRBool mSkipFocusEvent; nsCOMPtr mControllers; - nsCOMPtr mBinding; PRBool IsImage() const { @@ -232,11 +223,6 @@ nsHTMLInputElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - else if (aIID.Equals(NS_GET_IID(nsIBindableContent))) { - *aInstancePtr = (void*)(nsIBindableContent*) this; - NS_ADDREF_THIS(); - return NS_OK; - } return NS_NOINTERFACE; } @@ -632,30 +618,6 @@ nsHTMLInputElement::RemoveFocus(nsIPresContext* aPresContext) return NS_OK; } -NS_IMETHODIMP -nsHTMLInputElement::SetBinding(nsIXBLBinding* aBinding) -{ - mBinding = aBinding; // COMPtr does addref - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLInputElement::GetBinding(nsIXBLBinding** aResult) -{ - *aResult = mBinding; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLInputElement::GetBaseTag(nsIAtom** aResult) -{ - if (mBinding) - return mBinding->GetBaseTag(aResult); - else - return NS_OK; -} - NS_IMETHODIMP nsHTMLInputElement::Select() { diff --git a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp index 1efa4853724..3caf7296558 100644 --- a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp @@ -42,8 +42,6 @@ #include "nsIPresContext.h" #include "nsIHTMLAttributes.h" #include "nsIFormControlFrame.h" -#include "nsIBindableContent.h" -#include "nsIXBLBinding.h" #include "nsIEventStateManager.h" #include "nsISizeOfHandler.h" #include "nsLinebreakConverter.h" @@ -58,8 +56,7 @@ class nsHTMLTextAreaElement : public nsIDOMHTMLTextAreaElement, public nsIDOMNSHTMLTextAreaElement, public nsIJSScriptObject, public nsIHTMLContent, - public nsIFormControl, - public nsIBindableContent + public nsIFormControl { public: nsHTMLTextAreaElement(nsIAtom* aTag); @@ -119,16 +116,10 @@ public: NS_IMETHOD GetType(PRInt32* aType); NS_IMETHOD Init() { return NS_OK; } - // nsIBindableContent - NS_IMETHOD SetBinding(nsIXBLBinding* aBinding); - NS_IMETHOD GetBinding(nsIXBLBinding** aResult); - NS_IMETHOD GetBaseTag(nsIAtom** aResult); - protected: nsGenericHTMLContainerFormElement mInner; nsIForm* mForm; nsCOMPtr mControllers; - nsCOMPtr mBinding; }; nsresult @@ -183,11 +174,6 @@ nsHTMLTextAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - else if (aIID.Equals(NS_GET_IID(nsIBindableContent))) { - *aInstancePtr = (void*)(nsIBindableContent*) this; - NS_ADDREF_THIS(); - return NS_OK; - } return NS_NOINTERFACE; } @@ -305,30 +291,6 @@ nsHTMLTextAreaElement::RemoveFocus(nsIPresContext* aPresContext) return NS_OK; } -NS_IMETHODIMP -nsHTMLTextAreaElement::SetBinding(nsIXBLBinding* aBinding) -{ - mBinding = aBinding; // COMPtr does addref - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLTextAreaElement::GetBinding(nsIXBLBinding** aResult) -{ - *aResult = mBinding; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLTextAreaElement::GetBaseTag(nsIAtom** aResult) -{ - if (mBinding) - return mBinding->GetBaseTag(aResult); - else - return NS_OK; -} - NS_IMETHODIMP nsHTMLTextAreaElement::Select() { diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 63c8930ecda..cce55ac6718 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -5358,9 +5358,9 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, xblService->LoadBindings(aContent, ui->mBehavior); nsCOMPtr baseTag; - xblService->GetBaseTag(aContent, getter_AddRefs(baseTag)); + xblService->ResolveTag(aContent, getter_AddRefs(baseTag)); - if (baseTag) { + if (baseTag.get() != aTag) { // Construct the frame using the XBL base tag. return ConstructXULFrame( aPresShell, aPresContext, @@ -6309,6 +6309,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell, ProcessChildren(aPresShell, aPresContext, aState, aContent, scrolledFrame, PR_FALSE, childItems, PR_TRUE); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + childItems); + // Set the scrolled frame's initial child lists scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { @@ -6369,6 +6374,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell, ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, PR_TRUE); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + childItems); + // Set the frame's initial child list(s) newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (aState.mAbsoluteItems.childList) { @@ -6416,6 +6426,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell, ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, PR_TRUE); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + childItems); + // Set the frame's initial child list(s) newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (aState.mFloatedItems.childList) { @@ -6470,6 +6485,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell, ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, isBlockFrame); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + childItems); + // Set the frame's initial child list newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (aState.mAbsoluteItems.childList) { @@ -6999,6 +7019,9 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, if (processChildren) { rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, PR_FALSE); + + CreateAnonymousFrames(aPresShell, aPresContext, aTag, aState, aContent, newFrame, + childItems); } // Set the frame's initial child list @@ -7108,6 +7131,9 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsIPresShell* aPresShell, if (processChildren) { rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, PR_FALSE); + + CreateAnonymousFrames(aPresShell, aPresContext, aTag, aState, aContent, newFrame, + childItems); } // Set the frame's initial child list @@ -11815,6 +11841,11 @@ nsCSSFrameConstructor::ConstructBlock(nsIPresShell* aPresShell, nsresult rv = ProcessBlockChildren(aPresShell, aPresContext, aState, aContent, aNewFrame, PR_TRUE, childItems, PR_TRUE); + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, aNewFrame, + childItems); + // Set the frame's initial child list aNewFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); @@ -11994,6 +12025,11 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, aNewFrame, PR_TRUE, childItems, &kidsAllInline); if (kidsAllInline) { // Set the inline frame's initial child list + nsCOMPtr tag; + aContent->GetTag(*getter_AddRefs(tag)); + CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, aNewFrame, + childItems); + aNewFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); *aNewBlockFrame = nsnull; *aNextInlineFrame = nsnull; diff --git a/mozilla/layout/xbl/public/Makefile.in b/mozilla/layout/xbl/public/Makefile.in index 9443b6cfbc0..4ba3fc912b9 100644 --- a/mozilla/layout/xbl/public/Makefile.in +++ b/mozilla/layout/xbl/public/Makefile.in @@ -29,7 +29,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = layout EXPORTS = \ - nsIBindableContent.h \ + nsIBindingManager.h \ nsIXBLBinding.h \ nsIXBLService.h \ $(NULL) diff --git a/mozilla/layout/xbl/public/Manifest b/mozilla/layout/xbl/public/Manifest index 27419e80757..325a8328aa4 100644 --- a/mozilla/layout/xbl/public/Manifest +++ b/mozilla/layout/xbl/public/Manifest @@ -1,4 +1,4 @@ -nsIBindableContent.h +nsIBindingManager.h nsIXBLBinding.h nsIXBLService.h diff --git a/mozilla/layout/xbl/public/makefile.win b/mozilla/layout/xbl/public/makefile.win index aa17490316a..26058a00eba 100644 --- a/mozilla/layout/xbl/public/makefile.win +++ b/mozilla/layout/xbl/public/makefile.win @@ -22,7 +22,7 @@ DEPTH=..\..\.. EXPORTS = \ - nsIBindableContent.h \ + nsIBindingManager.h \ nsIXBLBinding.h \ nsIXBLService.h \ $(NULL) diff --git a/mozilla/layout/xbl/public/nsIBindingManager.h b/mozilla/layout/xbl/public/nsIBindingManager.h new file mode 100644 index 00000000000..4c4b87fab30 --- /dev/null +++ b/mozilla/layout/xbl/public/nsIBindingManager.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Original Author: David W. Hyatt (hyatt@netscape.com) + * + * Contributor(s): + */ + +/* + + Private interface to the XBL Binding + +*/ + +#ifndef nsIBinding_Manager_h__ +#define nsIBinding_Manager_h__ + +#include "nsString.h" +#include "nsISupports.h" + +class nsIContent; +class nsIXBLBinding; +class nsIAtom; + +// {55D70FE0-C8E5-11d3-97FB-00400553EEF0} +#define NS_IBINDING_MANAGER_IID \ +{ 0x55d70fe0, 0xc8e5, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } } + +class nsIBindingManager : public nsISupports +{ +public: + static const nsIID& GetIID() { static nsIID iid = NS_IBINDING_MANAGER_IID; return iid; } + + NS_IMETHOD GetBinding(nsIContent* aContent, nsIXBLBinding** aResult) = 0; + NS_IMETHOD SetBinding(nsIContent* aContent, nsIXBLBinding* aBinding) = 0; + + NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult) = 0; +}; + +#endif // nsIBinding_Manager_h__ diff --git a/mozilla/layout/xbl/public/nsIXBLService.h b/mozilla/layout/xbl/public/nsIXBLService.h index e6222a52035..6a4881bd86e 100644 --- a/mozilla/layout/xbl/public/nsIXBLService.h +++ b/mozilla/layout/xbl/public/nsIXBLService.h @@ -61,7 +61,7 @@ public: NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aChildElement) = 0; // Retrieves our base class (e.g., tells us what type of frame and content node to build) - NS_IMETHOD GetBaseTag(nsIContent* aContent, nsIAtom** aResult) = 0; + NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult) = 0; }; diff --git a/mozilla/layout/xbl/src/Makefile.in b/mozilla/layout/xbl/src/Makefile.in index 828ed62cf84..0a7689c0b7d 100644 --- a/mozilla/layout/xbl/src/Makefile.in +++ b/mozilla/layout/xbl/src/Makefile.in @@ -33,6 +33,7 @@ CPPSRCS = \ nsXBLBinding.cpp \ nsXBLEventHandler.cpp \ nsXBLService.cpp \ + nsBindingManager.cpp \ $(NULL) include $(topsrcdir)/config/config.mk diff --git a/mozilla/layout/xbl/src/makefile.win b/mozilla/layout/xbl/src/makefile.win index 7119c72058d..ca18d987b37 100644 --- a/mozilla/layout/xbl/src/makefile.win +++ b/mozilla/layout/xbl/src/makefile.win @@ -30,12 +30,15 @@ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN CPPSRCS= \ nsXBLBinding.cpp \ nsXBLService.cpp \ + nsXBLEventHandler.cpp \ + nsBindingManager.cpp \ $(NULL) CPP_OBJS= \ .\$(OBJDIR)\nsXBLBinding.obj \ .\$(OBJDIR)\nsXBLEventHandler.obj \ .\$(OBJDIR)\nsXBLService.obj \ + .\$(OBJDIR)\nsBindingManager.obj \ $(NULL) EXPORTS = \ diff --git a/mozilla/layout/xbl/src/nsXBLService.cpp b/mozilla/layout/xbl/src/nsXBLService.cpp index 27473b519d6..7ca29d0b6d7 100644 --- a/mozilla/layout/xbl/src/nsXBLService.cpp +++ b/mozilla/layout/xbl/src/nsXBLService.cpp @@ -37,7 +37,6 @@ #include "plstr.h" #include "nsIContent.h" #include "nsIDOMElement.h" -#include "nsIBindableContent.h" #include "nsIDocument.h" #include "nsIXMLContentSink.h" #include "nsLayoutCID.h" @@ -129,7 +128,7 @@ class nsXBLService: public nsIXBLService NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult, nsIContent** aChildElement); // Gets the object's base class type. - NS_IMETHOD GetBaseTag(nsIContent* aContent, nsIAtom** aResult); + NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult); public: nsXBLService(); @@ -240,12 +239,13 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL) { nsresult rv; - nsCOMPtr bindableContent(do_QueryInterface(aContent)); - if (!bindableContent) - return NS_ERROR_FAILURE; - + nsCOMPtr document; + aContent->GetDocument(*getter_AddRefs(document)); + nsCOMPtr bindingManager; + document->GetBindingManager(getter_AddRefs(bindingManager)); + nsCOMPtr binding; - bindableContent->GetBinding(getter_AddRefs(binding)); + bindingManager->GetBinding(aContent, getter_AddRefs(binding)); if (binding) { nsAutoString bindingURI; binding->GetBindingURI(bindingURI); @@ -269,7 +269,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL) } // Install the binding on the content node. - bindableContent->SetBinding(binding); + bindingManager->SetBinding(aContent, binding); // Tell the binding to build the anonymous content. binding->GenerateAnonymousContent(aContent); @@ -292,12 +292,15 @@ nsXBLService::GetContentList(nsIContent* aContent, nsISupportsArray** aResult, n // of anonymous items. *aResult = nsnull; *aParent = nsnull; - nsCOMPtr bindable = do_QueryInterface(aContent); - if (!bindable) - return NS_ERROR_FAILURE; + nsCOMPtr document; + aContent->GetDocument(*getter_AddRefs(document)); + nsCOMPtr bindingManager; + document->GetBindingManager(getter_AddRefs(bindingManager)); + nsCOMPtr binding; - bindable->GetBinding(getter_AddRefs(binding)); + bindingManager->GetBinding(aContent, getter_AddRefs(binding)); + while (binding) { // Get the anonymous content. nsCOMPtr content; @@ -328,13 +331,14 @@ nsXBLService::GetContentList(nsIContent* aContent, nsISupportsArray** aResult, n NS_IMETHODIMP nsXBLService::FlushBindings(nsIContent* aContent) { - nsCOMPtr bindable(do_QueryInterface(aContent)); - if (!bindable) - return NS_ERROR_FAILURE; - - // Get the original binding. + nsCOMPtr document; + aContent->GetDocument(*getter_AddRefs(document)); + nsCOMPtr bindingManager; + document->GetBindingManager(getter_AddRefs(bindingManager)); + nsCOMPtr binding; - bindable->GetBinding(getter_AddRefs(binding)); + bindingManager->GetBinding(aContent, getter_AddRefs(binding)); + if (binding) { // Clear out the script references. nsCOMPtr document; @@ -342,7 +346,8 @@ nsXBLService::FlushBindings(nsIContent* aContent) binding->ChangeDocument(document, nsnull); } - bindable->SetBinding(nsnull); // Flush old bindings + bindingManager->SetBinding(aContent, nsnull); // Flush old bindings + return NS_OK; } @@ -355,14 +360,20 @@ nsXBLService::FlushBindingDocuments() } NS_IMETHODIMP -nsXBLService::GetBaseTag(nsIContent* aContent, nsIAtom** aResult) +nsXBLService::ResolveTag(nsIContent* aContent, nsIAtom** aResult) { - *aResult = nsnull; - nsCOMPtr bindable(do_QueryInterface(aContent)); - if (!bindable) - return NS_ERROR_FAILURE; + nsCOMPtr document; + aContent->GetDocument(*getter_AddRefs(document)); + if (document) { + nsCOMPtr bindingManager; + document->GetBindingManager(getter_AddRefs(bindingManager)); + + if (bindingManager) + return bindingManager->ResolveTag(aContent, aResult); + } - return bindable->GetBaseTag(aResult); + aContent->GetTag(*aResult); // Addref happens here. + return NS_OK; } // Internal helper methods //////////////////////////////////////////////////////////////// diff --git a/mozilla/layout/xml/content/src/nsXMLElement.cpp b/mozilla/layout/xml/content/src/nsXMLElement.cpp index 078e985a18f..529092e2f36 100644 --- a/mozilla/layout/xml/content/src/nsXMLElement.cpp +++ b/mozilla/layout/xml/content/src/nsXMLElement.cpp @@ -111,12 +111,6 @@ nsXMLElement::QueryInterface(REFNSIID aIID, NS_ADDREF_THIS(); return NS_OK; } - else if (aIID.Equals(NS_GET_IID(nsIBindableContent))) { - nsIBindableContent* tmp = this; - *aInstancePtr = (void*) tmp; - NS_ADDREF_THIS(); - return NS_OK; - } return NS_NOINTERFACE; } @@ -478,27 +472,3 @@ nsXMLElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMETHODIMP -nsXMLElement::SetBinding(nsIXBLBinding* aBinding) -{ - mBinding = aBinding; // nsCOMPtr handles addrefing. - return NS_OK; -} - -NS_IMETHODIMP -nsXMLElement::GetBinding(nsIXBLBinding** aResult) -{ - *aResult = mBinding.get(); - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -NS_IMETHODIMP -nsXMLElement::GetBaseTag(nsIAtom** aResult) -{ - if (mBinding) - return mBinding->GetBaseTag(aResult); - else - return NS_OK; -} - diff --git a/mozilla/layout/xml/content/src/nsXMLElement.h b/mozilla/layout/xml/content/src/nsXMLElement.h index cbc3f7b8055..5831418dec3 100644 --- a/mozilla/layout/xml/content/src/nsXMLElement.h +++ b/mozilla/layout/xml/content/src/nsXMLElement.h @@ -24,14 +24,12 @@ #define nsXMLElement_h___ #include "nsCOMPtr.h" -#include "nsIXBLBinding.h" #include "nsIDOMElement.h" #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIXMLContent.h" #include "nsIJSScriptObject.h" #include "nsGenericXMLElement.h" -#include "nsIBindableContent.h" class nsIDocument; class nsIAtom; @@ -42,7 +40,6 @@ class nsIWebShell; class nsXMLElement : public nsIDOMElement, public nsIXMLContent, - public nsIBindableContent, public nsIJSScriptObject { public: @@ -209,11 +206,6 @@ public: } NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell); - // nsIBindableContent - NS_IMETHOD SetBinding(nsIXBLBinding* aBinding); - NS_IMETHOD GetBinding(nsIXBLBinding** aResult); - NS_IMETHOD GetBaseTag(nsIAtom** aResult); - // nsIJSScriptObject virtual PRBool AddProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp) { return mInner.AddProperty(aContext, aObj, aID, aVp); @@ -245,7 +237,6 @@ protected: nsGenericXMLElement mInner; PRBool mIsLink; PRUint32 mContentID; - nsCOMPtr mBinding; }; #endif // nsXMLElement_h___ diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index ec324251830..0c1ed455d3b 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -57,7 +57,7 @@ #include "nsWidgetsCID.h" #include "nsBoxLayoutState.h" #include "nsIXBLBinding.h" -#include "nsIBindableContent.h" +#include "nsIBindingManager.h" #define NS_MENU_POPUP_LIST_INDEX (NS_AREA_FRAME_ABSOLUTE_LIST_INDEX + 1) @@ -1237,16 +1237,8 @@ nsMenuFrame::BuildAcceleratorText(nsString& aAccelString) aAccelString += keyChar; } - if (!aAccelString.IsEmpty()) { + if (!aAccelString.IsEmpty()) mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::acceltext, aAccelString, PR_FALSE); - nsCOMPtr bindable(do_QueryInterface(mContent)); - if (bindable) { - nsCOMPtr binding; - bindable->GetBinding(getter_AddRefs(binding)); - if (binding) - binding->AttributeChanged(nsXULAtoms::acceltext, kNameSpaceID_None, PR_FALSE); - } - } } void diff --git a/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp b/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp index cee39a115fe..df0d9d4b9ff 100644 --- a/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp @@ -1,5 +1,5 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * + * * The contents of this file are subject to the Netscape 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 diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index cc009387683..5cb63d9187a 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -51,7 +51,8 @@ #include "nsIStyleContext.h" #include "nsWidgetsCID.h" #include "nsBoxLayoutState.h" -#include "nsIBindableContent.h" +#include "nsIXBLService.h" +#include "nsIServiceManager.h" #define REAL_TIME_DRAG @@ -779,12 +780,12 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) nsCOMPtr content; childFrame->GetContent(getter_AddRefs(content)); nsCOMPtr atom; - nsCOMPtr bindable(do_QueryInterface(content)); - if (bindable) { - bindable->GetBaseTag(getter_AddRefs(atom)); - } - - if (!atom) + nsresult rv; + NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); + + if (NS_SUCCEEDED(rv) && xblService) + xblService->ResolveTag(content, getter_AddRefs(atom)); + else content->GetTag(*getter_AddRefs(atom)); // skip over any splitters @@ -830,7 +831,7 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) } } - nsresult rv = childBox->GetNextBox(&childBox); + rv = childBox->GetNextBox(&childBox); NS_ASSERTION(rv == NS_OK,"failed to get next child"); count++; }