Kill nsAttributeChildList and use nsChildContentList instead. b=360319 r/sr=jst

This commit is contained in:
cvshook%sicking.cc 2006-11-11 00:28:20 +00:00
Родитель 8a3dd57758
Коммит 9e116a126d
9 изменённых файлов: 50 добавлений и 124 удалений

Просмотреть файл

@ -55,6 +55,7 @@ class nsIEventListenerManager;
class nsIPrincipal;
class nsVoidArray;
class nsIMutationObserver;
class nsChildContentList;
// This bit will be set if the node doesn't have nsSlots
#define NODE_DOESNT_HAVE_SLOTS 0x00000001U
@ -548,15 +549,15 @@ public:
class nsSlots
{
public:
nsSlots(PtrBits aFlags) : mFlags(aFlags)
nsSlots(PtrBits aFlags)
: mFlags(aFlags),
mChildNodes(nsnull)
{
}
// If needed we could remove the vtable pointer this dtor causes by
// putting a DestroySlots function on nsINode
virtual ~nsSlots()
{
}
virtual ~nsSlots();
/**
* Storage for flags for this node. These are the same flags as the
@ -569,6 +570,15 @@ public:
* A list of mutation observers
*/
nsTObserverArray<nsIMutationObserver> mMutationObservers;
/**
* An object implementing nsIDOMNodeList for this content (childNodes)
* @see nsIDOMNodeList
* @see nsGenericHTMLElement::GetChildNodes
*
* MSVC 7 doesn't like this as an nsRefPtr
*/
nsChildContentList* mChildNodes;
};
#ifdef DEBUG

Просмотреть файл

@ -63,7 +63,7 @@ PRBool nsDOMAttribute::sInitialized;
nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap,
nsINodeInfo *aNodeInfo,
const nsAString &aValue)
: nsIAttribute(aAttrMap, aNodeInfo), mValue(aValue), mChildList(nsnull)
: nsIAttribute(aAttrMap, aNodeInfo), mValue(aValue)
{
NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!");
@ -72,15 +72,6 @@ nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap,
// to drop our reference when it goes away.
}
nsDOMAttribute::~nsDOMAttribute()
{
if (mChildList) {
mChildList->DropReference();
NS_RELEASE(mChildList);
}
}
// QueryInterface implementation for nsDOMAttribute
NS_INTERFACE_MAP_BEGIN(nsDOMAttribute)
NS_INTERFACE_MAP_ENTRY(nsIDOMAttr)
@ -267,14 +258,17 @@ nsDOMAttribute::GetParentNode(nsIDOMNode** aParentNode)
NS_IMETHODIMP
nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
{
if (!mChildList) {
mChildList = new nsAttributeChildList(this);
NS_ENSURE_TRUE(mChildList, NS_ERROR_OUT_OF_MEMORY);
nsSlots *slots = GetSlots();
NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(mChildList);
if (!slots->mChildNodes) {
slots->mChildNodes = new nsChildContentList(this);
NS_ENSURE_TRUE(slots->mChildNodes, NS_ERROR_OUT_OF_MEMORY);
}
return CallQueryInterface(mChildList, aChildNodes);
NS_ADDREF(*aChildNodes = slots->mChildNodes);
return NS_OK;
}
NS_IMETHODIMP
@ -785,41 +779,3 @@ nsDOMAttribute::Shutdown()
{
sInitialized = PR_FALSE;
}
//----------------------------------------------------------------------
nsAttributeChildList::nsAttributeChildList(nsDOMAttribute* aAttribute)
{
// Don't increment the reference count. The attribute will tell
// us when it's going away
mAttribute = aAttribute;
}
nsAttributeChildList::~nsAttributeChildList()
{
}
NS_IMETHODIMP
nsAttributeChildList::GetLength(PRUint32* aLength)
{
*aLength = mAttribute ? mAttribute->GetChildCount() : 0;
return NS_OK;
}
NS_IMETHODIMP
nsAttributeChildList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{
*aReturn = nsnull;
if (mAttribute && 0 == aIndex) {
mAttribute->GetFirstChild(aReturn);
}
return NS_OK;
}
void
nsAttributeChildList::DropReference()
{
mAttribute = nsnull;
}

Просмотреть файл

@ -56,23 +56,6 @@
class nsDOMAttribute;
// bogus child list for an attribute
class nsAttributeChildList : public nsGenericDOMNodeList
{
public:
nsAttributeChildList(nsDOMAttribute* aAttribute);
virtual ~nsAttributeChildList();
// interface nsIDOMNodeList
NS_IMETHOD GetLength(PRUint32* aLength);
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
void DropReference();
protected:
nsDOMAttribute* mAttribute;
};
// Attribute helper class used to wrap up an attribute with a dom
// object that implements nsIDOMAttr, nsIDOM3Attr, nsIDOMNode, nsIDOM3Node
class nsDOMAttribute : public nsIDOMAttr,
@ -82,7 +65,6 @@ class nsDOMAttribute : public nsIDOMAttr,
public:
nsDOMAttribute(nsDOMAttributeMap* aAttrMap, nsINodeInfo *aNodeInfo,
const nsAString& aValue);
virtual ~nsDOMAttribute();
NS_DECL_ISUPPORTS
@ -136,7 +118,6 @@ private:
// XXX For now, there's only a single child - a text
// element representing the value
nsCOMPtr<nsIContent> mChild;
nsAttributeChildList* mChildList;
nsIContent *GetContentInternal() const
{

Просмотреть файл

@ -718,10 +718,6 @@ nsDocument::~nsDocument()
if (mStyleAttrStyleSheet)
mStyleAttrStyleSheet->SetOwningDocument(nsnull);
if (mChildNodes) {
mChildNodes->DropReference();
}
if (mListenerManager) {
mListenerManager->Disconnect();
}
@ -3401,14 +3397,17 @@ nsDocument::GetParentNode(nsIDOMNode** aParentNode)
NS_IMETHODIMP
nsDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
{
if (!mChildNodes) {
mChildNodes = new nsChildContentList(this);
if (!mChildNodes) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsSlots *slots = GetSlots();
NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
if (!slots->mChildNodes) {
slots->mChildNodes = new nsChildContentList(this);
NS_ENSURE_TRUE(slots->mChildNodes, NS_ERROR_OUT_OF_MEMORY);
}
return CallQueryInterface(mChildNodes.get(), aChildNodes);
NS_ADDREF(*aChildNodes = slots->mChildNodes);
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -732,8 +732,6 @@ protected:
nsRefPtr<nsScriptLoader> mScriptLoader;
nsDocHeaderData* mHeaderData;
nsRefPtr<nsChildContentList> mChildNodes;
nsHashtable mRadioGroups;
// True if the document has been detached from its content viewer.

Просмотреть файл

@ -65,19 +65,6 @@
#include "pldhash.h"
#include "prprf.h"
nsGenericDOMDataNode::nsDataSlots::nsDataSlots(PtrBits aFlags)
: nsINode::nsSlots(aFlags),
mBindingParent(nsnull)
{
}
nsGenericDOMDataNode::nsDataSlots::~nsDataSlots()
{
if (mChildNodes) {
mChildNodes->DropReference();
}
}
nsGenericDOMDataNode::nsGenericDOMDataNode(nsINodeInfo *aNodeInfo)
: nsIContent(aNodeInfo)
{
@ -95,8 +82,9 @@ NS_IMPL_RELEASE_WITH_DESTROY(nsGenericDOMDataNode,
nsNodeUtils::LastRelease(this, PR_TRUE))
NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
NS_INTERFACE_MAP_ENTRY(nsIContent)
NS_INTERFACE_MAP_ENTRY(nsIDOMGCParticipant)
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventReceiver,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget,
@ -105,9 +93,8 @@ NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY(nsIContent)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
NS_INTERFACE_MAP_END

Просмотреть файл

@ -274,14 +274,11 @@ protected:
class nsDataSlots : public nsINode::nsSlots
{
public:
nsDataSlots(PtrBits aFlags);
virtual ~nsDataSlots();
/**
* An object implementing nsIDOMNodeList for this content (childNodes)
* @see nsIDOMNodeList
*/
nsRefPtr<nsChildContentList> mChildNodes;
nsDataSlots(PtrBits aFlags)
: nsINode::nsSlots(aFlags),
mBindingParent(nsnull)
{
}
/**
* The nearest enclosing content node with a binding that created us.

Просмотреть файл

@ -135,8 +135,17 @@ DebugListContentTree(nsIContent* aElement)
PRInt32 nsIContent::sTabFocusModel = eTabFocus_any;
PRBool nsIContent::sTabFocusModelAppliesToXUL = PR_FALSE;
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
//----------------------------------------------------------------------
nsINode::nsSlots::~nsSlots()
{
if (mChildNodes) {
mChildNodes->DropReference();
NS_RELEASE(mChildNodes);
}
}
//----------------------------------------------------------------------
nsINode::~nsINode()
@ -876,10 +885,6 @@ nsGenericElement::nsDOMSlots::nsDOMSlots(PtrBits aFlags)
nsGenericElement::nsDOMSlots::~nsDOMSlots()
{
if (mChildNodes) {
mChildNodes->DropReference();
}
if (mStyle) {
mStyle->DropReference();
}
@ -1228,7 +1233,7 @@ nsGenericElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
nsresult
nsGenericElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
{
nsDOMSlots *slots = GetDOMSlots();
nsSlots *slots = GetSlots();
if (!slots) {
return NS_ERROR_OUT_OF_MEMORY;

Просмотреть файл

@ -881,13 +881,6 @@ public:
nsDOMSlots(PtrBits aFlags);
virtual ~nsDOMSlots();
/**
* An object implementing nsIDOMNodeList for this content (childNodes)
* @see nsIDOMNodeList
* @see nsGenericHTMLElement::GetChildNodes
*/
nsRefPtr<nsChildContentList> mChildNodes;
/**
* The .style attribute (an interface that forwards to the actual
* style rules)