From 9bf329bcdd20b6669a63b1b8408df7f854dd9a3a Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Mon, 30 Apr 2012 15:54:16 -0700 Subject: [PATCH] Bug 750424 - Make nsXULPrototypeNode an nsISupports (r=smaug) --- content/xul/content/src/nsXULElement.cpp | 23 +++++++++++-------- content/xul/content/src/nsXULElement.h | 17 +++----------- .../document/src/nsXULPrototypeDocument.cpp | 3 +-- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index b3e2781cc981..ff7c50a5d6c0 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -371,8 +371,7 @@ NS_TrustedNewXULElement(nsIContent** aResult, already_AddRefed aNod NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULElement, nsStyledElement) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mPrototype, - nsXULPrototypeElement) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrototype) { nsXULSlots* slots = static_cast(tmp->GetExistingSlots()); if (slots) { @@ -2526,7 +2525,7 @@ nsXULElement::RecompileScriptEventListeners() } NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULPrototypeNode) -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(nsXULPrototypeNode) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULPrototypeNode) if (tmp->mType == nsXULPrototypeNode::eType_Element) { static_cast(tmp)->Unlink(); } @@ -2534,7 +2533,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(nsXULPrototypeNode) static_cast(tmp)->UnlinkJSObjects(); } NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_BEGIN(nsXULPrototypeNode) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULPrototypeNode) if (tmp->mType == nsXULPrototypeNode::eType_Element) { nsXULPrototypeElement *elem = static_cast(tmp); @@ -2550,14 +2549,13 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_BEGIN(nsXULPrototypeNode) } } for (i = 0; i < elem->mChildren.Length(); ++i) { - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR(elem->mChildren[i].get(), - nsXULPrototypeNode, - "mChildren[i]") + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChildren[i]"); + cb.NoteXPCOMChild(elem->mChildren[i]); } } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(nsXULPrototypeNode) +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsXULPrototypeNode) if (tmp->mType == nsXULPrototypeNode::eType_Element) { nsXULPrototypeElement *elem = static_cast(tmp); @@ -2577,8 +2575,13 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(nsXULPrototypeNode) "mScriptObject.mObject") } NS_IMPL_CYCLE_COLLECTION_TRACE_END -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsXULPrototypeNode, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsXULPrototypeNode, Release) + +NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXULPrototypeNode) +NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXULPrototypeNode) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULPrototypeNode) + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END //---------------------------------------------------------------------- // diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index 958546c5844d..551c6dc70b1c 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -187,14 +187,14 @@ public: */ -class nsXULPrototypeNode +class nsXULPrototypeNode : public nsISupports { public: enum Type { eType_Element, eType_Script, eType_Text, eType_PI }; Type mType; - nsAutoRefCnt mRefCnt; + NS_DECL_CYCLE_COLLECTING_ISUPPORTS virtual ~nsXULPrototypeNode() {} virtual nsresult Serialize(nsIObjectOutputStream* aStream, @@ -210,17 +210,6 @@ public: virtual PRUint32 ClassSize() = 0; #endif - void AddRef() { - ++mRefCnt; - NS_LOG_ADDREF(this, mRefCnt, ClassName(), ClassSize()); - } - void Release() - { - --mRefCnt; - NS_LOG_RELEASE(this, mRefCnt, ClassName()); - if (mRefCnt == 0) - delete this; - } /** * The prototype document must call ReleaseSubtree when it is going * away. This makes the parents through the tree stop owning their @@ -231,7 +220,7 @@ public: */ virtual void ReleaseSubtree() { } - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsXULPrototypeNode) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsXULPrototypeNode) protected: nsXULPrototypeNode(Type aType) diff --git a/content/xul/document/src/nsXULPrototypeDocument.cpp b/content/xul/document/src/nsXULPrototypeDocument.cpp index e0321082db2f..7c0c980af922 100644 --- a/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -204,8 +204,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULPrototypeDocument) if (nsCCUncollectableMarker::InGeneration(cb, tmp->mCCGeneration)) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mRoot, - nsXULPrototypeElement) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRoot) NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mGlobalObject"); cb.NoteXPCOMChild(static_cast(tmp->mGlobalObject)); NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mNodeInfoManager,