diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index 99a75e6d27c..3b00506517a 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -85,6 +85,7 @@ #include "nsAccessibleTreeWalker.h" #include "nsIURI.h" #include "nsIImageLoadingContent.h" +#include "nsINameSpaceManager.h" #ifdef NS_DEBUG #include "nsIFrameDebug.h" diff --git a/mozilla/content/base/public/Makefile.in b/mozilla/content/base/public/Makefile.in index bff2c363946..2c868e66a9b 100644 --- a/mozilla/content/base/public/Makefile.in +++ b/mozilla/content/base/public/Makefile.in @@ -56,7 +56,6 @@ nsIDocument.h \ nsIDocumentEncoder.h \ nsIDocumentObserver.h \ nsIDocumentViewer.h \ -nsIElementFactory.h \ nsINameSpace.h \ nsINameSpaceManager.h \ nsINodeInfo.h \ @@ -78,6 +77,7 @@ nsIFrameLoader.h \ nsLayoutStylesheetCache.h \ nsContentCID.h \ nsCopySupport.h \ +nsContentCreatorFunctions.h \ $(NULL) SDK_XPIDLSRCS = \ diff --git a/mozilla/content/base/public/nsContentCID.h b/mozilla/content/base/public/nsContentCID.h index 1e86f1ce3fb..2fc9657973c 100644 --- a/mozilla/content/base/public/nsContentCID.h +++ b/mozilla/content/base/public/nsContentCID.h @@ -62,10 +62,6 @@ #define NS_LAYOUT_DEBUGGER_CID \ { 0xa6cf90f9, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} -/* a6cf90fc-15b3-11d2-932e-00805f8add32 */ -#define NS_HTML_ELEMENT_FACTORY_CID \ - { 0xa6cf90fc, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} - #define NS_HTMLDOCUMENT_CID \ { /* 5d0fcdd0-4daa-11d2-b328-00805f8a3859 */ \ 0x5d0fcdd0, 0x4daa, 0x11d2, \ @@ -81,11 +77,6 @@ 0xa6cf9063, 0x15b3, 0x11d2, \ {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} -#define NS_XML_ELEMENT_FACTORY_CID \ -{ /* CF170391-79CC-11d3-BE44-0020A6361667 */ \ - 0xcf170391, 0x79cc, 0x11d3, \ - {0xbe, 0x44, 0x0, 0x20, 0xa6, 0x36, 0x16, 0x67}} - #define NS_IMAGEDOCUMENT_CID \ { /* e11a6080-4daa-11d2-b328-00805f8a3859 */ \ 0xe11a6080, 0x4daa, 0x11d2, \ @@ -243,11 +234,6 @@ #define NS_DLGDEFAULTKEYS_CID \ { 0xdaedcb43, 0x1dd1, 0x11b2, { 0xb1, 0xd2, 0xca, 0xf0, 0x6c, 0xb4, 0x3, 0x87 } } -// {76E92881-CDDB-11d3-BF87-00105A1B0627} -#define NS_XULELEMENTFACTORY_CID \ -{ 0x76e92881, 0xcddb, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } - - // {BFD05264-834C-11d2-8EAC-00805F29F371} #define NS_XULSORTSERVICE_CID \ { 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x71 } } @@ -276,18 +262,8 @@ #define NS_RANGEUTILS_CID \ { 0xa6cf9126, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } -#ifdef MOZ_MATHML -// {68b9fbda-f230-45a9-bf92-dbbbd4ac8555} -#define NS_MATHMLELEMENTFACTORY_CID \ -{ 0x68b9fbda, 0xf230, 0x45a9, {0xbf, 0x92, 0xdb, 0xbb, 0xd4, 0xac, 0x85, 0x55 } } -#endif // MOZ_MATHML - #ifdef MOZ_SVG -// {34D9B28A-FBFF-4bbd-8546-1822FE3FB8B5} -#define NS_SVGELEMENTFACTORY_CID \ -{ 0x34d9b28a, 0xfbff, 0x4bbd, { 0x85, 0x46, 0x18, 0x22, 0xfe, 0x3f, 0xb8, 0xb5 } } - #define NS_SVGDOCUMENT_CID \ { /* b7f44954-1dd1-11b2-8c2e-c2feab4186bc */ \ 0xb7f44954, 0x11d1, 0x11b2, \ diff --git a/mozilla/content/base/public/nsContentCreatorFunctions.h b/mozilla/content/base/public/nsContentCreatorFunctions.h new file mode 100644 index 00000000000..d8ec17fe93f --- /dev/null +++ b/mozilla/content/base/public/nsContentCreatorFunctions.h @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Peter Van der Beken. + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Van der Beken + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsContentCreatorFunctions_h__ +#define nsContentCreatorFunctions_h__ + +/** + * Functions to create content, to be used only inside Gecko + * (mozilla/content and mozilla/layout). + */ + +class nsAString; +class nsIContent; +class nsINodeInfo; + +nsresult +NS_NewElement(nsIContent** aResult, PRInt32 aElementType, + nsINodeInfo* aNodeInfo); + +nsresult +NS_NewXMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo); + +nsresult +NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult, + const nsAString& aTarget, + const nsAString& aData); + +nsresult +NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult, + const nsAString& aData); + +nsresult +NS_NewXMLCDATASection(nsIContent** aInstancePtrResult); + +nsresult +NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo); + +#ifdef MOZ_MATHML +nsresult +NS_NewMathMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo); +#endif + +#ifdef MOZ_XUL +nsresult +NS_NewXULElement(nsIContent** aResult, nsINodeInfo* aNodeInfo); +#endif + +#ifdef MOZ_SVG +nsresult +NS_NewSVGElement(nsIContent** aResult, nsINodeInfo* aNodeInfo); +#endif + +#endif // nsContentCreatorFunctions_h__ diff --git a/mozilla/content/base/public/nsContentUtils.h b/mozilla/content/base/public/nsContentUtils.h index 1dff3d0013a..4abc2676314 100644 --- a/mozilla/content/base/public/nsContentUtils.h +++ b/mozilla/content/base/public/nsContentUtils.h @@ -51,14 +51,14 @@ #include "nsCOMArray.h" #include "nsIStatefulFrame.h" #include "nsIPref.h" +#include "nsINodeInfo.h" +#include "nsNodeInfoManager.h" class nsIXPConnect; class nsIContent; class nsIDocument; class nsIDocShell; class nsINameSpaceManager; -class nsINodeInfo; -class nsINodeInfoManager; class nsIScriptSecurityManager; class nsIThreadJSContextStack; class nsIParserService; @@ -283,7 +283,7 @@ public: static nsresult GetNodeInfoFromQName(const nsAString& aNamespaceURI, const nsAString& aQualifiedName, - nsINodeInfoManager* aNodeInfoManager, + nsNodeInfoManager* aNodeInfoManager, nsINodeInfo** aNodeInfo); static nsAdoptingCString GetCharPref(const char *aPref); @@ -332,6 +332,40 @@ public: imgIDecoderObserver* aObserver, PRInt32 aLoadFlags, imgIRequest** aRequest); + + /** + * Convenience method to create a new nodeinfo that differs only by name + * from aNodeInfo. + */ + static nsresult NameChanged(nsINodeInfo *aNodeInfo, nsIAtom *aName, + nsINodeInfo** aResult) + { + nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager(); + + return niMgr->GetNodeInfo(aName, aNodeInfo->GetPrefixAtom(), + aNodeInfo->NamespaceID(), aResult); + } + + /** + * Convenience method to create a new nodeinfo that differs only by prefix + * from aNodeInfo. + */ + static nsresult PrefixChanged(nsINodeInfo *aNodeInfo, nsIAtom *aPrefix, + nsINodeInfo** aResult) + { + nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager(); + + return niMgr->GetNodeInfo(aNodeInfo->NameAtom(), aPrefix, + aNodeInfo->NamespaceID(), aResult); + } + + /** + * Retrieve a pointer to the document that owns aNodeInfo. + */ + static nsIDocument *GetDocument(nsINodeInfo *aNodeInfo) + { + return aNodeInfo->NodeInfoManager()->GetDocument(); + } private: static nsresult doReparentContentWrapper(nsIContent *aChild, diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 0f465ec2ba8..79a4400024b 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -46,7 +46,6 @@ #include "nsCOMPtr.h" #include "nsIURI.h" #include "nsIBindingManager.h" -#include "nsINodeInfo.h" #include "nsWeakPtr.h" #include "nsIWeakReferenceUtils.h" #include "nsILoadGroup.h" @@ -83,14 +82,15 @@ class nsISupportsArray; class nsIScriptLoader; class nsIContentSink; class nsIScriptEventManager; +class nsNodeInfoManager; class nsICSSLoader; class nsHTMLStyleSheet; class nsIHTMLCSSStyleSheet; // IID for the nsIDocument interface #define NS_IDOCUMENT_IID \ -{ 0xa492d7cf, 0x1777, 0x4c7a, \ - {0xaa, 0x8f, 0x94, 0x08, 0x28, 0x05, 0x55, 0xc9} } +{ 0xf2a6e105, 0xb3c9, 0x11d8, \ + { 0xb2, 0x67, 0x00, 0x0a, 0x95, 0xdc, 0x23, 0x4c } } // The base value for the content ID counter. // This counter is used by the document to @@ -114,9 +114,13 @@ public: nsIDocument() : mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")), - mNextContentID(NS_CONTENT_ID_COUNTER_BASE) { } + mNextContentID(NS_CONTENT_ID_COUNTER_BASE), + mNodeInfoManager(nsnull) + { + } - virtual ~nsIDocument() { } + // Defined in nsDocument.cpp (it needs to clean up mNodeInfoManager). + virtual ~nsIDocument(); virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, @@ -527,7 +531,11 @@ public: return mBindingManager; } - nsINodeInfoManager* GetNodeInfoManager() const + /** + * Only to be used inside Gecko, you can't really do anything with the + * pointer outside Gecko anyway. + */ + nsNodeInfoManager* NodeInfoManager() const { return mNodeInfoManager; } @@ -581,6 +589,17 @@ public: virtual PRBool IsScriptEnabled() = 0; + /** + * Create an element with the specified name, prefix and namespace ID. + * If aDocumentDefaultType is true we create an element of the default type + * for that document (currently XHTML in HTML documents and XUL in XUL + * documents), otherwise we use the type specified by the namespace ID. + */ + virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, + PRBool aDocumentDefaultType, + nsIContent** aResult) = 0; + protected: nsString mDocumentTitle; nsCOMPtr mDocumentURI; @@ -605,7 +624,7 @@ protected: PRInt32 mNextContentID; nsCOMPtr mBindingManager; - nsCOMPtr mNodeInfoManager; + nsNodeInfoManager* mNodeInfoManager; // [STRONG] // True if BIDI is enabled. PRBool mBidiEnabled; diff --git a/mozilla/content/base/public/nsIElementFactory.h b/mozilla/content/base/public/nsIElementFactory.h deleted file mode 100644 index 718867b714b..00000000000 --- a/mozilla/content/base/public/nsIElementFactory.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsIElementFactory_h___ -#define nsIElementFactory_h___ - -#include "nsISupports.h" - -class nsIContent; -class nsINodeInfo; - -/* a6cf90fb-15b3-11d2-932e-00805f8add32 */ -#define NS_IELEMENT_FACTORY_IID \ - { 0xa6cf90fb, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} - -/** - * An API for creating html content objects - */ -class nsIElementFactory : public nsISupports { -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IELEMENT_FACTORY_IID) - - NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, - nsIContent** aResult) = 0; -}; - -// ContractIDs for element factory registration -#define NS_ELEMENT_FACTORY_CONTRACTID "@mozilla.org/layout/element-factory;1" -#define NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_ELEMENT_FACTORY_CONTRACTID "?namespace=" - -#define NS_HTML_NAMESPACE "http://www.w3.org/1999/xhtml" -#define NS_XML_NAMESPACE "http://www.w3.org/XML/1998/namespace" - -#define NS_HTML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_HTML_NAMESPACE -#define NS_XML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_XML_NAMESPACE - -#ifdef MOZ_MATHML -#define NS_MATHML_NAMESPACE "http://www.w3.org/1998/Math/MathML" -#define NS_MATHML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_MATHML_NAMESPACE -#endif - -#ifdef MOZ_SVG -#define NS_SVG_NAMESPACE "http://www.w3.org/2000/svg" -#define NS_SVG_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_SVG_NAMESPACE -#endif - -#endif /* nsIElementFactory_h___ */ diff --git a/mozilla/content/base/public/nsINameSpaceManager.h b/mozilla/content/base/public/nsINameSpaceManager.h index db45b0206b3..e051effb5f5 100644 --- a/mozilla/content/base/public/nsINameSpaceManager.h +++ b/mozilla/content/base/public/nsINameSpaceManager.h @@ -44,7 +44,6 @@ class nsIAtom; class nsString; class nsINameSpace; -class nsIElementFactory; #define kNameSpaceID_Unknown -1 #define kNameSpaceID_None 0 @@ -62,8 +61,8 @@ class nsIElementFactory; #define NS_NAMESPACEMANAGER_CONTRACTID "@mozilla.org/content/namespacemanager;1" #define NS_INAMESPACEMANAGER_IID \ - { 0xa6cf90d5, 0x15b3, 0x11d2, \ - {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} + { 0x409cd4de, 0xb3ca, 0x11d8, \ + { 0xb2, 0x67, 0x00, 0x0a, 0x95, 0xdc, 0x23, 0x4c } } /** * The Name Space Manager tracks the associtation between a NameSpace @@ -97,14 +96,7 @@ public: NS_IMETHOD GetNameSpaceID(const nsAString& aURI, PRInt32* aNameSpaceID) = 0; - NS_IMETHOD GetElementFactory(PRInt32 aNameSpaceID, - nsIElementFactory **aElementFactory) = 0; - - NS_IMETHOD HasRegisteredFactory(PRInt32 aNameSpaceID, - PRBool* aHasFactory) = 0; - - NS_IMETHOD HasNameSpaceURI(PRInt32 aNameSpaceID, - PRBool* aHasNameSpaceURI) = 0; + virtual PRBool HasElementCreator(PRInt32 aNameSpaceID) = 0; }; nsresult NS_GetNameSpaceManager(nsINameSpaceManager** aInstancePtrResult); diff --git a/mozilla/content/base/public/nsINodeInfo.h b/mozilla/content/base/public/nsINodeInfo.h index a18bae6c9d5..b930fdb52f0 100644 --- a/mozilla/content/base/public/nsINodeInfo.h +++ b/mozilla/content/base/public/nsINodeInfo.h @@ -41,13 +41,13 @@ * and attributes) that have the same name, prefix and namespace ID within * the same document. * - * nsINodeInfoManager is an interface to an object that manages a list of + * nsNodeInfoManager's are internal objects that manage a list of * nsINodeInfo's, every document object should hold a strong reference to - * a nsINodeInfoManager and every nsINodeInfo also holds a strong reference + * a nsNodeInfoManager and every nsINodeInfo also holds a strong reference * to their owning manager. When a nsINodeInfo is no longer used it will * automatically remove itself from its owner manager, and when all - * nsINodeInfo's have been removed from a nsINodeInfoManager and all external - * references are released the nsINodeInfoManager deletes itself. + * nsINodeInfo's have been removed from a nsNodeInfoManager and all external + * references are released the nsNodeInfoManager deletes itself. * * -- jst@netscape.com */ @@ -61,91 +61,17 @@ #include "nsDOMString.h" #include "nsINameSpaceManager.h" #include "nsCOMPtr.h" -#include "nsCOMArray.h" // Forward declarations -class nsINodeInfo; class nsIDocument; class nsIURI; class nsIPrincipal; - +class nsNodeInfoManager; // IID for the nsINodeInfo interface -#define NS_INODEINFO_IID \ -{ 0x93dbfd8c, 0x2fb3, 0x4ef5, \ - {0xa2, 0xa0, 0xcf, 0xf2, 0x69, 0x6f, 0x07, 0x88} } - -// IID for the nsINodeInfoManager interface -#define NS_INODEINFOMANAGER_IID \ -{ 0xb622469b, 0x4dcf, 0x45c4, \ - {0xb0, 0xb9, 0xa7, 0x32, 0xbc, 0xee, 0xa5, 0xcc} } - -#define NS_NODEINFOMANAGER_CONTRACTID "@mozilla.org/layout/nodeinfomanager;1" - - -class nsINodeInfoManager : public nsISupports -{ -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_INODEINFOMANAGER_IID) - - nsINodeInfoManager() - : mDocument(nsnull) - { - } - - virtual ~nsINodeInfoManager() { } - - /* - * Initialize the nodeinfo manager with a document. - */ - virtual nsresult Init(nsIDocument *aDocument) = 0; - - /* - * Release the reference to the document, this will be called when - * the document is going away. - */ - virtual void DropDocumentReference() = 0; - - /* - * Methods for creating nodeinfo's from atoms and/or strings. - */ - virtual nsresult GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, - nsINodeInfo** aNodeInfo) = 0; - virtual nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, - nsINodeInfo** aNodeInfo) = 0; - virtual nsresult GetNodeInfo(const nsAString& aQualifiedName, - const nsAString& aNamespaceURI, - nsINodeInfo** aNodeInfo) = 0; - virtual nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, - const nsAString& aNamespaceURI, - nsINodeInfo** aNodeInfo) = 0; - - /* - * Retrieve a pointer to the document that owns this node info - * manager. - */ - nsIDocument* GetDocument() const - { - return mDocument; - } - - /** - * Gets the principal of the document associated with this. - */ - virtual nsresult GetDocumentPrincipal(nsIPrincipal** aPrincipal) = 0; - - /** - * Sets the principal of the nodeinfo manager. This should only be called - * when this nodeinfo manager isn't connected to an nsIDocument. - */ - virtual nsresult SetDocumentPrincipal(nsIPrincipal* aPrincipal) = 0; - -protected: - nsIDocument *mDocument; // WEAK -}; - +#define NS_INODEINFO_IID \ +{ 0x290ecd20, 0xb3cb, 0x11d8, \ + { 0xb2, 0x67, 0x00, 0x0a, 0x95, 0xdc, 0x23, 0x4c } } class nsINodeInfo : public nsISupports { @@ -158,8 +84,6 @@ public: { } - virtual ~nsINodeInfo() { } - /* * Get the name from this node as a string, this does not include the prefix. * @@ -271,10 +195,11 @@ public: mIDAttributeAtom = aID; } - /* - * Get the owning node info manager, this will never return null. + /** + * Get the owning node info manager. Only to be used inside Gecko, you can't + * really do anything with the pointer outside Gecko anyway. */ - nsINodeInfoManager* NodeInfoManager() const + nsNodeInfoManager *NodeInfoManager() const { return mOwnerManager; } @@ -313,7 +238,7 @@ public: } PRBool Equals(nsIAtom *aNameAtom, nsIAtom *aPrefixAtom, - PRInt32 aNamespaceID) const + PRInt32 aNamespaceID) const { return ((mInner.mName == aNameAtom) && (mInner.mPrefix == aPrefixAtom) && @@ -336,41 +261,15 @@ public: // switch to UTF8 - this allows faster access for consumers virtual PRBool QualifiedNameEquals(const nsACString& aQualifiedName) const = 0; - /* - * This is a convinience method that creates a new nsINodeInfo that differs - * only by name from the one this is called on. - */ - nsresult NameChanged(nsIAtom *aName, nsINodeInfo** aResult) - { - return mOwnerManager->GetNodeInfo(aName, mInner.mPrefix, - mInner.mNamespaceID, aResult); - } - - /* - * This is a convinience method that creates a new nsINodeInfo that differs - * only by prefix from the one this is called on. - */ - nsresult PrefixChanged(nsIAtom *aPrefix, nsINodeInfo** aResult) - { - return mOwnerManager->GetNodeInfo(mInner.mName, aPrefix, - mInner.mNamespaceID, aResult); - } - /* * Retrieve a pointer to the document that owns this node info. */ - nsIDocument* GetDocument() const - { - return mOwnerManager->GetDocument(); - } + virtual nsIDocument* GetDocument() const = 0; /* * Retrieve a pointer to the principal for the document of this node info. */ - nsresult GetDocumentPrincipal(nsIPrincipal** aPrincipal) const - { - return mOwnerManager->GetDocumentPrincipal(aPrincipal); - } + virtual nsIPrincipal *GetDocumentPrincipal() const = 0; protected: /* @@ -406,10 +305,7 @@ protected: nsNodeInfoInner mInner; nsCOMPtr mIDAttributeAtom; - nsINodeInfoManager* mOwnerManager; // Strong reference! + nsNodeInfoManager* mOwnerManager; // Strong reference! }; -nsresult -NS_NewNodeInfoManager(nsINodeInfoManager** aResult); - #endif /* nsINodeInfo_h___ */ diff --git a/mozilla/content/base/src/Makefile.in b/mozilla/content/base/src/Makefile.in index 45e4186011f..f923a6524a8 100644 --- a/mozilla/content/base/src/Makefile.in +++ b/mozilla/content/base/src/Makefile.in @@ -79,6 +79,7 @@ REQUIRES = xpcom \ EXPORTS = \ nsStubDocumentObserver.h \ + nsNodeInfoManager.h \ nsStyleSet.h \ $(NULL) diff --git a/mozilla/content/base/src/nsContentSink.cpp b/mozilla/content/base/src/nsContentSink.cpp index 11ea2e91360..1d5e837442a 100644 --- a/mozilla/content/base/src/nsContentSink.cpp +++ b/mozilla/content/base/src/nsContentSink.cpp @@ -76,6 +76,7 @@ #include "nsEscape.h" #include "nsWeakReference.h" #include "nsUnicharUtils.h" +#include "nsNodeInfoManager.h" #ifdef ALLOW_ASYNCH_STYLE_SHEETS @@ -188,8 +189,8 @@ nsContentSink::Init(nsIDocument* aDoc, // XXX if it isn't we need to set it here... ProcessHTTPHeaders(aChannel); - mNodeInfoManager = aDoc->GetNodeInfoManager(); - return mNodeInfoManager ? NS_OK : NS_ERROR_NOT_INITIALIZED; + mNodeInfoManager = aDoc->NodeInfoManager(); + return NS_OK; } diff --git a/mozilla/content/base/src/nsContentSink.h b/mozilla/content/base/src/nsContentSink.h index 3e540330b42..c71e33c3682 100644 --- a/mozilla/content/base/src/nsContentSink.h +++ b/mozilla/content/base/src/nsContentSink.h @@ -46,18 +46,19 @@ #include "nsCOMPtr.h" #include "nsCOMArray.h" #include "nsString.h" +#include "nsAutoPtr.h" class nsIDocument; class nsIURI; class nsIChannel; class nsIDocShell; class nsICSSLoader; -class nsINodeInfoManager; class nsIParser; class nsIAtom; class nsIChannel; class nsIContent; class nsIViewManager; +class nsNodeInfoManager; class nsContentSink : public nsICSSLoaderObserver, public nsIScriptLoaderObserver, @@ -110,7 +111,7 @@ protected: nsCOMPtr mDocumentBaseURI; nsCOMPtr mDocShell; nsCOMPtr mCSSLoader; - nsCOMPtr mNodeInfoManager; + nsRefPtr mNodeInfoManager; nsCOMArray mScriptElements; diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index 694d5c2358b..687216e539c 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -94,6 +94,7 @@ #include "nsContentPolicyUtils.h" #include "nsDOMString.h" #include "nsGenericElement.h" +#include "nsNodeInfoManager.h" static const char kJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1"; static NS_DEFINE_IID(kParserServiceCID, NS_PARSERSERVICE_CID); @@ -445,13 +446,14 @@ nsContentUtils::GetDocumentAndPrincipal(nsIDOMNode* aNode, return NS_OK; } - ni->GetDocumentPrincipal(aPrincipal); - + *aPrincipal = ni->NodeInfoManager()->GetDocumentPrincipal(); if (!*aPrincipal) { // we can't get to the principal so we'll give up return NS_OK; } + + NS_ADDREF(*aPrincipal); } else { CallQueryInterface(domDoc, aDocument); @@ -498,7 +500,7 @@ nsContentUtils::CheckSameOrigin(nsIDOMNode *aTrustedNode, // In most cases this is a document, so lets try that first nsCOMPtr trustedDoc = do_QueryInterface(aTrustedNode); - nsCOMPtr trustedPrincipal; + nsIPrincipal* trustedPrincipal = nsnull; if (!trustedDoc) { #ifdef DEBUG @@ -512,7 +514,7 @@ nsContentUtils::CheckSameOrigin(nsIDOMNode *aTrustedNode, if (!domDoc) { // In theory this should never happen. But since theory and reality are // different for XUL elements we'll try to get the principal from the - // nsINodeInfoManager. + // nsNodeInfoManager. nsCOMPtr cont = do_QueryInterface(aTrustedNode); NS_ENSURE_TRUE(cont, NS_ERROR_UNEXPECTED); @@ -520,7 +522,7 @@ nsContentUtils::CheckSameOrigin(nsIDOMNode *aTrustedNode, nsINodeInfo *ni = cont->GetNodeInfo(); NS_ENSURE_TRUE(ni, NS_ERROR_UNEXPECTED); - ni->GetDocumentPrincipal(getter_AddRefs(trustedPrincipal)); + trustedPrincipal = ni->NodeInfoManager()->GetDocumentPrincipal(); if (!trustedPrincipal) { // Can't get principal of aTrustedNode so we can't check security @@ -761,7 +763,7 @@ nsContentUtils::ReparentContentWrapper(nsIContent *aContent, nsINodeInfo *ni = aContent->GetNodeInfo(); if (ni) { - old_doc = ni->GetDocument(); + old_doc = nsContentUtils::GetDocument(ni); } if (!old_doc) { @@ -1590,7 +1592,7 @@ nsContentUtils::CheckQName(const nsAString& aQualifiedName, nsresult nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI, const nsAString& aQualifiedName, - nsINodeInfoManager* aNodeInfoManager, + nsNodeInfoManager* aNodeInfoManager, nsINodeInfo** aNodeInfo) { nsIParserService* parserService = GetParserServiceWeakRef(); @@ -1601,6 +1603,8 @@ nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI, nsresult rv = parserService->CheckQName(qName, PR_TRUE, &colon); NS_ENSURE_SUCCESS(rv, rv); + PRInt32 nsID; + sNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsID); if (colon) { const PRUnichar* end; qName.EndReading(end); @@ -1608,16 +1612,15 @@ nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI, nsCOMPtr prefix = do_GetAtom(Substring(qName.get(), colon)); rv = aNodeInfoManager->GetNodeInfo(Substring(colon + 1, end), prefix, - aNamespaceURI, aNodeInfo); + nsID, aNodeInfo); } else { - rv = aNodeInfoManager->GetNodeInfo(aQualifiedName, nsnull, aNamespaceURI, + rv = aNodeInfoManager->GetNodeInfo(aQualifiedName, nsnull, nsID, aNodeInfo); } NS_ENSURE_SUCCESS(rv, rv); nsIAtom* prefix = (*aNodeInfo)->GetPrefixAtom(); - PRInt32 nsID = (*aNodeInfo)->NamespaceID(); nsIAtom* nil = nsnull; // NAMESPACE_ERR: Raised if the qualifiedName is a malformed qualified name, diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp index 206e26c5b33..5cfa87a994c 100644 --- a/mozilla/content/base/src/nsDOMAttribute.cpp +++ b/mozilla/content/base/src/nsDOMAttribute.cpp @@ -371,11 +371,12 @@ nsDOMAttribute::SetPrefix(const nsAString& aPrefix) nsCOMPtr newNodeInfo; nsCOMPtr prefix; - if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix)) { + if (!aPrefix.IsEmpty()) { prefix = do_GetAtom(aPrefix); } - nsresult rv = mNodeInfo->PrefixChanged(prefix, getter_AddRefs(newNodeInfo)); + nsresult rv = nsContentUtils::PrefixChanged(mNodeInfo, prefix, + getter_AddRefs(newNodeInfo)); NS_ENSURE_SUCCESS(rv, rv); if (mContent) { diff --git a/mozilla/content/base/src/nsDOMAttributeMap.cpp b/mozilla/content/base/src/nsDOMAttributeMap.cpp index b6f1c323a82..79dbe744b48 100644 --- a/mozilla/content/base/src/nsDOMAttributeMap.cpp +++ b/mozilla/content/base/src/nsDOMAttributeMap.cpp @@ -42,6 +42,7 @@ #include "nsINameSpaceManager.h" #include "nsDOMError.h" #include "nsContentUtils.h" +#include "nsNodeInfoManager.h" //---------------------------------------------------------------------- diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index f9b3ca9241e..6f75c4e7921 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -116,14 +116,22 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID); #include "nsScriptEventManager.h" #include "nsIXPathEvaluatorInternal.h" -#include "nsIElementFactory.h" #include "nsIParserService.h" +#include "nsContentCreatorFunctions.h" #include "nsIScriptContext.h" #include "nsICharsetAlias.h" static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID); +nsIDocument::~nsIDocument() +{ + if (mNodeInfoManager) { + mNodeInfoManager->DropDocumentReference(); + NS_RELEASE(mNodeInfoManager); + } +} + // Helper structs for the content->subdoc map class SubDocMapEntry : public PLDHashEntryHdr @@ -587,10 +595,6 @@ nsDocument::~nsDocument() mCSSLoader->DropDocumentReference(); } - if (mNodeInfoManager) { - mNodeInfoManager->DropDocumentReference(); - } - if (mAttrStyleSheet) { mAttrStyleSheet->SetOwningDocument(nsnull); } @@ -668,6 +672,8 @@ nsDocument::Init() mNodeInfoManager = new nsNodeInfoManager(); NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY); + NS_ADDREF(mNodeInfoManager); + return mNodeInfoManager->Init(this); } @@ -2167,12 +2173,12 @@ nsDocument::CreateElement(const nsAString& aTagName, nsCOMPtr name = do_GetAtom(aTagName); - nsCOMPtr nodeInfo; - rv = mNodeInfoManager->GetNodeInfo(name, nsnull, GetDefaultNamespaceID(), - getter_AddRefs(nodeInfo)); + nsCOMPtr content; + rv = CreateElement(name, nsnull, GetDefaultNamespaceID(), + mDefaultElementType, getter_AddRefs(content)); NS_ENSURE_SUCCESS(rv, rv); - return CreateElement(nodeInfo, aReturn); + return CallQueryInterface(content, aReturn); } NS_IMETHODIMP @@ -2189,7 +2195,12 @@ nsDocument::CreateElementNS(const nsAString& aNamespaceURI, getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, rv); - return CreateElement(nodeInfo, aReturn); + nsCOMPtr content; + rv = CreateElement(nodeInfo, nodeInfo->NamespaceID(), + getter_AddRefs(content)); + NS_ENSURE_SUCCESS(rv, rv); + + return CallQueryInterface(content, aReturn); } NS_IMETHODIMP @@ -4241,27 +4252,42 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel) } nsresult -nsDocument::CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult) +nsDocument::CreateElem(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID, + PRBool aDocumentDefaultType, nsIContent **aResult) { *aResult = nsnull; - PRInt32 namespaceID = aNodeInfo->NamespaceID(); + PRInt32 elementType = aDocumentDefaultType ? mDefaultElementType : + aNamespaceID; - nsCOMPtr elementFactory; - nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(namespaceID, - getter_AddRefs(elementFactory)); + return CreateElement(aName, aPrefix, aNamespaceID, elementType, aResult); +} - nsresult rv; +nsresult +nsDocument::CreateElement(nsIAtom *aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, PRInt32 aElementType, + nsIContent** aResult) +{ + nsCOMPtr nodeInfo; + nsresult rv = mNodeInfoManager->GetNodeInfo(aName, aPrefix, aNamespaceID, + getter_AddRefs(nodeInfo)); + NS_ENSURE_SUCCESS(rv, rv); + + return CreateElement(nodeInfo, aElementType, aResult); +} + +nsresult +nsDocument::CreateElement(nsINodeInfo *aNodeInfo, PRInt32 aElementType, + nsIContent** aResult) +{ nsCOMPtr content; - if (elementFactory) { - rv = elementFactory->CreateInstanceByTag(aNodeInfo, - getter_AddRefs(content)); - } else { - rv = NS_NewXMLElement(getter_AddRefs(content), aNodeInfo); - } + nsresult rv = NS_NewElement(getter_AddRefs(content), aElementType, + aNodeInfo); NS_ENSURE_SUCCESS(rv, rv); content->SetContentID(mNextContentID++); - return CallQueryInterface(content, aResult); + content.swap(*aResult); + + return NS_OK; } diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index fc9404d6b09..1d933f6af76 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -490,6 +490,11 @@ public: virtual nsresult Init(); + virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, + PRBool aDocumentDefaultType, + nsIContent **aResult); + protected: // subclass hooks for sheet ordering virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet, @@ -513,7 +518,11 @@ protected: nsresult ResetStylesheetsToURI(nsIURI* aURI); virtual nsStyleSet::sheetType GetAttrSheetType(); - nsresult CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult); + nsresult CreateElement(nsIAtom *aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, PRInt32 aElementType, + nsIContent** aResult); + nsresult CreateElement(nsINodeInfo *aNodeInfo, PRInt32 aElementType, + nsIContent** aResult); virtual PRInt32 GetDefaultNamespaceID() const { @@ -560,6 +569,8 @@ protected: PRUint8 mXMLDeclarationBits; + PRUint8 mDefaultElementType; + nsSupportsHashtable* mBoxObjectTable; nsSupportsHashtable mContentWrapperHash; diff --git a/mozilla/content/base/src/nsDocumentFragment.cpp b/mozilla/content/base/src/nsDocumentFragment.cpp index 14012d94853..82897385293 100644 --- a/mozilla/content/base/src/nsDocumentFragment.cpp +++ b/mozilla/content/base/src/nsDocumentFragment.cpp @@ -173,7 +173,7 @@ NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult, { NS_ENSURE_ARG(aOwnerDocument); - nsINodeInfoManager *nimgr = aOwnerDocument->GetNodeInfoManager(); + nsNodeInfoManager *nimgr = aOwnerDocument->NodeInfoManager(); nsCOMPtr nodeInfo; nsresult rv = nimgr->GetNodeInfo(nsLayoutAtoms::documentFragmentNodeName, diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 4c69b3c7f11..ea03617a91a 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -99,6 +99,7 @@ #include "jsapi.h" #include "nsIDOMXPathEvaluator.h" +#include "nsNodeInfoManager.h" #ifdef DEBUG_waterson @@ -1108,14 +1109,14 @@ nsGenericElement::SetPrefix(const nsAString& aPrefix) nsCOMPtr prefix; - if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix)) { + if (!aPrefix.IsEmpty()) { prefix = do_GetAtom(aPrefix); NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); } nsCOMPtr newNodeInfo; - nsresult rv = mNodeInfo->PrefixChanged(prefix, - getter_AddRefs(newNodeInfo)); + nsresult rv = nsContentUtils::PrefixChanged(mNodeInfo, prefix, + getter_AddRefs(newNodeInfo)); NS_ENSURE_SUCCESS(rv, rv); mNodeInfo = newNodeInfo; @@ -1721,18 +1722,16 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, // check the document on the nodeinfo to see whether we need a // new nodeinfo - if (aDocument && aDocument != mNodeInfo->GetDocument()) { + if (aDocument && aDocument != nsContentUtils::GetDocument(mNodeInfo)) { // get a new nodeinfo - nsINodeInfoManager* nodeInfoManager = aDocument->GetNodeInfoManager(); - if (nodeInfoManager) { - nsCOMPtr newNodeInfo; - nodeInfoManager->GetNodeInfo(mNodeInfo->NameAtom(), - mNodeInfo->GetPrefixAtom(), - mNodeInfo->NamespaceID(), - getter_AddRefs(newNodeInfo)); - if (newNodeInfo) { - mNodeInfo.swap(newNodeInfo); - } + nsNodeInfoManager* nodeInfoManager = aDocument->NodeInfoManager(); + nsCOMPtr newNodeInfo; + nodeInfoManager->GetNodeInfo(mNodeInfo->NameAtom(), + mNodeInfo->GetPrefixAtom(), + mNodeInfo->NamespaceID(), + getter_AddRefs(newNodeInfo)); + if (newNodeInfo) { + mNodeInfo.swap(newNodeInfo); } } diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index cd5c3d52549..eac631e3eaf 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -732,7 +732,7 @@ protected: nsIDocument* GetOwnerDocument() const { - return mDocument ? mDocument : mNodeInfo->GetDocument(); + return mDocument ? mDocument : nsContentUtils::GetDocument(mNodeInfo); } nsIContent* GetParent() const { diff --git a/mozilla/content/base/src/nsImageLoadingContent.cpp b/mozilla/content/base/src/nsImageLoadingContent.cpp index ff15a2ebbfa..9005f8f4dde 100644 --- a/mozilla/content/base/src/nsImageLoadingContent.cpp +++ b/mozilla/content/base/src/nsImageLoadingContent.cpp @@ -561,7 +561,7 @@ nsImageLoadingContent::GetOurDocument() // XXXbz GetOwnerDocument nsINodeInfo *nodeInfo = thisContent->GetNodeInfo(); if (nodeInfo) { - doc = nodeInfo->GetDocument(); + doc = nsContentUtils::GetDocument(nodeInfo); } } diff --git a/mozilla/content/base/src/nsNameSpaceManager.cpp b/mozilla/content/base/src/nsNameSpaceManager.cpp index 8c047ad3418..b10c58ef7bc 100644 --- a/mozilla/content/base/src/nsNameSpaceManager.cpp +++ b/mozilla/content/base/src/nsNameSpaceManager.cpp @@ -37,17 +37,13 @@ #include "nscore.h" #include "nsINameSpaceManager.h" #include "nsINameSpace.h" +#include "nsINodeInfo.h" #include "nsCOMArray.h" -#include "nsIElementFactory.h" -#include "nsIServiceManager.h" +#include "nsContentCreatorFunctions.h" #include "nsDoubleHashtable.h" #include "nsLayoutAtoms.h" #include "nsString.h" -static nsINameSpaceManager* gNameSpaceManager = nsnull; - -nsresult NS_NewXMLElementFactory(nsIElementFactory** aResult); - #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" @@ -99,6 +95,87 @@ private: PRInt32 mID; }; +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)); + } +}; + +class NameSpaceManagerImpl : public nsINameSpaceManager { +public: + NameSpaceManagerImpl(); + virtual ~NameSpaceManagerImpl(); + + NS_DECL_ISUPPORTS + + nsresult Init(); + + NS_IMETHOD CreateRootNameSpace(nsINameSpace** aRootNameSpace); + + NS_IMETHOD RegisterNameSpace(const nsAString& aURI, + PRInt32& aNameSpaceID); + + NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI); + NS_IMETHOD GetNameSpaceID(const nsAString& aURI, + PRInt32* aNameSpaceID); + + PRBool HasElementCreator(PRInt32 aNameSpaceID); + + PRBool HasNameSpaceURI(PRInt32 aNameSpaceID); + +private: + // These are not supported and are not implemented! + NameSpaceManagerImpl(const NameSpaceManagerImpl& aCopy); + NameSpaceManagerImpl& operator=(const NameSpaceManagerImpl& aCopy); + + nsresult AddNameSpace(const nsAString& aURI, const PRInt32 aNameSpaceID); + + nsNameSpaceHash mURIToIDTable; + nsStringArray mURIArray; +}; + +static NameSpaceManagerImpl* gNameSpaceManager = nsnull; + + + NameSpaceImpl::NameSpaceImpl(NameSpaceImpl* aParent, nsIAtom* aPrefix, const nsAString& aURI) @@ -237,9 +314,7 @@ NS_IMETHODIMP NameSpaceImpl::CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID, nsINameSpace** aChildNameSpace) { - PRBool hasNSURI; - gNameSpaceManager->HasNameSpaceURI(aNameSpaceID, &hasNSURI); - if (hasNSURI) { + if (gNameSpaceManager->HasNameSpaceURI(aNameSpaceID)) { NameSpaceImpl* child = new NameSpaceImpl(this, aPrefix, aNameSpaceID); NS_ENSURE_TRUE(child, NS_ERROR_OUT_OF_MEMORY); @@ -253,90 +328,6 @@ NameSpaceImpl::CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID, 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 - -class NameSpaceManagerImpl : public nsINameSpaceManager { -public: - NameSpaceManagerImpl(); - virtual ~NameSpaceManagerImpl(); - - NS_DECL_ISUPPORTS - - nsresult Init(); - - NS_IMETHOD CreateRootNameSpace(nsINameSpace** aRootNameSpace); - - NS_IMETHOD RegisterNameSpace(const nsAString& aURI, - PRInt32& aNameSpaceID); - - NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI); - NS_IMETHOD GetNameSpaceID(const nsAString& aURI, - PRInt32* aNameSpaceID); - NS_IMETHOD GetElementFactory(PRInt32 aNameSpaceID, - 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); - - nsresult AddNameSpace(const nsAString& aURI, const PRInt32 aNameSpaceID); - - nsNameSpaceHash mURIToIDTable; - nsStringArray mURIArray; - nsCOMArray mElementFactoryArray; - nsCOMPtr mDefaultElementFactory; -}; - NameSpaceManagerImpl::NameSpaceManagerImpl() { } @@ -364,7 +355,7 @@ nsresult NameSpaceManagerImpl::Init() AddNameSpace(NS_LITERAL_STRING(kXULNameSpaceURI), kNameSpaceID_XUL); AddNameSpace(NS_LITERAL_STRING(kSVGNameSpaceURI), kNameSpaceID_SVG); - return NS_NewXMLElementFactory(getter_AddRefs(mDefaultElementFactory)); + return NS_OK; } NS_IMETHODIMP @@ -449,91 +440,52 @@ NameSpaceManagerImpl::GetNameSpaceID(const nsAString& aURI, PRInt32* aNameSpaceI return NS_OK; } -NS_IMETHODIMP -NameSpaceManagerImpl::GetElementFactory(PRInt32 aNameSpaceID, - nsIElementFactory **aElementFactory) +nsresult +NS_NewElement(nsIContent** aResult, PRInt32 aElementType, + nsINodeInfo* aNodeInfo) { - *aElementFactory = nsnull; - - // Parsing should have aborted before we get here, but for now we'll have to - // live with returning the default factory. Bugs 184697 and 103255 - if (aNameSpaceID == kNameSpaceID_Unknown) { - *aElementFactory = mDefaultElementFactory; - NS_ADDREF(*aElementFactory); - - return NS_OK; + if (aElementType == kNameSpaceID_XHTML) { + return NS_NewHTMLElement(aResult, aNodeInfo); } - - NS_ENSURE_TRUE(aNameSpaceID >= 0, NS_ERROR_ILLEGAL_VALUE); - - if (aNameSpaceID < mElementFactoryArray.Count()) { - *aElementFactory = mElementFactoryArray.ObjectAt(aNameSpaceID); - if (*aElementFactory) { - NS_ADDREF(*aElementFactory); - - return NS_OK; - } +#ifdef MOZ_XUL + if (aElementType == kNameSpaceID_XUL) { + return NS_NewXULElement(aResult, aNodeInfo); } - - nsAutoString uri; - GetNameSpaceURI(aNameSpaceID, uri); - - nsCOMPtr ef; - - if (!uri.IsEmpty()) { - nsCAutoString contract_id(NS_ELEMENT_FACTORY_CONTRACTID_PREFIX); - AppendUTF16toUTF8(uri, contract_id); - ef = do_GetService(contract_id.get()); +#endif +#ifdef MOZ_MATHML + if (aElementType == kNameSpaceID_MathML) { + return NS_NewMathMLElement(aResult, aNodeInfo); } - - if (!ef) { - ef = mDefaultElementFactory; +#endif +#ifdef MOZ_SVG + if (aElementType == kNameSpaceID_SVG) { + return NS_NewSVGElement(aResult, aNodeInfo); } - - PRInt32 count = mElementFactoryArray.Count(); - - if (aNameSpaceID < count) { - mElementFactoryArray.ReplaceObjectAt(ef, aNameSpaceID); - } else { - // 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) { - mElementFactoryArray.AppendObject(nsnull); - } - - mElementFactoryArray.AppendObject(ef); - } - - *aElementFactory = ef; - NS_ADDREF(*aElementFactory); - - return NS_OK; +#endif + return NS_NewXMLElement(aResult, aNodeInfo); } -NS_IMETHODIMP -NameSpaceManagerImpl::HasRegisteredFactory(PRInt32 aNameSpaceID, - PRBool* aHasFactory) +PRBool +NameSpaceManagerImpl::HasElementCreator(PRInt32 aNameSpaceID) { - *aHasFactory = PR_FALSE; - NS_ENSURE_TRUE(mDefaultElementFactory, NS_ERROR_FAILURE); - - nsCOMPtr ef; - GetElementFactory(aNameSpaceID, getter_AddRefs(ef)); - *aHasFactory = ef != mDefaultElementFactory; - - return NS_OK; + return aNameSpaceID == kNameSpaceID_XHTML || +#ifdef MOZ_XUL + aNameSpaceID == kNameSpaceID_XUL || +#endif +#ifdef MOZ_MATHML + aNameSpaceID == kNameSpaceID_MathML || +#endif +#ifdef MOZ_SVG + aNameSpaceID == kNameSpaceID_SVG || +#endif + PR_FALSE; } -NS_IMETHODIMP -NameSpaceManagerImpl::HasNameSpaceURI(PRInt32 aNameSpaceID, - PRBool* aHasNameSpaceURI) +PRBool +NameSpaceManagerImpl::HasNameSpaceURI(PRInt32 aNameSpaceID) { - *aHasNameSpaceURI = (aNameSpaceID > kNameSpaceID_None || - aNameSpaceID <= mURIArray.Count()); - - return NS_OK; + return (aNameSpaceID > kNameSpaceID_None && + aNameSpaceID <= mURIArray.Count()); } nsresult NameSpaceManagerImpl::AddNameSpace(const nsAString& aURI, @@ -569,8 +521,7 @@ NS_GetNameSpaceManager(nsINameSpaceManager** aInstancePtrResult) if (manager) { nsresult rv = manager->Init(); if (NS_SUCCEEDED(rv)) { - gNameSpaceManager = manager; - NS_ADDREF(gNameSpaceManager); + manager.swap(gNameSpaceManager); } } } diff --git a/mozilla/content/base/src/nsNodeInfo.cpp b/mozilla/content/base/src/nsNodeInfo.cpp index 2343a889c99..c0dc65e1584 100644 --- a/mozilla/content/base/src/nsNodeInfo.cpp +++ b/mozilla/content/base/src/nsNodeInfo.cpp @@ -76,7 +76,7 @@ void nsNodeInfo::Clear() { if (mOwnerManager) { - NS_STATIC_CAST(nsNodeInfoManager*, mOwnerManager)->RemoveNodeInfo(this); + mOwnerManager->RemoveNodeInfo(this); NS_RELEASE(mOwnerManager); } diff --git a/mozilla/content/base/src/nsNodeInfo.h b/mozilla/content/base/src/nsNodeInfo.h index f2602951b66..e8d6c9c815d 100644 --- a/mozilla/content/base/src/nsNodeInfo.h +++ b/mozilla/content/base/src/nsNodeInfo.h @@ -39,12 +39,11 @@ #define nsNodeInfo_h___ #include "nsINodeInfo.h" +#include "nsNodeInfoManager.h" #include "plhash.h" #include "nsIAtom.h" #include "nsCOMPtr.h" -class nsNodeInfoManager; - class nsNodeInfo : public nsINodeInfo { public: @@ -63,6 +62,16 @@ public: virtual PRBool NamespaceEquals(const nsAString& aNamespaceURI) const; virtual PRBool QualifiedNameEquals(const nsACString& aQualifiedName) const; + nsIDocument* GetDocument() const + { + return mOwnerManager->GetDocument(); + } + + nsIPrincipal *GetDocumentPrincipal() const + { + return mOwnerManager->GetDocumentPrincipal(); + } + // nsNodeInfo // Create objects with Create public: diff --git a/mozilla/content/base/src/nsNodeInfoManager.cpp b/mozilla/content/base/src/nsNodeInfoManager.cpp index 550c83a0c44..05268bf1f2e 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.cpp +++ b/mozilla/content/base/src/nsNodeInfoManager.cpp @@ -49,20 +49,6 @@ PRUint32 nsNodeInfoManager::gNodeManagerCount; - -nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - - *aResult = new nsNodeInfoManager; - NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY); - - NS_ADDREF(*aResult); - - return NS_OK; -} - - PLHashNumber nsNodeInfoManager::GetNodeInfoInnerHashValue(const void *key) { @@ -92,7 +78,7 @@ nsNodeInfoManager::NodeInfoInnerKeyCompare(const void *key1, const void *key2) } -nsNodeInfoManager::nsNodeInfoManager() +nsNodeInfoManager::nsNodeInfoManager() : mDocument(nsnull) { ++gNodeManagerCount; @@ -124,10 +110,31 @@ nsNodeInfoManager::~nsNodeInfoManager() } -NS_IMPL_THREADSAFE_ISUPPORTS1(nsNodeInfoManager, nsINodeInfoManager) +nsrefcnt +nsNodeInfoManager::AddRef() +{ + NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); + nsrefcnt count = PR_AtomicIncrement((PRInt32*)&mRefCnt); + NS_LOG_ADDREF(this, count, "nsNodeInfoManager", sizeof(*this)); -// nsINodeInfoManager + return count; +} + +nsrefcnt +nsNodeInfoManager::Release() +{ + NS_PRECONDITION(0 != mRefCnt, "dup release"); + + nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mRefCnt); + NS_LOG_RELEASE(this, count, "nsNodeInfoManager"); + if (count == 0) { + mRefCnt = 1; /* stabilize */ + delete this; + } + + return count; +} nsresult nsNodeInfoManager::Init(nsIDocument *aDocument) @@ -248,27 +255,9 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName, return GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo); } -nsresult -nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, - const nsAString& aNamespaceURI, - nsINodeInfo** aNodeInfo) +nsIPrincipal* +nsNodeInfoManager::GetDocumentPrincipal() { - nsCOMPtr nameAtom = do_GetAtom(aName); - - PRInt32 nsid = kNameSpaceID_None; - if (!aNamespaceURI.IsEmpty()) { - nsresult rv = nsContentUtils::GetNSManagerWeakRef()-> - RegisterNameSpace(aNamespaceURI, nsid); - NS_ENSURE_SUCCESS(rv, rv); - } - - return GetNodeInfo(nameAtom, aPrefix, nsid, aNodeInfo); -} - -nsresult -nsNodeInfoManager::GetDocumentPrincipal(nsIPrincipal** aPrincipal) -{ - NS_ENSURE_ARG_POINTER(aPrincipal); NS_ASSERTION(!mDocument || !mPrincipal, "how'd we end up with both a document and a principal?"); @@ -276,28 +265,23 @@ nsNodeInfoManager::GetDocumentPrincipal(nsIPrincipal** aPrincipal) // If the document has a uri we'll ask for it's principal. Otherwise we'll // consider this document 'anonymous' if (!mDocument->GetDocumentURI()) { - *aPrincipal = nsnull; - return NS_OK; + return nsnull; } - *aPrincipal = mDocument->GetPrincipal(); - if (!*aPrincipal) - return NS_ERROR_FAILURE; - - NS_ADDREF(*aPrincipal); - return NS_OK; + return mDocument->GetPrincipal(); } - *aPrincipal = mPrincipal; - NS_IF_ADDREF(*aPrincipal); - return NS_OK; + + return mPrincipal; } -nsresult -nsNodeInfoManager::SetDocumentPrincipal(nsIPrincipal* aPrincipal) +void +nsNodeInfoManager::SetDocumentPrincipal(nsIPrincipal *aPrincipal) { - NS_ENSURE_FALSE(mDocument, NS_ERROR_UNEXPECTED); - mPrincipal = aPrincipal; - return NS_OK; + NS_ASSERTION(!mDocument, + "Don't set a principal, we already have a document."); + if (!mDocument) { + mPrincipal = aPrincipal; + } } void diff --git a/mozilla/content/base/src/nsNodeInfoManager.h b/mozilla/content/base/src/nsNodeInfoManager.h index e508bd23825..79c005a4fb8 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.h +++ b/mozilla/content/base/src/nsNodeInfoManager.h @@ -38,40 +38,73 @@ #ifndef nsNodeInfoManager_h___ #define nsNodeInfoManager_h___ -#include "nsINodeInfo.h" +#include "nsCOMArray.h" #include "nsCOMPtr.h" #include "plhash.h" +class nsIAtom; +class nsIDocument; +class nsINodeInfo; class nsNodeInfo; class nsIPrincipal; class nsIURI; - -class nsNodeInfoManager : public nsINodeInfoManager +class nsNodeInfoManager { public: - NS_DECL_ISUPPORTS - - // nsINodeInfoManager - virtual nsresult Init(nsIDocument *aDocument); - virtual void DropDocumentReference(); - virtual nsresult GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo); - virtual nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo); - virtual nsresult GetNodeInfo(const nsAString& aQualifiedName, - const nsAString& aNamespaceURI, - nsINodeInfo** aNodeInfo); - virtual nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, - const nsAString& aNamespaceURI, - nsINodeInfo** aNodeInfo); - - virtual nsresult GetDocumentPrincipal(nsIPrincipal** aPrincipal); - virtual nsresult SetDocumentPrincipal(nsIPrincipal* aPrincipal); - - // nsNodeInfoManager nsNodeInfoManager(); - virtual ~nsNodeInfoManager(); + ~nsNodeInfoManager(); + + nsrefcnt AddRef(void); + nsrefcnt Release(void); + + /** + * Initialize the nodeinfo manager with a document. + */ + nsresult Init(nsIDocument *aDocument); + + /** + * Release the reference to the document, this will be called when + * the document is going away. + */ + void DropDocumentReference(); + + /** + * Methods for creating nodeinfo's from atoms and/or strings. + */ + nsresult GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo); + nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo); + nsresult GetNodeInfo(const nsAString& aQualifiedName, + const nsAString& aNamespaceURI, + nsINodeInfo** aNodeInfo); + + /** + * Retrieve a pointer to the document that owns this node info + * manager. + */ + nsIDocument* GetDocument() const + { + return mDocument; + } + + /** + * Gets the principal of the document associated with this. + */ + nsIPrincipal *GetDocumentPrincipal(); + + /** + * Sets the principal of the nodeinfo manager. This should only be called + * when this nodeinfo manager isn't connected to an nsIDocument. + */ + void SetDocumentPrincipal(nsIPrincipal *aPrincipal); + + /** + * Populate the given nsCOMArray with all of the nsINodeInfos + * managed by this manager. + */ + nsresult GetNodeInfos(nsCOMArray *aArray); void RemoveNodeInfo(nsNodeInfo *aNodeInfo); @@ -80,7 +113,11 @@ private: const void *key2); static PLHashNumber PR_CALLBACK GetNodeInfoInnerHashValue(const void *key); + nsAutoRefCnt mRefCnt; + NS_DECL_OWNINGTHREAD + PLHashTable *mNodeInfoHash; + nsIDocument *mDocument; // WEAK nsCOMPtr mPrincipal; static PRUint32 gNodeManagerCount; diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index 98e2063a222..63dfc1c801e 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -1848,7 +1848,7 @@ nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval) // XXXbz GetOwnerDocument nsINodeInfo *nodeInfo = targetContent->GetNodeInfo(); if (nodeInfo) { - document = nodeInfo->GetDocument(); + document = nsContentUtils::GetDocument(nodeInfo); } } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index ccf06ab4283..a81eb4dd3e4 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -134,8 +134,8 @@ #include "nsIDOMText.h" #include "nsITextContent.h" -#include "nsAutoPtr.h" #include "nsCOMArray.h" +#include "nsNodeInfoManager.h" static NS_DEFINE_CID(kPresStateCID, NS_PRESSTATE_CID); // XXX todo: add in missing out-of-memory checks @@ -314,7 +314,7 @@ nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst, PRBool aDeep) NS_ENSURE_SUCCESS(rv, rv); } - nsIDocument *doc = mNodeInfo->GetDocument(); + nsIDocument *doc = nsContentUtils::GetDocument(mNodeInfo); PRInt32 id; if (doc) { @@ -2646,9 +2646,10 @@ nsGenericHTMLElement::ParseStyleAttribute(nsIContent* aContent, nsresult result = NS_OK; NS_ASSERTION(aContent->GetNodeInfo(), "If we don't have a nodeinfo, we are very screwed"); + // XXX GetOwnerDoc nsIDocument* doc = aContent->GetDocument(); if (!doc) { - doc = aContent->GetNodeInfo()->GetDocument(); + doc = nsContentUtils::GetDocument(aContent->GetNodeInfo()); } if (doc) { diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index c0df8de1b2d..4774171df2b 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -168,12 +168,9 @@ NS_NewHTMLImageElement(nsINodeInfo *aNodeInfo, PRBool aFromParser) do_QueryInterface(nsContentUtils::GetDocumentFromCaller()); NS_ENSURE_TRUE(doc, nsnull); - nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nodeInfoManager, nsnull); - - rv = nodeInfoManager->GetNodeInfo(nsHTMLAtoms::img, nsnull, - kNameSpaceID_None, - getter_AddRefs(nodeInfo)); + rv = doc->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::img, nsnull, + kNameSpaceID_None, + getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, nsnull); } diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index 98ed3951474..40f5cb16358 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -166,12 +166,9 @@ NS_NewHTMLOptionElement(nsINodeInfo *aNodeInfo, PRBool aFromParser) do_QueryInterface(nsContentUtils::GetDocumentFromCaller()); NS_ENSURE_TRUE(doc, nsnull); - nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nodeInfoManager, nsnull); - - rv = nodeInfoManager->GetNodeInfo(nsHTMLAtoms::option, nsnull, - kNameSpaceID_None, - getter_AddRefs(nodeInfo)); + rv = doc->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::option, nsnull, + kNameSpaceID_None, + getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, nsnull); } diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 089c2cc8bf4..102af8cd238 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -1051,7 +1051,8 @@ nsHTMLSelectElement::SetLength(PRUint32 aLength) // This violates the W3C DOM but we do this for backwards compatibility nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::option, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::option, + getter_AddRefs(nodeInfo)); nsCOMPtr element = NS_NewHTMLOptionElement(nodeInfo); if (!element) { diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp index 8935bede2d1..5ae7b389703 100644 --- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -520,7 +520,8 @@ nsHTMLTableElement::CreateTHead(nsIDOMHTMLElement** aValue) { // create a new head rowgroup nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::thead, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::thead, + getter_AddRefs(nodeInfo)); nsCOMPtr newHead = NS_NewHTMLTableSectionElement(nodeInfo); @@ -575,7 +576,8 @@ nsHTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue) else { // create a new foot rowgroup nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::tfoot, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::tfoot, + getter_AddRefs(nodeInfo)); nsCOMPtr newFoot = NS_NewHTMLTableSectionElement(nodeInfo); @@ -620,7 +622,8 @@ nsHTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue) else { // create a new head rowgroup nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::caption, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::caption, + getter_AddRefs(nodeInfo)); nsCOMPtr newCaption = NS_NewHTMLTableCaptionElement(nodeInfo); @@ -695,7 +698,8 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) refRow->GetParentNode(getter_AddRefs(parent)); // create the row nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::tr, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::tr, + getter_AddRefs(nodeInfo)); nsCOMPtr newRow = NS_NewHTMLTableRowElement(nodeInfo); @@ -742,7 +746,8 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) if (!rowGroup) { // need to create a TBODY nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::tbody, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::tbody, + getter_AddRefs(nodeInfo)); nsCOMPtr newRowGroup = NS_NewHTMLTableSectionElement(nodeInfo); @@ -756,7 +761,8 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) if (rowGroup) { nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::tr, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::tr, + getter_AddRefs(nodeInfo)); nsCOMPtr newRow = NS_NewHTMLTableRowElement(nodeInfo); if (newRow) { diff --git a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp index 782cf56c789..ac30e2b6643 100644 --- a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp @@ -303,7 +303,8 @@ nsHTMLTableRowElement::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue) // create the cell nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::td, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::td, + getter_AddRefs(nodeInfo)); nsCOMPtr cellContent = NS_NewHTMLTableCellElement(nodeInfo); if (!cellContent) { diff --git a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp index 1a32c6c3597..fc85206dc02 100644 --- a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -166,7 +166,8 @@ nsHTMLTableSectionElement::InsertRow(PRInt32 aIndex, // create the row nsCOMPtr nodeInfo; - mNodeInfo->NameChanged(nsHTMLAtoms::tr, getter_AddRefs(nodeInfo)); + nsContentUtils::NameChanged(mNodeInfo, nsHTMLAtoms::tr, + getter_AddRefs(nodeInfo)); nsCOMPtr rowContent = NS_NewHTMLTableRowElement(nodeInfo); if (!nodeInfo) { diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index fbd9d0bcd4a..ac9de6b9618 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -64,7 +64,6 @@ #include "nsInt64.h" #include "nsGenericHTMLElement.h" -#include "nsIElementFactory.h" #include "nsITextContent.h" #include "nsIDOMText.h" @@ -123,6 +122,8 @@ #include "nsEscape.h" #include "nsIElementObserver.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" //---------------------------------------------------------------------- @@ -281,7 +282,7 @@ protected: nsresult SetDocumentTitle(const nsAString& aTitle); // If aCheckIfPresent is true, will only set an attribute in cases // when it's not already set. - nsresult AddAttributes(const nsIParserNode& aNode, nsIHTMLContent* aContent, + nsresult AddAttributes(const nsIParserNode& aNode, nsIContent* aContent, PRBool aNotify = PR_FALSE, PRBool aCheckIfPresent = PR_FALSE); already_AddRefed @@ -397,7 +398,7 @@ protected: * added to the content node, since the way URI attributes are treated may * depend on the value of the base URI */ - void AddBaseTagInfo(nsIHTMLContent* aContent); + void AddBaseTagInfo(nsIContent* aContent); void ProcessBaseHref(const nsAString& aBaseHref); void ProcessBaseTarget(const nsAString& aBaseTarget); @@ -788,7 +789,7 @@ HTMLContentSink::SinkTraceNode(PRUint32 aBit, nsresult HTMLContentSink::AddAttributes(const nsIParserNode& aNode, - nsIHTMLContent* aContent, PRBool aNotify, + nsIContent* aContent, PRBool aNotify, PRBool aCheckIfPresent) { // Add tag attributes to the content attributes @@ -953,27 +954,29 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode, } nsresult -NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo, PRBool aCaseSensitive) +NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo) { + *aResult = nsnull; + nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef(); if (!parserService) return NS_ERROR_OUT_OF_MEMORY; nsIAtom *name = aNodeInfo->NameAtom(); - // Find tag in tag table PRInt32 id; - - if (aCaseSensitive) { + nsCOMPtr result; + if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) { + // Find tag in tag table parserService->HTMLCaseSensitiveAtomTagToId(name, &id); - } else { - parserService->HTMLAtomTagToId(name, &id); - } - if (aCaseSensitive) { - *aResult = MakeContentObject(nsHTMLTag(id), aNodeInfo, nsnull, - PR_FALSE, PR_FALSE).get(); - } else { + result = MakeContentObject(nsHTMLTag(id), aNodeInfo, nsnull, + PR_FALSE, PR_FALSE); + } + else { + // Find tag in tag table + parserService->HTMLAtomTagToId(name, &id); + // Revese map id to name to get the correct character case in // the tag name. @@ -988,76 +991,20 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo, PRBool aC if (!name->Equals(nsDependentString(tag))) { nsCOMPtr atom = do_GetAtom(tag); - nsresult rv = aNodeInfo->NameChanged(atom, getter_AddRefs(kungFuDeathGrip)); - NS_ENSURE_SUCCESS(rv, nsnull); + nsresult rv = + nsContentUtils::NameChanged(aNodeInfo, atom, + getter_AddRefs(kungFuDeathGrip)); + NS_ENSURE_SUCCESS(rv, rv); nodeInfo = kungFuDeathGrip; } } - *aResult = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull, - PR_FALSE, PR_FALSE).get(); + result = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull, + PR_FALSE, PR_FALSE); } - return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY; -} - -//---------------------------------------------------------------------- - - -class nsHTMLElementFactory : public nsIElementFactory, - public nsSupportsWeakReference -{ -public: - nsHTMLElementFactory(); - virtual ~nsHTMLElementFactory(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, - nsIContent** aResult); -}; - -nsresult -NS_NewHTMLElementFactory(nsIElementFactory** aInstancePtrResult) -{ - *aInstancePtrResult = new nsHTMLElementFactory(); - if (!*aInstancePtrResult) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(*aInstancePtrResult); - - return NS_OK; -} - -nsHTMLElementFactory::nsHTMLElementFactory() -{ -} - -nsHTMLElementFactory::~nsHTMLElementFactory() -{ -} - -NS_IMPL_ISUPPORTS2(nsHTMLElementFactory, nsIElementFactory, - nsISupportsWeakReference) - -NS_IMETHODIMP -nsHTMLElementFactory::CreateInstanceByTag(nsINodeInfo *aNodeInfo, - nsIContent** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - NS_ENSURE_ARG_POINTER(aNodeInfo); - - nsresult rv; - nsCOMPtr htmlContent; - rv = NS_CreateHTMLElement(getter_AddRefs(htmlContent), aNodeInfo, - aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)); - - *aResult = htmlContent; - NS_IF_ADDREF(*aResult); - - return rv; + return result ? CallQueryInterface(result, aResult) : NS_ERROR_OUT_OF_MEMORY; } already_AddRefed @@ -3736,7 +3683,7 @@ HTMLContentSink::TryToScrollToRef() } void -HTMLContentSink::AddBaseTagInfo(nsIHTMLContent* aContent) +HTMLContentSink::AddBaseTagInfo(nsIContent* aContent) { if (!mBaseHREF.IsEmpty()) { aContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::_baseHref, mBaseHREF, @@ -3887,13 +3834,13 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode) if (parent) { // Create content object - nsCOMPtr element; + nsCOMPtr element; nsCOMPtr nodeInfo; mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::base, nsnull, kNameSpaceID_None, getter_AddRefs(nodeInfo)); - result = NS_CreateHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE); + result = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo); NS_ENSURE_SUCCESS(result, result); element->SetContentID(mDocument->GetAndIncrementContentID()); @@ -3944,12 +3891,12 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) if (parent) { // Create content object - nsCOMPtr element; + nsCOMPtr element; nsCOMPtr nodeInfo; mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::link, nsnull, kNameSpaceID_None, getter_AddRefs(nodeInfo)); - result = NS_CreateHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE); + result = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo); NS_ENSURE_SUCCESS(result, result); element->SetContentID(mDocument->GetAndIncrementContentID()); @@ -4232,12 +4179,12 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // on to it till we are done. nsCOMPtr parent = mCurrentContext->mStack[mCurrentContext->mStackPos - 1].mContent; - nsCOMPtr element; + nsCOMPtr element; nsCOMPtr nodeInfo; mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::script, nsnull, kNameSpaceID_None, getter_AddRefs(nodeInfo)); - rv = NS_CreateHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE); + rv = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo); if (NS_FAILED(rv)) { return rv; } @@ -4354,8 +4301,8 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::style, nsnull, kNameSpaceID_None, getter_AddRefs(nodeInfo)); - nsCOMPtr element; - rv = NS_CreateHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE); + nsCOMPtr element; + rv = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo); NS_ENSURE_SUCCESS(rv, rv); element->SetContentID(mDocument->GetAndIncrementContentID()); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 948bd5921a3..b4925aecef9 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -108,7 +108,6 @@ #include "nsISelectElement.h" #include "nsIFrameSelection.h" #include "nsISelectionPrivate.h"//for toStringwithformat code -#include "nsIElementFactory.h" #include "nsICharsetDetector.h" #include "nsICharsetDetectionAdaptor.h" @@ -130,6 +129,7 @@ #include "nsBidiUtils.h" #include "nsIEditingSession.h" +#include "nsNodeInfoManager.h" #define DETECTOR_CONTRACTID_MAX 127 static char g_detector_contractid[DETECTOR_CONTRACTID_MAX + 1]; @@ -294,6 +294,8 @@ nsHTMLDocument::nsHTMLDocument() { CallGetService(kRDFServiceCID, &gRDF); } + + mDefaultElementType = kNameSpaceID_XHTML; } nsHTMLDocument::~nsHTMLDocument() @@ -1353,23 +1355,17 @@ nsHTMLDocument::CreateElement(const nsAString& aTagName, } nsAutoString tmp(aTagName); - if (!IsXHTML()) { ToLowerCase(tmp); } nsCOMPtr name = do_GetAtom(tmp); - nsCOMPtr nodeInfo; - rv = mNodeInfoManager->GetNodeInfo(name, nsnull, mDefaultNamespaceID, - getter_AddRefs(nodeInfo)); + nsCOMPtr content; + rv = nsDocument::CreateElement(name, nsnull, GetDefaultNamespaceID(), + mDefaultElementType, getter_AddRefs(content)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr content; - rv = NS_CreateHTMLElement(getter_AddRefs(content), nodeInfo, IsXHTML()); - NS_ENSURE_SUCCESS(rv, rv); - content->SetContentID(mNextContentID++); - return CallQueryInterface(content, aReturn); } @@ -1706,7 +1702,7 @@ nsHTMLDocument::GetBody(nsIDOMHTMLElement** aBody) nsresult rv; if (IsXHTML()) { - rv = GetElementsByTagNameNS(NS_LITERAL_STRING(NS_HTML_NAMESPACE), + rv = GetElementsByTagNameNS(NS_LITERAL_STRING("http://www.w3.org/1999/xhtml"), NS_LITERAL_STRING("frameset"), getter_AddRefs(nodeList)); } else { @@ -4186,3 +4182,19 @@ nsHTMLDocument::QueryCommandValue(const nsAString & commandID, return rv; } + +#ifdef DEBUG +nsresult +nsHTMLDocument::CreateElem(nsIAtom *aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, PRBool aDocumentDefaultType, + nsIContent** aResult) +{ + NS_ASSERTION(!aDocumentDefaultType || IsXHTML() || + aNamespaceID == kNameSpaceID_None, + "HTML elements in an HTML document should have " + "kNamespaceID_None as their namespace ID."); + + return nsDocument::CreateElement(aName, aPrefix, aNamespaceID, + aDocumentDefaultType, aResult); +} +#endif diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 5a8ff45f3dd..390ff0b2c0d 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -199,6 +199,13 @@ public: return mDefaultNamespaceID == kNameSpaceID_XHTML; } +#ifdef DEBUG + virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, + PRBool aDocumentDefaultType, + nsIContent** aResult); +#endif + protected: nsresult GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth, diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp index c460057f97f..ba51e8b54dd 100644 --- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -58,6 +58,8 @@ #include "nsUnicharUtils.h" #include "nsContentUtils.h" #include "nsEscape.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" // // XXX THIS IS TEMPORARY CODE @@ -129,11 +131,11 @@ public: nsIContent* aContent); nsresult AddText(const nsAString& aString); - nsresult AddTextToContent(nsIHTMLContent* aContent,const nsString& aText); + nsresult AddTextToContent(nsIContent* aContent,const nsString& aText); nsresult FlushText(); - void ProcessBaseTag(nsIHTMLContent* aContent); - void AddBaseTagInfo(nsIHTMLContent* aContent); + void ProcessBaseTag(nsIContent* aContent); + void AddBaseTagInfo(nsIContent* aContent); nsresult Init(); @@ -155,7 +157,7 @@ public: nsString mBaseTarget; nsCOMPtr mTargetDocument; - nsCOMPtr mNodeInfoManager; + nsRefPtr mNodeInfoManager; }; class nsHTMLFragmentContentSink2 : public nsHTMLFragmentContentSink @@ -415,7 +417,7 @@ nsHTMLFragmentContentSink::CloseMap() } void -nsHTMLFragmentContentSink::ProcessBaseTag(nsIHTMLContent* aContent) +nsHTMLFragmentContentSink::ProcessBaseTag(nsIContent* aContent) { nsAutoString value; if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, value)) { @@ -427,7 +429,7 @@ nsHTMLFragmentContentSink::ProcessBaseTag(nsIHTMLContent* aContent) } void -nsHTMLFragmentContentSink::AddBaseTagInfo(nsIHTMLContent* aContent) +nsHTMLFragmentContentSink::AddBaseTagInfo(nsIContent* aContent) { if (aContent) { if (!mBaseHREF.IsEmpty()) { @@ -457,7 +459,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode) FlushText(); nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType()); - nsIHTMLContent *content = nsnull; + nsIContent *content = nsnull; nsCOMPtr nodeInfo; @@ -485,7 +487,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode) NS_ENSURE_SUCCESS(result, result); - result = NS_CreateHTMLElement(&content, nodeInfo, PR_FALSE); + result = NS_NewHTMLElement(&content, nodeInfo); if (NS_OK == result) { result = AddAttributes(aNode, content); @@ -546,7 +548,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode) FlushText(); // Create new leaf content object - nsCOMPtr content; + nsCOMPtr content; nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType()); nsIParserService* parserService = @@ -575,7 +577,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode) NS_ENSURE_SUCCESS(result, result); if(NS_SUCCEEDED(result)) { - result = NS_CreateHTMLElement(getter_AddRefs(content), nodeInfo, PR_FALSE); + result = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo); if (NS_OK == result) { result = AddAttributes(aNode, content); @@ -703,20 +705,9 @@ nsHTMLFragmentContentSink::SetTargetDocument(nsIDocument* aTargetDocument) NS_ENSURE_ARG_POINTER(aTargetDocument); mTargetDocument = aTargetDocument; - mNodeInfoManager = aTargetDocument->GetNodeInfoManager(); - if (mNodeInfoManager) { - return NS_OK; - } + mNodeInfoManager = aTargetDocument->NodeInfoManager(); - nsresult rv = NS_NewNodeInfoManager(getter_AddRefs(mNodeInfoManager)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mNodeInfoManager->Init(aTargetDocument); - if (NS_FAILED(rv)) { - mNodeInfoManager = nsnull; - } - - return rv; + return NS_OK; } nsIContent* @@ -802,7 +793,7 @@ nsHTMLFragmentContentSink::AddText(const nsAString& aString) } nsresult -nsHTMLFragmentContentSink::AddTextToContent(nsIHTMLContent* aContent,const nsString& aText) { +nsHTMLFragmentContentSink::AddTextToContent(nsIContent* aContent,const nsString& aText) { NS_ASSERTION(aContent !=nsnull, "can't add text w/o a content"); nsresult result=NS_OK; diff --git a/mozilla/content/html/document/src/nsMediaDocument.cpp b/mozilla/content/html/document/src/nsMediaDocument.cpp index 536837527af..73bafde483e 100644 --- a/mozilla/content/html/document/src/nsMediaDocument.cpp +++ b/mozilla/content/html/document/src/nsMediaDocument.cpp @@ -51,6 +51,7 @@ #include "nsIDocShell.h" #include "nsIParser.h" // kCharsetFrom* macro definition #include "nsIDocumentCharsetInfo.h" +#include "nsNodeInfoManager.h" nsMediaDocumentStreamListener::nsMediaDocumentStreamListener(nsMediaDocument *aDocument) { diff --git a/mozilla/content/html/document/src/nsPluginDocument.cpp b/mozilla/content/html/document/src/nsPluginDocument.cpp index e4529b7f61f..c240a5a93e1 100644 --- a/mozilla/content/html/document/src/nsPluginDocument.cpp +++ b/mozilla/content/html/document/src/nsPluginDocument.cpp @@ -42,6 +42,7 @@ #include "nsIObjectFrame.h" #include "nsIPluginInstance.h" #include "nsIDocShellTreeItem.h" +#include "nsNodeInfoManager.h" class nsPluginDocument : public nsMediaDocument, public nsIPluginDocument diff --git a/mozilla/content/html/style/src/nsDOMCSSAttrDeclaration.cpp b/mozilla/content/html/style/src/nsDOMCSSAttrDeclaration.cpp index fc45f406e05..a2a5088136d 100644 --- a/mozilla/content/html/style/src/nsDOMCSSAttrDeclaration.cpp +++ b/mozilla/content/html/style/src/nsDOMCSSAttrDeclaration.cpp @@ -49,6 +49,7 @@ #include "nsIURI.h" #include "nsINameSpaceManager.h" #include "nsStyleConsts.h" +#include "nsContentUtils.h" MOZ_DECL_CTOR_COUNTER(nsDOMCSSAttributeDeclaration) @@ -149,7 +150,7 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI, nsINodeInfo *nodeInfo = mContent->GetNodeInfo(); // XXXbz GetOwnerDocument - nsIDocument* doc = nodeInfo->GetDocument(); + nsIDocument* doc = nsContentUtils::GetDocument(nodeInfo); nsCOMPtr base = mContent->GetBaseURI(); diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index b3de36c197e..5c8f83d3d57 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -59,6 +59,7 @@ #include "nsCSSProps.h" #include "nsICSSParser.h" #include "nsGenericHTMLElement.h" +#include "nsNodeInfoManager.h" nsSVGElement::nsSVGElement(nsINodeInfo *aNodeInfo) : nsGenericElement(aNodeInfo) diff --git a/mozilla/content/svg/content/src/nsSVGElementFactory.cpp b/mozilla/content/svg/content/src/nsSVGElementFactory.cpp index 1c3499e3f08..12793c859da 100644 --- a/mozilla/content/svg/content/src/nsSVGElementFactory.cpp +++ b/mozilla/content/svg/content/src/nsSVGElementFactory.cpp @@ -37,11 +37,10 @@ * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" -#include "nsIElementFactory.h" +#include "nsContentCreatorFunctions.h" #include "nsIAtom.h" #include "nsINodeInfo.h" #include "nsSVGAtoms.h" -#include "nsIXMLContent.h" nsresult @@ -75,59 +74,8 @@ NS_NewSVGStyleElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); nsresult NS_NewSVGDefsElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); - -class nsSVGElementFactory : public nsIElementFactory -{ -protected: - nsSVGElementFactory(); - virtual ~nsSVGElementFactory(); - - // nsISupports interface - NS_DECL_ISUPPORTS - - // nsIElementFactory interface - NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, nsIContent** aResult); - -public: - friend nsresult NS_NewSVGElementFactory(nsIElementFactory** aResult); -}; - - - -nsSVGElementFactory::nsSVGElementFactory() -{ -} - -nsSVGElementFactory::~nsSVGElementFactory() -{ - -} - - -NS_IMPL_ISUPPORTS1(nsSVGElementFactory, nsIElementFactory) - - nsresult -NS_NewSVGElementFactory(nsIElementFactory** aResult) -{ - NS_PRECONDITION(aResult != nsnull, "null ptr"); - if (! aResult) - return NS_ERROR_NULL_POINTER; - - nsSVGElementFactory* result = new nsSVGElementFactory(); - if (! result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *aResult = result; - return NS_OK; -} - - - -NS_IMETHODIMP -nsSVGElementFactory::CreateInstanceByTag(nsINodeInfo *aNodeInfo, - nsIContent** aResult) +NS_NewSVGElement(nsIContent** aResult, nsINodeInfo *aNodeInfo) { nsIAtom *name = aNodeInfo->NameAtom(); diff --git a/mozilla/content/xbl/src/nsXBLContentSink.cpp b/mozilla/content/xbl/src/nsXBLContentSink.cpp index 9af7f54cbf4..eaf79286f40 100644 --- a/mozilla/content/xbl/src/nsXBLContentSink.cpp +++ b/mozilla/content/xbl/src/nsXBLContentSink.cpp @@ -59,6 +59,7 @@ #include "nsIConsoleService.h" #include "nsIScriptError.h" #include "nsIStringBundle.h" +#include "nsNodeInfoManager.h" nsresult NS_NewXBLContentSink(nsIXMLContentSink** aResult, diff --git a/mozilla/content/xml/content/public/nsIXMLContent.h b/mozilla/content/xml/content/public/nsIXMLContent.h index b889feed072..83bbd644495 100644 --- a/mozilla/content/xml/content/public/nsIXMLContent.h +++ b/mozilla/content/xml/content/public/nsIXMLContent.h @@ -76,20 +76,4 @@ public: NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell) = 0; }; -nsresult -NS_NewXMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo); - -// XXX These belongs elsewhere -nsresult -NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult, - const nsAString& aTarget, - const nsAString& aData); - -nsresult -NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult, - const nsAString& aData); - -nsresult -NS_NewXMLCDATASection(nsIContent** aInstancePtrResult); - #endif // nsIXMLContent_h___ diff --git a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp index 905e22b2ed3..c08d395e760 100644 --- a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp +++ b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp @@ -40,6 +40,7 @@ #include "nsUnicharUtils.h" #include "nsXMLProcessingInstruction.h" #include "nsParserUtils.h" +#include "nsContentCreatorFunctions.h" nsresult NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult, diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 30a4028f3bf..99c7c710fa2 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -37,7 +37,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" #include "nsXMLContentSink.h" -#include "nsIElementFactory.h" #include "nsIParser.h" #include "nsIUnicharInputStream.h" #include "nsIDocument.h" @@ -97,7 +96,8 @@ #include "nsIPrincipal.h" #include "nsXBLAtoms.h" #include "nsXMLPrettyPrinter.h" - +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" static const char kNameSpaceSeparator = ':'; #define kXSLType "text/xsl" @@ -438,40 +438,21 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount, nsresult rv = NS_OK; nsCOMPtr content; + rv = NS_NewElement(getter_AddRefs(content), aNodeInfo->NamespaceID(), + aNodeInfo); + NS_ENSURE_SUCCESS(rv, rv); // XHTML needs some special attention if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) { mPrettyPrintHasFactoredElements = PR_TRUE; - nsIHTMLContent* htmlContent = nsnull; - rv = NS_CreateHTMLElement(&htmlContent, aNodeInfo, PR_TRUE); - NS_ENSURE_SUCCESS(rv, rv); - - nsIContent* tmp = htmlContent; - content.swap(tmp); } else { - // The first step here is to see if someone has provided their - // own content element implementation (e.g., XUL or MathML). - // This is done based off a contractid/namespace scheme. - nsCOMPtr elementFactory; - rv = nsContentUtils::GetNSManagerWeakRef()-> - GetElementFactory(aNodeInfo->NamespaceID(), - getter_AddRefs(elementFactory)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = elementFactory->CreateInstanceByTag(aNodeInfo, - getter_AddRefs(content)); - NS_ENSURE_SUCCESS(rv, rv); - // If we care, find out if we just used a special factory. if (!mPrettyPrintHasFactoredElements && !mPrettyPrintHasSpecialRoot && mPrettyPrintXML) { - PRBool hasFactory = PR_FALSE; - rv = nsContentUtils::GetNSManagerWeakRef()-> - HasRegisteredFactory(aNodeInfo->NamespaceID(), &hasFactory); - NS_ENSURE_SUCCESS(rv, rv); - - mPrettyPrintHasFactoredElements = hasFactory; + mPrettyPrintHasFactoredElements = + nsContentUtils::GetNSManagerWeakRef()-> + HasElementCreator(aNodeInfo->NamespaceID()); } if (!aNodeInfo->NamespaceEquals(kNameSpaceID_SVG)) { @@ -856,125 +837,20 @@ nsXMLContentSink::StartLayout() } -//////////////////////////////////////////////////////////////////////// -// -// XML Element Factory -// - -class XMLElementFactoryImpl : public nsIElementFactory -{ -protected: - XMLElementFactoryImpl(); - virtual ~XMLElementFactoryImpl(); - -public: - friend - nsresult - NS_NewXMLElementFactory(nsIElementFactory** aResult); - - // nsISupports interface - NS_DECL_ISUPPORTS - - // nsIElementFactory interface - NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, nsIContent** aResult); - -}; - - -XMLElementFactoryImpl::XMLElementFactoryImpl() -{ -} - -XMLElementFactoryImpl::~XMLElementFactoryImpl() -{ -} - - -NS_IMPL_ISUPPORTS1(XMLElementFactoryImpl, nsIElementFactory) - - -nsresult -NS_NewXMLElementFactory(nsIElementFactory** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - - XMLElementFactoryImpl* result = new XMLElementFactoryImpl(); - NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY); - - *aResult = result; - NS_ADDREF(*aResult); - - return NS_OK; -} - - - -NS_IMETHODIMP -XMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo *aNodeInfo, - nsIContent** aResult) -{ - return NS_NewXMLElement(aResult, aNodeInfo); -} - - #ifdef MOZ_MATHML //////////////////////////////////////////////////////////////////////// // MathML Element Factory - temporary location for bug 132844 // Will be factored out post 1.0 -class MathMLElementFactoryImpl : public nsIElementFactory -{ -protected: - MathMLElementFactoryImpl(); - virtual ~MathMLElementFactoryImpl(); - -public: - friend - nsresult - NS_NewMathMLElementFactory(nsIElementFactory** aResult); - - // nsISupports interface - NS_DECL_ISUPPORTS - - // nsIElementFactory interface - NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, nsIContent** aResult); - -}; - -MathMLElementFactoryImpl::MathMLElementFactoryImpl() -{ -} - -MathMLElementFactoryImpl::~MathMLElementFactoryImpl() -{ -} - -NS_IMPL_ISUPPORTS1(MathMLElementFactoryImpl, nsIElementFactory) - nsresult -NS_NewMathMLElementFactory(nsIElementFactory** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - - MathMLElementFactoryImpl* result = new MathMLElementFactoryImpl(); - NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY); - - *aResult = result; - NS_ADDREF(*aResult); - - return NS_OK; -} - -NS_IMETHODIMP -MathMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo* aNodeInfo, - nsIContent** aResult) +NS_NewMathMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo) { static const char kMathMLStyleSheetURI[] = "resource://gre/res/mathml.css"; aNodeInfo->SetIDAttributeAtom(nsHTMLAtoms::id); // this bit of code is to load mathml.css on demand - nsIDocument* doc = aNodeInfo->GetDocument(); + nsIDocument* doc = nsContentUtils::GetDocument(aNodeInfo); if (doc) { nsICSSLoader* cssLoader = doc->GetCSSLoader(); PRBool enabled; diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index a10bc53aadf..89745c74a07 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -84,12 +84,13 @@ #include "nsIEventListenerManager.h" #include "nsContentUtils.h" #include "nsJSUtils.h" -#include "nsIElementFactory.h" #include "nsCRT.h" #include "nsIWindowWatcher.h" #include "nsIAuthPrompt.h" #include "nsIScriptGlobalObjectOwner.h" #include "nsIJSContextStack.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" // XXX The XML world depends on the html atoms #include "nsHTMLAtoms.h" diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 12f8e7740db..17849fd2759 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -162,6 +162,7 @@ #include "nsReadableUtils.h" #include "nsITimelineService.h" #include "nsIFrame.h" +#include "nsNodeInfoManager.h" class nsIDocShell; @@ -516,7 +517,7 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype, } nsresult -nsXULElement::Create(nsINodeInfo *aNodeInfo, nsIContent** aResult) +NS_NewXULElement(nsIContent** aResult, nsINodeInfo *aNodeInfo) { NS_PRECONDITION(aNodeInfo, "need nodeinfo for non-proto Create"); @@ -768,7 +769,7 @@ nsXULElement::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) if (mDocument) { return CallQueryInterface(mDocument, aOwnerDocument); } - nsIDocument* doc = NodeInfo()->GetDocument(); + nsIDocument* doc = nsContentUtils::GetDocument(NodeInfo()); if (doc) { return CallQueryInterface(doc, aOwnerDocument); } @@ -800,7 +801,7 @@ nsXULElement::SetPrefix(const nsAString& aPrefix) nsCOMPtr newNodeInfo; nsCOMPtr prefix; - if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix)) { + if (!aPrefix.IsEmpty()) { prefix = do_GetAtom(aPrefix); NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); } @@ -808,8 +809,8 @@ nsXULElement::SetPrefix(const nsAString& aPrefix) nsresult rv = EnsureSlots(); NS_ENSURE_SUCCESS(rv, rv); - rv = mSlots->mNodeInfo->PrefixChanged(prefix, - getter_AddRefs(newNodeInfo)); + rv = nsContentUtils::PrefixChanged(mSlots->mNodeInfo, prefix, + getter_AddRefs(newNodeInfo)); NS_ENSURE_SUCCESS(rv, rv); NS_ASSERTION(newNodeInfo, "trying to assign null nodeinfo!"); @@ -892,12 +893,12 @@ nsXULElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) NS_ASSERTION(mSlots, "no prototype and no slots!"); NS_ENSURE_TRUE(mSlots, NS_ERROR_UNEXPECTED); - rv = nsXULElement::Create(mSlots->mNodeInfo, getter_AddRefs(result)); - NS_ENSURE_SUCCESS(rv, rv); - - // XXX setting document on nodes not in a document so XBL will bind - // and chrome won't break. Make XBL bind to document-less nodes! - result->SetDocument(mDocument, PR_TRUE, PR_TRUE); + rv = NS_NewXULElement(getter_AddRefs(result), mSlots->mNodeInfo); + if (NS_SUCCEEDED(rv)) { + // XXX setting document on nodes not in a document so XBL will bind + // and chrome won't break. Make XBL bind to document-less nodes! + result->SetDocument(mDocument, PR_TRUE, PR_TRUE); + } } // Copy attributes diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index eb50fadb636..52fa5c9e2bc 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -429,9 +429,6 @@ public: Create(nsXULPrototypeElement* aPrototype, nsIDocument* aDocument, PRBool aIsScriptable, nsIContent** aResult); - static nsresult - Create(nsINodeInfo* aNodeInfo, nsIContent** aResult); - // nsISupports NS_DECL_ISUPPORTS @@ -651,6 +648,9 @@ protected: nsIControllers *Controllers() const { return mSlots ? mSlots->mControllers.get() : nsnull; } void UnregisterAccessKey(const nsAString& aOldValue); + + friend nsresult + NS_NewXULElement(nsIContent** aResult, nsINodeInfo *aNodeInfo); }; diff --git a/mozilla/content/xul/document/public/nsIXULPrototypeDocument.h b/mozilla/content/xul/document/public/nsIXULPrototypeDocument.h index b48c4ea4901..dcd689fb23c 100644 --- a/mozilla/content/xul/document/public/nsIXULPrototypeDocument.h +++ b/mozilla/content/xul/document/public/nsIXULPrototypeDocument.h @@ -56,12 +56,10 @@ class nsVoidArray; class nsXULPrototypeElement; class nsIXULDocument; class nsIScriptGlobalObject; -class nsINodeInfoManager; +class nsNodeInfoManager; -// {187A63D0-8337-11d3-BE47-00104BDE6048} #define NS_IXULPROTOTYPEDOCUMENT_IID \ -{ 0x187a63d0, 0x8337, 0x11d3, { 0xbe, 0x47, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } - +{ 0x726f0ab8, 0xb3cb, 0x11d8, { 0xb2, 0x67, 0x00, 0x0a, 0x95, 0xdc, 0x23, 0x4c } } class nsIXULPrototypeDocument : public nsISerializable { @@ -89,10 +87,10 @@ public: NS_IMETHOD GetHeaderData(nsIAtom* aField, nsAString& aData) const = 0; NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsAString& aData) = 0; - virtual nsIPrincipal* GetDocumentPrincipal() = 0; - NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal) = 0; + virtual nsIPrincipal *GetDocumentPrincipal() = 0; + virtual void SetDocumentPrincipal(nsIPrincipal *aPrincipal) = 0; - NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager) = 0; + virtual nsNodeInfoManager *GetNodeInfoManager() = 0; NS_IMETHOD AwaitLoadDone(nsIXULDocument* aDocument, PRBool* aResult) = 0; NS_IMETHOD NotifyLoadDone() = 0; diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 59f222e2914..de92a1ea104 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -103,6 +103,7 @@ #include "nsUnicharUtils.h" #include "nsXULAtoms.h" #include "nsHTMLAtoms.h" +#include "nsNodeInfoManager.h" #include "nsContentUtils.h" #include "nsAttrName.h" @@ -184,7 +185,7 @@ protected: nsAutoVoidArray mNameSpaceStack; - nsCOMPtr mNodeInfoManager; + nsRefPtr mNodeInfoManager; nsresult NormalizeAttributeString(const nsAFlatString& aText, @@ -599,8 +600,9 @@ XULContentSinkImpl::Init(nsIDocument* aDocument, nsIXULPrototypeDocument* aProto mCSSLoader = aDocument->GetCSSLoader(); NS_ENSURE_TRUE(mCSSLoader, NS_ERROR_OUT_OF_MEMORY); - rv = aPrototype->GetNodeInfoManager(getter_AddRefs(mNodeInfoManager)); - if (NS_FAILED(rv)) return rv; + mNodeInfoManager = aPrototype->GetNodeInfoManager(); + if (! mNodeInfoManager) + return NS_ERROR_UNEXPECTED; mState = eInProlog; return NS_OK; diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 102eaaa9c95..c7c5e873c72 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -72,8 +72,6 @@ #include "nsIContentViewer.h" #include "nsGUIEvent.h" #include "nsIDOMXULElement.h" -#include "nsIElementFactory.h" -#include "nsIPrincipal.h" #include "nsIPrivateDOMEvent.h" #include "nsIRDFNode.h" #include "nsIRDFRemoteDataSource.h" @@ -112,6 +110,8 @@ #include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptSecurityManager.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" #include "nsContentUtils.h" #include "nsIParser.h" #include "nsICSSStyleSheet.h" @@ -121,11 +121,9 @@ // CIDs // -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kLocalStoreCID, NS_LOCALSTORE_CID); static NS_DEFINE_CID(kParserCID, NS_PARSER_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); -static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kXULPrototypeCacheCID, NS_XULPROTOTYPECACHE_CID); static PRBool IsChromeURI(nsIURI* aURI) @@ -161,9 +159,6 @@ nsIRDFResource* nsXULDocument::kNC_persist; nsIRDFResource* nsXULDocument::kNC_attribute; nsIRDFResource* nsXULDocument::kNC_value; -nsIElementFactory* nsXULDocument::gHTMLElementFactory; -nsIElementFactory* nsXULDocument::gXMLElementFactory; - nsIXULPrototypeCache* nsXULDocument::gXULCache; PRLogModuleInfo* nsXULDocument::gXULLog; @@ -367,6 +362,8 @@ nsXULDocument::nsXULDocument(void) // Override the default in nsDocument mCharacterSet.AssignLiteral("UTF-8"); + + mDefaultElementType = kNameSpaceID_XUL; } nsXULDocument::~nsXULDocument() @@ -414,9 +411,6 @@ nsXULDocument::~nsXULDocument() NS_IF_RELEASE(kNC_attribute); NS_IF_RELEASE(kNC_value); - NS_IF_RELEASE(gHTMLElementFactory); - NS_IF_RELEASE(gXMLElementFactory); - if (gXULCache) { // Remove the current document here from the FastLoad table in // case the document did not make it past StartLayout in @@ -2086,14 +2080,6 @@ nsXULDocument::Init() gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "value"), &kNC_value); - rv = CallGetService(kHTMLElementFactoryCID, &gHTMLElementFactory); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get HTML element factory"); - if (NS_FAILED(rv)) return rv; - - rv = CallGetService(kXMLElementFactoryCID, &gXMLElementFactory); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get XML element factory"); - if (NS_FAILED(rv)) return rv; - rv = CallGetService(kXULPrototypeCacheCID, &gXULCache); if (NS_FAILED(rv)) return rv; } @@ -3285,38 +3271,15 @@ nsXULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype, rv = nsXULElement::Create(aPrototype, this, PR_TRUE, getter_AddRefs(result)); if (NS_FAILED(rv)) return rv; } - else if (aPrototype->mNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) { - // If it's an HTML element, it's gonna be heavyweight no matter - // what. So we need to copy everything out of the prototype - // into the element. - - gHTMLElementFactory->CreateInstanceByTag(aPrototype->mNodeInfo, - getter_AddRefs(result)); - if (NS_FAILED(rv)) return rv; - - if (! result) - return NS_ERROR_UNEXPECTED; - - result->SetDocument(this, PR_FALSE, PR_TRUE); - - rv = AddAttributes(aPrototype, result); - if (NS_FAILED(rv)) return rv; - } else { // If it's not a XUL element, it's gonna be heavyweight no matter // what. So we need to copy everything out of the prototype // into the element. - - nsCOMPtr elementFactory; - GetElementFactory(aPrototype->mNodeInfo->NamespaceID(), - getter_AddRefs(elementFactory)); - rv = elementFactory->CreateInstanceByTag(aPrototype->mNodeInfo, - getter_AddRefs(result)); + rv = NS_NewElement(getter_AddRefs(result), + aPrototype->mNodeInfo->NamespaceID(), + aPrototype->mNodeInfo); if (NS_FAILED(rv)) return rv; - if (! result) - return NS_ERROR_UNEXPECTED; - result->SetDocument(this, PR_FALSE, PR_TRUE); rv = AddAttributes(aPrototype, result); @@ -3325,8 +3288,8 @@ nsXULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype, result->SetContentID(mNextContentID++); - *aResult = result; - NS_ADDREF(*aResult); + result.swap(*aResult); + return NS_OK; } @@ -3460,19 +3423,18 @@ nsXULDocument::CreateTemplateBuilder(nsIContent* aElement) if (! bodyContent) { // Get the document. - nsCOMPtr domdoc = - do_QueryInterface(aElement->GetDocument()); - NS_ASSERTION(domdoc, "no document"); - if (! domdoc) + nsIDocument *document = aElement->GetDocument(); + NS_ASSERTION(document, "no document"); + if (! document) return NS_ERROR_UNEXPECTED; - if (domdoc) { - nsCOMPtr bodyElement; - domdoc->CreateElement(NS_LITERAL_STRING("treechildren"), - getter_AddRefs(bodyElement)); - bodyContent = do_QueryInterface(bodyElement); - aElement->AppendChildTo(bodyContent, PR_FALSE, PR_TRUE); - } + nsresult rv = document->CreateElem(nsXULAtoms::treechildren, + nsnull, kNameSpaceID_XUL, + PR_FALSE, + getter_AddRefs(bodyContent)); + NS_ENSURE_SUCCESS(rv, rv); + + aElement->AppendChildTo(bodyContent, PR_FALSE, PR_TRUE); } } else { @@ -4084,21 +4046,6 @@ nsXULDocument::RemoveElement(nsIContent* aParent, nsIContent* aChild) return aParent->RemoveChildAt(nodeOffset, PR_TRUE); } -void -nsXULDocument::GetElementFactory(PRInt32 aNameSpaceID, - nsIElementFactory** aResult) -{ - // Retrieve the appropriate factory. - nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(aNameSpaceID, - aResult); - - if (!*aResult) { - // Nothing found. Use generic XML element. - *aResult = gXMLElementFactory; - NS_IF_ADDREF(*aResult); - } -} - //---------------------------------------------------------------------- // // CachedChromeStreamListener @@ -4228,63 +4175,3 @@ nsXULDocument::GetFocusController(nsIFocusController** aFocusController) } else *aFocusController = nsnull; } - -//---------------------------------------------------------------------- -// -// The XUL element factory -// - -class XULElementFactoryImpl : public nsIElementFactory -{ -protected: - XULElementFactoryImpl(); - virtual ~XULElementFactoryImpl(); - -public: - friend - nsresult - NS_NewXULElementFactory(nsIElementFactory** aResult); - - // nsISupports interface - NS_DECL_ISUPPORTS - - // nsIElementFactory interface - NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, nsIContent** aResult); -}; - -XULElementFactoryImpl::XULElementFactoryImpl() -{ -} - -XULElementFactoryImpl::~XULElementFactoryImpl() -{ -} - - -NS_IMPL_ISUPPORTS1(XULElementFactoryImpl, nsIElementFactory) - - -nsresult -NS_NewXULElementFactory(nsIElementFactory** aResult) -{ - NS_PRECONDITION(aResult != nsnull, "null ptr"); - if (! aResult) - return NS_ERROR_NULL_POINTER; - - XULElementFactoryImpl* result = new XULElementFactoryImpl(); - if (! result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *aResult = result; - return NS_OK; -} - - - -NS_IMETHODIMP -XULElementFactoryImpl::CreateInstanceByTag(nsINodeInfo *aNodeInfo, - nsIContent** aResult) -{ - return nsXULElement::Create(aNodeInfo, aResult); -} diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 59cab350460..b6c4880cd70 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -238,16 +238,10 @@ protected: static nsIRDFResource* kNC_attribute; static nsIRDFResource* kNC_value; - static nsIElementFactory* gHTMLElementFactory; - static nsIElementFactory* gXMLElementFactory; - static nsIXULPrototypeCache* gXULCache; static PRLogModuleInfo* gXULLog; - static void GetElementFactory(PRInt32 aNameSpaceID, - nsIElementFactory** aResult); - nsresult Persist(nsIContent* aElement, PRInt32 aNameSpaceID, nsIAtom* aAttribute); diff --git a/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp b/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp index ea894603e82..75d54e497b0 100644 --- a/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -68,6 +68,7 @@ #include "nsIDOMScriptObjectFactory.h" #include "nsDOMCID.h" #include "nsArray.h" +#include "nsNodeInfoManager.h" #include "nsContentUtils.h" @@ -147,13 +148,13 @@ public: NS_IMETHOD GetHeaderData(nsIAtom* aField, nsAString& aData) const; NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsAString& aData); - virtual nsIPrincipal* GetDocumentPrincipal(); - NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal); + virtual nsIPrincipal *GetDocumentPrincipal(); + void SetDocumentPrincipal(nsIPrincipal *aPrincipal); NS_IMETHOD AwaitLoadDone(nsIXULDocument* aDocument, PRBool* aResult); NS_IMETHOD NotifyLoadDone(); - NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager); + virtual nsNodeInfoManager *GetNodeInfoManager(); // nsIScriptGlobalObjectOwner methods NS_DECL_NSISCRIPTGLOBALOBJECTOWNER @@ -172,7 +173,7 @@ protected: PRPackedBool mLoaded; nsCOMPtr mPrototypeWaiters; - nsCOMPtr mNodeInfoManager; + nsRefPtr mNodeInfoManager; nsXULPrototypeDocument(); virtual ~nsXULPrototypeDocument(); @@ -256,13 +257,10 @@ nsXULPrototypeDocument::Init() rv = NS_NewISupportsArray(getter_AddRefs(mOverlayReferences)); NS_ENSURE_SUCCESS(rv, rv); - rv = NS_NewNodeInfoManager(getter_AddRefs(mNodeInfoManager)); - NS_ENSURE_SUCCESS(rv, rv); + mNodeInfoManager = new nsNodeInfoManager(); + NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY); - rv = mNodeInfoManager->Init(nsnull); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; + return mNodeInfoManager->Init(nsnull); } nsXULPrototypeDocument::~nsXULPrototypeDocument() @@ -696,21 +694,18 @@ nsXULPrototypeDocument::GetDocumentPrincipal() } -NS_IMETHODIMP -nsXULPrototypeDocument::SetDocumentPrincipal(nsIPrincipal* aPrincipal) +void +nsXULPrototypeDocument::SetDocumentPrincipal(nsIPrincipal *aPrincipal) { NS_PRECONDITION(mNodeInfoManager, "missing nodeInfoManager"); mDocumentPrincipal = aPrincipal; mNodeInfoManager->SetDocumentPrincipal(aPrincipal); - return NS_OK; } -NS_IMETHODIMP -nsXULPrototypeDocument::GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager) +nsNodeInfoManager* +nsXULPrototypeDocument::GetNodeInfoManager() { - *aNodeInfoManager = mNodeInfoManager; - NS_IF_ADDREF(*aNodeInfoManager); - return NS_OK; + return mNodeInfoManager; } diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index 62785b2faf7..6bce3e933ae 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -43,7 +43,6 @@ #include "nsIDocument.h" #include "nsIDOMNodeList.h" #include "nsIDOMXULDocument.h" -#include "nsIElementFactory.h" #include "nsINodeInfo.h" #include "nsIPrincipal.h" #include "nsIServiceManager.h" @@ -69,6 +68,8 @@ #include "nsXULElement.h" #include "nsXULTemplateBuilder.h" #include "nsSupportsArray.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" #include "nsContentUtils.h" #include "jsapi.h" @@ -77,9 +78,7 @@ //----------------------------------------------------------------------0 -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); -static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID); PRBool @@ -216,9 +215,6 @@ protected: PRBool IsLazyWidgetItem(nsIContent* aElement); - static void - GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult); - nsresult GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements); @@ -292,15 +288,11 @@ protected: // pseudo-constants static PRInt32 gRefCnt; - static nsIElementFactory* gHTMLElementFactory; - static nsIElementFactory* gXMLElementFactory; static nsIXULSortService* gXULSortService; }; PRInt32 nsXULContentBuilder::gRefCnt; nsIXULSortService* nsXULContentBuilder::gXULSortService; -nsIElementFactory* nsXULContentBuilder::gHTMLElementFactory; -nsIElementFactory* nsXULContentBuilder::gXMLElementFactory; NS_IMETHODIMP NS_NewXULContentBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult) @@ -333,8 +325,6 @@ nsXULContentBuilder::~nsXULContentBuilder() { if (--gRefCnt == 0) { NS_IF_RELEASE(gXULSortService); - NS_IF_RELEASE(gHTMLElementFactory); - NS_IF_RELEASE(gXMLElementFactory); } } @@ -345,14 +335,6 @@ nsXULContentBuilder::Init() nsresult rv = CallGetService(kXULSortServiceCID, &gXULSortService); if (NS_FAILED(rv)) return rv; - - rv = CallGetService(kHTMLElementFactoryCID, &gHTMLElementFactory); - if (NS_FAILED(rv)) - return rv; - - rv = CallGetService(kXMLElementFactoryCID, &gXMLElementFactory); - if (NS_FAILED(rv)) - return rv; } return nsXULTemplateBuilder::Init(); @@ -1472,8 +1454,8 @@ nsXULContentBuilder::GetElementsForResource(nsIRDFResource* aResource, nsresult nsXULContentBuilder::CreateElement(PRInt32 aNameSpaceID, - nsIAtom* aTag, - nsIContent** aResult) + nsIAtom* aTag, + nsIContent** aResult) { nsCOMPtr doc = mRoot->GetDocument(); NS_ASSERTION(doc != nsnull, "not initialized"); @@ -1483,35 +1465,12 @@ nsXULContentBuilder::CreateElement(PRInt32 aNameSpaceID, nsresult rv; nsCOMPtr result; - nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_NOT_INITIALIZED); - nsCOMPtr nodeInfo; - nodeInfoManager->GetNodeInfo(aTag, nsnull, aNameSpaceID, - getter_AddRefs(nodeInfo)); + doc->NodeInfoManager()->GetNodeInfo(aTag, nsnull, aNameSpaceID, + getter_AddRefs(nodeInfo)); - if (aNameSpaceID == kNameSpaceID_XUL) { - rv = nsXULElement::Create(nodeInfo, getter_AddRefs(result)); - if (NS_FAILED(rv)) return rv; - } - else if (aNameSpaceID == kNameSpaceID_XHTML) { - rv = gHTMLElementFactory->CreateInstanceByTag(nodeInfo, - getter_AddRefs(result)); - if (NS_FAILED(rv)) return rv; - - if (! result) - return NS_ERROR_UNEXPECTED; - } - else { - nsCOMPtr elementFactory; - GetElementFactory(aNameSpaceID, getter_AddRefs(elementFactory)); - rv = elementFactory->CreateInstanceByTag(nodeInfo, - getter_AddRefs(result)); - if (NS_FAILED(rv)) return rv; - - if (! result) - return NS_ERROR_UNEXPECTED; - } + rv = NS_NewElement(getter_AddRefs(result), aNameSpaceID, nodeInfo); + if (NS_FAILED(rv)) return rv; result->SetDocument(doc, PR_FALSE, PR_TRUE); @@ -1564,18 +1523,6 @@ nsXULContentBuilder::SetContainerAttrs(nsIContent *aElement, const nsTemplateMat } -void -nsXULContentBuilder::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult) -{ - nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(aNameSpaceID, - aResult); - - if (!*aResult) { - *aResult = gXMLElementFactory; // Nothing found. Use generic XML element. - NS_IF_ADDREF(*aResult); - } -} - //---------------------------------------------------------------------- // // nsIXULTemplateBuilder methods diff --git a/mozilla/content/xul/templates/src/nsXULSortService.cpp b/mozilla/content/xul/templates/src/nsXULSortService.cpp index 765b91561e4..e9ad2c90fec 100644 --- a/mozilla/content/xul/templates/src/nsXULSortService.cpp +++ b/mozilla/content/xul/templates/src/nsXULSortService.cpp @@ -89,6 +89,7 @@ #include "nsILocaleService.h" #include "nsIRDFContainerUtils.h" #include "nsXULAtoms.h" +#include "nsINodeInfo.h" //////////////////////////////////////////////////////////////////////// diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index 10ec8bb1f1e..d9106a08b8e 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -70,6 +70,7 @@ #include "nsIDOMNSEvent.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMEventListener.h" +#include "nsINodeInfo.h" // Window scriptable helper includes #include "nsIDocShell.h" diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index c82d4da080e..c2313cb1efd 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -98,13 +98,10 @@ #include "nsStyleSheetTxns.h" #include "IMETextTxn.h" -// included for nsEditor::CreateHTMLContent -#include "nsIElementFactory.h" -#include "nsINodeInfo.h" - #include "nsEditor.h" #include "nsEditorUtils.h" #include "nsISelectionDisplay.h" +#include "nsINameSpaceManager.h" #define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1) #define NS_ERROR_EDITOR_NO_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2) @@ -5063,43 +5060,20 @@ nsresult nsEditor::ClearSelection() nsresult nsEditor::CreateHTMLContent(const nsAString& aTag, nsIContent** aContent) { - nsresult rv; - - nsCOMPtr elementFactory = - do_GetService(NS_ELEMENT_FACTORY_CONTRACTID_PREFIX"http://www.w3.org/1999/xhtml", &rv); - if (!elementFactory) - return NS_ERROR_FAILURE; - nsCOMPtr tempDoc; - - rv = GetDocument(getter_AddRefs(tempDoc)); - if (NS_FAILED(rv)) - return rv; - if (!tempDoc) - return NS_ERROR_FAILURE; + GetDocument(getter_AddRefs(tempDoc)); nsCOMPtr doc = do_QueryInterface(tempDoc); - - nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); - - nsCOMPtr nodeInfo; - rv = nodeInfoManager->GetNodeInfo(aTag, nsnull, kNameSpaceID_None, - getter_AddRefs(nodeInfo)); - - if (NS_FAILED(rv)) - return rv; - if (!nodeInfo) + if (!doc) return NS_ERROR_FAILURE; - rv = elementFactory->CreateInstanceByTag(nodeInfo, aContent); + nsCOMPtr tag = do_GetAtom(aTag); + if (!tag) + return NS_ERROR_OUT_OF_MEMORY; - if (NS_FAILED(rv)) - return rv; - if (!aContent) - return NS_ERROR_FAILURE; - - return NS_OK; + // XXX If editor starts supporting XHTML documents, the kNameSpaceID_None + // should be kNameSpaceID_XHTML for those documents. + return doc->CreateElem(tag, nsnull, kNameSpaceID_None, PR_TRUE, aContent); } nsresult diff --git a/mozilla/extensions/transformiix/source/base/txURIUtils.cpp b/mozilla/extensions/transformiix/source/base/txURIUtils.cpp index 5d89370facc..f1856f1998c 100644 --- a/mozilla/extensions/transformiix/source/base/txURIUtils.cpp +++ b/mozilla/extensions/transformiix/source/base/txURIUtils.cpp @@ -250,7 +250,7 @@ PRBool URIUtils::CanCallerAccess(nsIDOMNode *aNode) // nsIContent (which is important performance wise) and if that QI // fails we QI to nsIDocument. If both those QI's fail we won't let // the caller access this unknown node. - nsCOMPtr principal; + nsIPrincipal *principal = nsnull; nsCOMPtr content = do_QueryInterface(aNode); nsCOMPtr attr; nsCOMPtr doc; @@ -289,8 +289,7 @@ PRBool URIUtils::CanCallerAccess(nsIDOMNode *aNode) return PR_TRUE; } - ni->GetDocumentPrincipal(getter_AddRefs(principal)); - + principal = ni->GetDocumentPrincipal(); if (!principal) { // we can't get to the principal so we'll give up and give the // caller access diff --git a/mozilla/extensions/transformiix/source/xml/XMLUtils.h b/mozilla/extensions/transformiix/source/xml/XMLUtils.h index a16aec4c390..d2b46736f95 100644 --- a/mozilla/extensions/transformiix/source/xml/XMLUtils.h +++ b/mozilla/extensions/transformiix/source/xml/XMLUtils.h @@ -46,6 +46,7 @@ #include "txCore.h" #include "nsCOMPtr.h" #include "nsDependentSubstring.h" +#include "nsIAtom.h" #include "txXPathNode.h" #ifndef TX_EXE diff --git a/mozilla/extensions/transformiix/source/xpath/VariableRefExpr.cpp b/mozilla/extensions/transformiix/source/xpath/VariableRefExpr.cpp index 85e4ad95563..8da7da34132 100644 --- a/mozilla/extensions/transformiix/source/xpath/VariableRefExpr.cpp +++ b/mozilla/extensions/transformiix/source/xpath/VariableRefExpr.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "Expr.h" +#include "nsIAtom.h" #include "txNodeSet.h" #include "txAtoms.h" #include "txIXPathContext.h" diff --git a/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.cpp b/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.cpp index de0adae9b53..fbb97286740 100644 --- a/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.cpp +++ b/mozilla/extensions/transformiix/source/xpath/nsXPathEvaluator.cpp @@ -38,6 +38,7 @@ #include "nsXPathEvaluator.h" #include "nsCOMPtr.h" +#include "nsIAtom.h" #include "nsIDOMClassInfo.h" #include "nsXPathException.h" #include "nsXPathExpression.h" @@ -51,6 +52,7 @@ #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsDOMString.h" +#include "nsINameSpaceManager.h" #include "txError.h" extern nsINameSpaceManager* gTxNameSpaceManager; diff --git a/mozilla/extensions/transformiix/source/xpath/txNameTest.cpp b/mozilla/extensions/transformiix/source/xpath/txNameTest.cpp index ac5d0247132..c232bcb380e 100644 --- a/mozilla/extensions/transformiix/source/xpath/txNameTest.cpp +++ b/mozilla/extensions/transformiix/source/xpath/txNameTest.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "Expr.h" +#include "nsIAtom.h" #include "txAtoms.h" #include "txXPathTreeWalker.h" #include "txIXPathContext.h" diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 6d158f58016..1570f875af8 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -96,7 +96,6 @@ #include "nsBoxLayoutState.h" #include "nsIBindingManager.h" #include "nsIXBLBinding.h" -#include "nsIElementFactory.h" #include "nsITheme.h" #include "nsContentCID.h" #include "nsContentUtils.h" @@ -117,7 +116,6 @@ #include "nsBoxFrame.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); #include "nsIDOMWindowInternal.h" #include "nsIMenuFrame.h" @@ -191,6 +189,8 @@ NS_NewSVGDefsFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aN #include "nsINodeInfo.h" #include "prenv.h" #include "nsWidgetsCID.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" // Global object maintenance nsIXBLService * nsCSSFrameConstructor::gXBLService = nsnull; @@ -1372,19 +1372,13 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create an HTML image content object, and set the SRC. // XXX Check if it's an image type we can handle... - nsINodeInfoManager *nimgr = aDocument->GetNodeInfoManager(); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - nsCOMPtr nodeInfo; - nimgr->GetNodeInfo(nsHTMLAtoms::img, nsnull, kNameSpaceID_None, - getter_AddRefs(nodeInfo)); - - nsresult rv; - nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&rv)); - NS_ENSURE_SUCCESS(rv, rv); + aDocument->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::img, nsnull, + kNameSpaceID_None, + getter_AddRefs(nodeInfo)); nsCOMPtr content; - rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + nsresult rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo); NS_ENSURE_SUCCESS(rv, rv); nsCAutoString spec; diff --git a/mozilla/layout/build/nsContentDLF.cpp b/mozilla/layout/build/nsContentDLF.cpp index 3d131d49960..79f4d3f44c9 100644 --- a/mozilla/layout/build/nsContentDLF.cpp +++ b/mozilla/layout/build/nsContentDLF.cpp @@ -336,41 +336,39 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup, nsIDocument **aDocum if (NS_SUCCEEDED(rv)) { rv = NS_ERROR_FAILURE; - nsINodeInfoManager *nim = blankDoc->GetNodeInfoManager(); + nsNodeInfoManager *nim = blankDoc->NodeInfoManager(); - if (nim) { - nsCOMPtr htmlNodeInfo; + nsCOMPtr htmlNodeInfo; - // generate an html html element - nim->GetNodeInfo(nsHTMLAtoms::html, 0, kNameSpaceID_None, - getter_AddRefs(htmlNodeInfo)); - nsCOMPtr htmlElement - = NS_NewHTMLHtmlElement(htmlNodeInfo); + // generate an html html element + nim->GetNodeInfo(nsHTMLAtoms::html, 0, kNameSpaceID_None, + getter_AddRefs(htmlNodeInfo)); + nsCOMPtr htmlElement = + NS_NewHTMLHtmlElement(htmlNodeInfo); - // generate an html head element - nim->GetNodeInfo(nsHTMLAtoms::head, 0, kNameSpaceID_None, - getter_AddRefs(htmlNodeInfo)); - nsCOMPtr headElement - = NS_NewHTMLHeadElement(htmlNodeInfo); + // generate an html head element + nim->GetNodeInfo(nsHTMLAtoms::head, 0, kNameSpaceID_None, + getter_AddRefs(htmlNodeInfo)); + nsCOMPtr headElement = + NS_NewHTMLHeadElement(htmlNodeInfo); - // generate an html body element - nim->GetNodeInfo(nsHTMLAtoms::body, 0, kNameSpaceID_None, - getter_AddRefs(htmlNodeInfo)); - nsCOMPtr bodyElement - = NS_NewHTMLBodyElement(htmlNodeInfo); + // generate an html body element + nim->GetNodeInfo(nsHTMLAtoms::body, 0, kNameSpaceID_None, + getter_AddRefs(htmlNodeInfo)); + nsCOMPtr bodyElement = + NS_NewHTMLBodyElement(htmlNodeInfo); - // blat in the structure - if (htmlElement && headElement && bodyElement) { - htmlElement->SetDocument(blankDoc, PR_FALSE, PR_TRUE); - blankDoc->SetRootContent(htmlElement); + // blat in the structure + if (htmlElement && headElement && bodyElement) { + htmlElement->SetDocument(blankDoc, PR_FALSE, PR_TRUE); + blankDoc->SetRootContent(htmlElement); - htmlElement->AppendChildTo(headElement, PR_FALSE, PR_FALSE); + htmlElement->AppendChildTo(headElement, PR_FALSE, PR_FALSE); - bodyElement->SetContentID(blankDoc->GetAndIncrementContentID()); - htmlElement->AppendChildTo(bodyElement, PR_FALSE, PR_FALSE); + bodyElement->SetContentID(blankDoc->GetAndIncrementContentID()); + htmlElement->AppendChildTo(bodyElement, PR_FALSE, PR_FALSE); - rv = NS_OK; - } + rv = NS_OK; } } diff --git a/mozilla/layout/build/nsLayoutCID.h b/mozilla/layout/build/nsLayoutCID.h index 39e512c35c4..f3a829e02c5 100644 --- a/mozilla/layout/build/nsLayoutCID.h +++ b/mozilla/layout/build/nsLayoutCID.h @@ -54,10 +54,6 @@ #define NS_LAYOUT_DEBUGGER_CID \ { 0xa6cf90f9, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} -/* a6cf90fc-15b3-11d2-932e-00805f8add32 */ -#define NS_HTML_ELEMENT_FACTORY_CID \ - { 0xa6cf90fc, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} - #define NS_HTMLDOCUMENT_CID \ { /* 5d0fcdd0-4daa-11d2-b328-00805f8a3859 */ \ 0x5d0fcdd0, 0x4daa, 0x11d2, \ @@ -68,11 +64,6 @@ 0xa6cf9063, 0x15b3, 0x11d2, \ {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} -#define NS_XML_ELEMENT_FACTORY_CID \ -{ /* CF170391-79CC-11d3-BE44-0020A6361667 */ \ - 0xcf170391, 0x79cc, 0x11d3, \ - {0xbe, 0x44, 0x0, 0x20, 0xa6, 0x36, 0x16, 0x67}} - #define NS_IMAGEDOCUMENT_CID \ { /* e11a6080-4daa-11d2-b328-00805f8a3859 */ \ 0xe11a6080, 0x4daa, 0x11d2, \ diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index 82a1bdab247..1534837cc63 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -74,7 +74,6 @@ #include "nsIDocument.h" #include "nsIDocumentEncoder.h" #include "nsIDocumentViewer.h" -#include "nsIElementFactory.h" #include "nsIEventListenerManager.h" #include "nsIFactory.h" #include "nsIFrameSelection.h" @@ -118,7 +117,6 @@ #include "nsStackLayout.h" #include "nsBox.h" #include "nsSpaceManager.h" -#include "nsTextControlFrame.h" #include "nsTextTransformer.h" #include "nsIFrameTraversal.h" #include "nsISelectionImageService.h" @@ -137,6 +135,8 @@ #include "nsView.h" #include "nsScrollPortView.h" #include "nsViewManager.h" +#include "nsContentCreatorFunctions.h" +#include "nsFrame.h" // DOM includes #include "nsDOMException.h" @@ -401,7 +401,6 @@ Shutdown() nsCSSFrameConstructor::ReleaseGlobals(); nsTextTransformer::Shutdown(); nsSpaceManager::Shutdown(); - nsTextControlFrame::ReleaseGlobals(); nsImageFrame::ReleaseGlobals(); NS_IF_RELEASE(nsContentDLF::gUAStyleSheet); @@ -433,7 +432,6 @@ nsresult NS_NewPopupBoxObject(nsIBoxObject** aResult); nsresult NS_NewBrowserBoxObject(nsIBoxObject** aResult); nsresult NS_NewIFrameBoxObject(nsIBoxObject** aResult); nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult); -nsresult NS_NewXULElementFactory(nsIElementFactory** aResult); #endif nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult); @@ -452,13 +450,10 @@ nsresult NS_NewGenRegularIterator(nsIContentIterator** aResult); nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aResult); nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult); nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult); -nsresult NS_NewHTMLElementFactory(nsIElementFactory** aResult); -nsresult NS_NewXMLElementFactory(nsIElementFactory** aResult); nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult); nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult); nsresult NS_NewXBLService(nsIXBLService** aResult); nsresult NS_NewBindingManager(nsIBindingManager** aResult); -nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult); nsresult NS_NewContentPolicy(nsIContentPolicy** aResult); nsresult NS_NewFrameLoader(nsIFrameLoader** aResult); nsresult NS_NewSyncLoadDOMService(nsISyncLoadDOMService** aResult); @@ -466,10 +461,6 @@ nsresult NS_NewDOMEventGroup(nsIDOMEventGroup** aResult); NS_IMETHODIMP NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult); -#ifdef MOZ_MATHML -nsresult NS_NewMathMLElementFactory(nsIElementFactory** aResult); -#endif - #ifdef MOZ_SVG #ifdef MOZ_SVG_RENDERER_GDIPLUS nsresult NS_NewSVGRendererGDIPlus(nsISVGRenderer** aResult); @@ -480,8 +471,6 @@ nsresult NS_NewSVGRendererLibart(nsISVGRenderer** aResult); #ifdef MOZ_SVG_RENDERER_CAIRO nsresult NS_NewSVGRendererCairo(nsISVGRenderer** aResult); #endif // MOZ_SVG_RENDERER_CAIRO - -nsresult NS_NewSVGElementFactory(nsIElementFactory** aResult); #endif #define MAKE_CTOR(ctor_, iface_, func_) \ @@ -553,11 +542,7 @@ MAKE_CTOR(CreateSVGDocument, nsIDocument, NS_NewSVG MAKE_CTOR(CreateImageDocument, nsIDocument, NS_NewImageDocument) MAKE_CTOR(CreateCSSParser, nsICSSParser, NS_NewCSSParser) MAKE_CTOR(CreateCSSLoader, nsICSSLoader, NS_NewCSSLoader) -MAKE_CTOR(CreateHTMLElementFactory, nsIElementFactory, NS_NewHTMLElementFactory) MAKE_CTOR(CreateTextNode, nsITextContent, NS_NewTextNode) -//MAKE_CTOR(CreateAnonymousElement, nsIContent, NS_NewAnonymousElement) -MAKE_CTOR(CreateXMLElementFactory, nsIElementFactory, NS_NewXMLElementFactory) -//MAKE_CTOR(CreateSelection, nsISelection, NS_NewSelection) MAKE_CTOR(CreateDOMSelection, nsISelection, NS_NewDomSelection) MAKE_CTOR(CreateSelection, nsIFrameSelection, NS_NewSelection) MAKE_CTOR(CreateRange, nsIDOMRange, NS_NewRange) @@ -581,7 +566,6 @@ MAKE_CTOR(CreateXBLService, nsIXBLService, NS_NewXBL MAKE_CTOR(CreateBindingManager, nsIBindingManager, NS_NewBindingManager) MAKE_CTOR(CreateContentPolicy, nsIContentPolicy, NS_NewContentPolicy) MAKE_CTOR(CreateFrameLoader, nsIFrameLoader, NS_NewFrameLoader) -MAKE_CTOR(CreateNodeInfoManager, nsINodeInfoManager, NS_NewNodeInfoManager) MAKE_CTOR(CreateComputedDOMStyle, nsIComputedDOMStyle, NS_NewComputedDOMStyle) #ifdef MOZ_XUL MAKE_CTOR(CreateXULSortService, nsIXULSortService, NS_NewXULSortService) @@ -591,13 +575,8 @@ MAKE_CTOR(CreateXULDocument, nsIXULDocument, NS_NewXUL MAKE_CTOR(CreateXULPopupListener, nsIXULPopupListener, NS_NewXULPopupListener) // NS_NewXULControllers // NS_NewXULPrototypeCache -MAKE_CTOR(CreateXULElementFactory, nsIElementFactory, NS_NewXULElementFactory) -#endif -#ifdef MOZ_MATHML -MAKE_CTOR(CreateMathMLElementFactory, nsIElementFactory, NS_NewMathMLElementFactory) #endif #ifdef MOZ_SVG -MAKE_CTOR(CreateSVGElementFactory, nsIElementFactory, NS_NewSVGElementFactory) MAKE_CTOR(CreateSVGRect, nsIDOMSVGRect, NS_NewSVGRect) #endif NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentHTTPStartup) @@ -986,35 +965,11 @@ static const nsModuleComponentInfo gComponents[] = { nsnull, CreateCSSLoader }, - { "HTML element factory", - NS_HTML_ELEMENT_FACTORY_CID, - NS_HTML_ELEMENT_FACTORY_CONTRACTID, - CreateHTMLElementFactory }, - { "Text element", NS_TEXTNODE_CID, nsnull, CreateTextNode }, -#if 0 // XXX apparently there is no such thing? - { "Anonymous Content", - NS_ANONYMOUSCONTENT_CID, - nsnull, - CreateAnonymousElement }, -#endif - - { "XML element factory", - NS_XML_ELEMENT_FACTORY_CID, - NS_XML_ELEMENT_FACTORY_CONTRACTID, - CreateXMLElementFactory }, - -#if 0 // XXX apparently there is no such thing? - { "Selection", - NS_SELECTION_CID, - nsnull, - CreateSelection }, -#endif - { "Dom selection", NS_DOMSELECTION_CID, "@mozilla.org/content/dom-selection;1", @@ -1199,11 +1154,6 @@ static const nsModuleComponentInfo gComponents[] = { NS_FRAMELOADER_CONTRACTID, CreateFrameLoader }, - { "NodeInfoManager", - NS_NODEINFOMANAGER_CID, - NS_NODEINFOMANAGER_CONTRACTID, - CreateNodeInfoManager }, - { "DOM CSS Computed Style Declaration", NS_COMPUTEDDOMSTYLE_CID, "@mozilla.org/DOM/Level2/CSS/computedStyleDeclaration;1", @@ -1249,31 +1199,9 @@ static const nsModuleComponentInfo gComponents[] = { NS_XULPROTOTYPEDOCUMENT_CID, nsnull, NS_NewXULPrototypeDocument }, - - { "XUL Element Factory", - NS_XULELEMENTFACTORY_CID, - NS_ELEMENT_FACTORY_CONTRACTID_PREFIX "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", - CreateXULElementFactory }, -#else - { "XML Element Factory", - NS_XULELEMENTFACTORY_CID, - NS_ELEMENT_FACTORY_CONTRACTID_PREFIX "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", - CreateXMLElementFactory }, -#endif - -#ifdef MOZ_MATHML - { "MathML Element Factory", - NS_MATHMLELEMENTFACTORY_CID, - NS_MATHML_ELEMENT_FACTORY_CONTRACTID, - CreateMathMLElementFactory }, #endif #ifdef MOZ_SVG - { "SVG element factory", - NS_SVGELEMENTFACTORY_CID, - NS_SVG_ELEMENT_FACTORY_CONTRACTID, - CreateSVGElementFactory }, - { "SVG Rect", NS_SVGRECT_CID, NS_SVGRECT_CONTRACTID, diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index eccd90a1d96..29cbb0a7beb 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -75,7 +75,6 @@ #include "nsIScrollableFrame.h" #include "nsIScrollableView.h" #include "nsListControlFrame.h" -#include "nsIElementFactory.h" #include "nsContentCID.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" @@ -85,9 +84,10 @@ #include "nsGUIEvent.h" #include "nsAutoPtr.h" #include "nsStyleSet.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); #ifdef MOZ_XUL #include "nsIXULDocument.h" // Temporary fix for Bug 36558 @@ -2031,9 +2031,9 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, //nsIAtom* tag = NS_NewAtom("mozcombodisplay"); // Add a child text content node for the label - nsresult result; - nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID,&result)); - if (NS_SUCCEEDED(result) && labelContent) { + nsresult rv; + nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID, &rv)); + if (NS_SUCCEEDED(rv) && labelContent) { // set the value of the text node mDisplayContent = do_QueryInterface(labelContent); mDisplayContent->SetText(NS_LITERAL_STRING("X"), PR_TRUE); @@ -2041,36 +2041,29 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc = mContent->GetDocument(); // mContent->AppendChildTo(labelContent, PR_FALSE, PR_FALSE); - nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - nsCOMPtr nodeInfo; - nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, - getter_AddRefs(nodeInfo)); + doc->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::input, nsnull, + kNameSpaceID_None, + getter_AddRefs(nodeInfo)); aChildList.AppendElement(labelContent); // create button which drops the list down - nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID)); - if (ef) { - nsCOMPtr content; - result = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); - if (NS_SUCCEEDED(result)) { - nsCOMPtr btnContent(do_QueryInterface(content)); - if (btnContent) { - // make someone to listen to the button. If its pressed by someone like Accessibility - // then open or close the combo box. - nsCOMPtr eventReceiver(do_QueryInterface(content)); - if (eventReceiver) { - mButtonListener = new nsComboButtonListener(this); - eventReceiver->AddEventListenerByIID(mButtonListener, NS_GET_IID(nsIDOMMouseListener)); - } + nsCOMPtr btnContent; + rv = NS_NewHTMLElement(getter_AddRefs(btnContent), nodeInfo); + NS_ENSURE_SUCCESS(rv, rv); - btnContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("button"), PR_FALSE); - aChildList.AppendElement(btnContent); - } - } + // make someone to listen to the button. If its pressed by someone like Accessibility + // then open or close the combo box. + nsCOMPtr eventReceiver(do_QueryInterface(btnContent)); + if (eventReceiver) { + mButtonListener = new nsComboButtonListener(this); + eventReceiver->AddEventListenerByIID(mButtonListener, NS_GET_IID(nsIDOMMouseListener)); } + + btnContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("button"), PR_FALSE); + + aChildList.AppendElement(btnContent); } return NS_OK; diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 2af259f6ff2..db7519832bf 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -38,7 +38,6 @@ #include "nsFileControlFrame.h" -#include "nsIElementFactory.h" #include "nsIContent.h" #include "prtypes.h" #include "nsIAtom.h" @@ -72,9 +71,8 @@ #include "nsIScriptGlobalObject.h" #include "nsILocalFile.h" #include "nsITextControlElement.h" - -#include "nsContentCID.h" -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" #define SYNC_TEXT 0x1 #define SYNC_BUTTON 0x2 @@ -164,34 +162,33 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, { // Get the NodeInfoManager and tag necessary to create input elements nsCOMPtr doc = mContent->GetDocument(); - nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; - nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, - getter_AddRefs(nodeInfo)); - - nsresult rv; - nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&rv)); - NS_ENSURE_SUCCESS(rv, rv); + doc->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::input, nsnull, + kNameSpaceID_None, + getter_AddRefs(nodeInfo)); // Create the text content - rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(mTextContent)); + nsCOMPtr content; + nsresult rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr fileContent(do_QueryInterface(mContent, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - PRInt32 tabIndex = -1; + content.swap(mTextContent); + + nsCOMPtr fileContent = do_QueryInterface(mContent); + if (mTextContent) { mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE); nsCOMPtr textControl = do_QueryInterface(mTextContent); - if (textControl) { + if (fileContent && textControl) { // Initialize value when we create the content in case the value was set // before we got here nsAutoString value; nsAutoString accessKey; fileContent->GetValue(value); textControl->SetValue(value); + + PRInt32 tabIndex; fileContent->GetTabIndex(&tabIndex); textControl->SetTabIndex(tabIndex); fileContent->GetAccessKey(accessKey); @@ -201,13 +198,15 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } // Create the browse button - rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(mBrowse)); + rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo); NS_ENSURE_SUCCESS(rv, rv); + mBrowse = do_QueryInterface(content); if (mBrowse) { mBrowse->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("button"), PR_FALSE); nsCOMPtr browseControl = do_QueryInterface(mBrowse); - if (browseControl) { + if (fileContent && browseControl) { + PRInt32 tabIndex; fileContent->GetTabIndex(&tabIndex); browseControl->SetTabIndex(tabIndex); } diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index 9a62ea7d655..b1c44bfc421 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -59,6 +59,7 @@ static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); // Saving PresState #include "nsIPresState.h" +#include "nsNodeInfoManager.h" const nscoord kSuggestedNotSet = -1; diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index 0559a9bd48f..25c94686ea4 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -76,11 +76,11 @@ #include "nsIFormControlFrame.h" #include "nsINodeInfo.h" #include "nsIDOMEventReceiver.h" -#include "nsIElementFactory.h" #include "nsContentCID.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); @@ -227,24 +227,18 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, // Get the node info manager (used to create hr's and input's) nsCOMPtr doc = mContent->GetDocument(); - nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&result)); - NS_ENSURE_SUCCESS(result, result); + nsNodeInfoManager *nimgr = doc->NodeInfoManager(); // Create an hr nsCOMPtr hrInfo; nimgr->GetNodeInfo(nsHTMLAtoms::hr, nsnull, kNameSpaceID_None, getter_AddRefs(hrInfo)); - nsCOMPtr content; - result = ef->CreateInstanceByTag(hrInfo,getter_AddRefs(content)); + + nsCOMPtr prehr; + result = NS_NewHTMLElement(getter_AddRefs(prehr), hrInfo); NS_ENSURE_SUCCESS(result, result); - nsCOMPtr prehr(do_QueryInterface(content,&result)); - if (NS_SUCCEEDED(result)) { - result = aChildList.AppendElement(prehr); - } + result = aChildList.AppendElement(prehr); // Add a child text content node for the label if (NS_SUCCEEDED(result)) { @@ -264,28 +258,23 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, getter_AddRefs(inputInfo)); - result = ef->CreateInstanceByTag(inputInfo,getter_AddRefs(content)); + result = NS_NewHTMLElement(&mInputContent, inputInfo); NS_ENSURE_SUCCESS(result, result); - result = content->QueryInterface(NS_GET_IID(nsIHTMLContent),(void**)&mInputContent); + mInputContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE); - if (NS_SUCCEEDED(result)) { - mInputContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE); - aChildList.AppendElement(mInputContent); + aChildList.AppendElement(mInputContent); - // Register as an event listener to submit on Enter press - nsCOMPtr reciever(do_QueryInterface(mInputContent)); - reciever->AddEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener)); - } + // Register as an event listener to submit on Enter press + nsCOMPtr receiver(do_QueryInterface(mInputContent)); + receiver->AddEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener)); // Create an hr - result = ef->CreateInstanceByTag(hrInfo,getter_AddRefs(content)); + nsCOMPtr posthr; + result = NS_NewHTMLElement(getter_AddRefs(posthr), hrInfo); NS_ENSURE_SUCCESS(result, result); - nsCOMPtr posthr(do_QueryInterface(content,&result)); - if (NS_SUCCEEDED(result)) { - aChildList.AppendElement(posthr); - } + aChildList.AppendElement(posthr); return result; } diff --git a/mozilla/layout/forms/nsIsIndexFrame.h b/mozilla/layout/forms/nsIsIndexFrame.h index d4b9d7118bf..e0d13e200b6 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.h +++ b/mozilla/layout/forms/nsIsIndexFrame.h @@ -137,7 +137,7 @@ public: protected: nsIHTMLContent* mTextContent; - nsIHTMLContent* mInputContent; + nsIContent* mInputContent; // XXX Hack: pres context needed by function KeyPress() and SetFocus() nsIPresContext* mPresContext; // weak reference diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index cc6e9b4e4ca..35c516e7e10 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -56,7 +56,6 @@ #include "nsIController.h" #include "nsIControllers.h" #include "nsIControllerContext.h" -#include "nsIElementFactory.h" #include "nsIHTMLContent.h" #include "nsIEditorIMESupport.h" #include "nsIPhonetic.h" @@ -119,7 +118,8 @@ #include "nsIEditorObserver.h" #include "nsITransactionManager.h" #include "nsIDOMText.h" //for multiline getselection - +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" #ifdef IBMBIDI #include "nsIBidiKeyboard.h" @@ -138,23 +138,6 @@ static const PRInt32 DEFAULT_COLS = 20; static const PRInt32 DEFAULT_ROWS = 1; static const PRInt32 DEFAULT_ROWS_TEXTAREA = 2; -static nsIWeakReference *sElementFactory = nsnull; - -static nsresult GetElementFactoryService(nsIElementFactory **aFactory) -{ - if (!sElementFactory) { - sElementFactory = NS_GetWeakReference( - nsCOMPtr( - do_GetService( - NS_ELEMENT_FACTORY_CONTRACTID_PREFIX - "http://www.w3.org/1999/xhtml"))); - if (!sElementFactory) - return NS_ERROR_FAILURE; - } - return CallQueryReferent(sElementFactory, aFactory); -} - - class nsTextInputListener : public nsISelectionListener, public nsIDOMFocusListener, public nsIEditorObserver, @@ -1161,12 +1144,6 @@ nsTextControlFrame::~nsTextControlFrame() //delete mTextSelImpl; dont delete this since mSelCon will release it. } -/* static */ void -nsTextControlFrame::ReleaseGlobals() -{ - NS_IF_RELEASE(sElementFactory); -} - static PRBool SuppressEventHandlers(nsIPresContext* aPresContext) { @@ -1615,20 +1592,10 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, return NS_ERROR_FAILURE; // Now create a DIV and add it to the anonymous content child list. - nsCOMPtr elementFactory; - rv = GetElementFactoryService(getter_AddRefs(elementFactory)); - if (NS_FAILED(rv)) - return rv; - if (!elementFactory) - return NS_ERROR_FAILURE; - - nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); - nsCOMPtr nodeInfo; - rv = nodeInfoManager->GetNodeInfo(nsHTMLAtoms::div, nsnull, - kNameSpaceID_XHTML, - getter_AddRefs(nodeInfo)); + rv = doc->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::div, nsnull, + kNameSpaceID_XHTML, + getter_AddRefs(nodeInfo)); if (NS_FAILED(rv)) return rv; @@ -1637,8 +1604,7 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, return NS_ERROR_FAILURE; nsCOMPtr divContent; - - rv = elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(divContent)); + rv = NS_NewHTMLElement(getter_AddRefs(divContent), nodeInfo); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/layout/forms/nsTextControlFrame.h b/mozilla/layout/forms/nsTextControlFrame.h index 240c62d0579..5538c2c19ef 100644 --- a/mozilla/layout/forms/nsTextControlFrame.h +++ b/mozilla/layout/forms/nsTextControlFrame.h @@ -54,7 +54,6 @@ class nsIPresState; class nsISupportsArray; -class nsIHTMLContent; class nsIEditor; class nsISelectionController; class nsTextInputSelectionImpl; @@ -77,8 +76,6 @@ public: nsTextControlFrame(nsIPresShell* aShell); virtual ~nsTextControlFrame(); - static void ReleaseGlobals(); - virtual void RemovedAsPrimaryFrame(nsIPresContext* aPresContext); NS_IMETHOD Destroy(nsIPresContext* aPresContext); diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index aa15d914b19..2f10607ff66 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -58,17 +58,17 @@ #include "nsIFontMetrics.h" #include "nsIDocumentObserver.h" #include "nsIDocument.h" -#include "nsIElementFactory.h" #include "nsBoxLayoutState.h" #include "nsINodeInfo.h" #include "nsIScrollbarFrame.h" #include "nsIScrollbarMediator.h" #include "nsITextControlFrame.h" #include "nsIDOMHTMLTextAreaElement.h" - +#include "nsNodeInfoManager.h" #include "nsIPrintPreviewContext.h" #include "nsIURI.h" #include "nsGUIEvent.h" +#include "nsContentCreatorFunctions.h" //---------------------------------------------------------------------- //----------nsHTMLScrollFrame------------------------------------------- @@ -1330,32 +1330,26 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr } } - // create horzontal scrollbar - nsresult rv; - nsCOMPtr elementFactory = - do_GetService(NS_ELEMENT_FACTORY_CONTRACTID_PREFIX "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", &rv); - if (!elementFactory) - return; - - nsINodeInfoManager *nodeInfoManager = nsnull; - if (document) - nodeInfoManager = document->GetNodeInfoManager(); - if (!nodeInfoManager) { + // create horizontal scrollbar + if (!document) { return; } + nsNodeInfoManager *nodeInfoManager = document->NodeInfoManager(); + nsCOMPtr nodeInfo; nodeInfoManager->GetNodeInfo(nsXULAtoms::scrollbar, nsnull, kNameSpaceID_XUL, getter_AddRefs(nodeInfo)); + nsCOMPtr content; + nsCOMPtr scrollable = do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mOuter)); ScrollbarStyles styles = scrollable->GetScrollbarStyles(); PRBool canHaveHorizontal = styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO || styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL; if (canHaveHorizontal) { - nsCOMPtr content; - elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content)); + NS_NewXULElement(getter_AddRefs(content), nodeInfo); content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient, NS_LITERAL_STRING("horizontal"), PR_FALSE); aAnonymousChildren.AppendElement(content); @@ -1364,8 +1358,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr PRBool canHaveVertical = styles.mVertical == NS_STYLE_OVERFLOW_AUTO || styles.mVertical == NS_STYLE_OVERFLOW_SCROLL; if (canHaveVertical) { - nsCOMPtr content; - elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content)); + NS_NewXULElement(getter_AddRefs(content), nodeInfo); content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient, NS_LITERAL_STRING("vertical"), PR_FALSE); aAnonymousChildren.AppendElement(content); @@ -1374,8 +1367,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr if (canHaveHorizontal && canHaveVertical) { nodeInfoManager->GetNodeInfo(nsXULAtoms::scrollcorner, nsnull, kNameSpaceID_XUL, getter_AddRefs(nodeInfo)); - nsCOMPtr content; - elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content)); + NS_NewXULElement(getter_AddRefs(content), nodeInfo); aAnonymousChildren.AppendElement(content); } } diff --git a/mozilla/layout/generic/nsHTMLParts.h b/mozilla/layout/generic/nsHTMLParts.h index 71a73016518..18c78a27e1d 100644 --- a/mozilla/layout/generic/nsHTMLParts.h +++ b/mozilla/layout/generic/nsHTMLParts.h @@ -78,17 +78,6 @@ NS_NewFrameContentIterator(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIContentIterator** aIterator); -/** - * Create a new content object for the given tag. - * Returns NS_ERROR_NOT_AVAILABLE for an unknown/unhandled tag. - * Returns some other error on error. - * Returns NS_OK on success - */ -PR_EXTERN(nsresult) -NS_CreateHTMLElement(nsIHTMLContent** aResult, - nsINodeInfo *aNodeInfo, - PRBool aCaseSensitive); - // Factory methods for creating html layout objects // These are variations on AreaFrame with slightly different layout diff --git a/mozilla/layout/generic/nsImageMap.cpp b/mozilla/layout/generic/nsImageMap.cpp index 8a7d8094919..8cfcd6e1822 100644 --- a/mozilla/layout/generic/nsImageMap.cpp +++ b/mozilla/layout/generic/nsImageMap.cpp @@ -65,7 +65,7 @@ #include "nsIScriptError.h" #include "nsIStringBundle.h" #include "nsIDocument.h" -#include "nsINodeInfo.h" +#include "nsContentUtils.h" static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); @@ -419,7 +419,7 @@ void RectArea::ParseCoords(const nsAString& aSpec) nsINodeInfo *nodeInfo = mArea->GetNodeInfo(); NS_ASSERTION(nodeInfo, "Element with no nodeinfo"); - nsIDocument* doc = nodeInfo->GetDocument(); + nsIDocument* doc = nsContentUtils::GetDocument(nodeInfo); nsCAutoString urlSpec; if (doc) { nsIURI *uri = doc->GetDocumentURI(); diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index aa15d914b19..2f10607ff66 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -58,17 +58,17 @@ #include "nsIFontMetrics.h" #include "nsIDocumentObserver.h" #include "nsIDocument.h" -#include "nsIElementFactory.h" #include "nsBoxLayoutState.h" #include "nsINodeInfo.h" #include "nsIScrollbarFrame.h" #include "nsIScrollbarMediator.h" #include "nsITextControlFrame.h" #include "nsIDOMHTMLTextAreaElement.h" - +#include "nsNodeInfoManager.h" #include "nsIPrintPreviewContext.h" #include "nsIURI.h" #include "nsGUIEvent.h" +#include "nsContentCreatorFunctions.h" //---------------------------------------------------------------------- //----------nsHTMLScrollFrame------------------------------------------- @@ -1330,32 +1330,26 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr } } - // create horzontal scrollbar - nsresult rv; - nsCOMPtr elementFactory = - do_GetService(NS_ELEMENT_FACTORY_CONTRACTID_PREFIX "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", &rv); - if (!elementFactory) - return; - - nsINodeInfoManager *nodeInfoManager = nsnull; - if (document) - nodeInfoManager = document->GetNodeInfoManager(); - if (!nodeInfoManager) { + // create horizontal scrollbar + if (!document) { return; } + nsNodeInfoManager *nodeInfoManager = document->NodeInfoManager(); + nsCOMPtr nodeInfo; nodeInfoManager->GetNodeInfo(nsXULAtoms::scrollbar, nsnull, kNameSpaceID_XUL, getter_AddRefs(nodeInfo)); + nsCOMPtr content; + nsCOMPtr scrollable = do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mOuter)); ScrollbarStyles styles = scrollable->GetScrollbarStyles(); PRBool canHaveHorizontal = styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO || styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL; if (canHaveHorizontal) { - nsCOMPtr content; - elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content)); + NS_NewXULElement(getter_AddRefs(content), nodeInfo); content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient, NS_LITERAL_STRING("horizontal"), PR_FALSE); aAnonymousChildren.AppendElement(content); @@ -1364,8 +1358,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr PRBool canHaveVertical = styles.mVertical == NS_STYLE_OVERFLOW_AUTO || styles.mVertical == NS_STYLE_OVERFLOW_SCROLL; if (canHaveVertical) { - nsCOMPtr content; - elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content)); + NS_NewXULElement(getter_AddRefs(content), nodeInfo); content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient, NS_LITERAL_STRING("vertical"), PR_FALSE); aAnonymousChildren.AppendElement(content); @@ -1374,8 +1367,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr if (canHaveHorizontal && canHaveVertical) { nodeInfoManager->GetNodeInfo(nsXULAtoms::scrollcorner, nsnull, kNameSpaceID_XUL, getter_AddRefs(nodeInfo)); - nsCOMPtr content; - elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content)); + NS_NewXULElement(getter_AddRefs(content), nodeInfo); aAnonymousChildren.AppendElement(content); } } diff --git a/mozilla/layout/html/base/src/nsHTMLParts.h b/mozilla/layout/html/base/src/nsHTMLParts.h index 71a73016518..18c78a27e1d 100644 --- a/mozilla/layout/html/base/src/nsHTMLParts.h +++ b/mozilla/layout/html/base/src/nsHTMLParts.h @@ -78,17 +78,6 @@ NS_NewFrameContentIterator(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIContentIterator** aIterator); -/** - * Create a new content object for the given tag. - * Returns NS_ERROR_NOT_AVAILABLE for an unknown/unhandled tag. - * Returns some other error on error. - * Returns NS_OK on success - */ -PR_EXTERN(nsresult) -NS_CreateHTMLElement(nsIHTMLContent** aResult, - nsINodeInfo *aNodeInfo, - PRBool aCaseSensitive); - // Factory methods for creating html layout objects // These are variations on AreaFrame with slightly different layout diff --git a/mozilla/layout/html/base/src/nsImageMap.cpp b/mozilla/layout/html/base/src/nsImageMap.cpp index 8a7d8094919..8cfcd6e1822 100644 --- a/mozilla/layout/html/base/src/nsImageMap.cpp +++ b/mozilla/layout/html/base/src/nsImageMap.cpp @@ -65,7 +65,7 @@ #include "nsIScriptError.h" #include "nsIStringBundle.h" #include "nsIDocument.h" -#include "nsINodeInfo.h" +#include "nsContentUtils.h" static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); @@ -419,7 +419,7 @@ void RectArea::ParseCoords(const nsAString& aSpec) nsINodeInfo *nodeInfo = mArea->GetNodeInfo(); NS_ASSERTION(nodeInfo, "Element with no nodeinfo"); - nsIDocument* doc = nodeInfo->GetDocument(); + nsIDocument* doc = nsContentUtils::GetDocument(nodeInfo); nsCAutoString urlSpec; if (doc) { nsIURI *uri = doc->GetDocumentURI(); diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index eccd90a1d96..29cbb0a7beb 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -75,7 +75,6 @@ #include "nsIScrollableFrame.h" #include "nsIScrollableView.h" #include "nsListControlFrame.h" -#include "nsIElementFactory.h" #include "nsContentCID.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" @@ -85,9 +84,10 @@ #include "nsGUIEvent.h" #include "nsAutoPtr.h" #include "nsStyleSet.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); #ifdef MOZ_XUL #include "nsIXULDocument.h" // Temporary fix for Bug 36558 @@ -2031,9 +2031,9 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, //nsIAtom* tag = NS_NewAtom("mozcombodisplay"); // Add a child text content node for the label - nsresult result; - nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID,&result)); - if (NS_SUCCEEDED(result) && labelContent) { + nsresult rv; + nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID, &rv)); + if (NS_SUCCEEDED(rv) && labelContent) { // set the value of the text node mDisplayContent = do_QueryInterface(labelContent); mDisplayContent->SetText(NS_LITERAL_STRING("X"), PR_TRUE); @@ -2041,36 +2041,29 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc = mContent->GetDocument(); // mContent->AppendChildTo(labelContent, PR_FALSE, PR_FALSE); - nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - nsCOMPtr nodeInfo; - nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, - getter_AddRefs(nodeInfo)); + doc->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::input, nsnull, + kNameSpaceID_None, + getter_AddRefs(nodeInfo)); aChildList.AppendElement(labelContent); // create button which drops the list down - nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID)); - if (ef) { - nsCOMPtr content; - result = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); - if (NS_SUCCEEDED(result)) { - nsCOMPtr btnContent(do_QueryInterface(content)); - if (btnContent) { - // make someone to listen to the button. If its pressed by someone like Accessibility - // then open or close the combo box. - nsCOMPtr eventReceiver(do_QueryInterface(content)); - if (eventReceiver) { - mButtonListener = new nsComboButtonListener(this); - eventReceiver->AddEventListenerByIID(mButtonListener, NS_GET_IID(nsIDOMMouseListener)); - } + nsCOMPtr btnContent; + rv = NS_NewHTMLElement(getter_AddRefs(btnContent), nodeInfo); + NS_ENSURE_SUCCESS(rv, rv); - btnContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("button"), PR_FALSE); - aChildList.AppendElement(btnContent); - } - } + // make someone to listen to the button. If its pressed by someone like Accessibility + // then open or close the combo box. + nsCOMPtr eventReceiver(do_QueryInterface(btnContent)); + if (eventReceiver) { + mButtonListener = new nsComboButtonListener(this); + eventReceiver->AddEventListenerByIID(mButtonListener, NS_GET_IID(nsIDOMMouseListener)); } + + btnContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("button"), PR_FALSE); + + aChildList.AppendElement(btnContent); } return NS_OK; diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp index 2af259f6ff2..db7519832bf 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp @@ -38,7 +38,6 @@ #include "nsFileControlFrame.h" -#include "nsIElementFactory.h" #include "nsIContent.h" #include "prtypes.h" #include "nsIAtom.h" @@ -72,9 +71,8 @@ #include "nsIScriptGlobalObject.h" #include "nsILocalFile.h" #include "nsITextControlElement.h" - -#include "nsContentCID.h" -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" #define SYNC_TEXT 0x1 #define SYNC_BUTTON 0x2 @@ -164,34 +162,33 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, { // Get the NodeInfoManager and tag necessary to create input elements nsCOMPtr doc = mContent->GetDocument(); - nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; - nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, - getter_AddRefs(nodeInfo)); - - nsresult rv; - nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&rv)); - NS_ENSURE_SUCCESS(rv, rv); + doc->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::input, nsnull, + kNameSpaceID_None, + getter_AddRefs(nodeInfo)); // Create the text content - rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(mTextContent)); + nsCOMPtr content; + nsresult rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr fileContent(do_QueryInterface(mContent, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - PRInt32 tabIndex = -1; + content.swap(mTextContent); + + nsCOMPtr fileContent = do_QueryInterface(mContent); + if (mTextContent) { mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE); nsCOMPtr textControl = do_QueryInterface(mTextContent); - if (textControl) { + if (fileContent && textControl) { // Initialize value when we create the content in case the value was set // before we got here nsAutoString value; nsAutoString accessKey; fileContent->GetValue(value); textControl->SetValue(value); + + PRInt32 tabIndex; fileContent->GetTabIndex(&tabIndex); textControl->SetTabIndex(tabIndex); fileContent->GetAccessKey(accessKey); @@ -201,13 +198,15 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } // Create the browse button - rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(mBrowse)); + rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo); NS_ENSURE_SUCCESS(rv, rv); + mBrowse = do_QueryInterface(content); if (mBrowse) { mBrowse->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("button"), PR_FALSE); nsCOMPtr browseControl = do_QueryInterface(mBrowse); - if (browseControl) { + if (fileContent && browseControl) { + PRInt32 tabIndex; fileContent->GetTabIndex(&tabIndex); browseControl->SetTabIndex(tabIndex); } diff --git a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp index 9a62ea7d655..b1c44bfc421 100644 --- a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -59,6 +59,7 @@ static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); // Saving PresState #include "nsIPresState.h" +#include "nsNodeInfoManager.h" const nscoord kSuggestedNotSet = -1; diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp index 0559a9bd48f..25c94686ea4 100644 --- a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp +++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp @@ -76,11 +76,11 @@ #include "nsIFormControlFrame.h" #include "nsINodeInfo.h" #include "nsIDOMEventReceiver.h" -#include "nsIElementFactory.h" #include "nsContentCID.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); @@ -227,24 +227,18 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, // Get the node info manager (used to create hr's and input's) nsCOMPtr doc = mContent->GetDocument(); - nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&result)); - NS_ENSURE_SUCCESS(result, result); + nsNodeInfoManager *nimgr = doc->NodeInfoManager(); // Create an hr nsCOMPtr hrInfo; nimgr->GetNodeInfo(nsHTMLAtoms::hr, nsnull, kNameSpaceID_None, getter_AddRefs(hrInfo)); - nsCOMPtr content; - result = ef->CreateInstanceByTag(hrInfo,getter_AddRefs(content)); + + nsCOMPtr prehr; + result = NS_NewHTMLElement(getter_AddRefs(prehr), hrInfo); NS_ENSURE_SUCCESS(result, result); - nsCOMPtr prehr(do_QueryInterface(content,&result)); - if (NS_SUCCEEDED(result)) { - result = aChildList.AppendElement(prehr); - } + result = aChildList.AppendElement(prehr); // Add a child text content node for the label if (NS_SUCCEEDED(result)) { @@ -264,28 +258,23 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, getter_AddRefs(inputInfo)); - result = ef->CreateInstanceByTag(inputInfo,getter_AddRefs(content)); + result = NS_NewHTMLElement(&mInputContent, inputInfo); NS_ENSURE_SUCCESS(result, result); - result = content->QueryInterface(NS_GET_IID(nsIHTMLContent),(void**)&mInputContent); + mInputContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE); - if (NS_SUCCEEDED(result)) { - mInputContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE); - aChildList.AppendElement(mInputContent); + aChildList.AppendElement(mInputContent); - // Register as an event listener to submit on Enter press - nsCOMPtr reciever(do_QueryInterface(mInputContent)); - reciever->AddEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener)); - } + // Register as an event listener to submit on Enter press + nsCOMPtr receiver(do_QueryInterface(mInputContent)); + receiver->AddEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener)); // Create an hr - result = ef->CreateInstanceByTag(hrInfo,getter_AddRefs(content)); + nsCOMPtr posthr; + result = NS_NewHTMLElement(getter_AddRefs(posthr), hrInfo); NS_ENSURE_SUCCESS(result, result); - nsCOMPtr posthr(do_QueryInterface(content,&result)); - if (NS_SUCCEEDED(result)) { - aChildList.AppendElement(posthr); - } + aChildList.AppendElement(posthr); return result; } diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.h b/mozilla/layout/html/forms/src/nsIsIndexFrame.h index d4b9d7118bf..e0d13e200b6 100644 --- a/mozilla/layout/html/forms/src/nsIsIndexFrame.h +++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.h @@ -137,7 +137,7 @@ public: protected: nsIHTMLContent* mTextContent; - nsIHTMLContent* mInputContent; + nsIContent* mInputContent; // XXX Hack: pres context needed by function KeyPress() and SetFocus() nsIPresContext* mPresContext; // weak reference diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index cc6e9b4e4ca..35c516e7e10 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -56,7 +56,6 @@ #include "nsIController.h" #include "nsIControllers.h" #include "nsIControllerContext.h" -#include "nsIElementFactory.h" #include "nsIHTMLContent.h" #include "nsIEditorIMESupport.h" #include "nsIPhonetic.h" @@ -119,7 +118,8 @@ #include "nsIEditorObserver.h" #include "nsITransactionManager.h" #include "nsIDOMText.h" //for multiline getselection - +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" #ifdef IBMBIDI #include "nsIBidiKeyboard.h" @@ -138,23 +138,6 @@ static const PRInt32 DEFAULT_COLS = 20; static const PRInt32 DEFAULT_ROWS = 1; static const PRInt32 DEFAULT_ROWS_TEXTAREA = 2; -static nsIWeakReference *sElementFactory = nsnull; - -static nsresult GetElementFactoryService(nsIElementFactory **aFactory) -{ - if (!sElementFactory) { - sElementFactory = NS_GetWeakReference( - nsCOMPtr( - do_GetService( - NS_ELEMENT_FACTORY_CONTRACTID_PREFIX - "http://www.w3.org/1999/xhtml"))); - if (!sElementFactory) - return NS_ERROR_FAILURE; - } - return CallQueryReferent(sElementFactory, aFactory); -} - - class nsTextInputListener : public nsISelectionListener, public nsIDOMFocusListener, public nsIEditorObserver, @@ -1161,12 +1144,6 @@ nsTextControlFrame::~nsTextControlFrame() //delete mTextSelImpl; dont delete this since mSelCon will release it. } -/* static */ void -nsTextControlFrame::ReleaseGlobals() -{ - NS_IF_RELEASE(sElementFactory); -} - static PRBool SuppressEventHandlers(nsIPresContext* aPresContext) { @@ -1615,20 +1592,10 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, return NS_ERROR_FAILURE; // Now create a DIV and add it to the anonymous content child list. - nsCOMPtr elementFactory; - rv = GetElementFactoryService(getter_AddRefs(elementFactory)); - if (NS_FAILED(rv)) - return rv; - if (!elementFactory) - return NS_ERROR_FAILURE; - - nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); - nsCOMPtr nodeInfo; - rv = nodeInfoManager->GetNodeInfo(nsHTMLAtoms::div, nsnull, - kNameSpaceID_XHTML, - getter_AddRefs(nodeInfo)); + rv = doc->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::div, nsnull, + kNameSpaceID_XHTML, + getter_AddRefs(nodeInfo)); if (NS_FAILED(rv)) return rv; @@ -1637,8 +1604,7 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, return NS_ERROR_FAILURE; nsCOMPtr divContent; - - rv = elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(divContent)); + rv = NS_NewHTMLElement(getter_AddRefs(divContent), nodeInfo); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.h b/mozilla/layout/html/forms/src/nsTextControlFrame.h index 240c62d0579..5538c2c19ef 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.h +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.h @@ -54,7 +54,6 @@ class nsIPresState; class nsISupportsArray; -class nsIHTMLContent; class nsIEditor; class nsISelectionController; class nsTextInputSelectionImpl; @@ -77,8 +76,6 @@ public: nsTextControlFrame(nsIPresShell* aShell); virtual ~nsTextControlFrame(); - static void ReleaseGlobals(); - virtual void RemovedAsPrimaryFrame(nsIPresContext* aPresContext); NS_IMETHOD Destroy(nsIPresContext* aPresContext); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 6d158f58016..1570f875af8 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -96,7 +96,6 @@ #include "nsBoxLayoutState.h" #include "nsIBindingManager.h" #include "nsIXBLBinding.h" -#include "nsIElementFactory.h" #include "nsITheme.h" #include "nsContentCID.h" #include "nsContentUtils.h" @@ -117,7 +116,6 @@ #include "nsBoxFrame.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); #include "nsIDOMWindowInternal.h" #include "nsIMenuFrame.h" @@ -191,6 +189,8 @@ NS_NewSVGDefsFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aN #include "nsINodeInfo.h" #include "prenv.h" #include "nsWidgetsCID.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" // Global object maintenance nsIXBLService * nsCSSFrameConstructor::gXBLService = nsnull; @@ -1372,19 +1372,13 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create an HTML image content object, and set the SRC. // XXX Check if it's an image type we can handle... - nsINodeInfoManager *nimgr = aDocument->GetNodeInfoManager(); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - nsCOMPtr nodeInfo; - nimgr->GetNodeInfo(nsHTMLAtoms::img, nsnull, kNameSpaceID_None, - getter_AddRefs(nodeInfo)); - - nsresult rv; - nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&rv)); - NS_ENSURE_SUCCESS(rv, rv); + aDocument->NodeInfoManager()->GetNodeInfo(nsHTMLAtoms::img, nsnull, + kNameSpaceID_None, + getter_AddRefs(nodeInfo)); nsCOMPtr content; - rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + nsresult rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo); NS_ENSURE_SUCCESS(rv, rv); nsCAutoString spec; diff --git a/mozilla/layout/html/tests/TestAttributes.cpp b/mozilla/layout/html/tests/TestAttributes.cpp index 7fb3bc38f09..c96214fe6b5 100644 --- a/mozilla/layout/html/tests/TestAttributes.cpp +++ b/mozilla/layout/html/tests/TestAttributes.cpp @@ -287,10 +287,9 @@ int main(int argc, char** argv) nsIHTMLContent* container; nsIAtom* li = NS_NewAtom("li"); - nsCOMPtr nimgr; nsCOMPtr ni; - myDoc->GetNodeInfoManager(getter_AddRefs(nimgr)); - nimgr->GetNodeInfo(li, nsnull, kNameSpaceID_None, *getter_AddRefs(ni)); + myDoc->NodeInfoManager()->GetNodeInfo(li, nsnull, kNameSpaceID_None, + getter_AddRefs(ni)); rv = NS_NewHTMLLIElement(&container,ni); if (NS_OK != rv) { diff --git a/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp b/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp index fc45f406e05..a2a5088136d 100644 --- a/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -49,6 +49,7 @@ #include "nsIURI.h" #include "nsINameSpaceManager.h" #include "nsStyleConsts.h" +#include "nsContentUtils.h" MOZ_DECL_CTOR_COUNTER(nsDOMCSSAttributeDeclaration) @@ -149,7 +150,7 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI, nsINodeInfo *nodeInfo = mContent->GetNodeInfo(); // XXXbz GetOwnerDocument - nsIDocument* doc = nodeInfo->GetDocument(); + nsIDocument* doc = nsContentUtils::GetDocument(nodeInfo); nsCOMPtr base = mContent->GetBaseURI(); diff --git a/mozilla/layout/xul/base/src/nsDocElementBoxFrame.cpp b/mozilla/layout/xul/base/src/nsDocElementBoxFrame.cpp index 55421063b95..7fd29998abc 100644 --- a/mozilla/layout/xul/base/src/nsDocElementBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsDocElementBoxFrame.cpp @@ -60,10 +60,11 @@ #include "nsStackLayout.h" #include "nsIRootBox.h" #include "nsIAnonymousContentCreator.h" -#include "nsIElementFactory.h" #include "nsINodeInfo.h" #include "nsIServiceManager.h" #include "nsISupportsArray.h" +#include "nsNodeInfoManager.h" +#include "nsContentCreatorFunctions.h" // Interface IDs @@ -117,28 +118,23 @@ NS_IMETHODIMP nsDocElementBoxFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsISupportsArray& aAnonymousItems) { - nsresult rv; - nsCOMPtr elementFactory = - do_GetService(NS_ELEMENT_FACTORY_CONTRACTID_PREFIX "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", &rv); - if (!elementFactory) - return NS_ERROR_FAILURE; - nsIDocument* doc = mContent->GetDocument(); if (!doc) // The page is currently being torn down. Why bother. return NS_ERROR_FAILURE; - nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); - NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); + nsNodeInfoManager *nodeInfoManager = doc->NodeInfoManager(); // create the top-secret popupgroup node. shhhhh! nsCOMPtr nodeInfo; - rv = nodeInfoManager->GetNodeInfo(nsXULAtoms::popupgroup, - nsnull, kNameSpaceID_XUL, - getter_AddRefs(nodeInfo)); + nsresult rv = nodeInfoManager->GetNodeInfo(nsXULAtoms::popupgroup, + nsnull, kNameSpaceID_XUL, + getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr content; - elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content)); + rv = NS_NewXULElement(getter_AddRefs(content), nodeInfo); + NS_ENSURE_SUCCESS(rv, rv); + aAnonymousItems.AppendElement(content); // create the top-secret default tooltip node. shhhhh! @@ -146,7 +142,9 @@ nsDocElementBoxFrame::CreateAnonymousContent(nsIPresContext* aPresContext, kNameSpaceID_XUL, getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, rv); - elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content)); + rv = NS_NewXULElement(getter_AddRefs(content), nodeInfo); + NS_ENSURE_SUCCESS(rv, rv); + content->SetAttr(nsnull, nsXULAtoms::defaultz, NS_LITERAL_STRING("true"), PR_FALSE); aAnonymousItems.AppendElement(content); diff --git a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp index 04b9a861e36..f0ec896df25 100644 --- a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -70,6 +70,7 @@ #include "nsStyleSet.h" #include "nsIDOMNSDocument.h" #include "nsPIBoxObject.h" +#include "nsINodeInfo.h" /////////////// nsListScrollSmoother ////////////////// diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 7053b31805a..e3b679654aa 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -94,6 +94,7 @@ #include "imgIContainer.h" #include "imgIContainerObserver.h" #include "imgILoader.h" +#include "nsINodeInfo.h" #ifdef IBMBIDI #include "nsBidiPresUtils.h" diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp index 1b22adc1252..a23a5771f83 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp @@ -49,6 +49,7 @@ #include "nsIDOMElement.h" #include "nsITreeBoxObject.h" #include "nsIDOMXULTreeElement.h" +#include "nsINodeInfo.h" // // NS_NewTreeColFrame diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeColumns.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeColumns.cpp index 05eee2afa66..02a22446952 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeColumns.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeColumns.cpp @@ -48,6 +48,7 @@ #include "nsTreeUtils.h" #include "nsStyleContext.h" #include "nsIDOMClassInfo.h" +#include "nsINodeInfo.h" // Column class that caches all the info about our column. nsTreeColumn::nsTreeColumn(nsTreeColumns* aColumns, nsIFrame* aFrame) diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp index 880ec81c6b8..ab55c2150e4 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp @@ -46,6 +46,7 @@ #include "nsIDOMHTMLOptGroupElement.h" #include "nsIDOMClassInfo.h" #include "nsIEventStateManager.h" +#include "nsINodeInfo.h" // A content model view implementation for the tree.