mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1377999 - Make nsIContent to declare a final DeleteCycleCollectable r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D63263 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
91fd21bfd1
commit
053f3e648d
@ -144,8 +144,11 @@ NS_INTERFACE_MAP_BEGIN(nsIContent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(nsIContent)
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(
|
||||
nsIContent, LastRelease())
|
||||
|
||||
NS_IMPL_DOMARENA_DESTROY(nsIContent)
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE_AND_DESTROY(
|
||||
nsIContent, LastRelease(), Destroy())
|
||||
|
||||
nsIContent* nsIContent::FindFirstNonChromeOnlyAccessContent() const {
|
||||
// This handles also nested native anonymous content.
|
||||
|
@ -75,9 +75,12 @@ class nsIContent : public nsINode {
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS_FINAL_DELETECYCLECOLLECTABLE
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(nsIContent)
|
||||
|
||||
NS_DECL_DOMARENA_DESTROY
|
||||
|
||||
NS_IMPL_FROMNODE_HELPER(nsIContent, IsContent())
|
||||
|
||||
/**
|
||||
|
@ -936,6 +936,31 @@ class ThreadSafeAutoRefCnt {
|
||||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { delete this; }
|
||||
|
||||
// _LAST_RELEASE can be useful when certain resources should be released
|
||||
// as soon as we know the object will be deleted.
|
||||
#define NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE_AND_DESTROY( \
|
||||
_class, _last, _destroy) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
bool shouldDelete = false; \
|
||||
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
||||
nsrefcnt count = mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>( \
|
||||
base, &shouldDelete); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
if (count == 0) { \
|
||||
mRefCnt.incr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
_last; \
|
||||
mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
if (shouldDelete) { \
|
||||
mRefCnt.stabilizeForDeletion(); \
|
||||
DeleteCycleCollectable(); \
|
||||
} \
|
||||
} \
|
||||
return count; \
|
||||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { _destroy; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user