зеркало из https://github.com/mozilla/gecko-dev.git
Bug 957652 - Replace the Attr element getters by something that returns an Element; r=bzbarsky
This commit is contained in:
Родитель
72c629af31
Коммит
1f40404fab
|
@ -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.
|
||||
|
|
|
@ -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<nsIAtom> 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<nsIURI>
|
||||
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<JSObject*> aScope)
|
|||
return AttrBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
Element*
|
||||
Attr::GetContentInternal() const
|
||||
{
|
||||
return mAttrMap ? mAttrMap->GetContent() : nullptr;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -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<nsIAtom> GetNameAtom(nsIContent* aContent);
|
||||
Element* GetContentInternal() const;
|
||||
|
||||
nsString mValue;
|
||||
};
|
||||
|
|
|
@ -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<const nsIAttribute*>(node1);
|
||||
const nsIContent* elem = attr1->GetContent();
|
||||
attr1 = static_cast<const Attr*>(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<const nsIAttribute*>(node2);
|
||||
const nsIContent* elem = attr2->GetContent();
|
||||
const Attr* attr2 = static_cast<const Attr*>(node2);
|
||||
const nsIContent* elem = attr2->GetElement();
|
||||
if (elem == node1 && attr1) {
|
||||
// Both nodes are attributes on the same element.
|
||||
// Compare position between the attributes.
|
||||
|
|
|
@ -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<nsIAttribute*>(contextNode.get())->GetContent();
|
||||
static_cast<Attr*>(contextNode.get())->GetElement();
|
||||
if (parent) {
|
||||
ctxBindingParent = parent->GetBindingParent();
|
||||
}
|
||||
|
|
|
@ -21,10 +21,13 @@
|
|||
#include "nsUnicharUtils.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/dom/Attr.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
|
||||
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*>(attr.get())->GetElement();
|
||||
if (!parent) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче