diff --git a/content/base/public/nsIAttribute.h b/content/base/public/nsIAttribute.h index f27272d00e52..7c6a449dd28a 100644 --- a/content/base/public/nsIAttribute.h +++ b/content/base/public/nsIAttribute.h @@ -12,8 +12,8 @@ class nsDOMAttributeMap; class nsIContent; #define NS_IATTRIBUTE_IID \ -{ 0x8d9d7dbf, 0xc42d, 0x4715, \ - { 0x95, 0xcf, 0x7a, 0x5e, 0xd5, 0xa4, 0x47, 0x70 } } +{ 0x727dc139, 0xf516, 0x46ff, \ + { 0x86, 0x11, 0x18, 0xea, 0xee, 0x4a, 0x3e, 0x6a } } class nsIAttribute : public nsINode { @@ -32,8 +32,6 @@ public: return mNodeInfo; } - virtual nsIContent* GetContent() const = 0; - /** * Called when our ownerElement is moved into a new document. * Updates the nodeinfo of this node. diff --git a/content/base/src/Attr.cpp b/content/base/src/Attr.cpp index d33ae6994a0f..da99faed6173 100644 --- a/content/base/src/Attr.cpp +++ b/content/base/src/Attr.cpp @@ -77,7 +77,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Attr) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(Attr) - Element* ownerElement = tmp->GetContentInternal(); + Element* ownerElement = tmp->GetElement(); if (tmp->IsBlack()) { if (ownerElement) { // The attribute owns the element via attribute map so we can @@ -128,16 +128,10 @@ Attr::SetMap(nsDOMAttributeMap *aMap) mAttrMap = aMap; } -nsIContent* -Attr::GetContent() const -{ - return GetContentInternal(); -} - Element* Attr::GetElement() const { - nsIContent* content = GetContent(); + nsIContent* content = mAttrMap ? mAttrMap->GetContent() : nullptr; return content ? content->AsElement() : nullptr; } @@ -188,7 +182,7 @@ Attr::GetNameAtom(nsIContent* aContent) NS_IMETHODIMP Attr::GetValue(nsAString& aValue) { - nsIContent* content = GetContentInternal(); + nsIContent* content = GetElement(); if (content) { nsCOMPtr nameAtom = GetNameAtom(content); content->GetAttr(mNodeInfo->NamespaceID(), nameAtom, aValue); @@ -203,7 +197,7 @@ Attr::GetValue(nsAString& aValue) void Attr::SetValue(const nsAString& aValue, ErrorResult& aRv) { - nsIContent* content = GetContentInternal(); + nsIContent* content = GetElement(); if (!content) { mValue = aValue; return; @@ -276,7 +270,7 @@ Attr::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const already_AddRefed Attr::GetBaseURI() const { - nsINode *parent = GetContentInternal(); + nsINode *parent = GetElement(); return parent ? parent->GetBaseURI() : nullptr; } @@ -301,7 +295,7 @@ Attr::SetTextContentInternal(const nsAString& aTextContent, NS_IMETHODIMP Attr::GetIsId(bool* aReturn) { - nsIContent* content = GetContentInternal(); + nsIContent* content = GetElement(); if (!content) { *aReturn = false; @@ -387,11 +381,5 @@ Attr::WrapObject(JSContext* aCx, JS::Handle aScope) return AttrBinding::Wrap(aCx, aScope, this); } -Element* -Attr::GetContentInternal() const -{ - return mAttrMap ? mAttrMap->GetContent() : nullptr; -} - } // namespace dom } // namespace mozilla diff --git a/content/base/src/Attr.h b/content/base/src/Attr.h index eb0d46d4de53..a65f5d7e8a4c 100644 --- a/content/base/src/Attr.h +++ b/content/base/src/Attr.h @@ -54,7 +54,6 @@ public: // nsIAttribute interface void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE; - nsIContent *GetContent() const MOZ_OVERRIDE; Element *GetElement() const; nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE; @@ -96,14 +95,13 @@ public: protected: virtual Element* GetNameSpaceElement() { - return GetContentInternal(); + return GetElement(); } static bool sInitialized; private: already_AddRefed GetNameAtom(nsIContent* aContent); - Element* GetContentInternal() const; nsString mValue; }; diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index d4aeedd88abf..7825d2e7aa07 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -774,10 +774,10 @@ nsINode::CompareDocumentPosition(nsINode& aOtherNode) const const nsINode *node1 = &aOtherNode, *node2 = this; // Check if either node is an attribute - const nsIAttribute* attr1 = nullptr; + const Attr* attr1 = nullptr; if (node1->IsNodeOfType(nsINode::eATTRIBUTE)) { - attr1 = static_cast(node1); - const nsIContent* elem = attr1->GetContent(); + attr1 = static_cast(node1); + const nsIContent* elem = attr1->GetElement(); // If there is an owner element add the attribute // to the chain and walk up to the element if (elem) { @@ -786,8 +786,8 @@ nsINode::CompareDocumentPosition(nsINode& aOtherNode) const } } if (node2->IsNodeOfType(nsINode::eATTRIBUTE)) { - const nsIAttribute* attr2 = static_cast(node2); - const nsIContent* elem = attr2->GetContent(); + const Attr* attr2 = static_cast(node2); + const nsIContent* elem = attr2->GetElement(); if (elem == node1 && attr1) { // Both nodes are attributes on the same element. // Compare position between the attributes. diff --git a/dom/xslt/xpath/nsXPathResult.cpp b/dom/xslt/xpath/nsXPathResult.cpp index 0c7acb1c1ad1..bf195a3eb67d 100644 --- a/dom/xslt/xpath/nsXPathResult.cpp +++ b/dom/xslt/xpath/nsXPathResult.cpp @@ -7,8 +7,8 @@ #include "txExprResult.h" #include "txNodeSet.h" #include "nsError.h" +#include "mozilla/dom/Attr.h" #include "mozilla/dom/Element.h" -#include "nsIAttribute.h" #include "nsDOMClassInfoID.h" #include "nsIDOMNode.h" #include "nsIDOMDocument.h" @@ -362,7 +362,7 @@ nsXPathResult::Invalidate(const nsIContent* aChangeRoot) ->GetBindingParent(); } else if (contextNode->IsNodeOfType(nsINode::eATTRIBUTE)) { nsIContent* parent = - static_cast(contextNode.get())->GetContent(); + static_cast(contextNode.get())->GetElement(); if (parent) { ctxBindingParent = parent->GetBindingParent(); } diff --git a/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp b/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp index 94b1aac1cea9..c41d615e3aba 100644 --- a/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp +++ b/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp @@ -21,10 +21,13 @@ #include "nsUnicharUtils.h" #include "nsAttrName.h" #include "nsTArray.h" +#include "mozilla/dom/Attr.h" #include "mozilla/dom/Element.h" #include #include +using mozilla::dom::Attr; + const uint32_t kUnknownIndex = uint32_t(-1); txXPathTreeWalker::txXPathTreeWalker(const txXPathTreeWalker& aOther) @@ -690,7 +693,7 @@ txXPathNativeNode::createXPathNode(nsIDOMNode* aNode, bool aKeepRootAlive) NS_ASSERTION(attr, "doesn't implement nsIAttribute"); nsINodeInfo *nodeInfo = attr->NodeInfo(); - nsIContent *parent = attr->GetContent(); + nsIContent *parent = static_cast(attr.get())->GetElement(); if (!parent) { return nullptr; }