From a185a3e8405f0e2124836a4268cfb62d337b4004 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 24 Jul 2013 09:39:46 +0200 Subject: [PATCH] Bug 776517 - Move GetExistingAttrNameFromQName from nsIContent to dom::Element; r=smaug --- content/base/public/Element.h | 15 +++++++++++- content/base/public/nsIContent.h | 16 ++----------- content/base/src/DocumentFragment.h | 6 ----- content/base/src/nsGenericDOMDataNode.cpp | 6 ----- content/base/src/nsGenericDOMDataNode.h | 2 +- content/xul/document/src/XULDocument.cpp | 7 +++--- .../xul/templates/src/nsXULContentBuilder.cpp | 23 ++++++++++--------- 7 files changed, 32 insertions(+), 43 deletions(-) diff --git a/content/base/public/Element.h b/content/base/public/Element.h index dc9cc334895..28421460649 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -406,7 +406,20 @@ public: bool aCompileEventHandlers) MOZ_OVERRIDE; virtual void UnbindFromTree(bool aDeep = true, bool aNullParent = true) MOZ_OVERRIDE; - virtual already_AddRefed GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE; + + /** + * Normalizes an attribute name and returns it as a nodeinfo if an attribute + * with that name exists. This method is intended for character case + * conversion if the content object is case insensitive (e.g. HTML). Returns + * the nodeinfo of the attribute with the specified name if one exists or + * null otherwise. + * + * @param aStr the unparsed attribute string + * @return the node info. May be nullptr. + */ + already_AddRefed + GetExistingAttrNameFromQName(const nsAString& aStr) const; + nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAString& aValue, bool aNotify) { diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 06dcbe6abad..7dc2371c809 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -34,8 +34,8 @@ enum nsLinkState { // IID for the nsIContent interface #define NS_ICONTENT_IID \ -{ 0Xf22c131c, 0Xc554, 0X4d06, \ - { 0X81, 0Xac, 0X86, 0X64, 0X2f, 0X05, 0Xcc, 0X81 } } +{ 0x976f4cd1, 0xbdfc, 0x4a1e, \ + { 0x82, 0x46, 0x1c, 0x13, 0x9c, 0xd3, 0x73, 0x7f } } /** * A node of content in a document's content model. This interface @@ -319,18 +319,6 @@ public: */ virtual nsIAtom *GetIDAttributeName() const = 0; - /** - * Normalizes an attribute name and returns it as a nodeinfo if an attribute - * with that name exists. This method is intended for character case - * conversion if the content object is case insensitive (e.g. HTML). Returns - * the nodeinfo of the attribute with the specified name if one exists or - * null otherwise. - * - * @param aStr the unparsed attribute string - * @return the node info. May be nullptr. - */ - virtual already_AddRefed GetExistingAttrNameFromQName(const nsAString& aStr) const = 0; - /** * Set attribute values. All attribute values are assumed to have a * canonical string representation that can be used for these diff --git a/content/base/src/DocumentFragment.h b/content/base/src/DocumentFragment.h index 884779f54fb..c1ca920f9a2 100644 --- a/content/base/src/DocumentFragment.h +++ b/content/base/src/DocumentFragment.h @@ -74,12 +74,6 @@ public: JS::Handle aScope) MOZ_OVERRIDE; // nsIContent - virtual already_AddRefed - GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE - { - return nullptr; - } - nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAString& aValue, bool aNotify) { diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index ee72b627946..67ed59149a6 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -572,12 +572,6 @@ nsGenericDOMDataNode::GetIDAttributeName() const return nullptr; } -already_AddRefed -nsGenericDOMDataNode::GetExistingAttrNameFromQName(const nsAString& aStr) const -{ - return nullptr; -} - nsresult nsGenericDOMDataNode::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttr, nsIAtom* aPrefix, const nsAString& aValue, diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index 409503787f5..29f1db2a1f5 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -115,7 +115,7 @@ public: virtual already_AddRefed GetChildren(uint32_t aFilter) MOZ_OVERRIDE; virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE; - virtual already_AddRefed GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE; + nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAString& aValue, bool aNotify) { diff --git a/content/xul/document/src/XULDocument.cpp b/content/xul/document/src/XULDocument.cpp index 36a72ef482c..95056e828ee 100644 --- a/content/xul/document/src/XULDocument.cpp +++ b/content/xul/document/src/XULDocument.cpp @@ -1293,16 +1293,15 @@ XULDocument::Persist(const nsAString& aID, if (mApplyingPersistedAttrs) return NS_OK; - nsresult rv; - - nsIContent *element = nsDocument::GetElementById(aID); - if (! element) + Element* element = nsDocument::GetElementById(aID); + if (!element) return NS_OK; nsCOMPtr tag; int32_t nameSpaceID; nsCOMPtr ni = element->GetExistingAttrNameFromQName(aAttr); + nsresult rv; if (ni) { tag = ni->NameAtom(); nameSpaceID = ni->NamespaceID(); diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp index 5026400d8c5..1210df10abc 100644 --- a/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/content/xul/templates/src/nsXULContentBuilder.cpp @@ -146,7 +146,7 @@ protected: * @param aResult result to look up variable->value bindings in */ nsresult - AddPersistentAttributes(nsIContent* aTemplateNode, + AddPersistentAttributes(Element* aTemplateNode, nsIXULTemplateResult* aResult, nsIContent* aRealNode); @@ -513,16 +513,16 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode, bool isGenerationElement = false; bool isUnique = aIsUnique; - { - // We identify the resource element by presence of a - // "uri='rdf:*'" attribute. (We also support the older - // "uri='...'" syntax.) - if (tmplKid->HasAttr(kNameSpaceID_None, nsGkAtoms::uri) && aMatch->IsActive()) { - isGenerationElement = true; - isUnique = false; - } + // We identify the resource element by presence of a + // "uri='rdf:*'" attribute. (We also support the older + // "uri='...'" syntax.) + if (tmplKid->HasAttr(kNameSpaceID_None, nsGkAtoms::uri) && aMatch->IsActive()) { + isGenerationElement = true; + isUnique = false; } + MOZ_ASSERT_IF(isGenerationElement, tmplKid->IsElement()); + nsIAtom *tag = tmplKid->Tag(); #ifdef PR_LOGGING @@ -679,7 +679,8 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode, // Add any persistent attributes if (isGenerationElement) { - rv = AddPersistentAttributes(tmplKid, aChild, realKid); + rv = AddPersistentAttributes(tmplKid->AsElement(), aChild, + realKid); if (NS_FAILED(rv)) return rv; } @@ -783,7 +784,7 @@ nsXULContentBuilder::CopyAttributesToElement(nsIContent* aTemplateNode, } nsresult -nsXULContentBuilder::AddPersistentAttributes(nsIContent* aTemplateNode, +nsXULContentBuilder::AddPersistentAttributes(Element* aTemplateNode, nsIXULTemplateResult* aResult, nsIContent* aRealNode) {