From d103a96ada96d388452855c53731ff1525398f93 Mon Sep 17 00:00:00 2001 From: "peterv%netscape.com" Date: Fri, 29 Nov 2002 23:44:07 +0000 Subject: [PATCH] Fix for bug 176610 (Make nsNameSpaceManager a service). r=caillon, sr=jst. git-svn-id: svn://10.0.0.236/trunk@134587 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/base/nsAccessibilityService.cpp | 1 - mozilla/accessible/src/base/nsAccessible.cpp | 1 - .../accessible/src/base/nsRootAccessible.cpp | 5 +- .../src/html/nsHTMLFormControlAccessible.cpp | 1 - mozilla/chrome/src/nsChromeRegistry.cpp | 1 - mozilla/content/base/public/nsContentUtils.h | 7 + mozilla/content/base/public/nsIDocument.h | 6 - mozilla/content/base/public/nsINameSpace.h | 5 +- .../content/base/public/nsINameSpaceManager.h | 28 +- mozilla/content/base/public/nsINodeInfo.h | 12 +- .../base/src/mozSanitizingSerializer.cpp | 1 - mozilla/content/base/src/nsContentUtils.cpp | 7 +- .../content/base/src/nsDOMAttributeMap.cpp | 14 +- mozilla/content/base/src/nsDocument.cpp | 31 +- mozilla/content/base/src/nsDocument.h | 6 - mozilla/content/base/src/nsDocumentViewer.cpp | 1 - mozilla/content/base/src/nsGenericElement.cpp | 84 +-- .../content/base/src/nsNameSpaceManager.cpp | 492 +++++++++--------- mozilla/content/base/src/nsNodeInfo.cpp | 18 +- mozilla/content/base/src/nsNodeInfo.h | 1 - .../content/base/src/nsNodeInfoManager.cpp | 36 +- mozilla/content/base/src/nsNodeInfoManager.h | 6 +- mozilla/content/base/src/nsPrintEngine.cpp | 1 - mozilla/content/base/src/nsScriptLoader.cpp | 1 - .../base/src/nsXMLContentSerializer.cpp | 13 +- mozilla/content/build/dlldeps.cpp | 3 - mozilla/content/build/nsContentModule.cpp | 16 +- .../events/src/nsEventStateManager.cpp | 2 +- .../html/document/src/nsHTMLDocument.cpp | 4 +- .../src/nsHTMLFragmentContentSink.cpp | 6 +- .../html/style/src/nsCSSStyleSheet.cpp | 41 +- mozilla/content/shared/public/nsSVGAtoms.h | 5 - mozilla/content/shared/public/nsXBLAtoms.h | 6 - mozilla/content/shared/public/nsXULAtoms.h | 6 - mozilla/content/shared/src/nsSVGAtoms.cpp | 29 -- mozilla/content/shared/src/nsXULAtoms.cpp | 35 +- .../content/svg/content/src/nsSVGAtoms.cpp | 29 -- mozilla/content/svg/content/src/nsSVGAtoms.h | 5 - .../content/svg/content/src/nsSVGElement.cpp | 1 - .../svg/document/src/nsSVGDocument.cpp | 6 +- .../content/svg/document/src/nsSVGDocument.h | 3 +- mozilla/content/xbl/src/nsBindingManager.cpp | 1 - mozilla/content/xbl/src/nsXBLAtoms.h | 6 - mozilla/content/xbl/src/nsXBLContentSink.cpp | 4 +- .../xbl/src/nsXBLContextMenuHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLDragHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLEventHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLFocusHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLFormHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLKeyHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLLoadHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLMouseHandler.cpp | 1 - .../xbl/src/nsXBLMouseMotionHandler.cpp | 1 - .../content/xbl/src/nsXBLMutationHandler.cpp | 1 - .../content/xbl/src/nsXBLScrollHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLService.cpp | 42 +- mozilla/content/xbl/src/nsXBLService.h | 9 - .../xbl/src/nsXBLWindowDragHandler.cpp | 1 - .../content/xbl/src/nsXBLWindowKeyHandler.cpp | 1 - mozilla/content/xbl/src/nsXBLXULHandler.cpp | 1 - .../xml/document/src/nsXMLContentSink.cpp | 40 +- .../xml/document/src/nsXMLContentSink.h | 4 - .../xml/document/src/nsXMLDocument.cpp | 4 +- .../content/xul/content/src/nsXULElement.cpp | 37 +- .../content/xul/content/src/nsXULElement.h | 4 - .../xul/document/src/nsXULContentSink.cpp | 61 +-- .../xul/document/src/nsXULDocument.cpp | 72 +-- .../content/xul/document/src/nsXULDocument.h | 7 - .../document/src/nsXULPrototypeDocument.cpp | 5 +- .../xul/templates/src/nsXULContentBuilder.cpp | 3 +- .../xul/templates/src/nsXULContentUtils.cpp | 13 +- .../xul/templates/src/nsXULContentUtils.h | 1 - .../xul/templates/src/nsXULSortService.cpp | 22 - .../templates/src/nsXULTemplateBuilder.cpp | 32 +- .../xul/templates/src/nsXULTemplateBuilder.h | 7 +- .../xul/templates/src/nsXULTreeBuilder.cpp | 1 + .../build/XSLTProcessorModule.cpp | 24 +- .../source/xml/dom/mozImpl/MozillaAttr.cpp | 7 +- .../xml/dom/mozImpl/MozillaDocument.cpp | 26 +- .../source/xml/dom/mozImpl/MozillaNode.cpp | 7 +- .../source/xml/dom/mozImpl/mozilladom.h | 7 +- .../source/xpath/nsXPathEvaluator.cpp | 12 +- .../source/xpath/nsXPathEvaluator.h | 2 - .../source/xslt/txMozillaXMLOutput.cpp | 13 +- .../source/xslt/txMozillaXMLOutput.h | 3 - .../source/xslt/txMozillaXSLTProcessor.cpp | 23 +- .../webservices/schema/src/nsDOMUtils.h | 1 - .../webservices/schema/src/nsSchemaLoader.cpp | 1 - .../webservices/wsdl/src/nsWSDLLoader.cpp | 1 - .../xmlextras/schema/src/nsDOMUtils.h | 1 - .../xmlextras/schema/src/nsSchemaLoader.cpp | 1 - .../xmlextras/wsdl/src/nsWSDLLoader.cpp | 1 - mozilla/layout/base/nsCSSFrameConstructor.cpp | 8 +- mozilla/layout/base/nsDocumentViewer.cpp | 1 - mozilla/layout/base/nsPresShell.cpp | 1 - mozilla/layout/build/dlldeps.cpp | 1 - mozilla/layout/forms/nsFormControlHelper.cpp | 1 - .../forms/nsGfxCheckboxControlFrame.cpp | 1 - .../layout/forms/nsGfxRadioControlFrame.cpp | 1 - mozilla/layout/forms/nsListControlFrame.cpp | 1 - mozilla/layout/forms/nsTextControlFrame.cpp | 1 - mozilla/layout/generic/nsTextFrame.cpp | 1 - mozilla/layout/html/base/src/nsPresShell.cpp | 1 - mozilla/layout/html/base/src/nsTextFrame.cpp | 1 - .../html/forms/src/nsFormControlHelper.cpp | 1 - .../forms/src/nsGfxCheckboxControlFrame.cpp | 1 - .../html/forms/src/nsGfxRadioControlFrame.cpp | 1 - .../html/forms/src/nsListControlFrame.cpp | 1 - .../html/forms/src/nsTextControlFrame.cpp | 1 - .../html/style/src/nsCSSFrameConstructor.cpp | 8 +- .../base/src/nsMathMLForeignFrameWrapper.cpp | 1 - .../layout/mathml/content/src/nsMathMLAtoms.h | 3 - mozilla/layout/printing/nsPrintEngine.cpp | 1 - mozilla/layout/style/nsCSSStyleSheet.cpp | 41 +- .../layout/xul/base/src/nsBoxLayoutState.cpp | 1 - .../xul/base/src/nsBoxToBlockAdaptor.cpp | 1 - .../layout/xul/base/src/nsContainerBox.cpp | 1 - .../xul/base/src/nsNativeScrollbarFrame.cpp | 1 - mozilla/layout/xul/base/src/nsSliderFrame.cpp | 1 - .../layout/xul/base/src/nsSprocketLayout.cpp | 1 - mozilla/layout/xul/base/src/nsStackFrame.cpp | 1 - .../layout/xul/base/src/nsTitleBarFrame.cpp | 2 - mozilla/rdf/base/src/nsRDFXMLDataSource.cpp | 1 - mozilla/rdf/chrome/src/nsChromeRegistry.cpp | 1 - mozilla/rdf/tests/localfile/localfile.cpp | 1 - mozilla/widget/public/nsWidgetAtoms.h | 5 - mozilla/widget/src/windows/Accessible.cpp | 1 - mozilla/widget/src/windows/SimpleDOMNode.cpp | 4 +- .../xpfe/appshell/src/nsWebShellWindow.cpp | 1 - mozilla/xpinstall/src/nsSoftwareUpdate.cpp | 1 - 130 files changed, 453 insertions(+), 1144 deletions(-) diff --git a/mozilla/accessible/src/base/nsAccessibilityService.cpp b/mozilla/accessible/src/base/nsAccessibilityService.cpp index 57b60c5197f..47d761b4c9b 100644 --- a/mozilla/accessible/src/base/nsAccessibilityService.cpp +++ b/mozilla/accessible/src/base/nsAccessibilityService.cpp @@ -67,7 +67,6 @@ #include "nsIDOMXULCheckboxElement.h" #include "nsIFrame.h" #include "nsILink.h" -#include "nsINameSpaceManager.h" #include "nsIObjectFrame.h" #include "nsIPluginInstance.h" #include "nsIPresContext.h" diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index 59ed2552473..2c56e03560e 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -74,7 +74,6 @@ #include "nsIAtom.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" -#include "nsINameSpaceManager.h" #include "nsGUIEvent.h" #include "nsILink.h" diff --git a/mozilla/accessible/src/base/nsRootAccessible.cpp b/mozilla/accessible/src/base/nsRootAccessible.cpp index a1520f96cec..96d4c566f4c 100644 --- a/mozilla/accessible/src/base/nsRootAccessible.cpp +++ b/mozilla/accessible/src/base/nsRootAccessible.cpp @@ -970,8 +970,9 @@ NS_IMETHODIMP nsDocAccessibleMixin::GetDocType(nsAString& aDocType) NS_IMETHODIMP nsDocAccessibleMixin::GetNameSpaceURIForID(PRInt16 aNameSpaceID, nsAString& aNameSpaceURI) { if (mDocument) { - nsCOMPtr nameSpaceManager; - if (NS_SUCCEEDED(mDocument->GetNameSpaceManager(*getter_AddRefs(nameSpaceManager)))) + nsCOMPtr nameSpaceManager = + do_GetService(NS_NAMESPACEMANAGER_CONTRACTID); + if (nameSpaceManager) return nameSpaceManager->GetNameSpaceURI(aNameSpaceID, aNameSpaceURI); } return NS_ERROR_FAILURE; diff --git a/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp b/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp index a808c822685..cd1ce4635bd 100644 --- a/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -57,7 +57,6 @@ #include "nsIEventStateManager.h" #include "nsIFrame.h" #include "nsITextControlFrame.h" -#include "nsINameSpaceManager.h" #include "nsIPlaintextEditor.h" #include "nsISelectionController.h" #include "nsReadableUtils.h" diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index 52fc596c20e..2409cc1a082 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -90,7 +90,6 @@ #include "nsICSSLoader.h" #include "nsIDocumentObserver.h" #include "nsIXULDocument.h" -#include "nsINameSpaceManager.h" #include "nsIIOService.h" #include "nsIResProtocolHandler.h" #include "nsLayoutCID.h" diff --git a/mozilla/content/base/public/nsContentUtils.h b/mozilla/content/base/public/nsContentUtils.h index ae4d5c7b524..7649bee2e81 100644 --- a/mozilla/content/base/public/nsContentUtils.h +++ b/mozilla/content/base/public/nsContentUtils.h @@ -49,6 +49,7 @@ class nsIXPConnect; class nsIContent; class nsIDocument; class nsIDocShell; +class nsINameSpaceManager; class nsIScriptSecurityManager; class nsIThreadJSContextStack; class nsIParserService; @@ -207,6 +208,11 @@ public: static nsIParserService* GetParserServiceWeakRef(); + static nsINameSpaceManager* GetNSManagerWeakRef() + { + return sNameSpaceManager; + }; + private: static nsresult doReparentContentWrapper(nsIContent *aChild, nsIDocument *aNewDocument, @@ -225,6 +231,7 @@ private: static nsIParserService *sParserService; + static nsINameSpaceManager *sNameSpaceManager; }; diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 49811f8fe61..6500de39028 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -65,7 +65,6 @@ class nsIDOMEvent; class nsIDeviceContext; class nsIParser; class nsIDOMNode; -class nsINameSpaceManager; class nsIDOMDocumentFragment; class nsILineBreaker; class nsIWordBreaker; @@ -292,11 +291,6 @@ public: NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject** aGlobalObject) = 0; NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0; - /** - * Get the name space manager for this document - */ - NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) = 0; - /** * Get the script loader for this document */ diff --git a/mozilla/content/base/public/nsINameSpace.h b/mozilla/content/base/public/nsINameSpace.h index e086c589e9b..d32436ab881 100644 --- a/mozilla/content/base/public/nsINameSpace.h +++ b/mozilla/content/base/public/nsINameSpace.h @@ -43,7 +43,6 @@ class nsIAtom; class nsString; -class nsINameSpaceManager; #define NS_INAMESPACE_IID \ { 0xa6cf90d4, 0x15b3, 0x11d2, \ @@ -58,15 +57,13 @@ class nsINameSpaceManager; * New NameSpaces are created as a child of an existing NameSpace. Searches * for NameSpaces based on prefix search up the chain of nested NameSpaces * - * Each NameSpace keeps a live reference on its parent and its Manager. + * Each NameSpace keeps a live reference on its parent. * */ class nsINameSpace : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_INAMESPACE_IID) - NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) const = 0; - // Get data of this name space NS_IMETHOD GetNameSpaceID(PRInt32& aID) const = 0; NS_IMETHOD GetNameSpaceURI(nsAString& aURI) const = 0; diff --git a/mozilla/content/base/public/nsINameSpaceManager.h b/mozilla/content/base/public/nsINameSpaceManager.h index 477c4c17c67..67cec1d7f39 100644 --- a/mozilla/content/base/public/nsINameSpaceManager.h +++ b/mozilla/content/base/public/nsINameSpaceManager.h @@ -56,9 +56,11 @@ class nsIElementFactory; #define kNameSpaceID_XSLT 5 #define kNameSpaceID_XBL 6 #define kNameSpaceID_MathML 7 +#define kNameSpaceID_RDF 8 +#define kNameSpaceID_XUL 9 +#define kNameSpaceID_SVG 10 -// 'html' is by definition bound to the namespace name "urn:w3-org-ns:HTML" XXX ??? -// 'xml' is by definition bound to the namespace name "urn:Connolly:input:required" XXX +#define NS_NAMESPACEMANAGER_CONTRACTID "@mozilla.org/content/namespacemanager;1" #define NS_INAMESPACEMANAGER_IID \ { 0xa6cf90d5, 0x15b3, 0x11d2, \ @@ -67,22 +69,18 @@ class nsIElementFactory; /** * The Name Space Manager tracks the associtation between a NameSpace * URI and the PRInt32 runtime id. Mappings between NameSpaces and - * NameSpace prefixes are managed by nsINameSpaces + * NameSpace prefixes are managed by nsINameSpaces. * * All NameSpace URIs are stored in a global table so that IDs are * consistent accross the app. NameSpace IDs are only consistent at runtime * ie: they are not guaranteed to be consistent accross app sessions. * * The nsINameSpaceManager needs to have a live reference for as long as - * the NameSpace IDs are needed. Generally, a document keeps a reference to - * a nsINameSpaceManager. Also, each nsINameSpace that comes from the manager - * keeps a reference to it. + * the NameSpace IDs are needed. * * To create a stack of NameSpaces, call CreateRootNameSpace, and then create * child NameSpaces from the root. * - * The "html" and "xml" namespaces come "pre-canned" from the root. - * */ class nsINameSpaceManager : public nsISupports @@ -105,13 +103,13 @@ public: NS_IMETHOD HasRegisteredFactory(PRInt32 aNameSpaceID, PRBool* aHasFactory) = 0; + + NS_IMETHOD HasNameSpaceURI(PRInt32 aNameSpaceID, + PRBool* aHasNameSpaceURI) = 0; }; - -nsresult - NS_NewNameSpaceManager(nsINameSpaceManager** aInstancePtrResult); - -void - NS_NameSpaceManagerShutdown(); - +nsresult NS_GetNameSpaceManager(nsINameSpaceManager** aInstancePtrResult); + +void NS_NameSpaceManagerShutdown(); + #endif // nsINameSpaceManager_h___ diff --git a/mozilla/content/base/public/nsINodeInfo.h b/mozilla/content/base/public/nsINodeInfo.h index d98dd00de0a..a492776c9c9 100644 --- a/mozilla/content/base/public/nsINodeInfo.h +++ b/mozilla/content/base/public/nsINodeInfo.h @@ -64,7 +64,6 @@ // Forward declarations class nsINodeInfoManager; -class nsINameSpaceManager; class nsIDocument; class nsIURI; class nsIPrincipal; @@ -335,11 +334,9 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_INODEINFOMANAGER_IID) /* - * Initialize the nodeinfo manager with a namespace manager, this should - * allways be done. + * Initialize the nodeinfo manager with a document. */ - NS_IMETHOD Init(nsIDocument *aDocument, - nsINameSpaceManager *aNameSpaceManager) = 0; + NS_IMETHOD Init(nsIDocument *aDocument) = 0; /* * Release the reference to the document, this will be called when @@ -363,11 +360,6 @@ public: const nsAString& aNamespaceURI, nsINodeInfo*& aNodeInfo) = 0; - /* - * Getter for the namespace manager used by this nodeinfo manager. - */ - NS_IMETHOD GetNamespaceManager(nsINameSpaceManager*& aNameSpaceManager) = 0; - /* * Retrieve a pointer to the document that owns this node info * manager. diff --git a/mozilla/content/base/src/mozSanitizingSerializer.cpp b/mozilla/content/base/src/mozSanitizingSerializer.cpp index 534e9a70581..0834a50e236 100644 --- a/mozilla/content/base/src/mozSanitizingSerializer.cpp +++ b/mozilla/content/base/src/mozSanitizingSerializer.cpp @@ -54,7 +54,6 @@ #include "nsHTMLAtoms.h" #include "nsIDOMText.h" #include "nsIDOMElement.h" -#include "nsINameSpaceManager.h" #include "nsIHTMLContent.h" #include "nsITextContent.h" #include "nsTextFragment.h" diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index 29f8cafc518..1d9660e958a 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -69,6 +69,7 @@ nsIXPConnect *nsContentUtils::sXPConnect = nsnull; nsIScriptSecurityManager *nsContentUtils::sSecurityManager = nsnull; nsIThreadJSContextStack *nsContentUtils::sThreadJSContextStack = nsnull; nsIParserService *nsContentUtils::sParserService = nsnull; +nsINameSpaceManager *nsContentUtils::sNameSpaceManager = nsnull; // static nsresult @@ -82,15 +83,18 @@ nsContentUtils::Init() rv = CallGetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &sSecurityManager); if (NS_FAILED(rv)) { + // We can run without a security manager, so don't return early. sSecurityManager = nsnull; } rv = CallGetService(kJSStackContractID, &sThreadJSContextStack); if (NS_FAILED(rv)) { sThreadJSContextStack = nsnull; + + return rv; } - return rv; + return NS_GetNameSpaceManager(&sNameSpaceManager); } /** @@ -379,6 +383,7 @@ nsContentUtils::Shutdown() NS_IF_RELEASE(sXPConnect); NS_IF_RELEASE(sSecurityManager); NS_IF_RELEASE(sThreadJSContextStack); + NS_IF_RELEASE(sNameSpaceManager); NS_IF_RELEASE(sParserService); } diff --git a/mozilla/content/base/src/nsDOMAttributeMap.cpp b/mozilla/content/base/src/nsDOMAttributeMap.cpp index f9fcc587da8..071051c7b5c 100644 --- a/mozilla/content/base/src/nsDOMAttributeMap.cpp +++ b/mozilla/content/base/src/nsDOMAttributeMap.cpp @@ -297,11 +297,8 @@ nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI, NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); if (aNamespaceURI.Length()) { - nsCOMPtr nsmgr; - nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr)); - NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE); - - nsmgr->GetNameSpaceID(aNamespaceURI, nameSpaceID); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + nameSpaceID); if (nameSpaceID == kNameSpaceID_Unknown) return NS_OK; @@ -417,11 +414,8 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI, NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); if (aNamespaceURI.Length()) { - nsCOMPtr nsmgr; - nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr)); - NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE); - - nsmgr->GetNameSpaceID(aNamespaceURI, nameSpaceID); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + nameSpaceID); if (nameSpaceID == kNameSpaceID_Unknown) return NS_ERROR_DOM_NOT_FOUND_ERR; diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index c88b9887e6b..55493531d57 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -529,7 +529,6 @@ nsDocument::nsDocument() : mSubDocuments(nsnull), mRootContent = nsnull; mListenerManager = nsnull; mInDestructor = PR_FALSE; - mNameSpaceManager = nsnull; mHeaderData = nsnull; mChildNodes = nsnull; mModCount = 0; @@ -620,8 +619,6 @@ nsDocument::~nsDocument() NS_RELEASE(mListenerManager); } - NS_IF_RELEASE(mNameSpaceManager); - if (mScriptLoader) { mScriptLoader->DropDocumentReference(); } @@ -694,7 +691,7 @@ NS_IMPL_RELEASE(nsDocument) nsresult nsDocument::Init() { - if (mNameSpaceManager) { + if (mArena) { return NS_ERROR_ALREADY_INITIALIZED; } @@ -703,13 +700,10 @@ nsresult nsDocument::Init() rv = NS_NewHeapArena(&mArena, nsnull); NS_ENSURE_SUCCESS(rv, rv); - rv = NS_NewNameSpaceManager(&mNameSpaceManager); - NS_ENSURE_SUCCESS(rv, rv); - mNodeInfoManager = new nsNodeInfoManager(); NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY); - mNodeInfoManager->Init(this, mNameSpaceManager); + mNodeInfoManager->Init(this); return rv; } @@ -756,8 +750,6 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) NS_IMETHODIMP nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup) { - nsresult rv = NS_OK; - mDocumentTitle.Truncate(); NS_IF_RELEASE(mDocumentURL); @@ -807,7 +799,6 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup) mStyleSheets.Clear(); NS_IF_RELEASE(mListenerManager); - NS_IF_RELEASE(mNameSpaceManager); mDOMStyleSheets = nsnull; // Release the stylesheets list. @@ -822,10 +813,7 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup) // load group, and it works just fine. } - if (NS_OK == rv) - rv = NS_NewNameSpaceManager(&mNameSpaceManager); - - return rv; + return NS_OK; } NS_IMETHODIMP @@ -1771,14 +1759,6 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) return NS_OK; } -NS_IMETHODIMP -nsDocument::GetNameSpaceManager(nsINameSpaceManager*& aManager) -{ - aManager = mNameSpaceManager; - NS_IF_ADDREF(aManager); - return NS_OK; -} - NS_IMETHODIMP nsDocument::GetScriptLoader(nsIScriptLoader** aScriptLoader) { @@ -2490,7 +2470,8 @@ nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI, nsCOMPtr list; if (!aNamespaceURI.Equals(NS_LITERAL_STRING("*"))) { - mNameSpaceManager->GetNameSpaceID(aNamespaceURI, nameSpaceId); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + nameSpaceId); if (nameSpaceId == kNameSpaceID_Unknown) { // Unkonwn namespace means no matches, we create an empty list... @@ -2877,7 +2858,7 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult) xblService->ResolveTag(content, &namespaceID, getter_AddRefs(tag)); nsCAutoString contractID("@mozilla.org/layout/xul-boxobject"); - if (namespaceID == nsXULAtoms::nameSpaceID) { + if (namespaceID == kNameSpaceID_XUL) { if (tag.get() == nsXULAtoms::browser) contractID += "-browser"; else if (tag.get() == nsXULAtoms::editor) diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 079b6179c46..4b1bce33558 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -453,11 +453,6 @@ public: NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject** aGlobalObject); NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject); - /** - * Get the name space manager for this document - */ - NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager); - /** * Get the script loader for this document */ @@ -645,7 +640,6 @@ protected: nsIEventListenerManager* mListenerManager; PRBool mInDestructor; nsCOMPtr mDOMStyleSheets; - nsINameSpaceManager* mNameSpaceManager; nsCOMPtr mScriptLoader; nsDocHeaderData* mHeaderData; nsCOMPtr mLineBreaker; diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 10727e61bfc..48857112c51 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -182,7 +182,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset #include "nsIDocument.h" #include "nsHTMLAtoms.h" #include "nsIHTMLContent.h" -#include "nsINameSpaceManager.h" #include "nsIWebShell.h" //focus diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 64eb27520fa..d8080ea1fe0 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -406,49 +406,10 @@ nsNode3Tearoff::LookupNamespacePrefix(const nsAString& aNamespaceURI, // XXX Waiting for DOM spec to list error codes. - nsCOMPtr manager; - nsCOMPtr ni; - - mContent->GetNodeInfo(*getter_AddRefs(ni)); - - if (!ni) { - // If there's no nodeinfo (i.e. mContent is a non-element node), - // check if the parent has nodeinfo - nsCOMPtr parent; - - mContent->GetParent(*getter_AddRefs(parent)); - - if (parent) { - parent->GetNodeInfo(*getter_AddRefs(ni)); - } - } - - if (ni) { - nsCOMPtr nimgr; - - ni->GetNodeInfoManager(*getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_UNEXPECTED); - - nimgr->GetNamespaceManager(*getter_AddRefs(manager)); - } - - // If there's no nodeinfo, get the manager from the document - if (!manager) { - nsCOMPtr doc; - mContent->GetDocument(*getter_AddRefs(doc)); - - if (doc) { - doc->GetNameSpaceManager(*getter_AddRefs(manager)); - } - } - - if (!manager) { - return NS_ERROR_UNEXPECTED; - } - // Get the namespace id for the URI PRInt32 namespaceId; - manager->GetNameSpaceID(aNamespaceURI, namespaceId); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + namespaceId); if (namespaceId == kNameSpaceID_Unknown) { return NS_OK; } @@ -1477,15 +1438,7 @@ nsGenericElement::GetAttributeNS(const nsAString& aNamespaceURI, nsCOMPtr name(dont_AddRef(NS_NewAtom(aLocalName))); PRInt32 nsid; - nsCOMPtr nimgr; - mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nsCOMPtr nsmgr; - nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr)); - NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE); - - nsmgr->GetNameSpaceID(aNamespaceURI, nsid); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); if (nsid == kNameSpaceID_Unknown) { // Unkonwn namespace means no attr... @@ -1524,15 +1477,7 @@ nsGenericElement::RemoveAttributeNS(const nsAString& aNamespaceURI, nsCOMPtr name(dont_AddRef(NS_NewAtom(aLocalName))); PRInt32 nsid; - nsCOMPtr nimgr; - mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nsCOMPtr nsmgr; - nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr)); - NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE); - - nsmgr->GetNameSpaceID(aNamespaceURI, nsid); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); if (nsid == kNameSpaceID_Unknown) { // Unkonwn namespace means no attr... @@ -1606,15 +1551,8 @@ nsGenericElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI, nsCOMPtr list; if (!aNamespaceURI.Equals(NS_LITERAL_STRING("*"))) { - nsCOMPtr nimgr; - mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nsCOMPtr nsmgr; - nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr)); - NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE); - - nsmgr->GetNameSpaceID(aNamespaceURI, nameSpaceId); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + nameSpaceId); if (nameSpaceId == kNameSpaceID_Unknown) { // Unknown namespace means no matches, we create an empty list... @@ -1662,15 +1600,7 @@ nsGenericElement::HasAttributeNS(const nsAString& aNamespaceURI, nsCOMPtr name(dont_AddRef(NS_NewAtom(aLocalName))); PRInt32 nsid; - nsCOMPtr nimgr; - mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nsCOMPtr nsmgr; - nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr)); - NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE); - - nsmgr->GetNameSpaceID(aNamespaceURI, nsid); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); if (nsid == kNameSpaceID_Unknown) { // Unkonwn namespace means no attr... diff --git a/mozilla/content/base/src/nsNameSpaceManager.cpp b/mozilla/content/base/src/nsNameSpaceManager.cpp index 2f079b41491..64b3c226498 100644 --- a/mozilla/content/base/src/nsNameSpaceManager.cpp +++ b/mozilla/content/base/src/nsNameSpaceManager.cpp @@ -38,156 +38,47 @@ #include "nscore.h" #include "nsINameSpaceManager.h" #include "nsINameSpace.h" -#include "nsISupportsArray.h" +#include "nsCOMArray.h" #include "nsIElementFactory.h" #include "nsIServiceManager.h" -#include "nsHashtable.h" +#include "nsDoubleHashtable.h" #include "nsVoidArray.h" #include "nsLayoutAtoms.h" #include "nsString.h" #include "nsCRT.h" #include "nsContentCID.h" +#include "rdf.h" +static nsINameSpaceManager* gNameSpaceManager = nsnull; extern nsresult NS_NewXMLElementFactory(nsIElementFactory** aResult); -static const char kXMLNSNameSpaceURI[] = "http://www.w3.org/2000/xmlns/"; -static const char kXMLNameSpaceURI[] = "http://www.w3.org/XML/1998/namespace"; -static const char kXHTMLNameSpaceURI[] = "http://www.w3.org/1999/xhtml"; -static const char kXLinkNameSpaceURI[] = "http://www.w3.org/1999/xlink"; -static const char kXSLTNameSpaceURI[] = "http://www.w3.org/1999/XSL/Transform"; -static const char kXBLNameSpaceURI[] = "http://www.mozilla.org/xbl"; -static const char kMathMLNameSpaceURI[] = "http://www.w3.org/1998/Math/MathML"; - -//----------------------------------------------------------- -// Name Space ID table support - -static PRBool gNameSpaceManagerIsInitialized = PR_FALSE; -static nsHashtable* gURIToIDTable; -static nsVoidArray* gURIArray; -static nsISupportsArray* gElementFactoryArray; -static nsIElementFactory* gDefaultElementFactory; - -#ifdef NS_DEBUG -static PRBool gNameSpaceManagerWasShutDown = PR_FALSE; -#endif - -static void InitializeNameSpaceManager() -{ - if (gNameSpaceManagerIsInitialized) { - return; - } - - NS_ASSERTION(!gURIToIDTable, "already have URI table"); - NS_ASSERTION(!gURIArray, "already have URI array"); - - gURIToIDTable = new nsHashtable(); - gURIArray = new nsVoidArray(); - - nsString* xmlns = new nsString(NS_ConvertASCIItoUCS2(kXMLNSNameSpaceURI)); - nsString* xml = new nsString(NS_ConvertASCIItoUCS2(kXMLNameSpaceURI)); - nsString* xhtml = new nsString(NS_ConvertASCIItoUCS2(kXHTMLNameSpaceURI)); - nsString* xlink = new nsString(NS_ConvertASCIItoUCS2(kXLinkNameSpaceURI)); - nsString* xslt = new nsString(NS_ConvertASCIItoUCS2(kXSLTNameSpaceURI)); - nsString* xbl = new nsString(NS_ConvertASCIItoUCS2(kXBLNameSpaceURI)); - nsString* mathml = new nsString(NS_ConvertASCIItoUCS2(kMathMLNameSpaceURI)); - - gURIArray->AppendElement(xmlns); // ordering here needs to match IDs - gURIArray->AppendElement(xml); - gURIArray->AppendElement(xhtml); - gURIArray->AppendElement(xlink); - gURIArray->AppendElement(xslt); - gURIArray->AppendElement(xbl); - gURIArray->AppendElement(mathml); - - nsStringKey xmlnsKey(*xmlns); - nsStringKey xmlKey(*xml); - nsStringKey xhtmlKey(*xhtml); - nsStringKey xlinkKey(*xlink); - nsStringKey xsltKey(*xslt); - nsStringKey xblKey(*xbl); - nsStringKey mathmlKey(*mathml); - - gURIToIDTable->Put(&xmlnsKey, NS_INT32_TO_PTR(kNameSpaceID_XMLNS)); - gURIToIDTable->Put(&xmlKey, NS_INT32_TO_PTR(kNameSpaceID_XML)); - gURIToIDTable->Put(&xhtmlKey, NS_INT32_TO_PTR(kNameSpaceID_XHTML)); - gURIToIDTable->Put(&xlinkKey, NS_INT32_TO_PTR(kNameSpaceID_XLink)); - gURIToIDTable->Put(&xsltKey, NS_INT32_TO_PTR(kNameSpaceID_XSLT)); - gURIToIDTable->Put(&xblKey, NS_INT32_TO_PTR(kNameSpaceID_XBL)); - gURIToIDTable->Put(&mathmlKey, NS_INT32_TO_PTR(kNameSpaceID_MathML)); - - NS_NewISupportsArray(&gElementFactoryArray); - NS_NewXMLElementFactory(&gDefaultElementFactory); - - NS_ASSERTION(gURIToIDTable, "no URI table"); - NS_ASSERTION(gURIArray, "no URI array"); - NS_ASSERTION(gElementFactoryArray, "no element factory array"); - - gNameSpaceManagerIsInitialized = PR_TRUE; -} - -void NS_NameSpaceManagerShutdown() -{ - delete gURIToIDTable; - PRInt32 index = gURIArray->Count(); - while (0 < index--) { - nsString* str = (nsString*)gURIArray->ElementAt(index); - delete str; - } - delete gURIArray; - gURIToIDTable = nsnull; - gURIArray = nsnull; - - NS_IF_RELEASE(gElementFactoryArray); - NS_IF_RELEASE(gDefaultElementFactory); - -#ifdef NS_DEBUG - gNameSpaceManagerWasShutDown = PR_TRUE; -#endif -} - -static PRInt32 FindNameSpaceID(const nsAString& aURI) -{ - if (aURI.IsEmpty()) { - return kNameSpaceID_None; // xmlns="", see bug 75700 for details - } - - NS_ASSERTION(gURIToIDTable, "no URI table"); - const nsPromiseFlatString& flatString = PromiseFlatString(aURI); - nsStringKey key(flatString); - void* value = gURIToIDTable->Get(&key); - if (value) { - return NS_PTR_TO_INT32(value); - } - - return kNameSpaceID_Unknown; -} - -static const nsString* FindNameSpaceURI(PRInt32 aID) -{ - NS_ASSERTION(gURIArray, "no URI array"); - return (const nsString*)gURIArray->SafeElementAt(aID - 1); -} +#define kXMLNSNameSpaceURI "http://www.w3.org/2000/xmlns/" +#define kXMLNameSpaceURI "http://www.w3.org/XML/1998/namespace" +#define kXHTMLNameSpaceURI "http://www.w3.org/1999/xhtml" +#define kXLinkNameSpaceURI "http://www.w3.org/1999/xlink" +#define kXSLTNameSpaceURI "http://www.w3.org/1999/XSL/Transform" +#define kXBLNameSpaceURI "http://www.mozilla.org/xbl" +#define kMathMLNameSpaceURI "http://www.w3.org/1998/Math/MathML" +#define kRDFNameSpaceURI RDF_NAMESPACE_URI +#define kXULNameSpaceURI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" +#define kSVGNameSpaceURI "http://www.w3.org/2000/svg" //----------------------------------------------------------- // Name Space class NameSpaceImpl : public nsINameSpace { public: - NameSpaceImpl(nsINameSpaceManager* aManager, - NameSpaceImpl* aParent, + NameSpaceImpl(NameSpaceImpl* aParent, nsIAtom* aPrefix, const nsAString& aURI); - NameSpaceImpl(nsINameSpaceManager* aManager, - NameSpaceImpl* aParent, + NameSpaceImpl(NameSpaceImpl* aParent, nsIAtom* aPrefix, PRInt32 aNameSpaceID); virtual ~NameSpaceImpl(); NS_DECL_ISUPPORTS - NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) const; - NS_IMETHOD GetNameSpaceID(PRInt32& aID) const; NS_IMETHOD GetNameSpaceURI(nsAString& aURI) const; NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aPrefix) const; @@ -208,75 +99,47 @@ private: NameSpaceImpl(const NameSpaceImpl& aCopy); NameSpaceImpl& operator=(const NameSpaceImpl& aCopy); -public: - nsINameSpaceManager* mManager; - NameSpaceImpl* mParent; - nsIAtom* mPrefix; - PRInt32 mID; + nsCOMPtr mParent; + nsCOMPtr mPrefix; + PRInt32 mID; }; -NameSpaceImpl::NameSpaceImpl(nsINameSpaceManager* aManager, - NameSpaceImpl* aParent, +NameSpaceImpl::NameSpaceImpl(NameSpaceImpl* aParent, nsIAtom* aPrefix, const nsAString& aURI) - : mManager(aManager), - mParent(aParent), + : mParent(aParent), mPrefix(aPrefix) { - NS_ASSERTION(aManager, "null namespace manager"); - NS_INIT_ISUPPORTS(); - NS_ADDREF(mManager); - NS_IF_ADDREF(mParent); - NS_IF_ADDREF(mPrefix); - mManager->RegisterNameSpace(aURI, mID); + gNameSpaceManager->RegisterNameSpace(aURI, mID); } -NameSpaceImpl::NameSpaceImpl(nsINameSpaceManager* aManager, - NameSpaceImpl* aParent, +NameSpaceImpl::NameSpaceImpl(NameSpaceImpl* aParent, nsIAtom* aPrefix, PRInt32 aNameSpaceID) - : mManager(aManager), - mParent(aParent), + : mParent(aParent), mPrefix(aPrefix), mID(aNameSpaceID) { - NS_ASSERTION(aManager, "null namespace manager"); - NS_INIT_ISUPPORTS(); - NS_ADDREF(mManager); - NS_IF_ADDREF(mParent); - NS_IF_ADDREF(mPrefix); } NameSpaceImpl::~NameSpaceImpl() { - NS_RELEASE(mManager); - NS_IF_RELEASE(mParent); - NS_IF_RELEASE(mPrefix); } NS_IMPL_ISUPPORTS1(NameSpaceImpl, nsINameSpace) -NS_IMETHODIMP -NameSpaceImpl::GetNameSpaceManager(nsINameSpaceManager*& aManager) const -{ - NS_ASSERTION(aManager, "null namespace manager"); - aManager = mManager; - NS_ADDREF(aManager); - return NS_OK; -} - NS_IMETHODIMP NameSpaceImpl::GetNameSpaceID(PRInt32& aID) const { aID = mID; + return NS_OK; } NS_IMETHODIMP NameSpaceImpl::GetNameSpaceURI(nsAString& aURI) const { - NS_ASSERTION(mManager, "null namespace manager"); - return mManager->GetNameSpaceURI(mID, aURI); + return gNameSpaceManager->GetNameSpaceURI(mID, aURI); } NS_IMETHODIMP @@ -284,6 +147,7 @@ NameSpaceImpl::GetNameSpacePrefix(nsIAtom*& aPrefix) const { aPrefix = mPrefix; NS_IF_ADDREF(aPrefix); + return NS_OK; } @@ -292,34 +156,39 @@ NameSpaceImpl::GetParentNameSpace(nsINameSpace*& aParent) const { aParent = mParent; NS_IF_ADDREF(aParent); + return NS_OK; } NS_IMETHODIMP NameSpaceImpl::FindNameSpace(nsIAtom* aPrefix, nsINameSpace*& aNameSpace) const { - const NameSpaceImpl* nameSpace = this; + const NameSpaceImpl* nameSpace = this; do { if (aPrefix == nameSpace->mPrefix) { aNameSpace = (nsINameSpace*)nameSpace; NS_ADDREF(aNameSpace); + return NS_OK; } nameSpace = nameSpace->mParent; } while (nameSpace); aNameSpace = nsnull; + return NS_ERROR_ILLEGAL_VALUE; } NS_IMETHODIMP NameSpaceImpl::FindNameSpaceID(nsIAtom* aPrefix, PRInt32& aNameSpaceID) const { - const NameSpaceImpl* nameSpace = this; + const NameSpaceImpl* nameSpace = this; + do { if (aPrefix == nameSpace->mPrefix) { aNameSpaceID = nameSpace->mID; + return NS_OK; } nameSpace = nameSpace->mParent; @@ -331,57 +200,107 @@ NameSpaceImpl::FindNameSpaceID(nsIAtom* aPrefix, PRInt32& aNameSpaceID) const else { aNameSpaceID = kNameSpaceID_Unknown; } + return NS_ERROR_ILLEGAL_VALUE; } NS_IMETHODIMP NameSpaceImpl::FindNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix) const { - const NameSpaceImpl* nameSpace = this; + const NameSpaceImpl* nameSpace = this; do { if (aNameSpaceID == nameSpace->mID) { aPrefix = nameSpace->mPrefix; NS_IF_ADDREF(aPrefix); + return NS_OK; } nameSpace = nameSpace->mParent; } while (nameSpace); aPrefix = nsnull; + return NS_ERROR_ILLEGAL_VALUE; } NS_IMETHODIMP NameSpaceImpl::CreateChildNameSpace(nsIAtom* aPrefix, const nsAString& aURI, - nsINameSpace*& aChildNameSpace) + nsINameSpace*& aChildNameSpace) { - NameSpaceImpl* child = new NameSpaceImpl(mManager, this, aPrefix, aURI); + NameSpaceImpl* child = new NameSpaceImpl(this, aPrefix, aURI); + NS_ENSURE_TRUE(child, NS_ERROR_OUT_OF_MEMORY); - if (child) { - return child->QueryInterface(NS_GET_IID(nsINameSpace), (void**)&aChildNameSpace); - } - aChildNameSpace = nsnull; - return NS_ERROR_OUT_OF_MEMORY; + aChildNameSpace = NS_STATIC_CAST(nsINameSpace*, child); + NS_ADDREF(aChildNameSpace); + + return NS_OK; } NS_IMETHODIMP NameSpaceImpl::CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID, - nsINameSpace*& aChildNameSpace) + nsINameSpace*& aChildNameSpace) { - if (FindNameSpaceURI(aNameSpaceID)) { - NameSpaceImpl* child = new NameSpaceImpl(mManager, this, aPrefix, aNameSpaceID); + PRBool hasNSURI; + gNameSpaceManager->HasNameSpaceURI(aNameSpaceID, &hasNSURI); + if (hasNSURI) { + NameSpaceImpl* child = new NameSpaceImpl(this, aPrefix, aNameSpaceID); + NS_ENSURE_TRUE(child, NS_ERROR_OUT_OF_MEMORY); - if (child) { - return child->QueryInterface(NS_GET_IID(nsINameSpace), (void**)&aChildNameSpace); - } - aChildNameSpace = nsnull; - return NS_ERROR_OUT_OF_MEMORY; + aChildNameSpace = NS_STATIC_CAST(nsINameSpace*, child); + NS_ADDREF(aChildNameSpace); + + return NS_OK; } aChildNameSpace = nsnull; + return NS_ERROR_ILLEGAL_VALUE; } +class nsNameSpaceEntry : public PLDHashEntryHdr +{ +public: + nsNameSpaceEntry(const void* aKey) : + mKey(NS_STATIC_CAST(const nsAString*, aKey)) + { + } + ~nsNameSpaceEntry() + { + } + const void* GetKey() const { + return mKey; + } + static PLDHashNumber HashKey(const void* aKey) { + return HashString(*NS_STATIC_CAST(const nsAString*, aKey)); + } + PRBool MatchEntry(const void* aKey) const { + return NS_STATIC_CAST(const nsAString*, aKey)->Equals(*mKey); + } + + const nsAString* mKey; + PRInt32 mNameSpaceID; +}; + +DECL_DHASH_WRAPPER(nsNameSpaceHashBase, nsNameSpaceEntry, nsAString&) +DHASH_WRAPPER(nsNameSpaceHashBase, nsNameSpaceEntry, nsAString&) + +class nsNameSpaceHash : public nsNameSpaceHashBase +{ +public: + nsNameSpaceHash() + { + } + ~nsNameSpaceHash() + { + } + nsNameSpaceEntry* LookupEntry(const nsAString& aUri) + { + return NS_STATIC_CAST(nsNameSpaceEntry*, + PL_DHashTableOperate(&mHashTable, &aUri, + PL_DHASH_LOOKUP)); + } +}; + //----------------------------------------------------------- // Name Space Manager @@ -391,6 +310,8 @@ public: NS_DECL_ISUPPORTS + nsresult Init(); + NS_IMETHOD CreateRootNameSpace(nsINameSpace*& aRootNameSpace); NS_IMETHOD RegisterNameSpace(const nsAString& aURI, @@ -403,24 +324,26 @@ public: nsIElementFactory **aElementFactory); NS_IMETHOD HasRegisteredFactory(PRInt32 aNameSpaceID, PRBool* aHasFactory); + NS_IMETHOD HasNameSpaceURI(PRInt32 aNameSpaceID, + PRBool* aHasNameSpaceURI); + private: // These are not supported and are not implemented! NameSpaceManagerImpl(const NameSpaceManagerImpl& aCopy); NameSpaceManagerImpl& operator=(const NameSpaceManagerImpl& aCopy); -protected: - virtual ~NameSpaceManagerImpl(); + nsresult AddNameSpace(const nsAString& aURI, const PRInt32 aNameSpaceID); + nsNameSpaceHash mURIToIDTable; + nsStringArray mURIArray; + nsCOMArray mElementFactoryArray; + nsCOMPtr mDefaultElementFactory; + + virtual ~NameSpaceManagerImpl(); }; NameSpaceManagerImpl::NameSpaceManagerImpl() { - NS_ASSERTION(!gNameSpaceManagerWasShutDown, - "Namespace manager used past content module shutdown!!!"); - - NS_INIT_ISUPPORTS(); - - InitializeNameSpaceManager(); } NameSpaceManagerImpl::~NameSpaceManagerImpl() @@ -429,20 +352,37 @@ NameSpaceManagerImpl::~NameSpaceManagerImpl() NS_IMPL_ISUPPORTS1(NameSpaceManagerImpl, nsINameSpaceManager) +nsresult NameSpaceManagerImpl::Init() +{ + nsresult rv = mURIToIDTable.Init(32); + NS_ENSURE_SUCCESS(rv, rv); + + // Need to be ordered according to ID. + AddNameSpace(NS_LITERAL_STRING(kXMLNSNameSpaceURI), kNameSpaceID_XMLNS); + AddNameSpace(NS_LITERAL_STRING(kXMLNameSpaceURI), kNameSpaceID_XML); + AddNameSpace(NS_LITERAL_STRING(kXHTMLNameSpaceURI), kNameSpaceID_XHTML); + AddNameSpace(NS_LITERAL_STRING(kXLinkNameSpaceURI), kNameSpaceID_XLink); + AddNameSpace(NS_LITERAL_STRING(kXSLTNameSpaceURI), kNameSpaceID_XSLT); + AddNameSpace(NS_LITERAL_STRING(kXBLNameSpaceURI), kNameSpaceID_XBL); + AddNameSpace(NS_LITERAL_STRING(kMathMLNameSpaceURI), kNameSpaceID_MathML); + AddNameSpace(NS_LITERAL_STRING(kRDFNameSpaceURI), kNameSpaceID_RDF); + AddNameSpace(NS_LITERAL_STRING(kXULNameSpaceURI), kNameSpaceID_XUL); + AddNameSpace(NS_LITERAL_STRING(kSVGNameSpaceURI), kNameSpaceID_SVG); + + return NS_NewXMLElementFactory(getter_AddRefs(mDefaultElementFactory)); +} + NS_IMETHODIMP NameSpaceManagerImpl::CreateRootNameSpace(nsINameSpace*& aRootNameSpace) { - NS_ASSERTION(!gNameSpaceManagerWasShutDown, - "Namespace manager used past content module shutdown!!!"); - nsresult rv = NS_ERROR_OUT_OF_MEMORY; aRootNameSpace = nsnull; - NameSpaceImpl* xmlns = new NameSpaceImpl(this, nsnull, + NameSpaceImpl* xmlns = new NameSpaceImpl(nsnull, nsLayoutAtoms::xmlnsNameSpace, kNameSpaceID_XMLNS); - if (nsnull != xmlns) { - NameSpaceImpl* xml = new NameSpaceImpl(this, xmlns, + if (xmlns) { + NameSpaceImpl* xml = new NameSpaceImpl(xmlns, nsLayoutAtoms::xmlNameSpace, kNameSpaceID_XML); if (xml) { @@ -452,6 +392,7 @@ NameSpaceManagerImpl::CreateRootNameSpace(nsINameSpace*& aRootNameSpace) delete xmlns; } } + return rv; } @@ -459,47 +400,57 @@ NS_IMETHODIMP NameSpaceManagerImpl::RegisterNameSpace(const nsAString& aURI, PRInt32& aNameSpaceID) { - NS_ASSERTION(!gNameSpaceManagerWasShutDown, - "Namespace manager used past content module shutdown!!!"); + if (aURI.IsEmpty()) { + aNameSpaceID = kNameSpaceID_None; // xmlns="", see bug 75700 for details - PRInt32 id = FindNameSpaceID(aURI); - - if (kNameSpaceID_Unknown == id) { - nsString* uri = new nsString(aURI); - if (!uri) - return NS_ERROR_OUT_OF_MEMORY; - gURIArray->AppendElement(uri); - id = gURIArray->Count(); // id is index + 1 - nsStringKey key(*uri); - gURIToIDTable->Put(&key, (void*)id); + return NS_OK; } - - aNameSpaceID = id; - return NS_OK; + + nsNameSpaceEntry* entry = mURIToIDTable.GetEntry(aURI); + if (entry) { + aNameSpaceID = entry->mNameSpaceID; + + return NS_OK; + } + + aNameSpaceID = mURIArray.Count() + 1; // id is index + 1 + + nsresult rv = AddNameSpace(aURI, aNameSpaceID); + if (NS_FAILED(rv)) { + aNameSpaceID = kNameSpaceID_Unknown; + } + + return rv; } NS_IMETHODIMP NameSpaceManagerImpl::GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI) { - NS_ASSERTION(!gNameSpaceManagerWasShutDown, - "Namespace manager used past content module shutdown!!!"); + PRInt32 index = aNameSpaceID - 1; // id is index + 1 + if (index < 0 || index >= mURIArray.Count()) { + aURI.Truncate(); - const nsString* result = FindNameSpaceURI(aNameSpaceID); - if (result) { - aURI = *result; - return NS_OK; + return NS_ERROR_ILLEGAL_VALUE; } - aURI.Truncate(); - return NS_ERROR_ILLEGAL_VALUE; + + mURIArray.StringAt(index, aURI); + + return NS_OK; } NS_IMETHODIMP NameSpaceManagerImpl::GetNameSpaceID(const nsAString& aURI, PRInt32& aNameSpaceID) { - NS_ASSERTION(!gNameSpaceManagerWasShutDown, - "Namespace manager used past content module shutdown!!!"); + if (aURI.IsEmpty()) { + aNameSpaceID = kNameSpaceID_None; // xmlns="", see bug 75700 for details + + return NS_OK; + } + + nsNameSpaceEntry* entry = mURIToIDTable.GetEntry(aURI); + + aNameSpaceID = entry ? entry->mNameSpaceID : kNameSpaceID_Unknown; - aNameSpaceID = FindNameSpaceID(aURI); return NS_OK; } @@ -507,24 +458,20 @@ NS_IMETHODIMP NameSpaceManagerImpl::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory **aElementFactory) { - NS_ASSERTION(!gNameSpaceManagerWasShutDown, - "Namespace manager used past content module shutdown!!!"); - *aElementFactory = nsnull; - NS_ENSURE_TRUE(gElementFactoryArray, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(aNameSpaceID >= 0, NS_ERROR_ILLEGAL_VALUE); - gElementFactoryArray->QueryElementAt(aNameSpaceID, - NS_GET_IID(nsIElementFactory), - (void **)aElementFactory); + if (aNameSpaceID < mElementFactoryArray.Count()) { + *aElementFactory = mElementFactoryArray.ObjectAt(aNameSpaceID); + if (*aElementFactory) { + NS_ADDREF(*aElementFactory); - if (*aElementFactory) { - return NS_OK; + return NS_OK; + } } nsAutoString uri; - GetNameSpaceURI(aNameSpaceID, uri); nsCOMPtr ef; @@ -532,29 +479,27 @@ NameSpaceManagerImpl::GetElementFactory(PRInt32 aNameSpaceID, if (!uri.IsEmpty()) { nsCAutoString contract_id(NS_ELEMENT_FACTORY_CONTRACTID_PREFIX); contract_id.Append(NS_ConvertUCS2toUTF8(uri)); - ef = do_GetService(contract_id.get()); } if (!ef) { - ef = gDefaultElementFactory; + ef = mDefaultElementFactory; } - PRUint32 count = 0; - gElementFactoryArray->Count(&count); + PRInt32 count = mElementFactoryArray.Count(); - if ((PRUint32)aNameSpaceID < count) { - gElementFactoryArray->ReplaceElementAt(ef, aNameSpaceID); + if (aNameSpaceID < count) { + mElementFactoryArray.ReplaceObjectAt(ef, aNameSpaceID); } else { - // This sucks, simply doing an InsertElementAt() should IMNSHO + // This sucks, simply doing an InsertObjectAt() should IMNSHO // automatically grow the array and insert null's as needed to // fill up the array!?!! - - for (PRInt32 i = count; i < aNameSpaceID; i++) { - gElementFactoryArray->AppendElement(nsnull); + + for (PRInt32 i = count; i < aNameSpaceID; ++i) { + mElementFactoryArray.AppendObject(nsnull); } - gElementFactoryArray->AppendElement(ef); + mElementFactoryArray.AppendObject(ef); } *aElementFactory = ef; @@ -568,25 +513,74 @@ NameSpaceManagerImpl::HasRegisteredFactory(PRInt32 aNameSpaceID, PRBool* aHasFactory) { *aHasFactory = PR_FALSE; + NS_ENSURE_TRUE(mDefaultElementFactory, NS_ERROR_FAILURE); + nsCOMPtr ef; GetElementFactory(aNameSpaceID, getter_AddRefs(ef)); - NS_ENSURE_TRUE(gDefaultElementFactory, NS_ERROR_FAILURE); - *aHasFactory = ef != gDefaultElementFactory; + *aHasFactory = ef != mDefaultElementFactory; + + return NS_OK; +} + +NS_IMETHODIMP +NameSpaceManagerImpl::HasNameSpaceURI(PRInt32 aNameSpaceID, + PRBool* aHasNameSpaceURI) +{ + *aHasNameSpaceURI = (aNameSpaceID > kNameSpaceID_None || + aNameSpaceID <= mURIArray.Count()); + + return NS_OK; +} + +nsresult NameSpaceManagerImpl::AddNameSpace(const nsAString& aURI, + const PRInt32 aNameSpaceID) +{ + NS_ASSERTION(aNameSpaceID - 1 == mURIArray.Count(), + "BAD! AddNameSpace not called in right order!"); + + if (!mURIArray.AppendString(aURI)) { + return NS_ERROR_OUT_OF_MEMORY; + } + + const nsString* uri = mURIArray.StringAt(aNameSpaceID - 1); + nsNameSpaceEntry* entry = mURIToIDTable.AddEntry(*uri); + if (!entry) { + mURIArray.RemoveStringAt(aNameSpaceID - 1); + + return NS_ERROR_OUT_OF_MEMORY; + } + + entry->mNameSpaceID = aNameSpaceID; + return NS_OK; } nsresult -NS_NewNameSpaceManager(nsINameSpaceManager** aInstancePtrResult) +NS_GetNameSpaceManager(nsINameSpaceManager** aInstancePtrResult) { NS_ENSURE_ARG_POINTER(aInstancePtrResult); - *aInstancePtrResult = new NameSpaceManagerImpl(); - - if (!*aInstancePtrResult) { - return NS_ERROR_OUT_OF_MEMORY; + if (!gNameSpaceManager) { + nsCOMPtr manager = new NameSpaceManagerImpl(); + if (manager) { + nsresult rv = manager->Init(); + if (NS_SUCCEEDED(rv)) { + gNameSpaceManager = manager; + NS_ADDREF(gNameSpaceManager); + } + } } + *aInstancePtrResult = gNameSpaceManager; + NS_ENSURE_TRUE(gNameSpaceManager, NS_ERROR_OUT_OF_MEMORY); + NS_ADDREF(*aInstancePtrResult); return NS_OK; } + +void +NS_NameSpaceManagerShutdown() +{ + NS_IF_RELEASE(gNameSpaceManager); +} diff --git a/mozilla/content/base/src/nsNodeInfo.cpp b/mozilla/content/base/src/nsNodeInfo.cpp index b3235a0aac2..0e157a14071 100644 --- a/mozilla/content/base/src/nsNodeInfo.cpp +++ b/mozilla/content/base/src/nsNodeInfo.cpp @@ -42,10 +42,9 @@ #include "nsCOMPtr.h" #include "nsString.h" #include "nsIAtom.h" -#include "nsINameSpaceManager.h" #include "domstubs.h" // for SetDOMStringToNull(); #include "nsCRT.h" - +#include "nsContentUtils.h" nsNodeInfo::nsNodeInfo() : nsINodeInfo(), mOwnerManager(nsnull) @@ -140,12 +139,8 @@ nsNodeInfo::GetNamespaceURI(nsAString& aNameSpaceURI) const nsresult rv = NS_OK; if (mInner.mNamespaceID > 0) { - nsCOMPtr nsm; - - mOwnerManager->GetNamespaceManager(*getter_AddRefs(nsm)); - NS_ENSURE_TRUE(nsm, NS_ERROR_NOT_INITIALIZED); - - rv = nsm->GetNameSpaceURI(mInner.mNamespaceID, aNameSpaceURI); + rv = nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceURI(mInner.mNamespaceID, + aNameSpaceURI); } else { SetDOMStringToNull(aNameSpaceURI); } @@ -245,13 +240,8 @@ nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix, NS_IMETHODIMP_(PRBool) nsNodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const { - nsCOMPtr nsmgr; - - NS_ENSURE_SUCCESS(mOwnerManager->GetNamespaceManager(*getter_AddRefs(nsmgr)), - NS_ERROR_NOT_INITIALIZED); - PRInt32 nsid; - nsmgr->GetNameSpaceID(aNamespaceURI, nsid); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); return nsINodeInfo::NamespaceEquals(nsid); } diff --git a/mozilla/content/base/src/nsNodeInfo.h b/mozilla/content/base/src/nsNodeInfo.h index aeeed079f40..30772dbb984 100644 --- a/mozilla/content/base/src/nsNodeInfo.h +++ b/mozilla/content/base/src/nsNodeInfo.h @@ -40,7 +40,6 @@ #define nsNodeInfo_h___ #include "nsINodeInfo.h" -#include "nsINameSpaceManager.h" #include "plhash.h" #include "nsIAtom.h" #include "nsCOMPtr.h" diff --git a/mozilla/content/base/src/nsNodeInfoManager.cpp b/mozilla/content/base/src/nsNodeInfoManager.cpp index c3bd6019af4..c38a361b616 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.cpp +++ b/mozilla/content/base/src/nsNodeInfoManager.cpp @@ -44,6 +44,7 @@ #include "nsIDocument.h" #include "nsIPrincipal.h" #include "nsISupportsArray.h" +#include "nsContentUtils.h" nsNodeInfoManager* nsNodeInfoManager::gAnonymousNodeInfoManager = nsnull; PRUint32 nsNodeInfoManager::gNodeManagerCount = 0; @@ -148,14 +149,11 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsNodeInfoManager, nsINodeInfoManager); // nsINodeInfoManager NS_IMETHODIMP -nsNodeInfoManager::Init(nsIDocument *aDocument, - nsINameSpaceManager *aNameSpaceManager) +nsNodeInfoManager::Init(nsIDocument *aDocument) { - NS_ENSURE_ARG_POINTER(aNameSpaceManager); NS_ENSURE_TRUE(mNodeInfoHash, NS_ERROR_OUT_OF_MEMORY); mDocument = aDocument; - mNameSpaceManager = aNameSpaceManager; if (aDocument) { mPrincipal = nsnull; } @@ -274,12 +272,8 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); } - if (!mNameSpaceManager) { - return NS_ERROR_NOT_INITIALIZED; - } - PRInt32 nsid; - nsresult rv = mNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsid); + nsresult rv = nsContentUtils::GetNSManagerWeakRef()->RegisterNameSpace(aNamespaceURI, nsid); NS_ENSURE_SUCCESS(rv, rv); return GetNodeInfo(name, prefix, nsid, aNodeInfo); @@ -314,27 +308,13 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName, PRInt32 nsid = kNameSpaceID_None; if (!aNamespaceURI.IsEmpty()) { - NS_ENSURE_TRUE(mNameSpaceManager, NS_ERROR_NOT_INITIALIZED); - - nsresult rv = mNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsid); + nsresult rv = nsContentUtils::GetNSManagerWeakRef()->RegisterNameSpace(aNamespaceURI, nsid); NS_ENSURE_SUCCESS(rv, rv); } return GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo); } - -NS_IMETHODIMP -nsNodeInfoManager::GetNamespaceManager(nsINameSpaceManager*& aNameSpaceManager) -{ - NS_ENSURE_TRUE(mNameSpaceManager, NS_ERROR_NOT_INITIALIZED); - - aNameSpaceManager = mNameSpaceManager; - NS_ADDREF(aNameSpaceManager); - - return NS_OK; -} - NS_IMETHODIMP nsNodeInfoManager::GetDocument(nsIDocument*& aDocument) { @@ -437,14 +417,6 @@ nsNodeInfoManager::GetAnonymousManager(nsINodeInfoManager*& aNodeInfoManager) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(gAnonymousNodeInfoManager); - - nsresult rv = NS_NewNameSpaceManager(getter_AddRefs(gAnonymousNodeInfoManager->mNameSpaceManager)); - - if (NS_FAILED(rv)) { - NS_RELEASE(gAnonymousNodeInfoManager); - - return rv; - } } aNodeInfoManager = gAnonymousNodeInfoManager; diff --git a/mozilla/content/base/src/nsNodeInfoManager.h b/mozilla/content/base/src/nsNodeInfoManager.h index 32c676ee268..a991fc7ff77 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.h +++ b/mozilla/content/base/src/nsNodeInfoManager.h @@ -40,7 +40,6 @@ #define nsNodeInfoManager_h___ #include "nsINodeInfo.h" -#include "nsINameSpaceManager.h" #include "nsCOMPtr.h" #include "plhash.h" #include "nsIURI.h" @@ -55,8 +54,7 @@ public: NS_DECL_ISUPPORTS // nsINodeInfoManager - NS_IMETHOD Init(nsIDocument *aDocument, - nsINameSpaceManager *aNameSpaceManager); + NS_IMETHOD Init(nsIDocument *aDocument); NS_IMETHOD DropDocumentReference(); NS_IMETHOD GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo); @@ -70,7 +68,6 @@ public: NS_IMETHOD GetNodeInfo(const nsAString& aQualifiedName, const nsAString& aNamespaceURI, nsINodeInfo*& aNodeInfo); - NS_IMETHOD GetNamespaceManager(nsINameSpaceManager*& aNameSpaceManager); NS_IMETHOD GetDocument(nsIDocument*& aDocument); NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aPrincipal); NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal); @@ -94,7 +91,6 @@ private: void* arg); PLHashTable *mNodeInfoHash; - nsCOMPtr mNameSpaceManager; nsIDocument *mDocument; // WEAK nsCOMPtr mPrincipal; diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 60cf6e82476..a4f8db75636 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -107,7 +107,6 @@ static const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprom #include "nsIDocument.h" #include "nsHTMLAtoms.h" #include "nsIHTMLContent.h" -#include "nsINameSpaceManager.h" #include "nsIWebShell.h" // Focus diff --git a/mozilla/content/base/src/nsScriptLoader.cpp b/mozilla/content/base/src/nsScriptLoader.cpp index 9f2c640148e..fa96a4a0c4e 100644 --- a/mozilla/content/base/src/nsScriptLoader.cpp +++ b/mozilla/content/base/src/nsScriptLoader.cpp @@ -34,7 +34,6 @@ #include "nsIScriptGlobalObject.h" #include "nsIScriptContext.h" #include "nsINodeInfo.h" -#include "nsINameSpaceManager.h" #include "nsIScriptSecurityManager.h" #include "nsIPrincipal.h" #include "nsContentPolicyUtils.h" diff --git a/mozilla/content/base/src/nsXMLContentSerializer.cpp b/mozilla/content/base/src/nsXMLContentSerializer.cpp index fa3b3e57174..c6cec5fc3a1 100644 --- a/mozilla/content/base/src/nsXMLContentSerializer.cpp +++ b/mozilla/content/base/src/nsXMLContentSerializer.cpp @@ -56,6 +56,7 @@ #include "nsUnicharUtils.h" #include "nsCRT.h" #include "nsIXMLDocument.h" +#include "nsContentUtils.h" typedef struct { nsString mPrefix; @@ -477,13 +478,6 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, // Now serialize each of the attributes // XXX Unfortunately we need a namespace manager to get // attribute URIs. - nsCOMPtr document; - nsCOMPtr nsmanager; - content->GetDocument(*getter_AddRefs(document)); - if (document) { - document->GetNameSpaceManager(*getter_AddRefs(nsmanager)); - } - for (index = 0; index < count; index++) { content->GetAttrNameAt(index, namespaceID, @@ -498,8 +492,9 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement, } addNSAttr = PR_FALSE; - if (kNameSpaceID_XMLNS != namespaceID && nsmanager) { - nsmanager->GetNameSpaceURI(namespaceID, uriStr); + if (kNameSpaceID_XMLNS != namespaceID) { + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceURI(namespaceID, + uriStr); addNSAttr = ConfirmPrefix(prefixStr, uriStr); } diff --git a/mozilla/content/build/dlldeps.cpp b/mozilla/content/build/dlldeps.cpp index 1cf00af6974..4dd9d0d0e97 100644 --- a/mozilla/content/build/dlldeps.cpp +++ b/mozilla/content/build/dlldeps.cpp @@ -41,13 +41,10 @@ #include "nsIDocument.h" #include "nsHTMLParts.h" -#include "nsINameSpaceManager.h" void XXXNeverCalled() { nsIDocument* doc; NS_NewHTMLDocument(&doc); NS_NewImageDocument(&doc); - nsINameSpaceManager* nsm; - NS_NewNameSpaceManager(&nsm); } diff --git a/mozilla/content/build/nsContentModule.cpp b/mozilla/content/build/nsContentModule.cpp index 40e3d70d858..35c54699ffa 100644 --- a/mozilla/content/build/nsContentModule.cpp +++ b/mozilla/content/build/nsContentModule.cpp @@ -181,15 +181,14 @@ static PRBool gInitialized = PR_FALSE; PR_STATIC_CALLBACK(nsresult) Initialize(nsIModule* aSelf) { - // XXXwaterson turns out we initialize the module twice, because - // nsXULAtoms::AddRefAtoms() creates a namespace manager using the - // component manager. We should probably fix that. - //NS_PRECONDITION(! gInitialized, "module already initialized"); + NS_PRECONDITION(!gInitialized, "module already initialized"); if (gInitialized) return NS_OK; gInitialized = PR_TRUE; + nsContentUtils::Init(); + // Register all of our atoms once nsCSSAnonBoxes::AddRefAtoms(); nsCSSPseudoClasses::AddRefAtoms(); @@ -210,8 +209,6 @@ Initialize(nsIModule* aSelf) nsSVGAtoms::AddRefAtoms(); #endif - nsContentUtils::Init(); - // Add our shutdown observer. nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1"); @@ -269,8 +266,9 @@ Shutdown(nsIModule* aSelf) NS_IF_RELEASE(nsContentDLF::gUAStyleSheet); NS_IF_RELEASE(nsRuleNode::gLangService); - nsContentUtils::Shutdown(); nsGenericHTMLElement::Shutdown(); + + nsContentUtils::Shutdown(); NS_NameSpaceManagerShutdown(); } @@ -326,7 +324,7 @@ ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \ return rv; \ } -MAKE_CTOR(CreateNameSpaceManager, nsINameSpaceManager, NS_NewNameSpaceManager) +MAKE_CTOR(CreateNameSpaceManager, nsINameSpaceManager, NS_GetNameSpaceManager) MAKE_CTOR(CreateEventListenerManager, nsIEventListenerManager, NS_NewEventListenerManager) MAKE_CTOR(CreateEventStateManager, nsIEventStateManager, NS_NewEventStateManager) MAKE_CTOR(CreateDOMEventGroup, nsIDOMEventGroup, NS_NewDOMEventGroup) @@ -504,7 +502,7 @@ UnregisterHTMLOptionElement(nsIComponentManager* aCompMgr, static const nsModuleComponentInfo gComponents[] = { { "Namespace manager", NS_NAMESPACEMANAGER_CID, - nsnull, + NS_NAMESPACEMANAGER_CONTRACTID, CreateNameSpaceManager }, { "Event listener manager", diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 78519ed421a..67d75ae6132 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -61,7 +61,7 @@ #include "nsIDOMHTMLBodyElement.h" #include "nsImageMapUtils.h" #include "nsIHTMLDocument.h" -#include "nsINameSpaceManager.h" // for kNameSpaceID_XHTML +#include "nsINameSpaceManager.h" #include "nsIWebShell.h" #include "nsIBaseWindow.h" #include "nsIScrollableView.h" diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 33933272230..eb4a8f73b76 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1580,8 +1580,8 @@ nsHTMLDocument::CreateElementNS(const nsAString& aNamespaceURI, nodeInfo->GetNamespaceID(namespaceID); nsCOMPtr elementFactory; - mNameSpaceManager->GetElementFactory(namespaceID, - getter_AddRefs(elementFactory)); + nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(namespaceID, + getter_AddRefs(elementFactory)); nsCOMPtr content; diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp index 58de7e68f4e..ccd71dfc41b 100644 --- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -295,11 +295,7 @@ nsresult nsHTMLFragmentContentSink::Init() nsresult rv = NS_NewNodeInfoManager(getter_AddRefs(mNodeInfoManager)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr nsmgr; - rv = NS_NewNameSpaceManager(getter_AddRefs(nsmgr)); - NS_ENSURE_SUCCESS(rv, rv); - - return mNodeInfoManager->Init(nsnull, nsmgr); + return mNodeInfoManager->Init(nsnull); } diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index a3dd758968e..0a0e60c198d 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -1615,27 +1615,18 @@ CreateNameSpace(nsISupports* aRule, void* aNameSpacePtr) void CSSStyleSheetInner::RebuildNameSpaces(void) { - nsCOMPtr nameSpaceMgr; - if (mNameSpace) { - mNameSpace->GetNameSpaceManager(*getter_AddRefs(nameSpaceMgr)); - } - else { - NS_NewNameSpaceManager(getter_AddRefs(nameSpaceMgr)); - } - if (nameSpaceMgr) { - nameSpaceMgr->CreateRootNameSpace(*getter_AddRefs(mNameSpace)); - if (kNameSpaceID_Unknown != mDefaultNameSpaceID) { - nsCOMPtr defaultNameSpace; - mNameSpace->CreateChildNameSpace(nsnull, mDefaultNameSpaceID, - *getter_AddRefs(defaultNameSpace)); - if (defaultNameSpace) { - mNameSpace = defaultNameSpace; - } - } - if (mOrderedRules) { - mOrderedRules->EnumerateForwards(CreateNameSpace, address_of(mNameSpace)); + nsContentUtils::GetNSManagerWeakRef()->CreateRootNameSpace(*getter_AddRefs(mNameSpace)); + if (kNameSpaceID_Unknown != mDefaultNameSpaceID) { + nsCOMPtr defaultNameSpace; + mNameSpace->CreateChildNameSpace(nsnull, mDefaultNameSpaceID, + *getter_AddRefs(defaultNameSpace)); + if (defaultNameSpace) { + mNameSpace = defaultNameSpace; } } + if (mOrderedRules) { + mOrderedRules->EnumerateForwards(CreateNameSpace, address_of(mNameSpace)); + } } #ifdef DEBUG @@ -2236,11 +2227,7 @@ CSSStyleSheetImpl::AppendStyleRule(nsICSSRule* aRule) aRule->GetType(type); if (nsICSSRule::NAMESPACE_RULE == type) { if (! mInner->mNameSpace) { - nsCOMPtr nameSpaceMgr; - NS_NewNameSpaceManager(getter_AddRefs(nameSpaceMgr)); - if (nameSpaceMgr) { - nameSpaceMgr->CreateRootNameSpace(*getter_AddRefs(mInner->mNameSpace)); - } + nsContentUtils::GetNSManagerWeakRef()->CreateRootNameSpace(*getter_AddRefs(mInner->mNameSpace)); } if (mInner->mNameSpace) { @@ -2935,11 +2922,7 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule, cssRule->GetType(type); if (type == nsICSSRule::NAMESPACE_RULE) { if (! mInner->mNameSpace) { - nsCOMPtr nameSpaceMgr; - result = NS_NewNameSpaceManager(getter_AddRefs(nameSpaceMgr)); - if (NS_FAILED(result)) - return result; - nameSpaceMgr->CreateRootNameSpace(*getter_AddRefs(mInner->mNameSpace)); + nsContentUtils::GetNSManagerWeakRef()->CreateRootNameSpace(*getter_AddRefs(mInner->mNameSpace)); } NS_ENSURE_TRUE(mInner->mNameSpace, NS_ERROR_FAILURE); diff --git a/mozilla/content/shared/public/nsSVGAtoms.h b/mozilla/content/shared/public/nsSVGAtoms.h index 63900a1c305..ad9a3a4ce23 100644 --- a/mozilla/content/shared/public/nsSVGAtoms.h +++ b/mozilla/content/shared/public/nsSVGAtoms.h @@ -27,8 +27,6 @@ #include "prtypes.h" #include "nsIAtom.h" -class nsINameSpaceManager; - /** * This class wraps up the creation and destruction of the standard * set of SVG atoms used during normal SVG handling. This object @@ -41,9 +39,6 @@ public: static void AddRefAtoms(); static void ReleaseAtoms(); - // SVG namespace ID, good for the life of the nsSVGAtoms object - static PRInt32 nameSpaceID; - /* Declare all atoms The atom names and values are stored in nsCSSAtomList.h and diff --git a/mozilla/content/shared/public/nsXBLAtoms.h b/mozilla/content/shared/public/nsXBLAtoms.h index 84a3a545813..d0fc9a98dae 100644 --- a/mozilla/content/shared/public/nsXBLAtoms.h +++ b/mozilla/content/shared/public/nsXBLAtoms.h @@ -39,11 +39,8 @@ #ifndef nsXBLAtoms_h___ #define nsXBLAtoms_h___ -#include "prtypes.h" #include "nsIAtom.h" -class nsINameSpaceManager; - /** * This class wraps up the creation and destruction of the standard * set of XBL atoms used during normal XBL handling. This object @@ -56,9 +53,6 @@ public: static void AddRefAtoms(); static void ReleaseAtoms(); - // XBL namespace ID, good for the life of the nsXBLAtoms object - static PRInt32 nameSpaceID; - /* Declare all atoms The atom names and values are stored in nsCSSAtomList.h and diff --git a/mozilla/content/shared/public/nsXULAtoms.h b/mozilla/content/shared/public/nsXULAtoms.h index 888aa8b5ccd..5e0b842d07a 100644 --- a/mozilla/content/shared/public/nsXULAtoms.h +++ b/mozilla/content/shared/public/nsXULAtoms.h @@ -39,11 +39,8 @@ #ifndef nsXULAtoms_h___ #define nsXULAtoms_h___ -#include "prtypes.h" #include "nsIAtom.h" -class nsINameSpaceManager; - /** * This class wraps up the creation and destruction of the standard * set of xul atoms used during normal xul handling. This object @@ -56,9 +53,6 @@ public: static void AddRefAtoms(); static void ReleaseAtoms(); - // XUL namespace ID, good for the life of the nsXULAtoms object - static PRInt32 nameSpaceID; - /* Declare all atoms The atom names and values are stored in nsCSSAtomList.h and diff --git a/mozilla/content/shared/src/nsSVGAtoms.cpp b/mozilla/content/shared/src/nsSVGAtoms.cpp index 1305ce77166..b284d8ac183 100644 --- a/mozilla/content/shared/src/nsSVGAtoms.cpp +++ b/mozilla/content/shared/src/nsSVGAtoms.cpp @@ -22,45 +22,18 @@ * Contributor(s): */ -#include "nsString.h" -#include "nsINameSpaceManager.h" #include "nsSVGAtoms.h" -#include "nsLayoutCID.h" - -static const char kSVGNameSpace[] = "http://www.w3.org/2000/svg"; - -PRInt32 nsSVGAtoms::nameSpaceID; // define storage for all atoms #define SVG_ATOM(_name, _value) nsIAtom* nsSVGAtoms::_name; #include "nsSVGAtomList.h" #undef SVG_ATOM - static nsrefcnt gRefCnt = 0; -static nsINameSpaceManager* gNameSpaceManager; void nsSVGAtoms::AddRefAtoms() { if (gRefCnt == 0) { - /* SVG Atoms registers the SVG name space ID because it's a convenient - place to do this, if you don't want a permanent, "well-known" ID. - */ - - NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); - nsCOMPtr nsmgr = - do_CreateInstance(kNameSpaceManagerCID); - - if (nsmgr) { - nsmgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kSVGNameSpace), - nameSpaceID); - - gNameSpaceManager = nsmgr; - NS_ADDREF(gNameSpaceManager); - } else { - NS_ASSERTION(0, "failed to create SVG atoms namespace manager"); - } - // now register the atoms #define SVG_ATOM(_name, _value) _name = NS_NewPermanentAtom(_value); #include "nsSVGAtomList.h" @@ -76,7 +49,5 @@ void nsSVGAtoms::ReleaseAtoms() { #define SVG_ATOM(_name, _value) NS_RELEASE(_name); #include "nsSVGAtomList.h" #undef SVG_ATOM - - NS_IF_RELEASE(gNameSpaceManager); } } diff --git a/mozilla/content/shared/src/nsXULAtoms.cpp b/mozilla/content/shared/src/nsXULAtoms.cpp index 9d8f5643125..e9499bf9dc6 100644 --- a/mozilla/content/shared/src/nsXULAtoms.cpp +++ b/mozilla/content/shared/src/nsXULAtoms.cpp @@ -38,14 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsString.h" -#include "nsINameSpaceManager.h" #include "nsXULAtoms.h" -#include "nsContentCID.h" -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); - -static const char kXULNameSpace[] = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - -PRInt32 nsXULAtoms::nameSpaceID; // define storage for all atoms #define XUL_ATOM(_name, _value) nsIAtom* nsXULAtoms::_name; @@ -54,38 +47,24 @@ PRInt32 nsXULAtoms::nameSpaceID; static nsrefcnt gRefCnt = 0; -static nsINameSpaceManager* gNameSpaceManager; -void nsXULAtoms::AddRefAtoms() { - - if (gRefCnt == 0) { - /* XUL Atoms registers the XUL name space ID because it's a convenient - place to do this, if you don't want a permanent, "well-known" ID. - */ - if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kNameSpaceManagerCID,nsnull,NS_GET_IID(nsINameSpaceManager),(void**)&gNameSpaceManager))) { -// gNameSpaceManager->CreateRootNameSpace(namespace); - nsAutoString nameSpace; nameSpace.AssignWithConversion(kXULNameSpace); - gNameSpaceManager->RegisterNameSpace(nameSpace, nameSpaceID); - } else { - NS_ASSERTION(0, "failed to create xul atoms namespace manager"); - } - - // now register the atoms +void nsXULAtoms::AddRefAtoms() +{ + if (++gRefCnt == 1) { + // create atoms #define XUL_ATOM(_name, _value) _name = NS_NewPermanentAtom(_value); #include "nsXULAtomList.h" #undef XUL_ATOM } - ++gRefCnt; } -void nsXULAtoms::ReleaseAtoms() { - +void nsXULAtoms::ReleaseAtoms() +{ NS_PRECONDITION(gRefCnt != 0, "bad release of xul atoms"); if (--gRefCnt == 0) { + // release atoms #define XUL_ATOM(_name, _value) NS_RELEASE(_name); #include "nsXULAtomList.h" #undef XUL_ATOM - - NS_IF_RELEASE(gNameSpaceManager); } } diff --git a/mozilla/content/svg/content/src/nsSVGAtoms.cpp b/mozilla/content/svg/content/src/nsSVGAtoms.cpp index 1305ce77166..b284d8ac183 100644 --- a/mozilla/content/svg/content/src/nsSVGAtoms.cpp +++ b/mozilla/content/svg/content/src/nsSVGAtoms.cpp @@ -22,45 +22,18 @@ * Contributor(s): */ -#include "nsString.h" -#include "nsINameSpaceManager.h" #include "nsSVGAtoms.h" -#include "nsLayoutCID.h" - -static const char kSVGNameSpace[] = "http://www.w3.org/2000/svg"; - -PRInt32 nsSVGAtoms::nameSpaceID; // define storage for all atoms #define SVG_ATOM(_name, _value) nsIAtom* nsSVGAtoms::_name; #include "nsSVGAtomList.h" #undef SVG_ATOM - static nsrefcnt gRefCnt = 0; -static nsINameSpaceManager* gNameSpaceManager; void nsSVGAtoms::AddRefAtoms() { if (gRefCnt == 0) { - /* SVG Atoms registers the SVG name space ID because it's a convenient - place to do this, if you don't want a permanent, "well-known" ID. - */ - - NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); - nsCOMPtr nsmgr = - do_CreateInstance(kNameSpaceManagerCID); - - if (nsmgr) { - nsmgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kSVGNameSpace), - nameSpaceID); - - gNameSpaceManager = nsmgr; - NS_ADDREF(gNameSpaceManager); - } else { - NS_ASSERTION(0, "failed to create SVG atoms namespace manager"); - } - // now register the atoms #define SVG_ATOM(_name, _value) _name = NS_NewPermanentAtom(_value); #include "nsSVGAtomList.h" @@ -76,7 +49,5 @@ void nsSVGAtoms::ReleaseAtoms() { #define SVG_ATOM(_name, _value) NS_RELEASE(_name); #include "nsSVGAtomList.h" #undef SVG_ATOM - - NS_IF_RELEASE(gNameSpaceManager); } } diff --git a/mozilla/content/svg/content/src/nsSVGAtoms.h b/mozilla/content/svg/content/src/nsSVGAtoms.h index 63900a1c305..ad9a3a4ce23 100644 --- a/mozilla/content/svg/content/src/nsSVGAtoms.h +++ b/mozilla/content/svg/content/src/nsSVGAtoms.h @@ -27,8 +27,6 @@ #include "prtypes.h" #include "nsIAtom.h" -class nsINameSpaceManager; - /** * This class wraps up the creation and destruction of the standard * set of SVG atoms used during normal SVG handling. This object @@ -41,9 +39,6 @@ public: static void AddRefAtoms(); static void ReleaseAtoms(); - // SVG namespace ID, good for the life of the nsSVGAtoms object - static PRInt32 nameSpaceID; - /* Declare all atoms The atom names and values are stored in nsCSSAtomList.h and diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index 3c7157c39c5..b886933b904 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -42,7 +42,6 @@ #include "nsIDOMEventReceiver.h" #include "nsIDOMMutationEvent.h" #include "nsMutationEvent.h" -#include "nsINameSpaceManager.h" #include "nsIBindingManager.h" #include "nsIXBLBinding.h" #include "nsStyleConsts.h" diff --git a/mozilla/content/svg/document/src/nsSVGDocument.cpp b/mozilla/content/svg/document/src/nsSVGDocument.cpp index bc54615a4d0..a723fb162ed 100644 --- a/mozilla/content/svg/document/src/nsSVGDocument.cpp +++ b/mozilla/content/svg/document/src/nsSVGDocument.cpp @@ -66,13 +66,15 @@ nsSVGDocument::StartDocumentLoad(const char* aCommand, nsILoadGroup* aLoadGroup, nsISupports* aContainer, nsIStreamListener **aDocListener, - PRBool aReset) { + PRBool aReset, + nsIContentSink* aSink) { nsresult rv = nsXMLDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, - aReset); + aReset, + aSink); if (NS_FAILED(rv)) return rv; nsCOMPtr httpChannel = do_QueryInterface(aChannel); diff --git a/mozilla/content/svg/document/src/nsSVGDocument.h b/mozilla/content/svg/document/src/nsSVGDocument.h index 95bfc3db4ed..390353699d5 100644 --- a/mozilla/content/svg/document/src/nsSVGDocument.h +++ b/mozilla/content/svg/document/src/nsSVGDocument.h @@ -58,7 +58,8 @@ class nsSVGDocument : public nsXMLDocument, nsILoadGroup* aLoadGroup, nsISupports* aContainer, nsIStreamListener **aDocListener, - PRBool aReset = PR_TRUE); + PRBool aReset = PR_TRUE, + nsIContentSink* aSink = nsnull); NS_DECL_NSIDOMSVGDOCUMENT NS_FORWARD_NSIDOMDOCUMENT(nsXMLDocument::) diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index ec20178ad64..53b3cf9ec8d 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -40,7 +40,6 @@ #include "nsCOMPtr.h" #include "nsIXBLService.h" #include "nsIInputStream.h" -#include "nsINameSpaceManager.h" #include "nsHashtable.h" #include "nsIURI.h" #include "nsIURL.h" diff --git a/mozilla/content/xbl/src/nsXBLAtoms.h b/mozilla/content/xbl/src/nsXBLAtoms.h index 84a3a545813..d0fc9a98dae 100644 --- a/mozilla/content/xbl/src/nsXBLAtoms.h +++ b/mozilla/content/xbl/src/nsXBLAtoms.h @@ -39,11 +39,8 @@ #ifndef nsXBLAtoms_h___ #define nsXBLAtoms_h___ -#include "prtypes.h" #include "nsIAtom.h" -class nsINameSpaceManager; - /** * This class wraps up the creation and destruction of the standard * set of XBL atoms used during normal XBL handling. This object @@ -56,9 +53,6 @@ public: static void AddRefAtoms(); static void ReleaseAtoms(); - // XBL namespace ID, good for the life of the nsXBLAtoms object - static PRInt32 nameSpaceID; - /* Declare all atoms The atom names and values are stored in nsCSSAtomList.h and diff --git a/mozilla/content/xbl/src/nsXBLContentSink.cpp b/mozilla/content/xbl/src/nsXBLContentSink.cpp index d980e548cfe..27de9e6082d 100644 --- a/mozilla/content/xbl/src/nsXBLContentSink.cpp +++ b/mozilla/content/xbl/src/nsXBLContentSink.cpp @@ -726,7 +726,7 @@ nsXBLContentSink::CreateElement(const PRUnichar** aAtts, nsINodeInfo* aNodeInfo, nsIContent** aResult) { - if (aNameSpaceID == nsXULAtoms::nameSpaceID) { + if (aNameSpaceID == kNameSpaceID_XUL) { nsXULPrototypeElement* prototype = new nsXULPrototypeElement(); if (!prototype) return NS_ERROR_OUT_OF_MEMORY; @@ -816,7 +816,7 @@ nsXBLContentSink::AddAttributesToXULPrototype(const PRUnichar **aAtts, // XUL elements may require some additional work to compute // derived information. - if (aElement->mNodeInfo->NamespaceEquals(nsXULAtoms::nameSpaceID)) { + if (aElement->mNodeInfo->NamespaceEquals(kNameSpaceID_XUL)) { nsAutoString value; // Compute the element's class list if the element has a 'class' attribute. diff --git a/mozilla/content/xbl/src/nsXBLContextMenuHandler.cpp b/mozilla/content/xbl/src/nsXBLContextMenuHandler.cpp index 6d14f8b0018..c66bb41ad90 100644 --- a/mozilla/content/xbl/src/nsXBLContextMenuHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLContextMenuHandler.cpp @@ -43,7 +43,6 @@ #include "nsIContent.h" #include "nsIAtom.h" #include "nsIDOMMouseEvent.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptObjectOwner.h" #include "nsIScriptGlobalObject.h" diff --git a/mozilla/content/xbl/src/nsXBLDragHandler.cpp b/mozilla/content/xbl/src/nsXBLDragHandler.cpp index 2f299fe42fd..78a63b1ef63 100644 --- a/mozilla/content/xbl/src/nsXBLDragHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLDragHandler.cpp @@ -43,7 +43,6 @@ #include "nsIContent.h" #include "nsIAtom.h" #include "nsIDOMMouseEvent.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLEventHandler.cpp b/mozilla/content/xbl/src/nsXBLEventHandler.cpp index b3ae3ecda12..4dd4e94d2af 100644 --- a/mozilla/content/xbl/src/nsXBLEventHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLEventHandler.cpp @@ -46,7 +46,6 @@ #include "nsIAtom.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMMouseEvent.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLFocusHandler.cpp b/mozilla/content/xbl/src/nsXBLFocusHandler.cpp index 066b93d4532..750106dccc7 100644 --- a/mozilla/content/xbl/src/nsXBLFocusHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLFocusHandler.cpp @@ -42,7 +42,6 @@ #include "nsXBLFocusHandler.h" #include "nsIContent.h" #include "nsIAtom.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLFormHandler.cpp b/mozilla/content/xbl/src/nsXBLFormHandler.cpp index 58f16fdb477..be318a04f32 100644 --- a/mozilla/content/xbl/src/nsXBLFormHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLFormHandler.cpp @@ -42,7 +42,6 @@ #include "nsXBLFormHandler.h" #include "nsIContent.h" #include "nsIAtom.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLKeyHandler.cpp b/mozilla/content/xbl/src/nsXBLKeyHandler.cpp index 99ce65eaab2..bd9d0157a05 100644 --- a/mozilla/content/xbl/src/nsXBLKeyHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLKeyHandler.cpp @@ -44,7 +44,6 @@ #include "nsIAtom.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMMouseEvent.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLLoadHandler.cpp b/mozilla/content/xbl/src/nsXBLLoadHandler.cpp index eaf71c5511e..3acf587b058 100644 --- a/mozilla/content/xbl/src/nsXBLLoadHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLLoadHandler.cpp @@ -42,7 +42,6 @@ #include "nsXBLLoadHandler.h" #include "nsIContent.h" #include "nsIAtom.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLMouseHandler.cpp b/mozilla/content/xbl/src/nsXBLMouseHandler.cpp index e385a19e36d..efccf3eee97 100644 --- a/mozilla/content/xbl/src/nsXBLMouseHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLMouseHandler.cpp @@ -43,7 +43,6 @@ #include "nsIContent.h" #include "nsIAtom.h" #include "nsIDOMMouseEvent.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLMouseMotionHandler.cpp b/mozilla/content/xbl/src/nsXBLMouseMotionHandler.cpp index 74f2badc080..8509088c4f6 100644 --- a/mozilla/content/xbl/src/nsXBLMouseMotionHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLMouseMotionHandler.cpp @@ -43,7 +43,6 @@ #include "nsIContent.h" #include "nsIAtom.h" #include "nsIDOMMouseEvent.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLMutationHandler.cpp b/mozilla/content/xbl/src/nsXBLMutationHandler.cpp index 13facc441c7..29f3fef621d 100644 --- a/mozilla/content/xbl/src/nsXBLMutationHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLMutationHandler.cpp @@ -42,7 +42,6 @@ #include "nsXBLMutationHandler.h" #include "nsIContent.h" #include "nsIAtom.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLScrollHandler.cpp b/mozilla/content/xbl/src/nsXBLScrollHandler.cpp index 23aeab0186c..3183be3fb0a 100644 --- a/mozilla/content/xbl/src/nsXBLScrollHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLScrollHandler.cpp @@ -42,7 +42,6 @@ #include "nsXBLScrollHandler.h" #include "nsIContent.h" #include "nsIAtom.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index 5867999e39d..622a0e996e5 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -93,7 +93,6 @@ #include "nsIDOMLoadListener.h" // Static IIDs/CIDs. Try to minimize these. -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); static PRBool IsChromeOrResourceURI(nsIURI* aURI) @@ -474,17 +473,12 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent) PRUint32 nsXBLService::gRefCnt = 0; nsIXULPrototypeCache* nsXBLService::gXULCache = nsnull; -nsINameSpaceManager* nsXBLService::gNameSpaceManager = nsnull; - nsHashtable* nsXBLService::gClassTable = nsnull; JSCList nsXBLService::gClassLRUList = JS_INIT_STATIC_CLIST(&nsXBLService::gClassLRUList); PRUint32 nsXBLService::gClassLRUListLength = 0; PRUint32 nsXBLService::gClassLRUListQuota = 64; -nsIAtom* nsXBLService::kEventAtom = nsnull; -nsIAtom* nsXBLService::kInputAtom = nsnull; - // Enabled by default. Must be over-ridden to disable PRBool nsXBLService::gDisableChromeCache = PR_FALSE; static const char kDisableChromeCachePref[] = "nglayout.debug.disable_xul_cache"; @@ -500,28 +494,18 @@ nsXBLService::nsXBLService(void) gRefCnt++; if (gRefCnt == 1) { - nsresult rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, - nsnull, - NS_GET_IID(nsINameSpaceManager), - (void**) &gNameSpaceManager); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create namespace manager"); - if (NS_FAILED(rv)) return; - - // Create our atoms - kEventAtom = NS_NewAtom("event"); - kInputAtom = NS_NewAtom("input"); - // Find out if the XUL cache is on or off + nsresult rv; nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) prefs->GetBoolPref(kDisableChromeCachePref, &gDisableChromeCache); gClassTable = new nsHashtable(); - rv = nsServiceManager::GetService("@mozilla.org/xul/xul-prototype-cache;1", - NS_GET_IID(nsIXULPrototypeCache), - (nsISupports**) &gXULCache); - if (NS_FAILED(rv)) return; + rv = CallGetService("@mozilla.org/xul/xul-prototype-cache;1", &gXULCache); + if (NS_FAILED(rv)) { + return; + } } } @@ -529,12 +513,6 @@ nsXBLService::~nsXBLService(void) { gRefCnt--; if (gRefCnt == 0) { - NS_IF_RELEASE(gNameSpaceManager); - - // Release our atoms - NS_RELEASE(kEventAtom); - NS_RELEASE(kInputAtom); - // Walk the LRU list removing and deleting the nsXBLJSClasses. FlushMemory(); @@ -548,10 +526,7 @@ nsXBLService::~nsXBLService(void) delete gClassTable; gClassTable = nsnull; - if (gXULCache) { - nsServiceManager::ReleaseService("@mozilla.org/xul/xul-prototype-cache;1", gXULCache); - gXULCache = nsnull; - } + NS_IF_RELEASE(gXULCache); } } @@ -981,7 +956,8 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement, PRInt32 nameSpaceID; - gNameSpaceManager->GetNameSpaceID(nameSpace, nameSpaceID); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(nameSpace, + nameSpaceID); nsCOMPtr tagName = getter_AddRefs(NS_NewAtom(display)); protoBinding->SetBaseTag(nameSpaceID, tagName); @@ -1057,7 +1033,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, nsIDocument* aB if (!info && bindingManager && (tagName != nsXULAtoms::scrollbar) && (tagName != nsXULAtoms::thumb) && - (tagName != kInputAtom) && + (tagName != nsHTMLAtoms::input) && (tagName != nsHTMLAtoms::select) && !aForceSyncLoad) { // The third line of defense is to investigate whether or not the // document is currently being loaded asynchronously. If so, there's no diff --git a/mozilla/content/xbl/src/nsXBLService.h b/mozilla/content/xbl/src/nsXBLService.h index d4e6d7bf26d..ba5f3db1336 100644 --- a/mozilla/content/xbl/src/nsXBLService.h +++ b/mozilla/content/xbl/src/nsXBLService.h @@ -52,7 +52,6 @@ class nsIXBLBinding; class nsIXBLDocumentInfo; class nsIXBLPrototypeHandler; class nsIXBLPrototypeBinding; -class nsINameSpaceManager; class nsIContent; class nsIDocument; class nsIAtom; @@ -61,7 +60,6 @@ class nsIURI; class nsSupportsHashtable; class nsHashtable; class nsIXULPrototypeCache; -class nsIXULContentUtils; class nsXBLService : public nsIXBLService, public nsIObserver, public nsSupportsWeakReference { @@ -119,11 +117,8 @@ public: // MEMBER VARIABLES public: - static nsIXULContentUtils* gXULUtils; static nsIXULPrototypeCache* gXULCache; - static nsINameSpaceManager* gNameSpaceManager; // Used to register the XBL namespace - static PRUint32 gRefCnt; // A count of XBLservice instances. static PRBool gDisableChromeCache; @@ -134,10 +129,6 @@ public: static PRUint32 gClassLRUListLength; // Number of classes on LRU list. static PRUint32 gClassLRUListQuota; // Quota on class LRU list. - // XBL Atoms - static nsIAtom* kEventAtom; - static nsIAtom* kInputAtom; - nsFixedSizeAllocator mPool; }; diff --git a/mozilla/content/xbl/src/nsXBLWindowDragHandler.cpp b/mozilla/content/xbl/src/nsXBLWindowDragHandler.cpp index b6056478077..3fc780e8e9c 100644 --- a/mozilla/content/xbl/src/nsXBLWindowDragHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLWindowDragHandler.cpp @@ -48,7 +48,6 @@ #include "nsXBLService.h" #include "nsIServiceManager.h" #include "nsHTMLAtoms.h" -#include "nsINameSpaceManager.h" #include "nsIXBLDocumentInfo.h" #include "nsIScriptGlobalObject.h" #include "nsIDOMElement.h" diff --git a/mozilla/content/xbl/src/nsXBLWindowKeyHandler.cpp b/mozilla/content/xbl/src/nsXBLWindowKeyHandler.cpp index 33b3aff8a75..e30d8eed0f3 100644 --- a/mozilla/content/xbl/src/nsXBLWindowKeyHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLWindowKeyHandler.cpp @@ -50,7 +50,6 @@ #include "nsXBLService.h" #include "nsIServiceManager.h" #include "nsHTMLAtoms.h" -#include "nsINameSpaceManager.h" #include "nsIXBLDocumentInfo.h" #include "nsIScriptGlobalObject.h" #include "nsIDOMElement.h" diff --git a/mozilla/content/xbl/src/nsXBLXULHandler.cpp b/mozilla/content/xbl/src/nsXBLXULHandler.cpp index 6a30565998b..3b72fd70ec6 100644 --- a/mozilla/content/xbl/src/nsXBLXULHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLXULHandler.cpp @@ -42,7 +42,6 @@ #include "nsXBLPrototypeHandler.h" #include "nsXBLXULHandler.h" #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" #include "nsIDocument.h" diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index c200fa5b1d9..8561c1997c6 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -118,12 +118,8 @@ static char kNameSpaceSeparator = ':'; static const char* kLoadAsData = "loadAsData"; -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); -nsINameSpaceManager* nsXMLContentSink::gNameSpaceManager = nsnull; -PRUint32 nsXMLContentSink::gRefCnt = 0; - // XXX Open Issues: // 1) what's not allowed - We need to figure out which HTML tags // (prefixed with a HTML namespace qualifier) are explicitly not @@ -160,17 +156,6 @@ NS_NewXMLContentSink(nsIXMLContentSink** aResult, nsXMLContentSink::nsXMLContentSink() { NS_INIT_ISUPPORTS(); - gRefCnt++; - if (gRefCnt == 1) { -#ifdef DEBUG - nsresult rv = -#endif - nsServiceManager::GetService(kNameSpaceManagerCID, - NS_GET_IID(nsINameSpaceManager), - (nsISupports**) &gNameSpaceManager); - - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get namespace manager"); - } mDocument = nsnull; mDocumentURL = nsnull; @@ -195,11 +180,6 @@ nsXMLContentSink::nsXMLContentSink() nsXMLContentSink::~nsXMLContentSink() { - gRefCnt--; - if (gRefCnt == 0) { - NS_IF_RELEASE(gNameSpaceManager); - } - NS_IF_RELEASE(mDocument); NS_IF_RELEASE(mDocumentURL); NS_IF_RELEASE(mDocumentBaseURL); @@ -227,8 +207,6 @@ nsXMLContentSink::Init(nsIDocument* aDoc, nsIWebShell* aContainer, nsIChannel* aChannel) { - NS_ENSURE_TRUE(gNameSpaceManager, NS_ERROR_OUT_OF_MEMORY); - NS_PRECONDITION(nsnull != aDoc, "null ptr"); NS_PRECONDITION(nsnull != aURL, "null ptr"); if ((nsnull == aDoc) || (nsnull == aURL)) { @@ -607,8 +585,8 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount, PR // own content element implementation (e.g., XUL or MathML). // This is done based off a contractid/namespace scheme. nsCOMPtr elementFactory; - gNameSpaceManager->GetElementFactory(aNameSpaceID, - getter_AddRefs(elementFactory)); + nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(aNameSpaceID, + getter_AddRefs(elementFactory)); if (elementFactory) { // Create the content element using the element factory. elementFactory->CreateInstanceByTag(aNodeInfo, aResult); @@ -621,7 +599,8 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount, PR if (!mPrettyPrintHasFactoredElements && !mPrettyPrintHasSpecialRoot && mPrettyPrintXML) { PRBool hasFactory = PR_FALSE; - rv = gNameSpaceManager->HasRegisteredFactory(aNameSpaceID, &hasFactory); + rv = nsContentUtils::GetNSManagerWeakRef()->HasRegisteredFactory(aNameSpaceID, + &hasFactory); NS_ENSURE_SUCCESS(rv, rv); mPrettyPrintHasFactoredElements = hasFactory; } @@ -2120,15 +2099,8 @@ nsXMLContentSink::PushNameSpacesFrom(const PRUnichar** aAtts) nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(mNameSpaceStack->Count() - 1); } else { - nsCOMPtr manager; - mDocument->GetNameSpaceManager(*getter_AddRefs(manager)); - - NS_ASSERTION(manager, "no name space manager in document"); - - if (manager) { - rv = manager->CreateRootNameSpace(*getter_AddRefs(nameSpace)); - NS_ENSURE_SUCCESS(rv, rv); - } + rv = nsContentUtils::GetNSManagerWeakRef()->CreateRootNameSpace(*getter_AddRefs(nameSpace)); + NS_ENSURE_SUCCESS(rv, rv); } NS_ENSURE_TRUE(nameSpace, NS_ERROR_UNEXPECTED); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.h b/mozilla/content/xml/document/src/nsXMLContentSink.h index 9751c8f5314..9be79e588a3 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.h +++ b/mozilla/content/xml/document/src/nsXMLContentSink.h @@ -69,7 +69,6 @@ class nsIUnicharInputStream; class nsIParser; class nsINameSpace; class nsICSSLoader; -class nsINameSpaceManager; class nsIElementFactory; typedef enum { @@ -178,9 +177,6 @@ protected: nsresult MaybePrettyPrint(); - static nsINameSpaceManager* gNameSpaceManager; - static PRUint32 gRefCnt; - nsIDocument* mDocument; nsIURI* mDocumentURL; nsIURI* mDocumentBaseURL; // can be set via HTTP headers diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 628b1db5817..70dd2c8b260 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -1019,8 +1019,8 @@ nsXMLDocument::CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult) aNodeInfo->GetNamespaceID(namespaceID); nsCOMPtr elementFactory; - mNameSpaceManager->GetElementFactory(namespaceID, - getter_AddRefs(elementFactory)); + nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(namespaceID, + getter_AddRefs(elementFactory)); if (elementFactory) { rv = elementFactory->CreateInstanceByTag(aNodeInfo, diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 4a89e7b12b0..7c51b613052 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -158,16 +158,9 @@ nsICSSParser* nsXULPrototypeElement::sCSSParser = nsnull; nsIXULPrototypeCache* nsXULPrototypeScript::sXULPrototypeCache = nsnull; nsIXBLService * nsXULElement::gXBLService = nsnull; -// XXX This is sure to change. Copied from mozilla/layout/xul/content/src/nsXULAtoms.cpp -#define XUL_NAMESPACE_URI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" -static const char kXULNameSpaceURI[] = XUL_NAMESPACE_URI; -static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI; -// End of XUL interface includes - //---------------------------------------------------------------------- static NS_DEFINE_CID(kEventListenerManagerCID, NS_EVENTLISTENERMANAGER_CID); -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID); @@ -435,9 +428,6 @@ StyleHintFor(nsINodeInfo* aNodeInfo) nsrefcnt nsXULElement::gRefCnt; nsIRDFService* nsXULElement::gRDFService; -nsINameSpaceManager* nsXULElement::gNameSpaceManager; -PRInt32 nsXULElement::kNameSpaceID_RDF; -PRInt32 nsXULElement::kNameSpaceID_XUL; #ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING PRUint32 nsXULPrototypeAttribute::gNumElements; @@ -478,20 +468,6 @@ nsXULElement::Init() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); if (NS_FAILED(rv)) return rv; - - rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, - nsnull, - NS_GET_IID(nsINameSpaceManager), - (void**) &gNameSpaceManager); - - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create namespace manager"); - if (NS_FAILED(rv)) return rv; - - if (gNameSpaceManager) { - gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kRDFNameSpaceURI), kNameSpaceID_RDF); - gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kXULNameSpaceURI), kNameSpaceID_XUL); - } - InitEventHandlerMap(); } @@ -524,8 +500,6 @@ nsXULElement::~nsXULElement() nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService); gRDFService = nsnull; } - - NS_IF_RELEASE(gNameSpaceManager); } } @@ -1459,7 +1433,8 @@ nsXULElement::GetAttributeNS(const nsAString& aNamespaceURI, nsCOMPtr name(dont_AddRef(NS_NewAtom(aLocalName))); PRInt32 nsid; - gNameSpaceManager->GetNameSpaceID(aNamespaceURI, nsid); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + nsid); if (nsid == kNameSpaceID_Unknown) { // Unkonwn namespace means no attr... @@ -1496,7 +1471,8 @@ nsXULElement::RemoveAttributeNS(const nsAString& aNamespaceURI, PRInt32 nameSpaceId; nsCOMPtr tag = dont_AddRef(NS_NewAtom(aLocalName)); - gNameSpaceManager->GetNameSpaceID(aNamespaceURI, nameSpaceId); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + nameSpaceId); return UnsetAttr(nameSpaceId, tag, PR_TRUE); } @@ -1554,7 +1530,8 @@ nsXULElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI, kungFuGrip = dont_AddRef(NS_STATIC_CAST(nsIDOMNodeList *, elements)); if (!aNamespaceURI.Equals(NS_LITERAL_STRING("*"))) { - gNameSpaceManager->GetNameSpaceID(aNamespaceURI, nameSpaceId); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + nameSpaceId); if (nameSpaceId == kNameSpaceID_Unknown) { // Unkonwn namespace means no matches, we return an empty list... @@ -1606,7 +1583,7 @@ nsXULElement::HasAttributeNS(const nsAString& aNamespaceURI, nsCOMPtr name(dont_AddRef(NS_NewAtom(aLocalName))); PRInt32 nsid; - gNameSpaceManager->GetNameSpaceID(aNamespaceURI, nsid); + nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); if (nsid == kNameSpaceID_Unknown) { // Unkonwn namespace means no attr... diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 8e2665f3f36..da90bcdce77 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -63,7 +63,6 @@ #include "nsIDOMXULMultSelectCntrlEl.h" #include "nsIEventListenerManager.h" #include "nsINameSpace.h" -#include "nsINameSpaceManager.h" #include "nsIRDFCompositeDataSource.h" #include "nsIRDFResource.h" #include "nsIScriptObjectOwner.h" @@ -394,9 +393,6 @@ protected: static nsrefcnt gRefCnt; // pseudo-constants static nsIRDFService* gRDFService; - static nsINameSpaceManager* gNameSpaceManager; - static PRInt32 kNameSpaceID_RDF; - static PRInt32 kNameSpaceID_XUL; public: static nsresult diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 731b068ef80..31353091124 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -103,6 +103,7 @@ #include "nsIExpatSink.h" #include "nsUnicharUtils.h" +#include "nsXULAtoms.h" static const char kNameSpaceSeparator = ':'; static const char kNameSpaceDef[] = "xmlns"; @@ -111,12 +112,6 @@ static const char kNameSpaceDef[] = "xmlns"; static PRLogModuleInfo* gLog; #endif -// XXX This is sure to change. Copied from mozilla/layout/xul/content/src/nsXULAtoms.cpp -#define XUL_NAMESPACE_URI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" -static const char kXULNameSpaceURI[] = XUL_NAMESPACE_URI; - - -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kXULPrototypeCacheCID, NS_XULPROTOTYPECACHE_CID); //---------------------------------------------------------------------- @@ -147,16 +142,9 @@ public: protected: // pseudo-constants static nsrefcnt gRefCnt; - static nsINameSpaceManager* gNameSpaceManager; static nsIXULPrototypeCache* gXULCache; - static nsIAtom* kClassAtom; - static nsIAtom* kIdAtom; static nsIAtom* kScriptAtom; - static nsIAtom* kStyleAtom; - static nsIAtom* kTemplateAtom; - - static PRInt32 kNameSpaceID_XUL; PRUnichar* mText; PRInt32 mTextLength; @@ -262,16 +250,9 @@ protected: }; nsrefcnt XULContentSinkImpl::gRefCnt; -nsINameSpaceManager* XULContentSinkImpl::gNameSpaceManager; nsIXULPrototypeCache* XULContentSinkImpl::gXULCache; -nsIAtom* XULContentSinkImpl::kClassAtom; -nsIAtom* XULContentSinkImpl::kIdAtom; nsIAtom* XULContentSinkImpl::kScriptAtom; -nsIAtom* XULContentSinkImpl::kStyleAtom; -nsIAtom* XULContentSinkImpl::kTemplateAtom; - -PRInt32 XULContentSinkImpl::kNameSpaceID_XUL; //---------------------------------------------------------------------- @@ -358,27 +339,9 @@ XULContentSinkImpl::XULContentSinkImpl(nsresult& rv) NS_INIT_ISUPPORTS(); if (gRefCnt++ == 0) { - rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, - nsnull, - NS_GET_IID(nsINameSpaceManager), - (void**) &gNameSpaceManager); + kScriptAtom = NS_NewAtom("script"); - if (NS_FAILED(rv)) return; - - - rv = gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kXULNameSpaceURI), kNameSpaceID_XUL); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register XUL namespace"); - if (NS_FAILED(rv)) return; - - kClassAtom = NS_NewAtom("class"); - kIdAtom = NS_NewAtom("id"); - kScriptAtom = NS_NewAtom("script"); - kStyleAtom = NS_NewAtom("style"); - kTemplateAtom = NS_NewAtom("template"); - - rv = nsServiceManager::GetService(kXULPrototypeCacheCID, - NS_GET_IID(nsIXULPrototypeCache), - (nsISupports**) &gXULCache); + rv = CallGetService(kXULPrototypeCacheCID, &gXULCache); } #ifdef PR_LOGGING @@ -465,18 +428,8 @@ XULContentSinkImpl::~XULContentSinkImpl() PR_FREEIF(mText); if (--gRefCnt == 0) { - NS_IF_RELEASE(gNameSpaceManager); - - NS_IF_RELEASE(kClassAtom); - NS_IF_RELEASE(kIdAtom); NS_IF_RELEASE(kScriptAtom); - NS_IF_RELEASE(kStyleAtom); - NS_IF_RELEASE(kTemplateAtom); - - if (gXULCache) { - nsServiceManager::ReleaseService(kXULPrototypeCacheCID, gXULCache); - gXULCache = nsnull; - } + NS_IF_RELEASE(gXULCache); } } @@ -1182,7 +1135,7 @@ XULContentSinkImpl::PushNameSpacesFrom(const PRUnichar** aAttributes) nameSpace = (nsINameSpace*)mNameSpaceStack.ElementAt(mNameSpaceStack.Count() - 1); } else { - gNameSpaceManager->CreateRootNameSpace(*getter_AddRefs(nameSpace)); + nsContentUtils::GetNSManagerWeakRef()->CreateRootNameSpace(*getter_AddRefs(nameSpace)); if (! nameSpace) return NS_ERROR_OUT_OF_MEMORY; } @@ -1576,7 +1529,7 @@ XULContentSinkImpl::AddAttributes(const PRUnichar** aAttributes, nsAutoString value; // Compute the element's class list if the element has a 'class' attribute. - rv = aElement->GetAttr(kNameSpaceID_None, kClassAtom, value); + rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::clazz, value); if (NS_FAILED(rv)) return rv; if (rv == NS_CONTENT_ATTR_HAS_VALUE) { @@ -1585,7 +1538,7 @@ XULContentSinkImpl::AddAttributes(const PRUnichar** aAttributes, } // Parse the element's 'style' attribute - rv = aElement->GetAttr(kNameSpaceID_None, kStyleAtom, value); + rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::style, value); if (NS_FAILED(rv)) return rv; if (rv == NS_CONTENT_ATTR_HAS_VALUE) { diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index da1c1300a63..9fa4256d864 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -175,7 +175,6 @@ static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kHTMLStyleSheetCID, NS_HTMLSTYLESHEET_CID); static NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID); static NS_DEFINE_CID(kLocalStoreCID, NS_LOCALSTORE_CID); -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kParserCID, NS_PARSER_CID); static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); @@ -202,8 +201,6 @@ static PRBool IsChromeURI(nsIURI* aURI) // Miscellaneous Constants // -#define XUL_NAMESPACE_URI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - const nsForwardReference::Phase nsForwardReference::kPasses[] = { nsForwardReference::eConstruction, nsForwardReference::eHookup, @@ -226,9 +223,6 @@ nsIRDFResource* nsXULDocument::kNC_value; nsIElementFactory* nsXULDocument::gHTMLElementFactory; nsIElementFactory* nsXULDocument::gXMLElementFactory; -nsINameSpaceManager* nsXULDocument::gNameSpaceManager; -PRInt32 nsXULDocument::kNameSpaceID_XUL; - nsIXULPrototypeCache* nsXULDocument::gXULCache; PRLogModuleInfo* nsXULDocument::gXULLog; @@ -517,12 +511,6 @@ nsXULDocument::~nsXULDocument() NS_IF_RELEASE(gHTMLElementFactory); NS_IF_RELEASE(gXMLElementFactory); - if (gNameSpaceManager) { - nsServiceManager::ReleaseService(kNameSpaceManagerCID, - gNameSpaceManager); - gNameSpaceManager = nsnull; - } - if (gXULCache) { // Remove the current document here from the FastLoad table in // case the document did not make it past StartLayout in @@ -1656,15 +1644,6 @@ nsXULDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject) return NS_OK; } -NS_IMETHODIMP -nsXULDocument::GetNameSpaceManager(nsINameSpaceManager*& aManager) -{ - aManager = mNameSpaceManager; - NS_IF_ADDREF(aManager); - return NS_OK; -} - - // Note: We don't hold a reference to the document observer; we assume // that it has a live reference to the document. void @@ -3721,7 +3700,8 @@ nsXULDocument::CreateElementNS(const nsAString& aNamespaceURI, // Get The real namespace ID PRInt32 nameSpaceID; - rv = mNameSpaceManager->GetNameSpaceID(aNamespaceURI, nameSpaceID); + rv = nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, + nameSpaceID); if (NS_FAILED(rv)) return rv; nsCOMPtr ni; @@ -3799,7 +3779,7 @@ nsXULDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI, if (root) { PRInt32 nsid = kNameSpaceID_Unknown; if (!aNamespaceURI.Equals(NS_LITERAL_STRING("*"))) { - rv = mNameSpaceManager->GetNameSpaceID(aNamespaceURI, nsid); + rv = nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); NS_ENSURE_SUCCESS(rv, rv); if (nsid == kNameSpaceID_Unknown) { @@ -4464,13 +4444,6 @@ nsXULDocument::Init() rv = NS_NewHeapArena(getter_AddRefs(mArena), nsnull); if (NS_FAILED(rv)) return rv; - // Create a namespace manager so we can manage tags - rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, - nsnull, - NS_GET_IID(nsINameSpaceManager), - getter_AddRefs(mNameSpaceManager)); - if (NS_FAILED(rv)) return rv; - rv = nsComponentManager::CreateInstance(NS_NODEINFOMANAGER_CONTRACTID, nsnull, NS_GET_IID(nsINodeInfoManager), @@ -4478,7 +4451,7 @@ nsXULDocument::Init() if (NS_FAILED(rv)) return rv; - mNodeInfoManager->Init(this, mNameSpaceManager); + mNodeInfoManager->Init(this); // Create our command dispatcher and hook it up. rv = nsXULCommandDispatcher::Create(this, getter_AddRefs(mCommandDispatcher)); @@ -4551,17 +4524,6 @@ nsXULDocument::Init() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get XML element factory"); if (NS_FAILED(rv)) return rv; - rv = nsServiceManager::GetService(kNameSpaceManagerCID, - NS_GET_IID(nsINameSpaceManager), - (nsISupports**) &gNameSpaceManager); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get namespace manager"); - if (NS_FAILED(rv)) return rv; - -#define XUL_NAMESPACE_URI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" -static const char kXULNameSpaceURI[] = XUL_NAMESPACE_URI; - gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kXULNameSpaceURI), kNameSpaceID_XUL); - - rv = nsServiceManager::GetService(kXULPrototypeCacheCID, NS_GET_IID(nsIXULPrototypeCache), (nsISupports**) &gXULCache); @@ -6908,7 +6870,8 @@ nsXULDocument::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult) { // Retrieve the appropriate factory. - gNameSpaceManager->GetElementFactory(aNameSpaceID, aResult); + nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(aNameSpaceID, + aResult); if (!*aResult) { // Nothing found. Use generic XML element. @@ -7192,34 +7155,11 @@ public: // nsIElementFactory interface NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, nsIContent** aResult); - - static PRBool gIsInitialized; - static PRInt32 kNameSpaceID_XUL; }; -PRBool XULElementFactoryImpl::gIsInitialized = PR_FALSE; -PRInt32 XULElementFactoryImpl::kNameSpaceID_XUL; - XULElementFactoryImpl::XULElementFactoryImpl() { NS_INIT_ISUPPORTS(); - - if (!gIsInitialized) { - nsCOMPtr nsmgr = - do_GetService(kNameSpaceManagerCID); - - NS_ASSERTION(nsmgr, "unable to get namespace manager"); - if (!nsmgr) - return; - -#define XUL_NAMESPACE_URI \ - "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - - nsmgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(XUL_NAMESPACE_URI), - kNameSpaceID_XUL); - - gIsInitialized = PR_TRUE; - } } XULElementFactoryImpl::~XULElementFactoryImpl() diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 2308122446c..17772b946a7 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -65,7 +65,6 @@ #include "nsIHTMLContentContainer.h" #include "nsIHTMLStyleSheet.h" #include "nsILineBreakerFactory.h" -#include "nsINameSpaceManager.h" #include "nsIParser.h" #include "nsIPrincipal.h" #include "nsIRDFDataSource.h" @@ -262,8 +261,6 @@ public: NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject); - NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager); - NS_IMETHOD GetScriptLoader(nsIScriptLoader** aScriptLoader); virtual void AddObserver(nsIDocumentObserver* aObserver); @@ -513,9 +510,6 @@ protected: static nsIElementFactory* gHTMLElementFactory; static nsIElementFactory* gXMLElementFactory; - static nsINameSpaceManager* gNameSpaceManager; - static PRInt32 kNameSpaceID_XUL; - static nsIXULContentUtils* gXULUtils; static nsIXULPrototypeCache* gXULCache; @@ -562,7 +556,6 @@ protected: // if we're attached to a DocumentViewImpl, we have a presshell nsAutoVoidArray mPresShells; nsCOMPtr mListenerManager; // [OWNER] - nsCOMPtr mNameSpaceManager; // [OWNER] nsCOMPtr mAttrStyleSheet; // [OWNER] nsCOMPtr mInlineStyleSheet; // [OWNER] nsCOMPtr mCSSLoader; // [OWNER] diff --git a/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp b/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp index 117ebc1ae18..8a389a78cc7 100644 --- a/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -246,10 +246,7 @@ nsXULPrototypeDocument::Init() mNodeInfoManager = do_CreateInstance(NS_NODEINFOMANAGER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr nsmgr; - rv = NS_NewNameSpaceManager(getter_AddRefs(nsmgr)); - NS_ENSURE_SUCCESS(rv, rv); - rv = mNodeInfoManager->Init(nsnull, nsmgr); + rv = mNodeInfoManager->Init(nsnull); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index a44755d1e3b..061e9e31183 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -1671,7 +1671,8 @@ nsXULContentBuilder::SetContainerAttrs(nsIContent *aElement, const nsTemplateMat void nsXULContentBuilder::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult) { - gNameSpaceManager->GetElementFactory(aNameSpaceID, aResult); + nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(aNameSpaceID, + aResult); if (!*aResult) { *aResult = gXMLElementFactory; // Nothing found. Use generic XML element. diff --git a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp index e6b6dfc1f10..b3b9d6c0714 100644 --- a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp @@ -66,21 +66,19 @@ #include "prlog.h" #include "prtime.h" #include "rdf.h" - +#include "nsContentUtils.h" #include "nsIDateTimeFormat.h" #include "nsDateTimeFormatCID.h" #include "nsIScriptableDateFormat.h" static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID); -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); //------------------------------------------------------------------------ nsrefcnt nsXULContentUtils::gRefCnt; nsIRDFService* nsXULContentUtils::gRDF; -nsINameSpaceManager* nsXULContentUtils::gNameSpaceManager; nsIDateTimeFormat* nsXULContentUtils::gFormat; #define XUL_RESOURCE(ident, uri) nsIRDFResource* nsXULContentUtils::ident @@ -119,12 +117,6 @@ nsXULContentUtils::Init() #undef XUL_RESOURCE #undef XUL_LITERAL - rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, - nsnull, - NS_GET_IID(nsINameSpaceManager), - (void**) &gNameSpaceManager); - if (NS_FAILED(rv)) return rv; - rv = nsComponentManager::CreateInstance(kDateTimeFormatCID, nsnull, NS_GET_IID(nsIDateTimeFormat), @@ -152,7 +144,6 @@ nsXULContentUtils::Finish() #undef XUL_RESOURCE #undef XUL_LITERAL - NS_IF_RELEASE(gNameSpaceManager); NS_IF_RELEASE(gFormat); } @@ -480,7 +471,7 @@ nsXULContentUtils::GetResource(PRInt32 aNameSpaceID, const nsAString& aAttribute PRUnichar buf[256]; nsAutoString uri(CBufDescriptor(buf, PR_TRUE, sizeof(buf) / sizeof(PRUnichar), 0)); if (aNameSpaceID != kNameSpaceID_Unknown && aNameSpaceID != kNameSpaceID_None) { - rv = gNameSpaceManager->GetNameSpaceURI(aNameSpaceID, uri); + rv = nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceURI(aNameSpaceID, uri); // XXX ignore failure; treat as "no namespace" } diff --git a/mozilla/content/xul/templates/src/nsXULContentUtils.h b/mozilla/content/xul/templates/src/nsXULContentUtils.h index 16a216fe462..8af9df8d08a 100644 --- a/mozilla/content/xul/templates/src/nsXULContentUtils.h +++ b/mozilla/content/xul/templates/src/nsXULContentUtils.h @@ -66,7 +66,6 @@ class nsXULContentUtils protected: static nsrefcnt gRefCnt; static nsIRDFService* gRDF; - static nsINameSpaceManager* gNameSpaceManager; static nsIDateTimeFormat* gFormat; static PRBool gDisableXULCache; diff --git a/mozilla/content/xul/templates/src/nsXULSortService.cpp b/mozilla/content/xul/templates/src/nsXULSortService.cpp index 1eb4480375f..663dc7faebe 100644 --- a/mozilla/content/xul/templates/src/nsXULSortService.cpp +++ b/mozilla/content/xul/templates/src/nsXULSortService.cpp @@ -81,16 +81,11 @@ //////////////////////////////////////////////////////////////////////// -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID); static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID); static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); -static const char kXULNameSpaceURI[] - = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; -static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI; - DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, BookmarkSeparator); typedef struct _sortStruct { @@ -162,9 +157,6 @@ private: static nsString *kAscendingStr; static nsString *kDescendingStr; - static PRInt32 kNameSpaceID_XUL; - static PRInt32 kNameSpaceID_RDF; - static nsIRDFService *gRDFService; static nsIRDFContainerUtils *gRDFC; @@ -216,9 +208,6 @@ nsString* XULSortServiceImpl::kNaturalStr = nsnull; nsString* XULSortServiceImpl::kAscendingStr = nsnull; nsString* XULSortServiceImpl::kDescendingStr = nsnull; -PRInt32 XULSortServiceImpl::kNameSpaceID_XUL; -PRInt32 XULSortServiceImpl::kNameSpaceID_RDF; - //////////////////////////////////////////////////////////////////////// XULSortServiceImpl::XULSortServiceImpl(void) @@ -265,17 +254,6 @@ XULSortServiceImpl::XULSortServiceImpl(void) NS_ERROR("unable to get application locale"); } else NS_ERROR("couldn't get locale factory"); - - // Register the XUL and RDF namespaces: these'll just retrieve - // the IDs if they've already been registered by someone else. - nsCOMPtr mgr = do_CreateInstance(kNameSpaceManagerCID); - if (mgr) { - rv = mgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kXULNameSpaceURI), kNameSpaceID_XUL); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register XUL namespace"); - rv = mgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kRDFNameSpaceURI), kNameSpaceID_RDF); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register RDF namespace"); - } else - NS_ERROR("couldn't create namepsace manager"); } ++gRefCnt; diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index fe40723f9a2..ab0a43557d1 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -125,7 +125,6 @@ //---------------------------------------------------------------------- -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); @@ -135,11 +134,8 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); // nsrefcnt nsXULTemplateBuilder::gRefCnt = 0; -PRInt32 nsXULTemplateBuilder::kNameSpaceID_RDF; -PRInt32 nsXULTemplateBuilder::kNameSpaceID_XUL; nsIRDFService* nsXULTemplateBuilder::gRDFService; nsIRDFContainerUtils* nsXULTemplateBuilder::gRDFContainerUtils; -nsINameSpaceManager* nsXULTemplateBuilder::gNameSpaceManager; nsIScriptSecurityManager* nsXULTemplateBuilder::gScriptSecurityManager; nsIPrincipal* nsXULTemplateBuilder::gSystemPrincipal; @@ -177,8 +173,6 @@ nsXULTemplateBuilder::~nsXULTemplateBuilder(void) gRDFContainerUtils = nsnull; } - NS_RELEASE(gNameSpaceManager); - NS_IF_RELEASE(gSystemPrincipal); if (gScriptSecurityManager) { @@ -195,30 +189,6 @@ nsXULTemplateBuilder::Init() if (gRefCnt++ == 0) { nsresult rv; - // Register the XUL and RDF namespaces: these'll just retrieve - // the IDs if they've already been registered by someone else. - rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, - nsnull, - NS_GET_IID(nsINameSpaceManager), - (void**) &gNameSpaceManager); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create namespace manager"); - if (NS_FAILED(rv)) return rv; - - // XXX This is sure to change. Copied from mozilla/layout/xul/content/src/nsXULAtoms.cpp - static const char kXULNameSpaceURI[] - = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - - static const char kRDFNameSpaceURI[] - = RDF_NAMESPACE_URI; - - rv = gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kXULNameSpaceURI), kNameSpaceID_XUL); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register XUL namespace"); - if (NS_FAILED(rv)) return rv; - - rv = gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kRDFNameSpaceURI), kNameSpaceID_RDF); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register RDF namespace"); - if (NS_FAILED(rv)) return rv; - // Initialize the global shared reference to the service // manager and get some shared resource objects. rv = nsServiceManager::GetService(kRDFServiceCID, @@ -1388,7 +1358,7 @@ nsXULTemplateBuilder::IsTemplateElement(nsIContent* aContent) PRInt32 nameSpaceID; aContent->GetNameSpaceID(nameSpaceID); - if (nameSpaceID == nsXULTemplateBuilder::kNameSpaceID_XUL) { + if (nameSpaceID == kNameSpaceID_XUL) { nsCOMPtr tag; aContent->GetTag(*getter_AddRefs(tag)); diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.h b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.h index bab11290534..dd200481cf7 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.h +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.h @@ -44,7 +44,6 @@ #define nsXULTemplateBuilder_h__ #include "nsIDocumentObserver.h" -#include "nsINameSpaceManager.h" #include "nsIScriptSecurityManager.h" #include "nsISecurityCheckedComponent.h" #include "nsIRDFCompositeDataSource.h" @@ -205,7 +204,7 @@ public: * syntax. */ nsresult - CompileSimpleRule(nsIContent* aRuleElement, PRInt32 aPriorty, InnerNode* naParentNode); + CompileSimpleRule(nsIContent* aRuleElement, PRInt32 aPriorty, InnerNode* aParentNode); /** * Can be overridden by subclasses to handle special attribute conditions @@ -334,13 +333,9 @@ protected: static nsrefcnt gRefCnt; static nsIRDFService* gRDFService; static nsIRDFContainerUtils* gRDFContainerUtils; - static nsINameSpaceManager* gNameSpaceManager; static nsIScriptSecurityManager* gScriptSecurityManager; static nsIPrincipal* gSystemPrincipal; - static PRInt32 kNameSpaceID_RDF; - static PRInt32 kNameSpaceID_XUL; - enum { eDontTestEmpty = (1 << 0) }; diff --git a/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp index 3f77bf73695..c1e82937267 100644 --- a/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -68,6 +68,7 @@ #include "nsXULTemplateBuilder.h" #include "nsVoidArray.h" #include "nsUnicharUtils.h" +#include "nsINameSpaceManager.h" // For security check #include "nsIDocument.h" diff --git a/mozilla/extensions/transformiix/build/XSLTProcessorModule.cpp b/mozilla/extensions/transformiix/build/XSLTProcessorModule.cpp index 65492a8d850..094cf2bc894 100755 --- a/mozilla/extensions/transformiix/build/XSLTProcessorModule.cpp +++ b/mozilla/extensions/transformiix/build/XSLTProcessorModule.cpp @@ -173,7 +173,8 @@ RegisterTransformiix(nsIComponentManager *aCompMgr, TX_LG_IMPL; static PRBool gInitialized = PR_FALSE; -static nsIExceptionProvider *sXPathExceptionProvider = 0; +static nsIExceptionProvider *gXPathExceptionProvider = 0; +nsINameSpaceManager *gNameSpaceManager = 0; // Perform our one-time intialization for this module PR_STATIC_CALLBACK(nsresult) @@ -185,14 +186,14 @@ Initialize(nsIModule* aSelf) gInitialized = PR_TRUE; - sXPathExceptionProvider = new nsXPathExceptionProvider(); - if (!sXPathExceptionProvider) + gXPathExceptionProvider = new nsXPathExceptionProvider(); + if (!gXPathExceptionProvider) return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(sXPathExceptionProvider); + NS_ADDREF(gXPathExceptionProvider); nsCOMPtr xs = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID); if (xs) - xs->RegisterExceptionProvider(sXPathExceptionProvider, + xs->RegisterExceptionProvider(gXPathExceptionProvider, NS_ERROR_MODULE_DOM_XPATH); if (!txXSLTProcessor::txInit()) { @@ -206,6 +207,12 @@ Initialize(nsIModule* aSelf) return rv; } + rv = CallGetService(NS_NAMESPACEMANAGER_CONTRACTID, &gNameSpaceManager); + if (NS_FAILED(rv)) { + gNameSpaceManager = nsnull; + return rv; + } + TX_LG_CREATE; return NS_OK; @@ -220,13 +227,13 @@ Shutdown(nsIModule* aSelf) return; gInitialized = PR_FALSE; - if (sXPathExceptionProvider) { + if (gXPathExceptionProvider) { nsCOMPtr xs = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID); if (xs) - xs->UnregisterExceptionProvider(sXPathExceptionProvider, + xs->UnregisterExceptionProvider(gXPathExceptionProvider, NS_ERROR_MODULE_DOM_XPATH); - NS_RELEASE(sXPathExceptionProvider); + NS_RELEASE(gXPathExceptionProvider); } NS_IF_RELEASE(NS_CLASSINFO_NAME(XSLTProcessor)); @@ -239,6 +246,7 @@ Shutdown(nsIModule* aSelf) txXSLTProcessor::txShutdown(); NS_IF_RELEASE(gTxSecurityManager); + NS_IF_RELEASE(gNameSpaceManager); TX_LG_DELETE; } diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaAttr.cpp b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaAttr.cpp index bbab73ba43e..9561cecb70c 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaAttr.cpp +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaAttr.cpp @@ -52,10 +52,9 @@ Attr::Attr(nsIDOMAttr* aAttr, Document* aOwner) : Node(aAttr, aOwner) aAttr->GetNamespaceURI(ns); mNamespaceID = kNameSpaceID_None; if (!ns.IsEmpty()) { - NS_ASSERTION(aOwner->nsNSManager, - "owner document lacks namespace manager"); - if (aOwner->nsNSManager) { - aOwner->nsNSManager->GetNameSpaceID(ns, mNamespaceID); + NS_ASSERTION(gNameSpaceManager,"No namespace manager"); + if (gNameSpaceManager) { + gNameSpaceManager->GetNameSpaceID(ns, mNamespaceID); } } mNSId = mNamespaceID; diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaDocument.cpp b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaDocument.cpp index 2152e31aa9e..9b637449039 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaDocument.cpp +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaDocument.cpp @@ -188,13 +188,6 @@ Document::Document(nsIDOMDocument* aDocument) : Node(aDocument, this) if (!success) { mAttributeNodes.ops = nsnull; } - - nsCOMPtr doc(do_QueryInterface(aDocument)); - NS_ASSERTION(doc,"document doesn't implement nsIDocument"); - if (doc) { - doc->GetNameSpaceManager(*getter_AddRefs(nsNSManager)); - NS_ASSERTION(nsNSManager, "Unable to get nsINamespaceManager"); - } } /** @@ -380,10 +373,9 @@ Attr* Document::createAttribute(nsIDOMAttr* aAttr) aAttr->GetNamespaceURI(ns); PRInt32 namespaceID = kNameSpaceID_None; if (!ns.IsEmpty()) { - NS_ASSERTION(nsNSManager, - "owner document lacks namespace manager"); - if (nsNSManager) { - nsNSManager->GetNameSpaceID(ns, namespaceID); + NS_ASSERTION(gNameSpaceManager, "No namespace manager"); + if (gNameSpaceManager) { + gNameSpaceManager->GetNameSpaceID(ns, namespaceID); } } @@ -660,18 +652,18 @@ Node* Document::createWrapper(nsIDOMNode* aNode) PRInt32 Document::namespaceURIToID(const String& aNamespaceURI) { PRInt32 namesspaceID = kNameSpaceID_Unknown; - if (nsNSManager) { - nsNSManager->RegisterNameSpace(aNamespaceURI, - namesspaceID); + if (gNameSpaceManager) { + gNameSpaceManager->RegisterNameSpace(aNamespaceURI, + namesspaceID); } return namesspaceID; } void Document::namespaceIDToURI(PRInt32 aNamespaceID, String& aNamespaceURI) { - if (nsNSManager) { - nsNSManager->GetNameSpaceURI(aNamespaceID, - aNamespaceURI); + if (gNameSpaceManager) { + gNameSpaceManager->GetNameSpaceURI(aNamespaceID, + aNamespaceURI); } } diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaNode.cpp b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaNode.cpp index da161b7b4cc..96c8b0d686b 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaNode.cpp +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaNode.cpp @@ -354,12 +354,11 @@ PRInt32 Node::lookupNamespaceID(txAtom* aPrefix) NS_ENSURE_SUCCESS(rv, kNameSpaceID_Unknown); if (rv != NS_CONTENT_ATTR_NOT_THERE) { PRInt32 nsId; - NS_ASSERTION(mOwnerDocument->nsNSManager, - "owner document lacks namespace manager"); - if (!mOwnerDocument->nsNSManager) { + NS_ASSERTION(gNameSpaceManager, "No namespace manager"); + if (!gNameSpaceManager) { return kNameSpaceID_Unknown; } - mOwnerDocument->nsNSManager->RegisterNameSpace(uri, nsId); + gNameSpaceManager->RegisterNameSpace(uri, nsId); return nsId; } diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/mozilladom.h b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/mozilladom.h index dd59c736f73..16b5fe7288e 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/mozilladom.h +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/mozilladom.h @@ -61,6 +61,8 @@ typedef UNICODE_CHAR DOM_CHAR; #define kTxAttrIndexOffset 0x40000000; #define kTxChildIndexOffset 0x80000000; +extern nsINameSpaceManager* gNameSpaceManager; + class nsIDOMAttr; class nsIDOMDocument; class nsIDOMDocumentType; @@ -310,14 +312,9 @@ public: void namespaceIDToURI(PRInt32 aNamespaceID, String& aNamespaceURI); private: - friend class Attr; // Attrs and Nodes need to get to the cached nsNSManager - friend class Node; - PLDHashTable mWrapperHashTable; PLDHashTable mAttributeNodes; - nsCOMPtr nsNSManager; - #ifdef DEBUG friend class MozillaObjectWrapper; diff --git a/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.cpp b/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.cpp index 83a38992693..4e64107245d 100644 --- a/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.cpp +++ b/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.cpp @@ -50,6 +50,7 @@ #include "nsDOMError.h" #include "txURIUtils.h" +extern nsINameSpaceManager* gNameSpaceManager; NS_IMPL_ADDREF(nsXPathEvaluator) NS_IMPL_RELEASE(nsXPathEvaluator) @@ -128,8 +129,6 @@ nsXPathEvaluator::Evaluate(const nsAString & aExpression, * ParseContextImpl bases on a nsIDOMXPathNSResolver */ -static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); - nsresult nsXPathEvaluator::ParseContextImpl::resolveNamespacePrefix (txAtom* aPrefix, PRInt32& aID) { @@ -153,15 +152,8 @@ nsresult nsXPathEvaluator::ParseContextImpl::resolveNamespacePrefix return NS_OK; } - if (!mNSMan) { - mNSMan = do_GetService(kNameSpaceManagerCID); - if (!mNSMan) { - return NS_ERROR_FAILURE; - } - } // get the namespaceID for the URI - - return mNSMan->RegisterNameSpace(ns, aID); + return gNameSpaceManager->RegisterNameSpace(ns, aID); } nsresult nsXPathEvaluator::ParseContextImpl::resolveFunctionCall(txAtom* aName, diff --git a/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.h b/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.h index 4e310f3ba41..43be00df5e3 100644 --- a/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.h +++ b/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.h @@ -42,7 +42,6 @@ #include "nsIDOMXPathEvaluator.h" #include "txIXPathContext.h" -#include "nsINameSpaceManager.h" /** * A class for evaluating an XPath expression string @@ -86,7 +85,6 @@ private: private: nsIDOMXPathNSResolver* mResolver; nsresult mLastError; - nsCOMPtr mNSMan; }; }; diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp b/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp index 7a079d59417..5bc41b134fc 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp @@ -62,6 +62,9 @@ #include "TxLog.h" #include "nsIConsoleService.h" #include "nsIDOMDocumentFragment.h" +#include "nsINameSpaceManager.h" + +extern nsINameSpaceManager* gNameSpaceManager; static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); static NS_DEFINE_CID(kHTMLDocumentCID, NS_HTMLDOCUMENT_CID); @@ -111,10 +114,6 @@ txMozillaXMLOutput::txMozillaXMLOutput(txOutputFormat* aFormat, mOutputFormat.setFromDefaults(); aFragment->GetOwnerDocument(getter_AddRefs(mDocument)); - nsCOMPtr doc = do_QueryInterface(mDocument); - NS_ASSERTION(doc, "can't QI to nsIDocument"); - doc->GetNameSpaceManager(*getter_AddRefs(mNameSpaceManager)); - NS_ASSERTION(mNameSpaceManager, "Can't get namespace manager."); mCurrentNode = aFragment; } @@ -154,7 +153,7 @@ void txMozillaXMLOutput::attribute(const String& aName, } else { nsAutoString nsURI; - mNameSpaceManager->GetNameSpaceURI(aNsID, nsURI); + gNameSpaceManager->GetNameSpaceURI(aNsID, nsURI); element->SetAttributeNS(nsURI, aName, aValue); } } @@ -374,7 +373,7 @@ void txMozillaXMLOutput::startElement(const String& aName, } else { nsAutoString nsURI; - mNameSpaceManager->GetNameSpaceURI(aNsID, nsURI); + gNameSpaceManager->GetNameSpaceURI(aNsID, nsURI); rv = mDocument->CreateElementNS(nsURI, aName, getter_AddRefs(element)); NS_ASSERTION(NS_SUCCEEDED(rv), "Can't create element"); @@ -679,8 +678,6 @@ txMozillaXMLOutput::createResultDocument(const String& aName, PRInt32 aNsID, doc = do_QueryInterface(aResultDocument); } mCurrentNode = mDocument; - doc->GetNameSpaceManager(*getter_AddRefs(mNameSpaceManager)); - NS_ASSERTION(mNameSpaceManager, "Can't get namespace manager."); // Reset and set up the document nsCOMPtr loadGroup; diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.h b/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.h index 4e87cca2eea..2124f2d1e10 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.h +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.h @@ -43,7 +43,6 @@ #include "nsIContent.h" #include "nsIDOMDocument.h" #include "nsIDOMHTMLTextAreaElement.h" -#include "nsINameSpaceManager.h" #include "nsIScriptLoader.h" #include "nsIScriptLoaderObserver.h" #include "nsIStyleSheetLinkingElement.h" @@ -193,8 +192,6 @@ private: PRUint32 mBadChildLevel; nsCString mRefreshString; - nsCOMPtr mNameSpaceManager; - nsCOMPtr mScriptElements; nsAutoString mText; diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp index 513863a4ef2..d2f83f2f8a8 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp @@ -224,8 +224,6 @@ txToFragmentHandlerFactory::createHandlerWith(txOutputFormat* aFormat, * txMozillaXSLTProcessor */ -NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); - NS_IMPL_ADDREF(txMozillaXSLTProcessor) NS_IMPL_RELEASE(txMozillaXSLTProcessor) NS_INTERFACE_MAP_BEGIN(txMozillaXSLTProcessor) @@ -602,13 +600,8 @@ txMozillaXSLTProcessor::SetParameter(const nsAString & aNamespaceURI, } } - nsresult rv; - nsCOMPtr namespaceManager = - do_GetService(kNameSpaceManagerCID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - PRInt32 nsId = kNameSpaceID_Unknown; - rv = namespaceManager->RegisterNameSpace(aNamespaceURI, nsId); + nsresult rv = gNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsId); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr localName = do_GetAtom(aLocalName); txExpandedName varName(nsId, localName); @@ -630,13 +623,8 @@ txMozillaXSLTProcessor::GetParameter(const nsAString& aNamespaceURI, const nsAString& aLocalName, nsIVariant **aResult) { - nsresult rv; - nsCOMPtr namespaceManager = - do_GetService(kNameSpaceManagerCID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - PRInt32 nsId = kNameSpaceID_Unknown; - rv = namespaceManager->RegisterNameSpace(aNamespaceURI, nsId); + nsresult rv = gNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsId); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr localName = do_GetAtom(aLocalName); txExpandedName varName(nsId, localName); @@ -652,13 +640,8 @@ NS_IMETHODIMP txMozillaXSLTProcessor::RemoveParameter(const nsAString& aNamespaceURI, const nsAString& aLocalName) { - nsresult rv; - nsCOMPtr namespaceManager = - do_GetService(kNameSpaceManagerCID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - PRInt32 nsId = kNameSpaceID_Unknown; - rv = namespaceManager->RegisterNameSpace(aNamespaceURI, nsId); + nsresult rv = gNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsId); nsCOMPtr localName = do_GetAtom(aLocalName); txExpandedName varName(nsId, localName); diff --git a/mozilla/extensions/webservices/schema/src/nsDOMUtils.h b/mozilla/extensions/webservices/schema/src/nsDOMUtils.h index 3447871ff6d..d20991d2a1d 100644 --- a/mozilla/extensions/webservices/schema/src/nsDOMUtils.h +++ b/mozilla/extensions/webservices/schema/src/nsDOMUtils.h @@ -26,7 +26,6 @@ // content includes #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsINodeInfo.h" #include "nsIDOMElement.h" #include "nsIDOMNode.h" diff --git a/mozilla/extensions/webservices/schema/src/nsSchemaLoader.cpp b/mozilla/extensions/webservices/schema/src/nsSchemaLoader.cpp index 8268ac657e3..52c0eadf082 100644 --- a/mozilla/extensions/webservices/schema/src/nsSchemaLoader.cpp +++ b/mozilla/extensions/webservices/schema/src/nsSchemaLoader.cpp @@ -26,7 +26,6 @@ // content includes #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsINodeInfo.h" #include "nsIDOMDocument.h" diff --git a/mozilla/extensions/webservices/wsdl/src/nsWSDLLoader.cpp b/mozilla/extensions/webservices/wsdl/src/nsWSDLLoader.cpp index 544f2fc73ca..f8e03585521 100644 --- a/mozilla/extensions/webservices/wsdl/src/nsWSDLLoader.cpp +++ b/mozilla/extensions/webservices/wsdl/src/nsWSDLLoader.cpp @@ -30,7 +30,6 @@ // content includes #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsINodeInfo.h" #include "nsIDOMDocument.h" diff --git a/mozilla/extensions/xmlextras/schema/src/nsDOMUtils.h b/mozilla/extensions/xmlextras/schema/src/nsDOMUtils.h index 3447871ff6d..d20991d2a1d 100644 --- a/mozilla/extensions/xmlextras/schema/src/nsDOMUtils.h +++ b/mozilla/extensions/xmlextras/schema/src/nsDOMUtils.h @@ -26,7 +26,6 @@ // content includes #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsINodeInfo.h" #include "nsIDOMElement.h" #include "nsIDOMNode.h" diff --git a/mozilla/extensions/xmlextras/schema/src/nsSchemaLoader.cpp b/mozilla/extensions/xmlextras/schema/src/nsSchemaLoader.cpp index 8268ac657e3..52c0eadf082 100644 --- a/mozilla/extensions/xmlextras/schema/src/nsSchemaLoader.cpp +++ b/mozilla/extensions/xmlextras/schema/src/nsSchemaLoader.cpp @@ -26,7 +26,6 @@ // content includes #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsINodeInfo.h" #include "nsIDOMDocument.h" diff --git a/mozilla/extensions/xmlextras/wsdl/src/nsWSDLLoader.cpp b/mozilla/extensions/xmlextras/wsdl/src/nsWSDLLoader.cpp index 544f2fc73ca..f8e03585521 100644 --- a/mozilla/extensions/xmlextras/wsdl/src/nsWSDLLoader.cpp +++ b/mozilla/extensions/xmlextras/wsdl/src/nsWSDLLoader.cpp @@ -30,7 +30,6 @@ // content includes #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsINodeInfo.h" #include "nsIDOMDocument.h" diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 70b5d80d177..ea62cc81b45 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -3472,7 +3472,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, #endif #ifdef MOZ_SVG if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) && - (nameSpaceID == nsSVGAtoms::nameSpaceID)) { + (nameSpaceID == kNameSpaceID_SVG)) { rv = NS_NewSVGOuterSVGFrame(aPresShell, aDocElement, &contentFrame); if (NS_FAILED(rv)) { return rv; @@ -5361,7 +5361,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, const nsStyleDisplay* display = (const nsStyleDisplay*) aStyleContext->GetStyleData(eStyleStruct_Display); - PRBool isXULNS = (aNameSpaceID == nsXULAtoms::nameSpaceID); + PRBool isXULNS = (aNameSpaceID == kNameSpaceID_XUL); PRBool isXULDisplay = IsXULDisplayType(display); if (isXULNS || isXULDisplay) { @@ -7107,7 +7107,7 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsIPresShell* aPresShell, nsFrameItems& aFrameItems) { NS_ASSERTION(NS_SUCCEEDED(aContent->GetNameSpaceID(aNameSpaceID)) && - (aNameSpaceID == nsSVGAtoms::nameSpaceID), "SVG frame constructed in wrong namespace"); + (aNameSpaceID == kNameSpaceID_SVG), "SVG frame constructed in wrong namespace"); nsresult rv = NS_OK; PRBool isAbsolutelyPositioned = PR_FALSE; @@ -7465,7 +7465,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || (lastChild == aFrameItems.lastChild)) && - (aNameSpaceID == nsSVGAtoms::nameSpaceID)) { + (aNameSpaceID == kNameSpaceID_SVG)) { rv = ConstructSVGFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aNameSpaceID, styleContext, aFrameItems); } diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 10727e61bfc..48857112c51 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -182,7 +182,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset #include "nsIDocument.h" #include "nsHTMLAtoms.h" #include "nsIHTMLContent.h" -#include "nsINameSpaceManager.h" #include "nsIWebShell.h" //focus diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index f111db6bc98..6e4e38726d4 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -153,7 +153,6 @@ // For style data reconstruction #include "nsStyleChangeList.h" #include "nsIStyleFrameConstruction.h" -#include "nsINameSpaceManager.h" #include "nsIBindingManager.h" #include "nsIMenuFrame.h" #include "nsITreeBoxObject.h" diff --git a/mozilla/layout/build/dlldeps.cpp b/mozilla/layout/build/dlldeps.cpp index 39637c89b40..de8fd266feb 100644 --- a/mozilla/layout/build/dlldeps.cpp +++ b/mozilla/layout/build/dlldeps.cpp @@ -46,7 +46,6 @@ #include "nsIStyleSet.h" #include "nsIDocument.h" #include "nsHTMLParts.h" -#include "nsINameSpaceManager.h" void XXXNeverCalled() { diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index dc43c83ba58..b34f1aa3e5c 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -62,7 +62,6 @@ #include "nsStyleConsts.h" #include "nsUnitConversion.h" #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsNetCID.h" diff --git a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp index fc22d39fb2e..6522e4c6dce 100644 --- a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp @@ -43,7 +43,6 @@ #include "nsIContent.h" #include "nsIComponentManager.h" #include "nsHTMLAtoms.h" -#include "nsINameSpaceManager.h" #include "nsIPresState.h" #include "nsIPresShell.h" #include "nsIDocument.h" diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp index 90d2775d157..bb479832eef 100644 --- a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp @@ -47,7 +47,6 @@ #include "nsIPresState.h" #include "nsIPresShell.h" #include "nsIDocument.h" -#include "nsINameSpaceManager.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 5a68d41f643..ccd757a8396 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -45,7 +45,6 @@ #include "nsHTMLAtoms.h" #include "nsIHTMLContent.h" #include "nsIFormControl.h" -#include "nsINameSpaceManager.h" #include "nsIDeviceContext.h" #include "nsIDOMHTMLCollection.h" #include "nsIDOMNSHTMLOptionCollectn.h" diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 0fcae21e3e3..ff457db8742 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -86,7 +86,6 @@ #include "nsIComponentManager.h" #include "nsBoxLayoutState.h" -#include "nsINameSpaceManager.h" #include "nsLayoutAtoms.h" //getframetype //for keylistener for "return" check #include "nsIPrivateDOMEvent.h" diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 6caf4cae6fd..6fc88fdce51 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -88,7 +88,6 @@ #include "nsIAccessible.h" #include "nsIAccessibilityService.h" #endif -#include "nsINameSpaceManager.h" #include "nsGUIEvent.h" #ifdef IBMBIDI diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index f111db6bc98..6e4e38726d4 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -153,7 +153,6 @@ // For style data reconstruction #include "nsStyleChangeList.h" #include "nsIStyleFrameConstruction.h" -#include "nsINameSpaceManager.h" #include "nsIBindingManager.h" #include "nsIMenuFrame.h" #include "nsITreeBoxObject.h" diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 6caf4cae6fd..6fc88fdce51 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -88,7 +88,6 @@ #include "nsIAccessible.h" #include "nsIAccessibilityService.h" #endif -#include "nsINameSpaceManager.h" #include "nsGUIEvent.h" #ifdef IBMBIDI diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp index dc43c83ba58..b34f1aa3e5c 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp @@ -62,7 +62,6 @@ #include "nsStyleConsts.h" #include "nsUnitConversion.h" #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsNetCID.h" diff --git a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp index fc22d39fb2e..6522e4c6dce 100644 --- a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp @@ -43,7 +43,6 @@ #include "nsIContent.h" #include "nsIComponentManager.h" #include "nsHTMLAtoms.h" -#include "nsINameSpaceManager.h" #include "nsIPresState.h" #include "nsIPresShell.h" #include "nsIDocument.h" diff --git a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp index 90d2775d157..bb479832eef 100644 --- a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp @@ -47,7 +47,6 @@ #include "nsIPresState.h" #include "nsIPresShell.h" #include "nsIDocument.h" -#include "nsINameSpaceManager.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 5a68d41f643..ccd757a8396 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -45,7 +45,6 @@ #include "nsHTMLAtoms.h" #include "nsIHTMLContent.h" #include "nsIFormControl.h" -#include "nsINameSpaceManager.h" #include "nsIDeviceContext.h" #include "nsIDOMHTMLCollection.h" #include "nsIDOMNSHTMLOptionCollectn.h" diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index 0fcae21e3e3..ff457db8742 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -86,7 +86,6 @@ #include "nsIComponentManager.h" #include "nsBoxLayoutState.h" -#include "nsINameSpaceManager.h" #include "nsLayoutAtoms.h" //getframetype //for keylistener for "return" check #include "nsIPrivateDOMEvent.h" diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 70b5d80d177..ea62cc81b45 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -3472,7 +3472,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, #endif #ifdef MOZ_SVG if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) && - (nameSpaceID == nsSVGAtoms::nameSpaceID)) { + (nameSpaceID == kNameSpaceID_SVG)) { rv = NS_NewSVGOuterSVGFrame(aPresShell, aDocElement, &contentFrame); if (NS_FAILED(rv)) { return rv; @@ -5361,7 +5361,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, const nsStyleDisplay* display = (const nsStyleDisplay*) aStyleContext->GetStyleData(eStyleStruct_Display); - PRBool isXULNS = (aNameSpaceID == nsXULAtoms::nameSpaceID); + PRBool isXULNS = (aNameSpaceID == kNameSpaceID_XUL); PRBool isXULDisplay = IsXULDisplayType(display); if (isXULNS || isXULDisplay) { @@ -7107,7 +7107,7 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsIPresShell* aPresShell, nsFrameItems& aFrameItems) { NS_ASSERTION(NS_SUCCEEDED(aContent->GetNameSpaceID(aNameSpaceID)) && - (aNameSpaceID == nsSVGAtoms::nameSpaceID), "SVG frame constructed in wrong namespace"); + (aNameSpaceID == kNameSpaceID_SVG), "SVG frame constructed in wrong namespace"); nsresult rv = NS_OK; PRBool isAbsolutelyPositioned = PR_FALSE; @@ -7465,7 +7465,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || (lastChild == aFrameItems.lastChild)) && - (aNameSpaceID == nsSVGAtoms::nameSpaceID)) { + (aNameSpaceID == kNameSpaceID_SVG)) { rv = ConstructSVGFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aNameSpaceID, styleContext, aFrameItems); } diff --git a/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp b/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp index 8c01151d395..8c3c6685393 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp @@ -35,7 +35,6 @@ #include "nsUnitConversion.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" -#include "nsINameSpaceManager.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/mathml/content/src/nsMathMLAtoms.h b/mozilla/layout/mathml/content/src/nsMathMLAtoms.h index 6af167d297e..b02da618dfa 100644 --- a/mozilla/layout/mathml/content/src/nsMathMLAtoms.h +++ b/mozilla/layout/mathml/content/src/nsMathMLAtoms.h @@ -23,11 +23,8 @@ #ifndef nsMathMLAtoms_h___ #define nsMathMLAtoms_h___ -#include "prtypes.h" #include "nsIAtom.h" -class nsINameSpaceManager; - /** * This class wraps up the creation and destruction of the standard * set of MathML atoms used during normal MathML handling. This object diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index 60cf6e82476..a4f8db75636 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -107,7 +107,6 @@ static const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprom #include "nsIDocument.h" #include "nsHTMLAtoms.h" #include "nsIHTMLContent.h" -#include "nsINameSpaceManager.h" #include "nsIWebShell.h" // Focus diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index a3dd758968e..0a0e60c198d 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -1615,27 +1615,18 @@ CreateNameSpace(nsISupports* aRule, void* aNameSpacePtr) void CSSStyleSheetInner::RebuildNameSpaces(void) { - nsCOMPtr nameSpaceMgr; - if (mNameSpace) { - mNameSpace->GetNameSpaceManager(*getter_AddRefs(nameSpaceMgr)); - } - else { - NS_NewNameSpaceManager(getter_AddRefs(nameSpaceMgr)); - } - if (nameSpaceMgr) { - nameSpaceMgr->CreateRootNameSpace(*getter_AddRefs(mNameSpace)); - if (kNameSpaceID_Unknown != mDefaultNameSpaceID) { - nsCOMPtr defaultNameSpace; - mNameSpace->CreateChildNameSpace(nsnull, mDefaultNameSpaceID, - *getter_AddRefs(defaultNameSpace)); - if (defaultNameSpace) { - mNameSpace = defaultNameSpace; - } - } - if (mOrderedRules) { - mOrderedRules->EnumerateForwards(CreateNameSpace, address_of(mNameSpace)); + nsContentUtils::GetNSManagerWeakRef()->CreateRootNameSpace(*getter_AddRefs(mNameSpace)); + if (kNameSpaceID_Unknown != mDefaultNameSpaceID) { + nsCOMPtr defaultNameSpace; + mNameSpace->CreateChildNameSpace(nsnull, mDefaultNameSpaceID, + *getter_AddRefs(defaultNameSpace)); + if (defaultNameSpace) { + mNameSpace = defaultNameSpace; } } + if (mOrderedRules) { + mOrderedRules->EnumerateForwards(CreateNameSpace, address_of(mNameSpace)); + } } #ifdef DEBUG @@ -2236,11 +2227,7 @@ CSSStyleSheetImpl::AppendStyleRule(nsICSSRule* aRule) aRule->GetType(type); if (nsICSSRule::NAMESPACE_RULE == type) { if (! mInner->mNameSpace) { - nsCOMPtr nameSpaceMgr; - NS_NewNameSpaceManager(getter_AddRefs(nameSpaceMgr)); - if (nameSpaceMgr) { - nameSpaceMgr->CreateRootNameSpace(*getter_AddRefs(mInner->mNameSpace)); - } + nsContentUtils::GetNSManagerWeakRef()->CreateRootNameSpace(*getter_AddRefs(mInner->mNameSpace)); } if (mInner->mNameSpace) { @@ -2935,11 +2922,7 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule, cssRule->GetType(type); if (type == nsICSSRule::NAMESPACE_RULE) { if (! mInner->mNameSpace) { - nsCOMPtr nameSpaceMgr; - result = NS_NewNameSpaceManager(getter_AddRefs(nameSpaceMgr)); - if (NS_FAILED(result)) - return result; - nameSpaceMgr->CreateRootNameSpace(*getter_AddRefs(mInner->mNameSpace)); + nsContentUtils::GetNSManagerWeakRef()->CreateRootNameSpace(*getter_AddRefs(mInner->mNameSpace)); } NS_ENSURE_TRUE(mInner->mNameSpace, NS_ERROR_FAILURE); diff --git a/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp b/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp index f88287e9b28..e4e05413354 100644 --- a/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp +++ b/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp @@ -49,7 +49,6 @@ #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" #include "nsIContent.h" -#include "nsINameSpaceManager.h" #include "nsIPresContext.h" nsBoxLayoutState::nsBoxLayoutState(nsIPresContext* aPresContext):mPresContext(aPresContext), diff --git a/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp b/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp index 49655358881..7a19e49aba3 100644 --- a/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp +++ b/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp @@ -48,7 +48,6 @@ #include "nsIPresContext.h" #include "nsCOMPtr.h" #include "nsUnitConversion.h" -#include "nsINameSpaceManager.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" #include "nsHTMLReflowCommand.h" diff --git a/mozilla/layout/xul/base/src/nsContainerBox.cpp b/mozilla/layout/xul/base/src/nsContainerBox.cpp index acd2b8ebf40..a1ac108575b 100644 --- a/mozilla/layout/xul/base/src/nsContainerBox.cpp +++ b/mozilla/layout/xul/base/src/nsContainerBox.cpp @@ -62,7 +62,6 @@ #include "nsIPresContext.h" #include "nsCOMPtr.h" #include "nsUnitConversion.h" -#include "nsINameSpaceManager.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" #include "nsIContent.h" diff --git a/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp b/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp index 48d3e26ed90..fa42e74a676 100644 --- a/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp @@ -37,7 +37,6 @@ #include "nsNativeScrollbarFrame.h" -#include "nsINameSpaceManager.h" #include "nsXULAtoms.h" #include "nsBoxLayoutState.h" #include "nsComponentManagerUtils.h" diff --git a/mozilla/layout/xul/base/src/nsSliderFrame.cpp b/mozilla/layout/xul/base/src/nsSliderFrame.cpp index 9dda413921b..a3b05192cf9 100644 --- a/mozilla/layout/xul/base/src/nsSliderFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSliderFrame.cpp @@ -70,7 +70,6 @@ #include "nsIXMLContent.h" #include "nsXULAtoms.h" #include "nsHTMLAtoms.h" -#include "nsINameSpaceManager.h" #include "nsIScrollableView.h" #include "nsRepeatService.h" #include "nsBoxLayoutState.h" diff --git a/mozilla/layout/xul/base/src/nsSprocketLayout.cpp b/mozilla/layout/xul/base/src/nsSprocketLayout.cpp index 7ee033fc37b..2534ebe6b38 100644 --- a/mozilla/layout/xul/base/src/nsSprocketLayout.cpp +++ b/mozilla/layout/xul/base/src/nsSprocketLayout.cpp @@ -55,7 +55,6 @@ #include "nsIPresShell.h" #include "nsHTMLContainerFrame.h" #include "nsBoxFrame.h" -#include "nsINameSpaceManager.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" #include "nsBoxFrame.h" diff --git a/mozilla/layout/xul/base/src/nsStackFrame.cpp b/mozilla/layout/xul/base/src/nsStackFrame.cpp index 4fb8218e588..3659d2a9156 100644 --- a/mozilla/layout/xul/base/src/nsStackFrame.cpp +++ b/mozilla/layout/xul/base/src/nsStackFrame.cpp @@ -48,7 +48,6 @@ #include "nsIContent.h" #include "nsCOMPtr.h" #include "nsUnitConversion.h" -#include "nsINameSpaceManager.h" #include "nsXULAtoms.h" #include "nsHTMLAtoms.h" #include "nsHTMLParts.h" diff --git a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp index a8f558053b4..f79e24bd988 100644 --- a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp @@ -43,8 +43,6 @@ #include "nsIDOMXULDocument.h" #include "nsIDOMNodeList.h" #include "nsHTMLAtoms.h" -#include "nsINameSpaceManager.h" - #include "nsIWidget.h" #include "nsIPresContext.h" #include "nsIDOMWindowInternal.h" diff --git a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp index 15838410467..8c1909306cf 100644 --- a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp +++ b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp @@ -110,7 +110,6 @@ #include "nsIFileURL.h" #include "nsNetUtil.h" #include "nsIChannel.h" -#include "nsLayoutCID.h" // for NS_NAMESPACEMANAGER_CID. #include "nsRDFCID.h" #include "nsRDFBaseDataSources.h" #include "nsVoidArray.h" diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index 52fc596c20e..2409cc1a082 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -90,7 +90,6 @@ #include "nsICSSLoader.h" #include "nsIDocumentObserver.h" #include "nsIXULDocument.h" -#include "nsINameSpaceManager.h" #include "nsIIOService.h" #include "nsIResProtocolHandler.h" #include "nsLayoutCID.h" diff --git a/mozilla/rdf/tests/localfile/localfile.cpp b/mozilla/rdf/tests/localfile/localfile.cpp index d9d576fbc94..918e8624c13 100644 --- a/mozilla/rdf/tests/localfile/localfile.cpp +++ b/mozilla/rdf/tests/localfile/localfile.cpp @@ -71,7 +71,6 @@ #include "nsIStreamListener.h" #include "nsIURL.h" #include "nsDOMCID.h" // for NS_SCRIPT_NAMESET_REGISTRY_CID -#include "nsLayoutCID.h" // for NS_NAMESPACEMANAGER_CID #include "nsRDFCID.h" #include "nsRDFCID.h" #include "nsIComponentManager.h" diff --git a/mozilla/widget/public/nsWidgetAtoms.h b/mozilla/widget/public/nsWidgetAtoms.h index 752a39be3c4..fa161d7d9be 100644 --- a/mozilla/widget/public/nsWidgetAtoms.h +++ b/mozilla/widget/public/nsWidgetAtoms.h @@ -41,8 +41,6 @@ #include "prtypes.h" #include "nsIAtom.h" -class nsINameSpaceManager; - /** * This class wraps up the creation and destruction of the standard * set of xul atoms used during normal xul handling. This object @@ -58,9 +56,6 @@ public: static void AddRefAtoms(); static void ReleaseAtoms(); - // XUL namespace ID, good for the life of the nsXULAtoms object - static PRInt32 nameSpaceID; - /* Declare all atoms The atom names and values are stored in nsWidgetAtomList.h and diff --git a/mozilla/widget/src/windows/Accessible.cpp b/mozilla/widget/src/windows/Accessible.cpp index 85e8d4022a3..f15eb988a4c 100644 --- a/mozilla/widget/src/windows/Accessible.cpp +++ b/mozilla/widget/src/windows/Accessible.cpp @@ -47,7 +47,6 @@ #include "nsIDocument.h" #include "nsIViewManager.h" #include "nsIDOMDocumentType.h" -#include "nsINameSpaceManager.h" #include "nsITextContent.h" #include "nsIWidget.h" #include "nsIXULDocument.h" diff --git a/mozilla/widget/src/windows/SimpleDOMNode.cpp b/mozilla/widget/src/windows/SimpleDOMNode.cpp index 865e33ab8b7..9238bf61c70 100644 --- a/mozilla/widget/src/windows/SimpleDOMNode.cpp +++ b/mozilla/widget/src/windows/SimpleDOMNode.cpp @@ -263,8 +263,8 @@ STDMETHODIMP SimpleDOMNode::get_attributesForNames( if (!doc) return E_FAIL; - nsCOMPtr nameSpaceManager; - doc->GetNameSpaceManager(*getter_AddRefs(nameSpaceManager)); + nsCOMPtr nameSpaceManager = + do_GetService(NS_NAMESPACEMANAGER_CONTRACTID); PRInt32 index; diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 323cb664a05..eab990a5879 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -54,7 +54,6 @@ #include "nsIPref.h" #include "nsReadableUtils.h" -#include "nsINameSpaceManager.h" #include "nsEscape.h" #include "nsVoidArray.h" #include "nsIScriptGlobalObject.h" diff --git a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp index c0241e05c01..19f261ca684 100644 --- a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp +++ b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp @@ -62,7 +62,6 @@ /* For Javascript Namespace Access */ #include "nsDOMCID.h" #include "nsIServiceManager.h" -#include "nsINameSpaceManager.h" #include "nsIScriptNameSpaceManager.h" #include "nsIScriptExternalNameSet.h"