diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 6368dccf5cbe..1d5fbcd746bb 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -40,6 +40,7 @@ class nsIContent; class nsISupportsArray; class nsIDOMRange; class nsISizeOfHandler; +class nsINodeInfo; // IID for the nsIContent interface #define NS_ICONTENT_IID \ @@ -136,6 +137,23 @@ public: const nsString& aValue, PRBool aNotify) = 0; + /** + * Set attribute values. All attribute values are assumed to have a + * canonical string representation that can be used for these + * methods. The setAttribute method is assumed to perform a translation + * of the canonical form into the underlying content specific + * form. + * + * @param aNodeInfo the node info (name, prefix, namespace id) of the + * attribute + * @param aValue may legitimately be the empty string. + * + * @param aNotify specifies whether or not the document should be + * notified of the attribute change. + */ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify) = 0; + /** * Get the current value of the attribute. This returns a form that is * suitable for passing back into setAttribute. diff --git a/content/base/src/nsCommentNode.cpp b/content/base/src/nsCommentNode.cpp index cb7f253795fa..f093d9755cb1 100644 --- a/content/base/src/nsCommentNode.cpp +++ b/content/base/src/nsCommentNode.cpp @@ -124,6 +124,10 @@ public: const nsString& aValue, PRBool aNotify) { return mInner.SetAttribute(aNameSpaceID, aAttribute, aValue, aNotify); } + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, PRBool aNotify) { + return mInner.SetAttribute(aNodeInfo, aValue, aNotify); + } NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) { return mInner.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); diff --git a/content/base/src/nsDocumentFragment.cpp b/content/base/src/nsDocumentFragment.cpp index 95af3f91eab0..b9c3a0721dab 100644 --- a/content/base/src/nsDocumentFragment.cpp +++ b/content/base/src/nsDocumentFragment.cpp @@ -164,6 +164,10 @@ public: const nsString& aValue, PRBool aNotify) { return NS_OK; } + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) + { return NS_OK; } NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index e8cf56e28c11..90ba96271a48 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -173,6 +173,10 @@ struct nsGenericDOMDataNode { PRBool aNotify) { return NS_OK; } + nsresult SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, + PRBool aNotify) { + return NS_OK; + } nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) { return NS_OK; } @@ -490,6 +494,10 @@ struct nsGenericDOMDataNode { const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aAttribute, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \ PRBool aNotify) { \ return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \ diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 9e6155549a29..d9448a02847e 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -2300,6 +2300,24 @@ nsGenericContainerElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, return rv; } +nsresult +nsGenericContainerElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + nsresult nsGenericContainerElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index a3fdd383e36f..5375784c40b6 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -312,6 +312,8 @@ public: nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + nsresult SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify); nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const; nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, @@ -555,6 +557,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -670,6 +676,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -785,6 +795,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -898,6 +912,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -1015,6 +1033,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -1124,6 +1146,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ diff --git a/content/html/content/src/nsAttributeContent.cpp b/content/html/content/src/nsAttributeContent.cpp index 961eee0ff679..e24d989c58dc 100644 --- a/content/html/content/src/nsAttributeContent.cpp +++ b/content/html/content/src/nsAttributeContent.cpp @@ -127,6 +127,8 @@ public: NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, const nsString& aValue, PRBool aNotify) { return NS_OK; } + NS_IMETHOD SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, + PRBool aNotify) { return NS_OK; } NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) { return NS_OK; } NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, nsString &aResult) const {return NS_CONTENT_ATTR_NOT_THERE; } NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, PRInt32& aNameSpaceID, nsIAtom*& aName) const { diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 2fb9eda92029..117c1cbdc098 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -1304,6 +1304,24 @@ nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID, return result; } +nsresult +nsGenericHTMLElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + static PRInt32 GetStyleImpactFrom(const nsHTMLValue& aValue) { PRInt32 hint = NS_STYLE_HINT_NONE; @@ -3414,6 +3432,24 @@ nsGenericHTMLContainerFormElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* a return nsGenericHTMLElement::SetAttribute(aNameSpaceID, aName, aValue, aNotify); } +nsresult +nsGenericHTMLContainerFormElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + //---------------------------------------------------------------------- nsGenericHTMLLeafFormElement::nsGenericHTMLLeafFormElement() @@ -3446,4 +3482,22 @@ nsGenericHTMLLeafFormElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, return nsGenericHTMLElement::SetAttribute(aNameSpaceID, aName, aValue, aNotify); } +nsresult +nsGenericHTMLLeafFormElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + //---------------------------------------------------------------------- diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 90410af7a698..241f64e81f21 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -104,6 +104,7 @@ public: nsIAtom* aOffsetParentTag, nsIContent** aOffsetParent); + // Implementation for nsIContent nsresult GetNameSpaceID(PRInt32& aNameSpaceID) const; nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); @@ -114,6 +115,8 @@ public: nsIAtom*& aPrefix); nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + nsresult SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify); nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const; nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify); nsresult GetAttributeNameAt(PRInt32 aIndex, @@ -460,6 +463,8 @@ public: nsresult SetForm(nsIForm* aForm); nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + nsresult SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify); nsresult SetAttribute(const nsString& aName, const nsString& aValue) { return nsGenericHTMLElement::SetAttribute(aName, aValue); @@ -478,6 +483,8 @@ public: nsresult SetForm(nsIForm* aForm); nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + nsresult SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify); nsresult SetAttribute(const nsString& aName, const nsString& aValue) { return nsGenericHTMLElement::SetAttribute(aName, aValue); diff --git a/content/html/content/src/nsHTMLMapElement.cpp b/content/html/content/src/nsHTMLMapElement.cpp index 6bc653f3426f..08fd0b3570c4 100644 --- a/content/html/content/src/nsHTMLMapElement.cpp +++ b/content/html/content/src/nsHTMLMapElement.cpp @@ -125,6 +125,10 @@ public: const nsString& aValue, PRBool aNotify) { return mInner.SetAttribute(aNameSpaceID, aName, aValue, aNotify); } + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, PRBool aNotify) { + return mInner.SetAttribute(aNodeInfo, aValue, aNotify); + } NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { return mInner.GetAttribute(aNameSpaceID, aName, aResult); diff --git a/content/html/content/src/nsHTMLUnknownElement.cpp b/content/html/content/src/nsHTMLUnknownElement.cpp index 7946d1c99247..2a9da8b90bca 100644 --- a/content/html/content/src/nsHTMLUnknownElement.cpp +++ b/content/html/content/src/nsHTMLUnknownElement.cpp @@ -122,6 +122,8 @@ public: } NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, PRBool aNotify); NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { return mInner.GetAttribute(aNameSpaceID, aName, aResult); @@ -426,6 +428,24 @@ nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID, return result; } +NS_IMETHODIMP +nsHTMLUnknownElement::SetAttribute(nsINodeInfo *aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + NS_IMETHODIMP nsHTMLUnknownElement::HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, diff --git a/content/xml/content/src/nsXMLElement.cpp b/content/xml/content/src/nsXMLElement.cpp index 83bb19ad5ef1..b590c3ac1986 100644 --- a/content/xml/content/src/nsXMLElement.cpp +++ b/content/xml/content/src/nsXMLElement.cpp @@ -216,8 +216,8 @@ nsXMLElement::GetXMLBaseURI(nsIURI **aURI) NS_IMETHODIMP nsXMLElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsString& aValue, - PRBool aNotify) + const nsString& aValue, + PRBool aNotify) { if ((kNameSpaceID_XLink == aNameSpaceID) && (kTypeAtom == aName)) { @@ -240,6 +240,23 @@ nsXMLElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, return mInner.SetAttribute(aNameSpaceID, aName, aValue, aNotify); } +NS_IMETHODIMP +nsXMLElement::SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + static nsresult WebShellToPresContext(nsIWebShell *aShell, nsIPresContext **aPresContext) { *aPresContext = nsnull; diff --git a/content/xml/content/src/nsXMLElement.h b/content/xml/content/src/nsXMLElement.h index a9621de76ba4..f68bc8455435 100644 --- a/content/xml/content/src/nsXMLElement.h +++ b/content/xml/content/src/nsXMLElement.h @@ -118,6 +118,8 @@ public: } NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + NS_IMETHOD SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, + PRBool aNotify); NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { return mInner.GetAttribute(aNameSpaceID, aName, aResult); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 5d6b1ee6df34..71cf8ca0ca99 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -2867,6 +2867,24 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID, return rv; } +NS_IMETHODIMP +nsXULElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + NS_IMETHODIMP nsXULElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index 994bcdd0be09..345dda43ffbf 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -395,6 +395,7 @@ public: NS_IMETHOD ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID); NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, nsIAtom*& aPrefix); NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + NS_IMETHOD SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, PRBool aNotify); NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const; NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify); NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, PRInt32& aNameSpaceID, diff --git a/layout/base/public/nsIContent.h b/layout/base/public/nsIContent.h index 6368dccf5cbe..1d5fbcd746bb 100644 --- a/layout/base/public/nsIContent.h +++ b/layout/base/public/nsIContent.h @@ -40,6 +40,7 @@ class nsIContent; class nsISupportsArray; class nsIDOMRange; class nsISizeOfHandler; +class nsINodeInfo; // IID for the nsIContent interface #define NS_ICONTENT_IID \ @@ -136,6 +137,23 @@ public: const nsString& aValue, PRBool aNotify) = 0; + /** + * Set attribute values. All attribute values are assumed to have a + * canonical string representation that can be used for these + * methods. The setAttribute method is assumed to perform a translation + * of the canonical form into the underlying content specific + * form. + * + * @param aNodeInfo the node info (name, prefix, namespace id) of the + * attribute + * @param aValue may legitimately be the empty string. + * + * @param aNotify specifies whether or not the document should be + * notified of the attribute change. + */ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify) = 0; + /** * Get the current value of the attribute. This returns a form that is * suitable for passing back into setAttribute. diff --git a/layout/base/src/nsCommentNode.cpp b/layout/base/src/nsCommentNode.cpp index cb7f253795fa..f093d9755cb1 100644 --- a/layout/base/src/nsCommentNode.cpp +++ b/layout/base/src/nsCommentNode.cpp @@ -124,6 +124,10 @@ public: const nsString& aValue, PRBool aNotify) { return mInner.SetAttribute(aNameSpaceID, aAttribute, aValue, aNotify); } + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, PRBool aNotify) { + return mInner.SetAttribute(aNodeInfo, aValue, aNotify); + } NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) { return mInner.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); diff --git a/layout/base/src/nsDocumentFragment.cpp b/layout/base/src/nsDocumentFragment.cpp index 95af3f91eab0..b9c3a0721dab 100644 --- a/layout/base/src/nsDocumentFragment.cpp +++ b/layout/base/src/nsDocumentFragment.cpp @@ -164,6 +164,10 @@ public: const nsString& aValue, PRBool aNotify) { return NS_OK; } + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) + { return NS_OK; } NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/base/src/nsGenericDOMDataNode.h b/layout/base/src/nsGenericDOMDataNode.h index e8cf56e28c11..90ba96271a48 100644 --- a/layout/base/src/nsGenericDOMDataNode.h +++ b/layout/base/src/nsGenericDOMDataNode.h @@ -173,6 +173,10 @@ struct nsGenericDOMDataNode { PRBool aNotify) { return NS_OK; } + nsresult SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, + PRBool aNotify) { + return NS_OK; + } nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) { return NS_OK; } @@ -490,6 +494,10 @@ struct nsGenericDOMDataNode { const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aAttribute, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \ PRBool aNotify) { \ return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \ diff --git a/layout/base/src/nsGenericElement.cpp b/layout/base/src/nsGenericElement.cpp index 9e6155549a29..d9448a02847e 100644 --- a/layout/base/src/nsGenericElement.cpp +++ b/layout/base/src/nsGenericElement.cpp @@ -2300,6 +2300,24 @@ nsGenericContainerElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, return rv; } +nsresult +nsGenericContainerElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + nsresult nsGenericContainerElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const diff --git a/layout/base/src/nsGenericElement.h b/layout/base/src/nsGenericElement.h index a3fdd383e36f..5375784c40b6 100644 --- a/layout/base/src/nsGenericElement.h +++ b/layout/base/src/nsGenericElement.h @@ -312,6 +312,8 @@ public: nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + nsresult SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify); nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const; nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, @@ -555,6 +557,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -670,6 +676,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -785,6 +795,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -898,6 +912,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -1015,6 +1033,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ @@ -1124,6 +1146,10 @@ public: const nsString& aValue, PRBool aNotify) { \ return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \ } \ + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, \ + const nsString& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aNodeInfo, aValue, aNotify); \ + } \ NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \ nsString& aResult) const { \ return _g.GetAttribute(aNameSpaceID, aName, aResult); \ diff --git a/layout/html/content/src/nsAttributeContent.cpp b/layout/html/content/src/nsAttributeContent.cpp index 961eee0ff679..e24d989c58dc 100644 --- a/layout/html/content/src/nsAttributeContent.cpp +++ b/layout/html/content/src/nsAttributeContent.cpp @@ -127,6 +127,8 @@ public: NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, const nsString& aValue, PRBool aNotify) { return NS_OK; } + NS_IMETHOD SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, + PRBool aNotify) { return NS_OK; } NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) { return NS_OK; } NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, nsString &aResult) const {return NS_CONTENT_ATTR_NOT_THERE; } NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, PRInt32& aNameSpaceID, nsIAtom*& aName) const { diff --git a/layout/html/content/src/nsGenericHTMLElement.cpp b/layout/html/content/src/nsGenericHTMLElement.cpp index 2fb9eda92029..117c1cbdc098 100644 --- a/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/layout/html/content/src/nsGenericHTMLElement.cpp @@ -1304,6 +1304,24 @@ nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID, return result; } +nsresult +nsGenericHTMLElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + static PRInt32 GetStyleImpactFrom(const nsHTMLValue& aValue) { PRInt32 hint = NS_STYLE_HINT_NONE; @@ -3414,6 +3432,24 @@ nsGenericHTMLContainerFormElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* a return nsGenericHTMLElement::SetAttribute(aNameSpaceID, aName, aValue, aNotify); } +nsresult +nsGenericHTMLContainerFormElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + //---------------------------------------------------------------------- nsGenericHTMLLeafFormElement::nsGenericHTMLLeafFormElement() @@ -3446,4 +3482,22 @@ nsGenericHTMLLeafFormElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, return nsGenericHTMLElement::SetAttribute(aNameSpaceID, aName, aValue, aNotify); } +nsresult +nsGenericHTMLLeafFormElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + //---------------------------------------------------------------------- diff --git a/layout/html/content/src/nsGenericHTMLElement.h b/layout/html/content/src/nsGenericHTMLElement.h index 90410af7a698..241f64e81f21 100644 --- a/layout/html/content/src/nsGenericHTMLElement.h +++ b/layout/html/content/src/nsGenericHTMLElement.h @@ -104,6 +104,7 @@ public: nsIAtom* aOffsetParentTag, nsIContent** aOffsetParent); + // Implementation for nsIContent nsresult GetNameSpaceID(PRInt32& aNameSpaceID) const; nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); @@ -114,6 +115,8 @@ public: nsIAtom*& aPrefix); nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + nsresult SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify); nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const; nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify); nsresult GetAttributeNameAt(PRInt32 aIndex, @@ -460,6 +463,8 @@ public: nsresult SetForm(nsIForm* aForm); nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + nsresult SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify); nsresult SetAttribute(const nsString& aName, const nsString& aValue) { return nsGenericHTMLElement::SetAttribute(aName, aValue); @@ -478,6 +483,8 @@ public: nsresult SetForm(nsIForm* aForm); nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + nsresult SetAttribute(nsINodeInfo* aNodeInfo, const nsString& aValue, + PRBool aNotify); nsresult SetAttribute(const nsString& aName, const nsString& aValue) { return nsGenericHTMLElement::SetAttribute(aName, aValue); diff --git a/layout/html/content/src/nsHTMLMapElement.cpp b/layout/html/content/src/nsHTMLMapElement.cpp index 6bc653f3426f..08fd0b3570c4 100644 --- a/layout/html/content/src/nsHTMLMapElement.cpp +++ b/layout/html/content/src/nsHTMLMapElement.cpp @@ -125,6 +125,10 @@ public: const nsString& aValue, PRBool aNotify) { return mInner.SetAttribute(aNameSpaceID, aName, aValue, aNotify); } + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, PRBool aNotify) { + return mInner.SetAttribute(aNodeInfo, aValue, aNotify); + } NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { return mInner.GetAttribute(aNameSpaceID, aName, aResult); diff --git a/layout/html/content/src/nsHTMLUnknownElement.cpp b/layout/html/content/src/nsHTMLUnknownElement.cpp index 7946d1c99247..2a9da8b90bca 100644 --- a/layout/html/content/src/nsHTMLUnknownElement.cpp +++ b/layout/html/content/src/nsHTMLUnknownElement.cpp @@ -122,6 +122,8 @@ public: } NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + NS_IMETHOD SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, PRBool aNotify); NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { return mInner.GetAttribute(aNameSpaceID, aName, aResult); @@ -426,6 +428,24 @@ nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID, return result; } +NS_IMETHODIMP +nsHTMLUnknownElement::SetAttribute(nsINodeInfo *aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + NS_IMETHODIMP nsHTMLUnknownElement::HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, diff --git a/layout/xml/content/src/nsGenericXMLElement.h b/layout/xml/content/src/nsGenericXMLElement.h index 0ca315992a80..637c6f3e9bab 100644 --- a/layout/xml/content/src/nsGenericXMLElement.h +++ b/layout/xml/content/src/nsGenericXMLElement.h @@ -62,6 +62,12 @@ public: return nsGenericContainerElement::SetAttribute(aNameSpaceID, aName, aValue, aNotify); } + nsresult SetAttribute(nsINodeInfo *aNodeInfo, + const nsString& aValue, + PRBool aNotify) + { + return nsGenericContainerElement::SetAttribute(aNodeInfo, aValue, aNotify); + } nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { diff --git a/layout/xml/content/src/nsXMLElement.cpp b/layout/xml/content/src/nsXMLElement.cpp index 83bb19ad5ef1..b590c3ac1986 100644 --- a/layout/xml/content/src/nsXMLElement.cpp +++ b/layout/xml/content/src/nsXMLElement.cpp @@ -216,8 +216,8 @@ nsXMLElement::GetXMLBaseURI(nsIURI **aURI) NS_IMETHODIMP nsXMLElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsString& aValue, - PRBool aNotify) + const nsString& aValue, + PRBool aNotify) { if ((kNameSpaceID_XLink == aNameSpaceID) && (kTypeAtom == aName)) { @@ -240,6 +240,23 @@ nsXMLElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, return mInner.SetAttribute(aNameSpaceID, aName, aValue, aNotify); } +NS_IMETHODIMP +nsXMLElement::SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + static nsresult WebShellToPresContext(nsIWebShell *aShell, nsIPresContext **aPresContext) { *aPresContext = nsnull; diff --git a/layout/xml/content/src/nsXMLElement.h b/layout/xml/content/src/nsXMLElement.h index a9621de76ba4..f68bc8455435 100644 --- a/layout/xml/content/src/nsXMLElement.h +++ b/layout/xml/content/src/nsXMLElement.h @@ -118,6 +118,8 @@ public: } NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + NS_IMETHOD SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, + PRBool aNotify); NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const { return mInner.GetAttribute(aNameSpaceID, aName, aResult); diff --git a/rdf/content/src/nsXULElement.cpp b/rdf/content/src/nsXULElement.cpp index 5d6b1ee6df34..71cf8ca0ca99 100644 --- a/rdf/content/src/nsXULElement.cpp +++ b/rdf/content/src/nsXULElement.cpp @@ -2867,6 +2867,24 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID, return rv; } +NS_IMETHODIMP +nsXULElement::SetAttribute(nsINodeInfo* aNodeInfo, + const nsString& aValue, + PRBool aNotify) +{ + NS_ENSURE_ARG_POINTER(aNodeInfo); + + nsCOMPtr atom; + PRInt32 nsid; + + aNodeInfo->GetNameAtom(*getter_AddRefs(atom)); + aNodeInfo->GetNamespaceID(nsid); + + // We still rely on the old way of setting the attribute. + + return SetAttribute(nsid, atom, aValue, aNotify); +} + NS_IMETHODIMP nsXULElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, diff --git a/rdf/content/src/nsXULElement.h b/rdf/content/src/nsXULElement.h index 994bcdd0be09..345dda43ffbf 100644 --- a/rdf/content/src/nsXULElement.h +++ b/rdf/content/src/nsXULElement.h @@ -395,6 +395,7 @@ public: NS_IMETHOD ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID); NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, nsIAtom*& aPrefix); NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify); + NS_IMETHOD SetAttribute(nsINodeInfo *aNodeInfo, const nsString& aValue, PRBool aNotify); NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const; NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify); NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, PRInt32& aNameSpaceID,