Bug 1094531 - make nsNodeInfoManager skippable. r=smaug.

This commit is contained in:
Shih-Chiang Chien 2014-11-17 13:04:00 +01:00
parent fc2ececed6
commit 7cea0477fe
3 changed files with 43 additions and 6 deletions

View File

@ -28,6 +28,7 @@
#include "nsHashKeys.h"
#include "nsCCUncollectableMarker.h"
#include "nsNameSpaceManager.h"
#include "nsDocument.h"
using namespace mozilla;
using mozilla::dom::NodeInfo;
@ -153,11 +154,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsNodeInfoManager)
if (tmp->mDocument &&
nsCCUncollectableMarker::InGeneration(cb,
tmp->mDocument->GetMarkedCCGeneration())) {
return NS_SUCCESS_INTERRUPTED_TRAVERSE;
}
if (tmp->mNonDocumentNodeInfos) {
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mDocument)
}
@ -167,6 +163,24 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsNodeInfoManager, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsNodeInfoManager, Release)
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsNodeInfoManager)
if (tmp->mDocument) {
return NS_CYCLE_COLLECTION_PARTICIPANT(nsDocument)->CanSkip(tmp->mDocument, aRemovingAllowed);
}
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsNodeInfoManager)
if (tmp->mDocument) {
return NS_CYCLE_COLLECTION_PARTICIPANT(nsDocument)->CanSkipInCC(tmp->mDocument);
}
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsNodeInfoManager)
if (tmp->mDocument) {
return NS_CYCLE_COLLECTION_PARTICIPANT(nsDocument)->CanSkipThis(tmp->mDocument);
}
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
nsresult
nsNodeInfoManager::Init(nsIDocument *aDocument)
{

View File

@ -40,7 +40,7 @@ private:
public:
nsNodeInfoManager();
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsNodeInfoManager)
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_NATIVE_CLASS(nsNodeInfoManager)
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsNodeInfoManager)

View File

@ -713,6 +713,29 @@ static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
}; \
static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_NATIVE_CLASS(_class) \
void DeleteCycleCollectable(void) \
{ \
delete this; \
} \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public nsCycleCollectionParticipant \
{ \
public: \
MOZ_CONSTEXPR NS_CYCLE_COLLECTION_INNERCLASS () \
: nsCycleCollectionParticipant(true) {} \
private: \
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \
NS_IMETHOD_(bool) CanSkipReal(void *p, bool aRemovingAllowed); \
NS_IMETHOD_(bool) CanSkipInCCReal(void *p); \
NS_IMETHOD_(bool) CanSkipThisReal(void *p); \
static nsCycleCollectionParticipant* GetParticipant() \
{ \
return &_class::NS_CYCLE_COLLECTION_INNERNAME; \
} \
}; \
static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_NATIVE_CLASS_WITH_CUSTOM_DELETE(_class) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public nsCycleCollectionParticipant \