Implement Get/SetProperty for nsIAttribute. Bug 285597, r+sr=peterv,a=mkaply
This commit is contained in:
Родитель
c176d27c59
Коммит
cbd5abf513
|
@ -42,12 +42,15 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsPropertyTable.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIAtom;
|
||||
class nsDOMAttributeMap;
|
||||
|
||||
#define NS_IATTRIBUTE_IID \
|
||||
{0x9a9066ec, 0x35ba, 0x4244, \
|
||||
{0x8f, 0xb9, 0x49, 0x73, 0x90, 0xb0, 0x3f, 0x66}}
|
||||
{0x4940cc50, 0x2ede, 0x4883, \
|
||||
{0x95, 0xf5, 0x53, 0xdb, 0x50, 0x50, 0x13, 0x3e}}
|
||||
|
||||
class nsIAttribute : public nsISupports
|
||||
{
|
||||
|
@ -66,7 +69,29 @@ public:
|
|||
return mNodeInfo;
|
||||
}
|
||||
|
||||
virtual nsIContent* GetContent() = 0;
|
||||
virtual nsIContent* GetContent() const = 0;
|
||||
|
||||
nsIDocument *GetOwnerDoc() const
|
||||
{
|
||||
nsIContent* content = GetContent();
|
||||
return content ? content->GetOwnerDoc() : mNodeInfo->GetDocument();
|
||||
}
|
||||
|
||||
/*
|
||||
* Methods for manipulating content node properties. For documentation on
|
||||
* properties, see nsPropertyTable.h.
|
||||
*/
|
||||
virtual void* GetProperty(nsIAtom *aPropertyName,
|
||||
nsresult *aStatus = nsnull) = 0;
|
||||
|
||||
virtual nsresult SetProperty(nsIAtom *aPropertyName,
|
||||
void *aValue,
|
||||
NSPropertyDtorFunc aDtor = nsnull) = 0;
|
||||
|
||||
virtual nsresult DeleteProperty(nsIAtom *aPropertyName) = 0;
|
||||
|
||||
virtual void* UnsetProperty(nsIAtom *aPropertyName,
|
||||
nsresult *aStatus = nsnull) = 0;
|
||||
|
||||
protected:
|
||||
nsIAttribute(nsDOMAttributeMap *aAttrMap, nsINodeInfo *aNodeInfo)
|
||||
|
|
|
@ -64,6 +64,10 @@ nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap,
|
|||
|
||||
nsDOMAttribute::~nsDOMAttribute()
|
||||
{
|
||||
nsIDocument *doc = GetOwnerDoc();
|
||||
if (doc)
|
||||
doc->PropertyTable()->DeleteAllPropertiesFor(this);
|
||||
|
||||
NS_IF_RELEASE(mChild);
|
||||
NS_IF_RELEASE(mChildList);
|
||||
}
|
||||
|
@ -98,7 +102,7 @@ nsDOMAttribute::SetMap(nsDOMAttributeMap *aMap)
|
|||
}
|
||||
|
||||
nsIContent*
|
||||
nsDOMAttribute::GetContent()
|
||||
nsDOMAttribute::GetContent() const
|
||||
{
|
||||
return GetContentInternal();
|
||||
}
|
||||
|
@ -679,6 +683,49 @@ nsDOMAttribute::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
|||
return rv;
|
||||
}
|
||||
|
||||
void*
|
||||
nsDOMAttribute::GetProperty(nsIAtom* aPropertyName, nsresult* aStatus)
|
||||
{
|
||||
nsIDocument *doc = GetOwnerDoc();
|
||||
if (!doc)
|
||||
return nsnull;
|
||||
|
||||
return doc->PropertyTable()->GetProperty(this, aPropertyName, aStatus);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::SetProperty(nsIAtom *aPropertyName,
|
||||
void *aValue,
|
||||
NSPropertyDtorFunc aDtor)
|
||||
{
|
||||
nsIDocument *doc = GetOwnerDoc();
|
||||
if (!doc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return doc->PropertyTable()->SetProperty(this, aPropertyName, aValue, aDtor,
|
||||
nsnull);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::DeleteProperty(nsIAtom* aPropertyName)
|
||||
{
|
||||
nsIDocument *doc = GetOwnerDoc();
|
||||
if (!doc)
|
||||
return nsnull;
|
||||
|
||||
return doc->PropertyTable()->DeleteProperty(this, aPropertyName);
|
||||
}
|
||||
|
||||
void*
|
||||
nsDOMAttribute::UnsetProperty(nsIAtom* aPropertyName, nsresult* aStatus)
|
||||
{
|
||||
nsIDocument *doc = GetOwnerDoc();
|
||||
if (!doc)
|
||||
return nsnull;
|
||||
|
||||
return doc->PropertyTable()->UnsetProperty(this, aPropertyName, aStatus);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsAttributeChildList::nsAttributeChildList(nsDOMAttribute* aAttribute)
|
||||
|
|
|
@ -91,7 +91,17 @@ public:
|
|||
|
||||
// nsIAttribute interface
|
||||
void SetMap(nsDOMAttributeMap *aMap);
|
||||
nsIContent *GetContent();
|
||||
nsIContent *GetContent() const;
|
||||
|
||||
// Property functions, see nsPropertyTable.h
|
||||
virtual void* GetProperty(nsIAtom *aPropertyName,
|
||||
nsresult *aStatus = nsnull);
|
||||
virtual nsresult SetProperty(nsIAtom *aPropertyName,
|
||||
void *aValue,
|
||||
NSPropertyDtorFunc aDtor);
|
||||
virtual nsresult DeleteProperty(nsIAtom *aPropertyName);
|
||||
virtual void* UnsetProperty(nsIAtom *aPropertyName,
|
||||
nsresult *aStatus = nsnull);
|
||||
|
||||
private:
|
||||
nsString mValue;
|
||||
|
@ -100,7 +110,7 @@ private:
|
|||
nsIDOMText* mChild;
|
||||
nsAttributeChildList* mChildList;
|
||||
|
||||
nsIContent *GetContentInternal()
|
||||
nsIContent *GetContentInternal() const
|
||||
{
|
||||
return mAttrMap ? mAttrMap->GetContent() : nsnull;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче