From 98fb7d25298802e12ad661237e7bbb3f698552c3 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Sat, 15 Nov 2003 05:27:37 +0000 Subject: [PATCH] deCOMtaminate nsINodeInfo and nsINodeInfoManager. See bug 225060 for details. r=sicking, sr=jst. git-svn-id: svn://10.0.0.236/trunk@149340 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsINodeInfo.h | 216 +++++++++++------- mozilla/content/base/src/nsDOMAttribute.cpp | 31 ++- .../content/base/src/nsDOMAttributeMap.cpp | 57 ++--- mozilla/content/base/src/nsGenericElement.cpp | 74 +++--- mozilla/content/base/src/nsNodeInfo.cpp | 86 ++----- mozilla/content/base/src/nsNodeInfo.h | 37 +-- .../content/base/src/nsNodeInfoManager.cpp | 52 ++--- mozilla/content/base/src/nsNodeInfoManager.h | 30 ++- mozilla/content/base/src/nsScriptLoader.cpp | 8 +- .../html/content/src/nsGenericHTMLElement.cpp | 24 +- .../html/document/src/nsHTMLContentSink.cpp | 2 +- .../html/document/src/nsHTMLDocument.cpp | 2 +- .../html/style/src/nsHTMLAttributes.cpp | 23 +- .../svg/content/src/nsSVGAttributes.cpp | 10 +- .../svg/content/src/nsSVGElementFactory.cpp | 2 +- .../xml/document/src/nsXMLContentSink.cpp | 6 +- .../xml/document/src/nsXMLDocument.cpp | 2 +- .../xul/content/src/nsXULAttributes.cpp | 6 +- .../content/xul/content/src/nsXULElement.cpp | 111 ++++----- .../content/xul/content/src/nsXULElement.h | 16 +- .../xul/document/src/nsXULContentSink.cpp | 2 +- .../xul/document/src/nsXULDocument.cpp | 20 +- .../document/src/nsXULPrototypeDocument.cpp | 25 +- .../xul/templates/src/nsXULContentBuilder.cpp | 4 +- .../source/xml/dom/mozImpl/MozillaElement.cpp | 2 +- .../xslt/txMozillaStylesheetCompiler.cpp | 12 +- .../webservices/schema/src/nsDOMUtils.h | 2 +- 27 files changed, 362 insertions(+), 500 deletions(-) diff --git a/mozilla/content/base/public/nsINodeInfo.h b/mozilla/content/base/public/nsINodeInfo.h index cd6e81fbea4..8e269383509 100644 --- a/mozilla/content/base/public/nsINodeInfo.h +++ b/mozilla/content/base/public/nsINodeInfo.h @@ -61,13 +61,14 @@ #include "nsAString.h" #include "domstubs.h" #include "nsINameSpaceManager.h" +#include "nsCOMPtr.h" +#include "nsCOMArray.h" // Forward declarations -class nsINodeInfoManager; +class nsINodeInfo; class nsIDocument; class nsIURI; class nsIPrincipal; -class nsISupportsArray; // IID for the nsINodeInfo interface @@ -83,27 +84,99 @@ class nsISupportsArray; #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 nsACString& aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, + 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; + + /** + * Populate the given nsCOMArray with all of the nsINodeInfos + * managed by this manager. + */ + virtual nsresult GetNodeInfos(nsCOMArray *aArray) = 0; + +protected: + nsIDocument *mDocument; // WEAK +}; + + class nsINodeInfo : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_INODEINFO_IID) nsINodeInfo() - : mInner(nsnull, nsnull, kNameSpaceID_None) + : mInner(nsnull, nsnull, kNameSpaceID_None), + mOwnerManager(nsnull) { } + virtual ~nsINodeInfo() { } + /* * Get the name from this node as a string, this does not include the prefix. * * For the HTML element "" this will return "body" and for the XML * element "" this will return "body". */ - nsresult GetName(nsAString& aName) const + void GetName(nsAString& aName) const { mInner.mName->ToString(aName); - - return NS_OK; } /* @@ -113,9 +186,8 @@ public: * For the HTML element "" this will return the "body" atom and for * the XML element "" this will return the "body" atom. */ - already_AddRefed GetNameAtom() const + nsIAtom* NameAtom() const { - NS_ADDREF(mInner.mName); return mInner.mName; } @@ -126,7 +198,7 @@ public: * For the HTML element "" this will return "body" and for the XML * element "" this will return "html:body". */ - NS_IMETHOD GetQualifiedName(nsAString& aQualifiedName) const = 0; + virtual void GetQualifiedName(nsAString& aQualifiedName) const = 0; /* * Get the local name from this node as a string, GetLocalName() gets the @@ -137,7 +209,7 @@ public: * For the HTML element "" in a HTML document this will return a null * string and for the XML element "" this will return "body". */ - NS_IMETHOD GetLocalName(nsAString& aLocalName) const = 0; + virtual void GetLocalName(nsAString& aLocalName) const = 0; /* * Get the prefix from this node as a string. @@ -145,15 +217,13 @@ public: * For the HTML element "" this will return a null string and for * the XML element "" this will return the string "html". */ - nsresult GetPrefix(nsAString& aPrefix) const + void GetPrefix(nsAString& aPrefix) const { if (mInner.mPrefix) { mInner.mPrefix->ToString(aPrefix); } else { SetDOMStringToNull(aPrefix); } - - return NS_OK; } /* @@ -162,10 +232,8 @@ public: * For the HTML element "" this will return a null atom and for * the XML element "" this will return the "html" atom. */ - already_AddRefed GetPrefixAtom() const + nsIAtom* GetPrefixAtom() const { - NS_IF_ADDREF(mInner.mPrefix); - return mInner.mPrefix; } @@ -178,7 +246,7 @@ public: * xmlns:html='http://www.w3.org/1999/xhtml' attribute) this will return * the string "http://www.w3.org/1999/xhtml". */ - NS_IMETHOD GetNamespaceURI(nsAString& aNameSpaceURI) const = 0; + virtual nsresult GetNamespaceURI(nsAString& aNameSpaceURI) const = 0; /* * Get the namespace ID for a node if the node has a namespace, if not this @@ -190,7 +258,7 @@ public: * xmlns:html='http://www.w3.org/1999/xhtml' attribute) this will return * the namespace ID for "http://www.w3.org/1999/xhtml". */ - PRInt32 GetNamespaceID() const + PRInt32 NamespaceID() const { return mInner.mNamespaceID; } @@ -201,13 +269,23 @@ public: * for the definition of an ID attribute. * */ - NS_IMETHOD_(nsIAtom*) GetIDAttributeAtom() const = 0; - NS_IMETHOD SetIDAttributeAtom(nsIAtom* aResult) = 0; + nsIAtom* GetIDAttributeAtom() const + { + return mIDAttributeAtom; + } + + void SetIDAttributeAtom(nsIAtom* aID) + { + mIDAttributeAtom = aID; + } /* * Get the owning node info manager, this will never return null. */ - NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager) const = 0; + nsINodeInfoManager* NodeInfoManager() const + { + return mOwnerManager; + } /* * Utility functions that can be used to check if a nodeinfo holds a specific @@ -255,39 +333,52 @@ public: return mInner.mNamespaceID == aNamespaceID; } - NS_IMETHOD_(PRBool) Equals(const nsAString& aName) const = 0; - NS_IMETHOD_(PRBool) Equals(const nsAString& aName, - const nsAString& aPrefix) const = 0; - NS_IMETHOD_(PRBool) Equals(const nsAString& aName, - PRInt32 aNamespaceID) const = 0; - NS_IMETHOD_(PRBool) Equals(const nsAString& aName, - const nsAString& aPrefix, - PRInt32 aNamespaceID) const = 0; - NS_IMETHOD_(PRBool) NamespaceEquals(const nsAString& aNamespaceURI) const = 0; + virtual PRBool Equals(const nsAString& aName) const = 0; + virtual PRBool Equals(const nsAString& aName, + const nsAString& aPrefix) const = 0; + virtual PRBool Equals(const nsAString& aName, + PRInt32 aNamespaceID) const = 0; + virtual PRBool Equals(const nsAString& aName, const nsAString& aPrefix, + PRInt32 aNamespaceID) const = 0; + virtual PRBool NamespaceEquals(const nsAString& aNamespaceURI) const = 0; // switch to UTF8 - this allows faster access for consumers - NS_IMETHOD_(PRBool) QualifiedNameEquals(const nsACString& aQualifiedName) const = 0; + 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. */ - NS_IMETHOD NameChanged(nsIAtom *aName, nsINodeInfo** aResult) = 0; + 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. */ - NS_IMETHOD PrefixChanged(nsIAtom *aPrefix, nsINodeInfo** aResult) = 0; + 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. */ - virtual nsIDocument* GetDocument() const = 0; + nsIDocument* GetDocument() const + { + return mOwnerManager->GetDocument(); + } /* * Retrieve a pointer to the principal for the document of this node info. */ - NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aPrincipal) const = 0; + nsresult GetDocumentPrincipal(nsIPrincipal** aPrincipal) const + { + return mOwnerManager->GetDocumentPrincipal(aPrincipal); + } protected: /* @@ -321,60 +412,9 @@ protected: friend class nsNodeInfoManager; nsNodeInfoInner mInner; -}; - -class nsINodeInfoManager : public nsISupports -{ -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_INODEINFOMANAGER_IID) - - /* - * Initialize the nodeinfo manager with a document. - */ - NS_IMETHOD Init(nsIDocument *aDocument) = 0; - - /* - * Release the reference to the document, this will be called when - * the document is going away. - */ - NS_IMETHOD DropDocumentReference() = 0; - - /* - * Methods for creating nodeinfo's from atoms and/or strings. - */ - NS_IMETHOD GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) = 0; - NS_IMETHOD GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) = 0; - NS_IMETHOD GetNodeInfo(const nsAString& aQualifiedName, - const nsAString& aNamespaceURI, - nsINodeInfo** aNodeInfo) = 0; - - NS_IMETHOD GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) = 0; - - /* - * Retrieve a pointer to the document that owns this node info - * manager. - */ - virtual nsIDocument* GetDocument() const = 0; - - /** - * Gets the principal of the document associated with this. - */ - NS_IMETHOD 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. - */ - NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal) = 0; - - /** - * Returns an nsISupportsArray of all nsINodeInfos managed by this manager - */ - NS_IMETHOD GetNodeInfoArray(nsISupportsArray** aArray) = 0; + nsCOMPtr mIDAttributeAtom; + nsINodeInfoManager* mOwnerManager; // Strong reference! }; nsresult diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp index 30f41fa02e1..092adadc229 100644 --- a/mozilla/content/base/src/nsDOMAttribute.cpp +++ b/mozilla/content/base/src/nsDOMAttribute.cpp @@ -120,7 +120,8 @@ nsDOMAttribute::GetName(nsAString& aName) { NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE); - return mNodeInfo->GetQualifiedName(aName); + mNodeInfo->GetQualifiedName(aName); + return NS_OK; } nsresult @@ -129,11 +130,9 @@ nsDOMAttribute::GetValue(nsAString& aValue) NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE); if (mContent) { - nsCOMPtr name = mNodeInfo->GetNameAtom(); - PRInt32 nameSpaceID = mNodeInfo->GetNamespaceID(); - nsAutoString tmpValue; - nsresult attrResult = mContent->GetAttr(nameSpaceID, name, + nsresult attrResult = mContent->GetAttr(mNodeInfo->NamespaceID(), + mNodeInfo->NameAtom(), tmpValue); if (NS_CONTENT_ATTR_NOT_THERE != attrResult) { mValue = tmpValue; @@ -170,10 +169,8 @@ nsDOMAttribute::GetSpecified(PRBool* aSpecified) return NS_OK; } - nsCOMPtr name = mNodeInfo->GetNameAtom(); - PRInt32 nameSpaceID = mNodeInfo->GetNamespaceID(); - - *aSpecified = mContent->HasAttr(nameSpaceID, name); + *aSpecified = mContent->HasAttr(mNodeInfo->NamespaceID(), + mNodeInfo->NameAtom()); return NS_OK; } @@ -362,11 +359,9 @@ nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) nsDOMAttribute* newAttr; if (mContent) { - nsCOMPtr name = mNodeInfo->GetNameAtom(); - PRInt32 nameSpaceID = mNodeInfo->GetNamespaceID(); - nsAutoString value; - mContent->GetAttr(nameSpaceID, name, value); + mContent->GetAttr(mNodeInfo->NamespaceID(), + mNodeInfo->NameAtom(), value); newAttr = new nsDOMAttribute(nsnull, mNodeInfo, value); } else { @@ -410,7 +405,8 @@ nsDOMAttribute::GetPrefix(nsAString& aPrefix) { NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE); - return mNodeInfo->GetPrefix(aPrefix); + mNodeInfo->GetPrefix(aPrefix); + return NS_OK; } NS_IMETHODIMP @@ -428,8 +424,8 @@ nsDOMAttribute::SetPrefix(const nsAString& aPrefix) NS_ENSURE_SUCCESS(rv, rv); if (mContent) { - nsCOMPtr name = mNodeInfo->GetNameAtom(); - PRInt32 nameSpaceID = mNodeInfo->GetNamespaceID(); + nsIAtom *name = mNodeInfo->NameAtom(); + PRInt32 nameSpaceID = mNodeInfo->NamespaceID(); nsAutoString tmpValue; rv = mContent->GetAttr(nameSpaceID, name, tmpValue); @@ -450,7 +446,8 @@ nsDOMAttribute::GetLocalName(nsAString& aLocalName) { NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE); - return mNodeInfo->GetLocalName(aLocalName); + mNodeInfo->GetLocalName(aLocalName); + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/content/base/src/nsDOMAttributeMap.cpp b/mozilla/content/base/src/nsDOMAttributeMap.cpp index fbf01736e40..d3fac0cace4 100644 --- a/mozilla/content/base/src/nsDOMAttributeMap.cpp +++ b/mozilla/content/base/src/nsDOMAttributeMap.cpp @@ -88,12 +88,10 @@ nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName, return NS_OK; } - PRInt32 nsid = ni->GetNamespaceID(); - nsCOMPtr nameAtom = ni->GetNameAtom(); - nsAutoString value; // Eventually we shouldn't need to get the value here at all - nsresult rv = mContent->GetAttr(nsid, nameAtom, value); + nsresult rv = mContent->GetAttr(ni->NamespaceID(), + ni->NameAtom(), value); NS_ASSERTION(rv != NS_CONTENT_ATTR_NOT_THERE, "unable to get attribute"); NS_ENSURE_SUCCESS(rv, rv); @@ -146,10 +144,7 @@ nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn) nsCOMPtr ni = mContent->GetExistingAttrNameFromQName(name); if (ni) { - nsCOMPtr nameAtom = ni->GetNameAtom(); - PRInt32 nsid = ni->GetNamespaceID(); - - rv = mContent->GetAttr(nsid, nameAtom, value); + rv = mContent->GetAttr(ni->NamespaceID(), ni->NameAtom(), value); NS_ASSERTION(rv != NS_CONTENT_ATTR_NOT_THERE, "unable to get attribute"); NS_ENSURE_SUCCESS(rv, rv); @@ -166,12 +161,9 @@ nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn) nsCOMPtr contentNi = mContent->GetNodeInfo(); NS_ENSURE_TRUE(contentNi, NS_ERROR_FAILURE); - nsCOMPtr nimgr; - contentNi->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - rv = nimgr->GetNodeInfo(name, nsnull, kNameSpaceID_None, - getter_AddRefs(ni)); + rv = contentNi->NodeInfoManager()->GetNodeInfo(name, nsnull, + kNameSpaceID_None, + getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); // value is already empty } @@ -205,8 +197,8 @@ nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName, return NS_ERROR_DOM_NOT_FOUND_ERR; } - PRInt32 nsid = ni->GetNamespaceID(); - nsCOMPtr nameAtom = ni->GetNameAtom(); + PRInt32 nsid = ni->NamespaceID(); + nsIAtom *nameAtom = ni->NameAtom(); nsAutoString value; rv = mContent->GetAttr(nsid, nameAtom, value); @@ -246,11 +238,8 @@ nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsCOMPtr ni(mContent->GetNodeInfo()); NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE); - nsCOMPtr nimgr; - ni->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nimgr->GetNodeInfo(nameAtom, prefix, nameSpaceID, getter_AddRefs(ni)); + ni->NodeInfoManager()->GetNodeInfo(nameAtom, prefix, nameSpaceID, + getter_AddRefs(ni)); NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE); nsDOMAttribute* domAttribute = new nsDOMAttribute(mContent, ni, value); @@ -296,10 +285,6 @@ nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI, nsCOMPtr ni(mContent->GetNodeInfo()); NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE); - nsCOMPtr nimgr; - ni->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - if (aNamespaceURI.Length()) { nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, &nameSpaceID); @@ -315,7 +300,8 @@ nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI, getter_AddRefs(prefix), value); if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) { - nimgr->GetNodeInfo(nameAtom, prefix, nameSpaceID, getter_AddRefs(ni)); + ni->NodeInfoManager()->GetNodeInfo(nameAtom, prefix, + nameSpaceID, getter_AddRefs(ni)); NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE); nsDOMAttribute* domAttribute = new nsDOMAttribute(mContent, ni, value); @@ -366,17 +352,11 @@ nsDOMAttributeMap::SetNamedItemNS(nsIDOMNode* aArg, nsIDOMNode** aReturn) nsCOMPtr ni(mContent->GetNodeInfo()); NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE); - nsCOMPtr nimgr; - ni->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nimgr->GetNodeInfo(name, nsURI, getter_AddRefs(ni)); + ni->NodeInfoManager()->GetNodeInfo(name, nsURI, getter_AddRefs(ni)); NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE); - PRInt32 nameSpaceID = ni->GetNamespaceID(); - nsCOMPtr nameAtom = ni->GetNameAtom(); - - nsresult attrResult = mContent->GetAttr(nameSpaceID, nameAtom, value); + nsresult attrResult = mContent->GetAttr(ni->NamespaceID(), + ni->NameAtom(), value); if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) { // We pass a null content here since the attr node we return isn't @@ -422,10 +402,6 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI, nsCOMPtr ni(mContent->GetNodeInfo()); NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE); - nsCOMPtr nimgr; - ni->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - if (aNamespaceURI.Length()) { nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, &nameSpaceID); @@ -440,7 +416,8 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI, getter_AddRefs(prefix), value); if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) { - nimgr->GetNodeInfo(nameAtom, prefix, nameSpaceID, getter_AddRefs(ni)); + ni->NodeInfoManager()->GetNodeInfo(nameAtom, prefix, nameSpaceID, + getter_AddRefs(ni)); NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE); nsDOMAttribute* domAttribute = new nsDOMAttribute(nsnull, ni, value); diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 7df55b303eb..9ed5408536d 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -1008,13 +1008,15 @@ nsGenericElement::Init(nsINodeInfo *aNodeInfo) NS_IMETHODIMP nsGenericElement::GetNodeName(nsAString& aNodeName) { - return mNodeInfo->GetQualifiedName(aNodeName); + mNodeInfo->GetQualifiedName(aNodeName); + return NS_OK; } NS_IMETHODIMP nsGenericElement::GetLocalName(nsAString& aLocalName) { - return mNodeInfo->GetLocalName(aLocalName); + mNodeInfo->GetLocalName(aLocalName); + return NS_OK; } NS_IMETHODIMP @@ -1145,7 +1147,8 @@ nsGenericElement::GetNamespaceURI(nsAString& aNamespaceURI) NS_IMETHODIMP nsGenericElement::GetPrefix(nsAString& aPrefix) { - return mNodeInfo->GetPrefix(aPrefix); + mNodeInfo->GetPrefix(aPrefix); + return NS_OK; } NS_IMETHODIMP @@ -1267,7 +1270,8 @@ nsGenericElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes) NS_IMETHODIMP nsGenericElement::GetTagName(nsAString& aTagName) { - return mNodeInfo->GetQualifiedName(aTagName); + mNodeInfo->GetQualifiedName(aTagName); + return NS_OK; } nsresult @@ -1281,10 +1285,7 @@ nsGenericElement::GetAttribute(const nsAString& aName, return NS_OK; } - PRInt32 nsid = ni->GetNamespaceID(); - nsCOMPtr nameAtom = ni->GetNameAtom(); - - GetAttr(nsid, nameAtom, aReturn); + GetAttr(ni->NamespaceID(), ni->NameAtom(), aReturn); return NS_OK; } @@ -1295,12 +1296,9 @@ nsGenericElement::SetAttribute(const nsAString& aName, { nsCOMPtr ni = GetExistingAttrNameFromQName(aName); if (!ni) { - nsCOMPtr nimgr; - mNodeInfo->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nsresult rv = nimgr->GetNodeInfo(aName, nsnull, kNameSpaceID_None, - getter_AddRefs(ni)); + nsresult rv = mNodeInfo->NodeInfoManager()->GetNodeInfo(aName, nsnull, + kNameSpaceID_None, + getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); } @@ -1315,10 +1313,7 @@ nsGenericElement::RemoveAttribute(const nsAString& aName) return NS_OK; } - PRInt32 nsid = ni->GetNamespaceID(); - nsCOMPtr tag = ni->GetNameAtom(); - - return UnsetAttr(nsid, tag, PR_TRUE); + return UnsetAttr(ni->NamespaceID(), ni->NameAtom(), PR_TRUE); } nsresult @@ -1436,13 +1431,10 @@ nsGenericElement::SetAttributeNS(const nsAString& aNamespaceURI, const nsAString& aQualifiedName, const nsAString& aValue) { - nsCOMPtr nimgr; - mNodeInfo->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - nsCOMPtr ni; - nsresult rv = nimgr->GetNodeInfo(aQualifiedName, aNamespaceURI, - getter_AddRefs(ni)); + nsresult rv = mNodeInfo->NodeInfoManager()->GetNodeInfo(aQualifiedName, + aNamespaceURI, + getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); return SetAttr(ni, aValue, PR_TRUE); @@ -1716,14 +1708,12 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, // new nodeinfo if (aDocument != mNodeInfo->GetDocument()) { // get a new nodeinfo - nsCOMPtr name = mNodeInfo->GetNameAtom(); - nsCOMPtr prefix = mNodeInfo->GetPrefixAtom(); - PRInt32 nameSpaceID = mNodeInfo->GetNamespaceID(); - nsINodeInfoManager* nodeInfoManager = aDocument->GetNodeInfoManager(); if (nodeInfoManager) { nsCOMPtr newNodeInfo; - nodeInfoManager->GetNodeInfo(name, prefix, nameSpaceID, + nodeInfoManager->GetNodeInfo(mNodeInfo->NameAtom(), + mNodeInfo->GetPrefixAtom(), + mNodeInfo->NamespaceID(), getter_AddRefs(newNodeInfo)); if (newNodeInfo) { mNodeInfo = newNodeInfo; @@ -1773,7 +1763,7 @@ nsGenericElement::SetNativeAnonymous(PRBool aAnonymous) nsresult nsGenericElement::GetNameSpaceID(PRInt32* aNameSpaceID) const { - *aNameSpaceID = mNodeInfo->GetNamespaceID(); + *aNameSpaceID = mNodeInfo->NamespaceID(); return NS_OK; } @@ -1781,8 +1771,7 @@ nsGenericElement::GetNameSpaceID(PRInt32* aNameSpaceID) const nsresult nsGenericElement::GetTag(nsIAtom** aResult) const { - // AddRefs - *aResult = mNodeInfo->GetNameAtom().get(); + NS_ADDREF(*aResult = mNodeInfo->NameAtom()); return NS_OK; } @@ -3447,13 +3436,10 @@ nsGenericContainerElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, const nsAString& aValue, PRBool aNotify) { - nsCOMPtr nimgr; - nsresult rv = mNodeInfo->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr ni; - rv = nimgr->GetNodeInfo(aName, nsnull, aNameSpaceID, - getter_AddRefs(ni)); + nsresult rv = mNodeInfo->NodeInfoManager()->GetNodeInfo(aName, nsnull, + aNameSpaceID, + getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); return SetAttr(ni, aValue, aNotify); @@ -3538,8 +3524,8 @@ nsGenericContainerElement::SetAttr(nsINodeInfo* aNodeInfo, NS_ENSURE_TRUE(mAttributes, NS_ERROR_OUT_OF_MEMORY); } - nsCOMPtr name = aNodeInfo->GetNameAtom(); - PRInt32 nameSpaceID = aNodeInfo->GetNamespaceID(); + nsIAtom *name = aNodeInfo->NameAtom(); + PRInt32 nameSpaceID = aNodeInfo->NamespaceID(); nsGenericAttribute* attr = nsnull; PRInt32 index; @@ -3657,7 +3643,7 @@ nsGenericContainerElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, const nsGenericAttribute* attr = (const nsGenericAttribute*)mAttributes->ElementAt(index); if (attr->mNodeInfo->NamespaceEquals(aNameSpaceID) && (attr->mNodeInfo->Equals(aName))) { - *aPrefix = attr->mNodeInfo->GetPrefixAtom().get(); + NS_IF_ADDREF(*aPrefix = attr->mNodeInfo->GetPrefixAtom()); aResult.Assign(attr->mValue); if (!aResult.IsEmpty()) { rv = NS_CONTENT_ATTR_HAS_VALUE; @@ -3790,9 +3776,9 @@ nsGenericContainerElement::GetAttrNameAt(PRUint32 aIndex, if (mAttributes) { nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(aIndex); if (attr) { - *aNameSpaceID = attr->mNodeInfo->GetNamespaceID(); - *aName = attr->mNodeInfo->GetNameAtom().get(); - *aPrefix = attr->mNodeInfo->GetPrefixAtom().get(); + *aNameSpaceID = attr->mNodeInfo->NamespaceID(); + NS_ADDREF(*aName = attr->mNodeInfo->NameAtom()); + NS_IF_ADDREF(*aPrefix = attr->mNodeInfo->GetPrefixAtom()); return NS_OK; } diff --git a/mozilla/content/base/src/nsNodeInfo.cpp b/mozilla/content/base/src/nsNodeInfo.cpp index a6835b5f2a7..9f31625d953 100644 --- a/mozilla/content/base/src/nsNodeInfo.cpp +++ b/mozilla/content/base/src/nsNodeInfo.cpp @@ -64,7 +64,6 @@ nsNodeInfo::Create() } nsNodeInfo::nsNodeInfo() - : nsINodeInfo(), mOwnerManager(nsnull) { } @@ -78,7 +77,7 @@ void nsNodeInfo::Clear() { if (mOwnerManager) { - mOwnerManager->RemoveNodeInfo(this); + NS_STATIC_CAST(nsNodeInfoManager*, mOwnerManager)->RemoveNodeInfo(this); NS_RELEASE(mOwnerManager); } @@ -119,7 +118,7 @@ NS_IMPL_QUERY_INTERFACE1(nsNodeInfo, nsINodeInfo) // nsINodeInfo -NS_IMETHODIMP +void nsNodeInfo::GetQualifiedName(nsAString& aQualifiedName) const { if (mInner.mPrefix) { @@ -134,29 +133,25 @@ nsNodeInfo::GetQualifiedName(nsAString& aQualifiedName) const mInner.mName->ToString(name); aQualifiedName.Append(name); - - return NS_OK; } -NS_IMETHODIMP +void nsNodeInfo::GetLocalName(nsAString& aLocalName) const { #ifdef STRICT_DOM_LEVEL2_LOCALNAME if (mInner.mNamespaceID > 0) { - return mInner.mName->ToString(aLocalName); + mInner.mName->ToString(aLocalName); + } else { + SetDOMStringToNull(aLocalName); } - - SetDOMStringToNull(aLocalName); - - return NS_OK; #else - return mInner.mName->ToString(aLocalName); + mInner.mName->ToString(aLocalName); #endif } -NS_IMETHODIMP +nsresult nsNodeInfo::GetNamespaceURI(nsAString& aNameSpaceURI) const { nsresult rv = NS_OK; @@ -172,40 +167,14 @@ nsNodeInfo::GetNamespaceURI(nsAString& aNameSpaceURI) const } -NS_IMETHODIMP_(nsIAtom*) -nsNodeInfo::GetIDAttributeAtom() const -{ - return mIDAttributeAtom; -} - -NS_IMETHODIMP -nsNodeInfo::SetIDAttributeAtom(nsIAtom* aID) -{ - NS_ENSURE_ARG(aID); - mIDAttributeAtom = aID; - - return NS_OK; -} - - - -NS_IMETHODIMP -nsNodeInfo::GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager) const -{ - NS_ADDREF(*aNodeInfoManager = mOwnerManager); - - return NS_OK; -} - - -NS_IMETHODIMP_(PRBool) +PRBool nsNodeInfo::Equals(const nsAString& aName) const { return mInner.mName->Equals(aName); } -NS_IMETHODIMP_(PRBool) +PRBool nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const { if (!mInner.mName->Equals(aName)) { @@ -220,7 +189,7 @@ nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const } -NS_IMETHODIMP_(PRBool) +PRBool nsNodeInfo::Equals(const nsAString& aName, PRInt32 aNamespaceID) const { return mInner.mNamespaceID == aNamespaceID && @@ -228,7 +197,7 @@ nsNodeInfo::Equals(const nsAString& aName, PRInt32 aNamespaceID) const } -NS_IMETHODIMP_(PRBool) +PRBool nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix, PRInt32 aNamespaceID) const { @@ -241,7 +210,7 @@ nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix, } -NS_IMETHODIMP_(PRBool) +PRBool nsNodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const { PRInt32 nsid; @@ -250,7 +219,7 @@ nsNodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const return nsINodeInfo::NamespaceEquals(nsid); } -NS_IMETHODIMP_(PRBool) +PRBool nsNodeInfo::QualifiedNameEquals(const nsACString& aQualifiedName) const { @@ -293,33 +262,6 @@ nsNodeInfo::QualifiedNameEquals(const nsACString& aQualifiedName) const return mInner.mName->EqualsUTF8(Substring(colon, end)); } -NS_IMETHODIMP -nsNodeInfo::NameChanged(nsIAtom *aName, nsINodeInfo** aResult) -{ - return mOwnerManager->GetNodeInfo(aName, mInner.mPrefix, mInner.mNamespaceID, - aResult); -} - - -NS_IMETHODIMP -nsNodeInfo::PrefixChanged(nsIAtom *aPrefix, nsINodeInfo** aResult) -{ - return mOwnerManager->GetNodeInfo(mInner.mName, aPrefix, mInner.mNamespaceID, - aResult); -} - -nsIDocument* -nsNodeInfo::GetDocument() const -{ - return mOwnerManager->GetDocument(); -} - -NS_IMETHODIMP -nsNodeInfo::GetDocumentPrincipal(nsIPrincipal** aPrincipal) const -{ - return mOwnerManager->GetDocumentPrincipal(aPrincipal); -} - // static nsNodeInfo *nsNodeInfo::sCachedNodeInfo = nsnull; diff --git a/mozilla/content/base/src/nsNodeInfo.h b/mozilla/content/base/src/nsNodeInfo.h index 90d49c6daa5..1ba1bd8c648 100644 --- a/mozilla/content/base/src/nsNodeInfo.h +++ b/mozilla/content/base/src/nsNodeInfo.h @@ -52,27 +52,17 @@ public: NS_DECL_ISUPPORTS // nsINodeInfo - NS_IMETHOD GetQualifiedName(nsAString &aQualifiedName) const; - NS_IMETHOD GetLocalName(nsAString& aLocalName) const; - NS_IMETHOD GetNamespaceURI(nsAString& aNameSpaceURI) const; - NS_IMETHOD_(nsIAtom*) GetIDAttributeAtom() const; - NS_IMETHOD SetIDAttributeAtom(nsIAtom* aResult); - NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager) const; - NS_IMETHOD_(PRBool) Equals(const nsAString& aName) const; - NS_IMETHOD_(PRBool) Equals(const nsAString& aName, - const nsAString& aPrefix) const; - NS_IMETHOD_(PRBool) Equals(const nsAString& aName, - PRInt32 aNamespaceID) const; - NS_IMETHOD_(PRBool) Equals(const nsAString& aName, const nsAString& aPrefix, - PRInt32 aNamespaceID) const; - NS_IMETHOD_(PRBool) NamespaceEquals(const nsAString& aNamespaceURI) const; - NS_IMETHOD_(PRBool) QualifiedNameEquals(const nsACString& aQualifiedName) const; - - NS_IMETHOD NameChanged(nsIAtom *aName, nsINodeInfo** aResult); - NS_IMETHOD PrefixChanged(nsIAtom *aPrefix, nsINodeInfo** aResult); - - virtual nsIDocument* GetDocument() const; - NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aPrincipal) const; + virtual void GetQualifiedName(nsAString &aQualifiedName) const; + virtual void GetLocalName(nsAString& aLocalName) const; + virtual nsresult GetNamespaceURI(nsAString& aNameSpaceURI) const; + virtual PRBool Equals(const nsAString& aName) const; + virtual PRBool Equals(const nsAString& aName, + const nsAString& aPrefix) const; + virtual PRBool Equals(const nsAString& aName, PRInt32 aNamespaceID) const; + virtual PRBool Equals(const nsAString& aName, const nsAString& aPrefix, + PRInt32 aNamespaceID) const; + virtual PRBool NamespaceEquals(const nsAString& aNamespaceURI) const; + virtual PRBool QualifiedNameEquals(const nsACString& aQualifiedName) const; // nsNodeInfo // Create objects with Create @@ -99,11 +89,6 @@ public: */ static void ClearCache(); -protected: - nsCOMPtr mIDAttributeAtom; - - nsNodeInfoManager* mOwnerManager; // Strong reference! - private: void Clear(); diff --git a/mozilla/content/base/src/nsNodeInfoManager.cpp b/mozilla/content/base/src/nsNodeInfoManager.cpp index 7ece299cabe..268c99366b3 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.cpp +++ b/mozilla/content/base/src/nsNodeInfoManager.cpp @@ -44,7 +44,7 @@ #include "nsIDocument.h" #include "nsIPrincipal.h" #include "nsIURI.h" -#include "nsISupportsArray.h" +#include "nsArray.h" #include "nsContentUtils.h" #include "nsReadableUtils.h" @@ -95,7 +95,6 @@ nsNodeInfoManager::NodeInfoInnerKeyCompare(const void *key1, const void *key2) nsNodeInfoManager::nsNodeInfoManager() - : mDocument(nsnull) { if (gNodeManagerCount == 1 && gAnonymousNodeInfoManager) { @@ -154,7 +153,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsNodeInfoManager, nsINodeInfoManager) // nsINodeInfoManager -NS_IMETHODIMP +nsresult nsNodeInfoManager::Init(nsIDocument *aDocument) { NS_ENSURE_TRUE(mNodeInfoHash, NS_ERROR_OUT_OF_MEMORY); @@ -168,7 +167,7 @@ nsNodeInfoManager::Init(nsIDocument *aDocument) } -NS_IMETHODIMP +void nsNodeInfoManager::DropDocumentReference() { if (mDocument) { @@ -183,12 +182,10 @@ nsNodeInfoManager::DropDocumentReference() } } mDocument = nsnull; - - return NS_OK; } -NS_IMETHODIMP +nsresult nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) { @@ -224,7 +221,7 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, } -NS_IMETHODIMP +nsresult nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) { @@ -233,7 +230,7 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, } -NS_IMETHODIMP +nsresult nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName, const nsAString& aNamespaceURI, nsINodeInfo** aNodeInfo) @@ -274,7 +271,7 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName, return nsNodeInfoManager::GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo); } -NS_IMETHODIMP +nsresult nsNodeInfoManager::GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix, PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) { @@ -287,13 +284,7 @@ nsNodeInfoManager::GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix, } -nsIDocument* -nsNodeInfoManager::GetDocument() const -{ - return mDocument; -} - -NS_IMETHODIMP +nsresult nsNodeInfoManager::GetDocumentPrincipal(nsIPrincipal** aPrincipal) { NS_ENSURE_ARG_POINTER(aPrincipal); @@ -320,7 +311,7 @@ nsNodeInfoManager::GetDocumentPrincipal(nsIPrincipal** aPrincipal) return NS_OK; } -NS_IMETHODIMP +nsresult nsNodeInfoManager::SetDocumentPrincipal(nsIPrincipal* aPrincipal) { NS_ENSURE_FALSE(mDocument, NS_ERROR_UNEXPECTED); @@ -328,24 +319,14 @@ nsNodeInfoManager::SetDocumentPrincipal(nsIPrincipal* aPrincipal) return NS_OK; } -NS_IMETHODIMP -nsNodeInfoManager::GetNodeInfoArray(nsISupportsArray** aArray) +nsresult +nsNodeInfoManager::GetNodeInfos(nsCOMArray *aArray) { - *aArray = nsnull; - - nsCOMPtr array; - nsresult rv = NS_NewISupportsArray(getter_AddRefs(array)); - NS_ENSURE_SUCCESS(rv, rv); - PL_HashTableEnumerateEntries(mNodeInfoHash, GetNodeInfoArrayEnumerator, - array); - PRUint32 n; - array->Count(&n); - NS_ENSURE_TRUE(n == mNodeInfoHash->nentries, NS_ERROR_OUT_OF_MEMORY); - - *aArray = array; - NS_ADDREF(*aArray); + aArray); + PRInt32 n = aArray->Count(); + NS_ENSURE_TRUE((PRUint32)n == mNodeInfoHash->nentries, NS_ERROR_OUT_OF_MEMORY); return NS_OK; } @@ -356,10 +337,9 @@ nsNodeInfoManager::GetNodeInfoArrayEnumerator(PLHashEntry* he, PRIntn i, void* arg) { NS_ASSERTION(arg, "missing array"); - nsISupportsArray* array = (nsISupportsArray*)arg; + nsCOMArray *array = (nsCOMArray *) arg; - nsresult rv = array->AppendElement((nsINodeInfo*)he->value); - if (NS_FAILED(rv)) { + if (!array->AppendObject((nsINodeInfo*)he->value)) { return HT_ENUMERATE_STOP; } diff --git a/mozilla/content/base/src/nsNodeInfoManager.h b/mozilla/content/base/src/nsNodeInfoManager.h index 59cef5c35c7..2318d0183a8 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.h +++ b/mozilla/content/base/src/nsNodeInfoManager.h @@ -54,23 +54,22 @@ public: NS_DECL_ISUPPORTS // nsINodeInfoManager - NS_IMETHOD Init(nsIDocument *aDocument); - NS_IMETHOD DropDocumentReference(); - NS_IMETHOD GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo); - NS_IMETHOD GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo); - NS_IMETHOD GetNodeInfo(const nsAString& aQualifiedName, - const nsAString& aNamespaceURI, - nsINodeInfo** aNodeInfo); + 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); - NS_IMETHOD GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix, - PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo); + virtual nsresult GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix, + PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo); - virtual nsIDocument* GetDocument() const; - NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aPrincipal); - NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal); - NS_IMETHOD GetNodeInfoArray(nsISupportsArray** aArray); + virtual nsresult GetDocumentPrincipal(nsIPrincipal** aPrincipal); + virtual nsresult SetDocumentPrincipal(nsIPrincipal* aPrincipal); + virtual nsresult GetNodeInfos(nsCOMArray *aArray); // nsNodeInfoManager nsNodeInfoManager(); @@ -90,7 +89,6 @@ private: void* arg); PLHashTable *mNodeInfoHash; - nsIDocument *mDocument; // WEAK nsCOMPtr mPrincipal; /* diff --git a/mozilla/content/base/src/nsScriptLoader.cpp b/mozilla/content/base/src/nsScriptLoader.cpp index 8725d6ab4ed..aaf73bba6c3 100644 --- a/mozilla/content/base/src/nsScriptLoader.cpp +++ b/mozilla/content/base/src/nsScriptLoader.cpp @@ -240,16 +240,16 @@ nsScriptLoader::InNonScriptingContainer(nsIDOMHTMLScriptElement* aScriptElement) NS_ASSERTION(nodeInfo, "element without node info"); if (nodeInfo) { - nsCOMPtr localName = nodeInfo->GetNameAtom(); + nsIAtom *localName = nodeInfo->NameAtom(); // XXX noframes and noembed are currently unconditionally not // displayed and processed. This might change if we support either // prefs or per-document container settings for not allowing // frames or plugins. if (content->IsContentOfType(nsIContent::eHTML) && - ((localName.get() == nsHTMLAtoms::iframe) || - (localName.get() == nsHTMLAtoms::noframes) || - (localName.get() == nsHTMLAtoms::noembed))) { + ((localName == nsHTMLAtoms::iframe) || + (localName == nsHTMLAtoms::noframes) || + (localName == nsHTMLAtoms::noembed))) { return PR_TRUE; } } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 91ab5f4e309..d06ec2f20e3 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -403,12 +403,12 @@ nsGenericHTMLElement::SetAttribute(const nsAString& aName, nsresult nsGenericHTMLElement::GetNodeName(nsAString& aNodeName) { - nsresult rv = mNodeInfo->GetQualifiedName(aNodeName); + mNodeInfo->GetQualifiedName(aNodeName); if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) ToUpperCase(aNodeName); - return rv; + return NS_OK; } nsresult @@ -1699,12 +1699,9 @@ nsGenericHTMLElement::GetExistingAttrNameFromQName(const nsAString& aStr) getter_AddRefs(prefixAtom)); if (QualifiedNameEquals(lower, nameAtom, prefixAtom)) { - nsCOMPtr nimgr; - mNodeInfo->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, nsnull); - nsINodeInfo* nodeInfo; - nimgr->GetNodeInfo(nameAtom, prefixAtom, nameSpace, &nodeInfo); + mNodeInfo->NodeInfoManager()->GetNodeInfo(nameAtom, prefixAtom, + nameSpace, &nodeInfo); return nodeInfo; } @@ -1726,13 +1723,10 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID, nsresult result = NS_OK; if (aNameSpaceID != kNameSpaceID_None) { - nsCOMPtr nimgr; - result = mNodeInfo->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(result, result); - nsCOMPtr ni; - result = nimgr->GetNodeInfo(aAttribute, nsnull, aNameSpaceID, - getter_AddRefs(ni)); + result = mNodeInfo->NodeInfoManager()->GetNodeInfo(aAttribute, nsnull, + aNameSpaceID, + getter_AddRefs(ni)); NS_ENSURE_SUCCESS(result, result); return SetAttr(ni, aValue, aNotify); @@ -1851,8 +1845,8 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo, { NS_ENSURE_ARG_POINTER(aNodeInfo); - nsCOMPtr localName = aNodeInfo->GetNameAtom(); - PRInt32 namespaceID = aNodeInfo->GetNamespaceID(); + nsIAtom *localName = aNodeInfo->NameAtom(); + PRInt32 namespaceID = aNodeInfo->NamespaceID(); NS_ASSERTION(namespaceID != kNameSpaceID_XHTML, "Error, attribute on [X]HTML element set with XHTML namespace, " diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 043c13e91fb..5dd957cd988 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -969,7 +969,7 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo, if (!parserService) return NS_ERROR_OUT_OF_MEMORY; - nsCOMPtr name = aNodeInfo->GetNameAtom(); + nsIAtom *name = aNodeInfo->NameAtom(); // Find tag in tag table PRInt32 id; diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 513524a5c55..6792eed9769 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1543,7 +1543,7 @@ nsHTMLDocument::CreateElementNS(const nsAString& aNamespaceURI, getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, rv); - PRInt32 namespaceID = nodeInfo->GetNamespaceID(); + PRInt32 namespaceID = nodeInfo->NamespaceID(); nsCOMPtr elementFactory; nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(namespaceID, diff --git a/mozilla/content/html/style/src/nsHTMLAttributes.cpp b/mozilla/content/html/style/src/nsHTMLAttributes.cpp index ff97215e2de..d58d5adbcf2 100644 --- a/mozilla/content/html/style/src/nsHTMLAttributes.cpp +++ b/mozilla/content/html/style/src/nsHTMLAttributes.cpp @@ -1263,11 +1263,8 @@ nsHTMLAttributes::SetAttributeFor(nsINodeInfo* aAttrName, rv = SetAttributeName(aAttrName, haveAttr); NS_ENSURE_SUCCESS(rv, rv); if (haveAttr) { - PRInt32 namespaceID = aAttrName->GetNamespaceID(); - nsCOMPtr localName = aAttrName->GetNameAtom(); - - HTMLAttribute* attr = HTMLAttribute::FindHTMLAttribute(localName, - namespaceID, + HTMLAttribute* attr = HTMLAttribute::FindHTMLAttribute(aAttrName->NameAtom(), + aAttrName->NamespaceID(), mFirstUnmapped); NS_ASSERTION(attr, "failed to find attribute"); if (!attr) @@ -1301,8 +1298,7 @@ nsHTMLAttributes::GetAttribute(nsIAtom* aAttrName, PRInt32 aNamespaceID, *aValue = &attr->mValue; - // AddRefs - *aPrefix = attr->mAttribute.GetNodeInfo()->GetPrefixAtom().get(); + NS_IF_ADDREF(*aPrefix = attr->mAttribute.GetNodeInfo()->GetPrefixAtom()); return attr->mValue.GetUnit() == eHTMLUnit_Null ? NS_CONTENT_ATTR_NO_VALUE : @@ -1327,12 +1323,10 @@ nsHTMLAttributes::GetAttributeNameAt(PRInt32 aIndex, } else { nsINodeInfo* ni = mAttrNames[aIndex].GetNodeInfo(); - *aNamespaceID = ni->GetNamespaceID(); + *aNamespaceID = ni->NamespaceID(); - // AddRefs - *aName = ni->GetNameAtom().get(); - // AddRefs - *aPrefix = ni->GetPrefixAtom().get(); + NS_ADDREF(*aName = ni->NameAtom()); + NS_IF_ADDREF(*aPrefix = ni->GetPrefixAtom()); } result = NS_OK; } @@ -1500,11 +1494,10 @@ nsHTMLAttributes::List(FILE* out, PRInt32 aIndent) const } else { nsINodeInfo* ni = mAttrNames[index].GetNodeInfo(); - PRInt32 namespaceID = ni->GetNamespaceID(); - nsCOMPtr localName = ni->GetNameAtom(); nsCOMPtr prefix; const nsHTMLValue *tmp; - GetAttribute(localName, namespaceID, getter_AddRefs(prefix), &tmp); + GetAttribute(ni->NameAtom(), ni->GetNamespaceID(), + getter_AddRefs(prefix), &tmp); value = *tmp; ni->GetQualifiedName(buffer); } diff --git a/mozilla/content/svg/content/src/nsSVGAttributes.cpp b/mozilla/content/svg/content/src/nsSVGAttributes.cpp index ca85a10b9bb..fd33e59936d 100644 --- a/mozilla/content/svg/content/src/nsSVGAttributes.cpp +++ b/mozilla/content/svg/content/src/nsSVGAttributes.cpp @@ -550,7 +550,7 @@ nsSVGAttributes::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, attr->GetNodeInfo()->NamespaceEquals(aNameSpaceID)) && (attr->GetNodeInfo()->Equals(aName))) { // AddRefs - *aPrefix = attr->GetNodeInfo()->GetPrefixAtom().get(); + *aPrefix = attr->GetNodeInfo()->PrefixAtom().get(); attr->GetValue()->GetValueString(aResult); if (!aResult.IsEmpty()) { rv = NS_CONTENT_ATTR_HAS_VALUE; @@ -604,7 +604,7 @@ nsSVGAttributes::SetAttr(nsINodeInfo* aNodeInfo, } PRInt32 nameSpaceID = aNodeInfo->GetNamespaceID(); - nsCOMPtr name = aNodeInfo->GetNameAtom(); + nsIAtom *name = aNodeInfo->NameAtom(); // Send the notification before making any updates mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify); @@ -799,10 +799,8 @@ nsSVGAttributes::GetAttrNameAt(PRInt32 aIndex, nsSVGAttribute* attr = ElementAt(aIndex); if (attr) { *aNameSpaceID = attr->GetNodeInfo()->GetNamespaceID(); - // AddRefs - *aName = attr->GetNodeInfo()->GetNameAtom().get(); - // AddRefs - *aPrefix = attr->GetNodeInfo()->GetPrefixAtom().get(); + NS_ADDREF(*aName = attr->GetNodeInfo()->NameAtom()); + NS_IF_ADDREF(*aPrefix = attr->GetNodeInfo()->PrefixAtom()); return NS_OK; } diff --git a/mozilla/content/svg/content/src/nsSVGElementFactory.cpp b/mozilla/content/svg/content/src/nsSVGElementFactory.cpp index a036885321e..093ac84f3d5 100644 --- a/mozilla/content/svg/content/src/nsSVGElementFactory.cpp +++ b/mozilla/content/svg/content/src/nsSVGElementFactory.cpp @@ -118,7 +118,7 @@ NS_IMETHODIMP nsSVGElementFactory::CreateInstanceByTag(nsINodeInfo *aNodeInfo, nsIContent** aResult) { - nsCOMPtr name = aNodeInfo->GetNameAtom(); + nsIAtom *name = aNodeInfo->NameAtom(); if (name == nsSVGAtoms::polyline) return NS_NewSVGPolylineElement(aResult, aNodeInfo); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 27b141b20c7..477b347d37c 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -449,7 +449,7 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount, *aAppendContent = PR_TRUE; nsresult rv = NS_OK; - PRInt32 nameSpaceID = aNodeInfo->GetNamespaceID(); + PRInt32 nameSpaceID = aNodeInfo->NamespaceID(); // XHTML needs some special attention if (nameSpaceID != kNameSpaceID_XHTML) { @@ -484,7 +484,7 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount, rv = CallQueryInterface(htmlContent, aResult); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr tagAtom = aNodeInfo->GetNameAtom(); + nsIAtom *tagAtom = aNodeInfo->NameAtom(); if (tagAtom == nsHTMLAtoms::script) { // Don't append the content to the tree until we're all // done collecting its contents @@ -1199,7 +1199,7 @@ nsXMLContentSink::HandleStartElement(const PRUnichar *aName, nsCOMPtr IDAttr = do_GetAtom(aAtts[aIndex]); if (IDAttr) { - result = nodeInfo->SetIDAttributeAtom(IDAttr); + nodeInfo->SetIDAttributeAtom(IDAttr); } } diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 876fb295110..5b4bb0d6043 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -1137,7 +1137,7 @@ nsXMLDocument::CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult) nsCOMPtr content; - PRInt32 namespaceID = aNodeInfo->GetNamespaceID(); + PRInt32 namespaceID = aNodeInfo->NamespaceID(); nsCOMPtr elementFactory; nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(namespaceID, diff --git a/mozilla/content/xul/content/src/nsXULAttributes.cpp b/mozilla/content/xul/content/src/nsXULAttributes.cpp index 1f153de592b..fe939a5acb1 100644 --- a/mozilla/content/xul/content/src/nsXULAttributes.cpp +++ b/mozilla/content/xul/content/src/nsXULAttributes.cpp @@ -296,7 +296,8 @@ nsXULAttribute::GetNamespaceURI(nsAString& aNamespaceURI) NS_IMETHODIMP nsXULAttribute::GetPrefix(nsAString& aPrefix) { - return mNodeInfo->GetPrefix(aPrefix); + mNodeInfo->GetPrefix(aPrefix); + return NS_OK; } NS_IMETHODIMP @@ -326,7 +327,8 @@ nsXULAttribute::SetPrefix(const nsAString& aPrefix) NS_IMETHODIMP nsXULAttribute::GetLocalName(nsAString& aLocalName) { - return mNodeInfo->GetLocalName(aLocalName); + mNodeInfo->GetLocalName(aLocalName); + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index e1a51da72e2..e7aee5b1685 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -101,7 +101,6 @@ #include "nsICSSStyleRule.h" #include "nsIStyleSheet.h" #include "nsIStyledContent.h" -#include "nsISupportsArray.h" #include "nsIURL.h" #include "nsIViewManager.h" #include "nsIWidget.h" @@ -646,7 +645,8 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result) NS_IMETHODIMP nsXULElement::GetNodeName(nsAString& aNodeName) { - return NodeInfo()->GetQualifiedName(aNodeName); + NodeInfo()->GetQualifiedName(aNodeName); + return NS_OK; } @@ -862,7 +862,8 @@ nsXULElement::GetNamespaceURI(nsAString& aNamespaceURI) NS_IMETHODIMP nsXULElement::GetPrefix(nsAString& aPrefix) { - return NodeInfo()->GetPrefix(aPrefix); + NodeInfo()->GetPrefix(aPrefix); + return NS_OK; } @@ -896,7 +897,8 @@ nsXULElement::SetPrefix(const nsAString& aPrefix) NS_IMETHODIMP nsXULElement::GetLocalName(nsAString& aLocalName) { - return NodeInfo()->GetLocalName(aLocalName); + NodeInfo()->GetLocalName(aLocalName); + return NS_OK; } @@ -1181,7 +1183,8 @@ nsXULElement::IsSupported(const nsAString& aFeature, NS_IMETHODIMP nsXULElement::GetTagName(nsAString& aTagName) { - return NodeInfo()->GetQualifiedName(aTagName); + NodeInfo()->GetQualifiedName(aTagName); + return NS_OK; } NS_IMETHODIMP_(nsINodeInfo *) @@ -1201,10 +1204,7 @@ nsXULElement::GetAttribute(const nsAString& aName, return NS_OK; } - nsCOMPtr nameAtom = nodeInfo->GetNameAtom(); - PRInt32 nameSpaceID = nodeInfo->GetNamespaceID(); - - GetAttr(nameSpaceID, nameAtom, aReturn); + GetAttr(nodeInfo->NamespaceID(), nodeInfo->NameAtom(), aReturn); return NS_OK; } @@ -1216,12 +1216,9 @@ nsXULElement::SetAttribute(const nsAString& aName, { nsCOMPtr ni = GetExistingAttrNameFromQName(aName); if (!ni) { - nsCOMPtr nimgr; - NodeInfo()->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - - nsresult rv = nimgr->GetNodeInfo(aName, nsnull, kNameSpaceID_None, - getter_AddRefs(ni)); + nsresult rv = NodeInfo()->NodeInfoManager()->GetNodeInfo(aName, nsnull, + kNameSpaceID_None, + getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); } @@ -1237,10 +1234,7 @@ nsXULElement::RemoveAttribute(const nsAString& aName) return NS_OK; } - nsCOMPtr tag = ni->GetNameAtom(); - PRInt32 nameSpaceID = ni->GetNamespaceID(); - - return UnsetAttr(nameSpaceID, tag, PR_TRUE); + return UnsetAttr(ni->NamespaceID(), ni->NameAtom(), PR_TRUE); } @@ -1345,12 +1339,10 @@ nsXULElement::SetAttributeNS(const nsAString& aNamespaceURI, const nsAString& aQualifiedName, const nsAString& aValue) { - nsCOMPtr nimgr; - nsresult rv = NodeInfo()->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr ni; - rv = nimgr->GetNodeInfo(aQualifiedName, aNamespaceURI, getter_AddRefs(ni)); + nsresult rv = NodeInfo()->NodeInfoManager()->GetNodeInfo(aQualifiedName, + aNamespaceURI, + getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); return SetAttr(ni, aValue, PR_TRUE); @@ -1722,10 +1714,10 @@ nsXULElement::AddListenerFor(nsINodeInfo *aNodeInfo, // If appropriate, add a popup listener and/or compile the event // handler. Called when we change the element's document, create a // new element, change an attribute's value, etc. - PRInt32 nameSpaceID = aNodeInfo->GetNamespaceID(); + PRInt32 nameSpaceID = aNodeInfo->NamespaceID(); if (nameSpaceID == kNameSpaceID_None) { - nsCOMPtr attr = aNodeInfo->GetNameAtom(); + nsIAtom *attr = aNodeInfo->NameAtom(); if (attr == nsXULAtoms::menu || attr == nsXULAtoms::contextmenu || @@ -2189,7 +2181,7 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) NS_IMETHODIMP nsXULElement::GetNameSpaceID(PRInt32* aNameSpaceID) const { - *aNameSpaceID = NodeInfo()->GetNamespaceID(); + *aNameSpaceID = NodeInfo()->NamespaceID(); return NS_OK; } @@ -2197,8 +2189,7 @@ nsXULElement::GetNameSpaceID(PRInt32* aNameSpaceID) const NS_IMETHODIMP nsXULElement::GetTag(nsIAtom** aResult) const { - // AddRefs - *aResult = NodeInfo()->GetNameAtom().get(); + NS_ADDREF(*aResult = NodeInfo()->NameAtom()); return NS_OK; } @@ -2287,9 +2278,6 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo, if (nsnull == aNodeInfo) return NS_ERROR_NULL_POINTER; - nsCOMPtr attrName = aNodeInfo->GetNameAtom(); - PRInt32 attrns = aNodeInfo->GetNamespaceID(); - nsresult rv = EnsureAttributes(); if (NS_FAILED(rv)) return rv; @@ -2311,6 +2299,9 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo, return NS_OK; } + nsIAtom *attrName = aNodeInfo->NameAtom(); + PRInt32 attrns = aNodeInfo->NamespaceID(); + // Send the update notification _before_ changing anything mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify); if (mDocument && aNotify) { @@ -2424,13 +2415,9 @@ nsXULElement::SetAttr(PRInt32 aNameSpaceID, const nsAString& aValue, PRBool aNotify) { - nsCOMPtr nimgr; - - NodeInfo()->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - nsCOMPtr ni; - nimgr->GetNodeInfo(aName, nsnull, aNameSpaceID, getter_AddRefs(ni)); + NodeInfo()->NodeInfoManager()->GetNodeInfo(aName, nsnull, aNameSpaceID, + getter_AddRefs(ni)); return SetAttr(ni, aValue, aNotify); } @@ -2468,8 +2455,7 @@ nsXULElement::GetAttr(PRInt32 aNameSpaceID, nsINodeInfo *ni = attr->GetNodeInfo(); if (ni->Equals(aName, aNameSpaceID)) { - // AddRefs - *aPrefix = ni->GetPrefixAtom().get(); + NS_IF_ADDREF(*aPrefix = ni->GetPrefixAtom()); attr->GetValue(aResult); return aResult.IsEmpty() ? NS_CONTENT_ATTR_NO_VALUE : NS_CONTENT_ATTR_HAS_VALUE; } @@ -2484,8 +2470,7 @@ nsXULElement::GetAttr(PRInt32 aNameSpaceID, nsINodeInfo *ni = attr->mNodeInfo; if (ni->Equals(aName, aNameSpaceID)) { - // AddRefs - *aPrefix = ni->GetPrefixAtom().get(); + NS_IF_ADDREF(*aPrefix = ni->GetPrefixAtom()); attr->mValue.GetValue( aResult ); return aResult.IsEmpty() ? NS_CONTENT_ATTR_NO_VALUE : NS_CONTENT_ATTR_HAS_VALUE; } @@ -2712,11 +2697,9 @@ nsXULElement::GetAttrNameAt(PRUint32 aIndex, if (aIndex < Attributes()->Count()) { nsXULAttribute* attr = NS_REINTERPRET_CAST(nsXULAttribute*, Attributes()->ElementAt(aIndex)); if (attr) { - *aNameSpaceID = attr->GetNodeInfo()->GetNamespaceID(); - // AddRefs - *aName = attr->GetNodeInfo()->GetNameAtom().get(); - // AddRefs - *aPrefix = attr->GetNodeInfo()->GetPrefixAtom().get(); + *aNameSpaceID = attr->GetNodeInfo()->NamespaceID(); + NS_ADDREF(*aName = attr->GetNodeInfo()->NameAtom()); + NS_IF_ADDREF(*aPrefix = attr->GetNodeInfo()->GetPrefixAtom()); #ifdef DEBUG_ATTRIBUTE_STATS fprintf(stderr, " local!\n"); #endif @@ -2745,12 +2728,10 @@ nsXULElement::GetAttrNameAt(PRUint32 aIndex, #ifdef DEBUG_ATTRIBUTE_STATS fprintf(stderr, " proto[%d]!\n", aIndex); #endif - *aNameSpaceID = attr->mNodeInfo->GetNamespaceID(); + *aNameSpaceID = attr->mNodeInfo->NamespaceID(); - // AddRefs - *aName = attr->mNodeInfo->GetNameAtom().get(); - // AddRefs - *aPrefix = attr->mNodeInfo->GetPrefixAtom().get(); + NS_ADDREF(*aName = attr->mNodeInfo->NameAtom()); + NS_IF_ADDREF(*aPrefix = attr->mNodeInfo->GetPrefixAtom()); return NS_OK; } @@ -3556,13 +3537,11 @@ nsXULElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify) attr->SetValueInternal(stringValue); } else { - nsCOMPtr nimgr; - NodeInfo()->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); - nsCOMPtr ni; - rv = nimgr->GetNodeInfo(nsXULAtoms::style, nsnull, kNameSpaceID_None, - getter_AddRefs(ni)); + rv = NodeInfo()->NodeInfoManager()->GetNodeInfo(nsXULAtoms::style, + nsnull, + kNameSpaceID_None, + getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); // Need to create a local attr @@ -4607,7 +4586,7 @@ nsXULPrototypeAttribute::~nsXULPrototypeAttribute() nsresult nsXULPrototypeElement::Serialize(nsIObjectOutputStream* aStream, nsIScriptContext* aContext, - nsISupportsArray* aNodeInfos) + const nsCOMArray *aNodeInfos) { nsresult rv; @@ -4674,7 +4653,7 @@ nsresult nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream, nsIScriptContext* aContext, nsIURI* aDocumentURI, - nsISupportsArray* aNodeInfos) + const nsCOMArray *aNodeInfos) { NS_PRECONDITION(aNodeInfos, "missing nodeinfo array"); nsresult rv; @@ -4682,7 +4661,7 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream, // Read Node Info PRUint32 number; rv = aStream->Read32(&number); - mNodeInfo = do_QueryElementAt(aNodeInfos, number); + mNodeInfo = aNodeInfos->SafeObjectAt(number); if (!mNodeInfo) return NS_ERROR_UNEXPECTED; @@ -4699,7 +4678,7 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream, nsAutoString attributeValue; for (i = 0; i < mNumAttributes; ++i) { rv |= aStream->Read32(&number); - mAttributes[i].mNodeInfo = do_QueryElementAt(aNodeInfos, number); + mAttributes[i].mNodeInfo = aNodeInfos->SafeObjectAt(number); if (!mAttributes[i].mNodeInfo) return NS_ERROR_UNEXPECTED; @@ -4844,7 +4823,7 @@ nsXULPrototypeScript::~nsXULPrototypeScript() nsresult nsXULPrototypeScript::Serialize(nsIObjectOutputStream* aStream, nsIScriptContext* aContext, - nsISupportsArray* aNodeInfos) + const nsCOMArray *aNodeInfos) { NS_ASSERTION(!mSrcLoading || mSrcLoadWaiters != nsnull || !mJSObject, "script source still loading when serializing?!"); @@ -4966,7 +4945,7 @@ nsresult nsXULPrototypeScript::Deserialize(nsIObjectInputStream* aStream, nsIScriptContext* aContext, nsIURI* aDocumentURI, - nsISupportsArray* aNodeInfos) + const nsCOMArray *aNodeInfos) { NS_TIMELINE_MARK_FUNCTION("chrome js deserialize"); nsresult rv; @@ -5221,7 +5200,7 @@ nsXULPrototypeScript::Compile(const PRUnichar* aText, nsresult nsXULPrototypeText::Serialize(nsIObjectOutputStream* aStream, nsIScriptContext* aContext, - nsISupportsArray* aNodeInfos) + const nsCOMArray *aNodeInfos) { nsresult rv; @@ -5237,7 +5216,7 @@ nsresult nsXULPrototypeText::Deserialize(nsIObjectInputStream* aStream, nsIScriptContext* aContext, nsIURI* aDocumentURI, - nsISupportsArray* aNodeInfos) + const nsCOMArray *aNodeInfos) { nsresult rv; diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index dd387876ba5..68f8bb129b7 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -204,11 +204,11 @@ public: virtual ~nsXULPrototypeNode() {} virtual nsresult Serialize(nsIObjectOutputStream* aStream, nsIScriptContext* aContext, - nsISupportsArray* aNodeInfos) = 0; + const nsCOMArray *aNodeInfos) = 0; virtual nsresult Deserialize(nsIObjectInputStream* aStream, nsIScriptContext* aContext, nsIURI* aDocumentURI, - nsISupportsArray* aNodeInfos) = 0; + const nsCOMArray *aNodeInfos) = 0; void AddRef() { ++mRefCnt; }; void Release() @@ -262,11 +262,11 @@ public: virtual nsresult Serialize(nsIObjectOutputStream* aStream, nsIScriptContext* aContext, - nsISupportsArray* aNodeInfos); + const nsCOMArray *aNodeInfos); virtual nsresult Deserialize(nsIObjectInputStream* aStream, nsIScriptContext* aContext, nsIURI* aDocumentURI, - nsISupportsArray* aNodeInfos); + const nsCOMArray *aNodeInfos); PRUint32 mNumChildren; nsXULPrototypeNode** mChildren; // [OWNER] @@ -309,13 +309,13 @@ public: virtual nsresult Serialize(nsIObjectOutputStream* aStream, nsIScriptContext* aContext, - nsISupportsArray* aNodeInfos); + const nsCOMArray *aNodeInfos); nsresult SerializeOutOfLine(nsIObjectOutputStream* aStream, nsIScriptContext* aContext); virtual nsresult Deserialize(nsIObjectInputStream* aStream, nsIScriptContext* aContext, nsIURI* aDocumentURI, - nsISupportsArray* aNodeInfos); + const nsCOMArray *aNodeInfos); nsresult DeserializeOutOfLine(nsIObjectInputStream* aInput, nsIScriptContext* aContext); @@ -364,11 +364,11 @@ public: virtual nsresult Serialize(nsIObjectOutputStream* aStream, nsIScriptContext* aContext, - nsISupportsArray* aNodeInfos); + const nsCOMArray *aNodeInfos); virtual nsresult Deserialize(nsIObjectInputStream* aStream, nsIScriptContext* aContext, nsIURI* aDocumentURI, - nsISupportsArray* aNodeInfos); + const nsCOMArray *aNodeInfos); nsString mValue; }; diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 7d748be597d..7568a903132 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -822,7 +822,7 @@ XULContentSinkImpl::HandleStartElement(const PRUnichar *aName, nsCOMPtr IDAttr = do_GetAtom(aAtts[aIndex]); if (IDAttr) { - rv = nodeInfo->SetIDAttributeAtom(IDAttr); + nodeInfo->SetIDAttributeAtom(IDAttr); } } diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index d407130c5ff..a8caadbd508 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1532,8 +1532,8 @@ nsXULDocument::Persist(const nsAString& aID, nsCOMPtr ni = element->GetExistingAttrNameFromQName(aAttr); if (ni) { - tag = ni->GetNameAtom(); - nameSpaceID = ni->GetNamespaceID(); + tag = ni->NameAtom(); + nameSpaceID = ni->NamespaceID(); } else { tag = do_GetAtom(aAttr); @@ -2339,10 +2339,9 @@ nsXULDocument::CreateElement(nsINodeInfo *aNodeInfo, nsIContent** aResult) if (NS_FAILED(rv)) return rv; } else { - PRInt32 namespaceID = aNodeInfo->GetNamespaceID(); - nsCOMPtr elementFactory; - GetElementFactory(namespaceID, getter_AddRefs(elementFactory)); + GetElementFactory(aNodeInfo->NamespaceID(), + getter_AddRefs(elementFactory)); rv = elementFactory->CreateInstanceByTag(aNodeInfo, getter_AddRefs(result)); @@ -3474,10 +3473,8 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe // what. So we need to copy everything out of the prototype // into the element. - PRInt32 namespaceID = aPrototype->mNodeInfo->GetNamespaceID(); - nsCOMPtr elementFactory; - GetElementFactory(namespaceID, + GetElementFactory(aPrototype->mNodeInfo->NamespaceID(), getter_AddRefs(elementFactory)); rv = elementFactory->CreateInstanceByTag(aPrototype->mNodeInfo, getter_AddRefs(result)); @@ -3836,11 +3833,8 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode, nsCOMPtr ni = aTargetNode->GetNodeInfo(); if (ni) { - nsCOMPtr nimgr; - ni->GetNodeInfoManager(getter_AddRefs(nimgr)); - - nimgr->GetNodeInfo(attr, prefix, nameSpaceID, - getter_AddRefs(ni)); + ni->NodeInfoManager()->GetNodeInfo(attr, prefix, nameSpaceID, + getter_AddRefs(ni)); } rv = aTargetNode->SetAttr(ni, value, PR_FALSE); diff --git a/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp b/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp index 261ad73d3a5..5d6b04690a8 100644 --- a/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -68,6 +68,7 @@ #include "nsIScriptError.h" #include "nsIDOMScriptObjectFactory.h" #include "nsDOMCID.h" +#include "nsArray.h" static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, @@ -411,9 +412,7 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream) "no prototype script context!"); // nsINodeInfo table - nsCOMPtr nodeInfos; - rv |= NS_NewISupportsArray(getter_AddRefs(nodeInfos)); - NS_ENSURE_TRUE(nodeInfos, rv); + nsCOMArray nodeInfos; rv |= aStream->Read32(&referenceCount); nsAutoString namespaceURI, qualifiedName; @@ -423,7 +422,8 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream) nsCOMPtr nodeInfo; rv |= mNodeInfoManager->GetNodeInfo(qualifiedName, namespaceURI, getter_AddRefs(nodeInfo)); - rv |= nodeInfos->AppendElement(nodeInfo); + if (!nodeInfos.AppendObject(nodeInfo)) + rv |= NS_ERROR_OUT_OF_MEMORY; } // Document contents @@ -433,7 +433,7 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream) if ((nsXULPrototypeNode::Type)type != nsXULPrototypeNode::eType_Element) return NS_ERROR_FAILURE; - rv |= mRoot->Deserialize(aStream, scriptContext, mURI, nodeInfos); + rv |= mRoot->Deserialize(aStream, scriptContext, mURI, &nodeInfos); rv |= NotifyLoadDone(); return rv; @@ -478,15 +478,14 @@ nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream) rv |= NS_WriteOptionalObject(aStream, mDocumentPrincipal, PR_TRUE); // nsINodeInfo table - nsCOMPtr nodeInfos; - rv |= mNodeInfoManager->GetNodeInfoArray(getter_AddRefs(nodeInfos)); + nsCOMArray nodeInfos; + rv |= mNodeInfoManager->GetNodeInfos(&nodeInfos); NS_ENSURE_SUCCESS(rv, rv); - PRUint32 nodeInfoCount; - nodeInfos->Count(&nodeInfoCount); + PRInt32 nodeInfoCount = nodeInfos.Count(); rv |= aStream->Write32(nodeInfoCount); - for (i = 0; i < nodeInfoCount; ++i) { - nsCOMPtr nodeInfo = do_QueryElementAt(nodeInfos, i); + for (PRInt32 j = 0; j < nodeInfoCount; ++j) { + nsINodeInfo *nodeInfo = nodeInfos[j]; NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE); nsAutoString namespaceURI; @@ -494,7 +493,7 @@ nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream) rv |= aStream->WriteWStringZ(namespaceURI.get()); nsAutoString qualifiedName; - rv |= nodeInfo->GetQualifiedName(qualifiedName); + nodeInfo->GetQualifiedName(qualifiedName); rv |= aStream->WriteWStringZ(qualifiedName.get()); } @@ -506,7 +505,7 @@ nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream) rv |= globalObject->GetContext(getter_AddRefs(scriptContext)); if (mRoot) - rv |= mRoot->Serialize(aStream, scriptContext, nodeInfos); + rv |= mRoot->Serialize(aStream, scriptContext, &nodeInfos); return rv; } diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index 31d8d7c3702..f11d8605969 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -871,8 +871,8 @@ nsXULContentBuilder::AddPersistentAttributes(nsIContent* aTemplateNode, nsCOMPtr ni = aTemplateNode->GetExistingAttrNameFromQName(attribute); if (ni) { - tag = ni->GetNameAtom(); - nameSpaceID = ni->GetNamespaceID(); + tag = ni->NameAtom(); + nameSpaceID = ni->NamespaceID(); } else { tag = do_GetAtom(attribute); diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaElement.cpp b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaElement.cpp index b6ab4120932..7d0f49e0a3a 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaElement.cpp +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaElement.cpp @@ -45,7 +45,7 @@ Element::Element(nsIDOMElement* aElement, Document* aOwner) : NS_ASSERTION(cont, "Element doesn't implement nsIContent"); nsINodeInfo *nodeInfo = cont->GetNodeInfo(); NS_ASSERTION(nodeInfo, "a element without nodeinfo"); - mNamespaceID = nodeInfo->GetNamespaceID(); + mNamespaceID = nodeInfo->NamespaceID(); } /** diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp b/mozilla/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp index b8e9bba0f40..b886cce77e8 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp @@ -573,12 +573,6 @@ handleNode(nsIDOMNode* aNode, txStylesheetCompiler* aCompiler) { nsCOMPtr element = do_QueryInterface(aNode); - nsINodeInfo *ni = element->GetNodeInfo(); - - PRInt32 namespaceID = ni->GetNamespaceID(); - nsCOMPtr localname = ni->GetNameAtom(); - nsCOMPtr prefix = ni->GetPrefixAtom(); - PRUint32 attsCount = element->GetAttrCount(); nsAutoArrayPtr atts; if (attsCount > 0) { @@ -595,7 +589,11 @@ handleNode(nsIDOMNode* aNode, txStylesheetCompiler* aCompiler) } } - rv = aCompiler->startElement(namespaceID, localname, prefix, atts, + nsINodeInfo *ni = element->GetNodeInfo(); + + rv = aCompiler->startElement(ni->NamespaceID(), + ni->NameAtom(), + ni->GetPrefixAtom(), atts, attsCount); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/extensions/webservices/schema/src/nsDOMUtils.h b/mozilla/extensions/webservices/schema/src/nsDOMUtils.h index 57260d86a55..160a4eaa480 100644 --- a/mozilla/extensions/webservices/schema/src/nsDOMUtils.h +++ b/mozilla/extensions/webservices/schema/src/nsDOMUtils.h @@ -137,7 +137,7 @@ public: return NS_ERROR_FAILURE; } - *aElementName = nodeInfo->GetNameAtom().get(); + NS_ADDREF(*aElementName = nodeInfo->NameAtom()); *aChildElement = childElement; NS_ADDREF(*aChildElement);