mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1186780: Replace EnumerateRead with new iterators in cycle collection code. r=mccr8
This commit is contained in:
parent
8c51fea88e
commit
ebd7c7a59e
@ -28,11 +28,11 @@ DataContainerEvent::DataContainerEvent(EventTarget* aOwner,
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(DataContainerEvent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DataContainerEvent, Event)
|
||||
tmp->mData.Clear();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DataContainerEvent, Event)
|
||||
tmp->mData.EnumerateRead(TraverseEntry, &cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(DataContainerEvent, Event)
|
||||
@ -81,18 +81,6 @@ DataContainerEvent::SetData(JSContext* aCx, const nsAString& aKey,
|
||||
aRv = SetData(aKey, val);
|
||||
}
|
||||
|
||||
PLDHashOperator
|
||||
DataContainerEvent::TraverseEntry(const nsAString& aKey,
|
||||
nsIVariant* aDataItem,
|
||||
void* aUserArg)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(aUserArg);
|
||||
cb->NoteXPCOMChild(aDataItem);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -51,9 +51,6 @@ protected:
|
||||
~DataContainerEvent() {}
|
||||
|
||||
private:
|
||||
static PLDHashOperator
|
||||
TraverseEntry(const nsAString& aKey, nsIVariant* aDataItem, void* aUserArg);
|
||||
|
||||
nsInterfaceHashtable<nsStringHashKey, nsIVariant> mData;
|
||||
};
|
||||
|
||||
|
@ -39,42 +39,14 @@ using namespace mozilla::dom;
|
||||
static const char kXBLCachePrefix[] = "xblcache";
|
||||
|
||||
/* Implementation file */
|
||||
|
||||
static PLDHashOperator
|
||||
TraverseProtos(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
|
||||
aProto->Traverse(*cb);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
UnlinkProto(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
||||
{
|
||||
aProto->Unlink();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
struct ProtoTracer
|
||||
{
|
||||
const TraceCallbacks &mCallbacks;
|
||||
void *mClosure;
|
||||
};
|
||||
|
||||
static PLDHashOperator
|
||||
TraceProtos(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
||||
{
|
||||
ProtoTracer* closure = static_cast<ProtoTracer*>(aClosure);
|
||||
aProto->Trace(closure->mCallbacks, closure->mClosure);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXBLDocumentInfo)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXBLDocumentInfo)
|
||||
if (tmp->mBindingTable) {
|
||||
tmp->mBindingTable->EnumerateRead(UnlinkProto, nullptr);
|
||||
for (auto iter = tmp->mBindingTable->ConstIter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
iter.UserData()->Unlink();
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
@ -86,14 +58,19 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXBLDocumentInfo)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
|
||||
if (tmp->mBindingTable) {
|
||||
tmp->mBindingTable->EnumerateRead(TraverseProtos, &cb);
|
||||
for (auto iter = tmp->mBindingTable->ConstIter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
iter.UserData()->Traverse(cb);
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsXBLDocumentInfo)
|
||||
if (tmp->mBindingTable) {
|
||||
ProtoTracer closure = { aCallbacks, aClosure };
|
||||
tmp->mBindingTable->EnumerateRead(TraceProtos, &closure);
|
||||
for (auto iter = tmp->mBindingTable->ConstIter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
iter.UserData()->Trace(aCallbacks, aClosure);
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
|
@ -343,41 +343,6 @@ protected:
|
||||
void* aArg);
|
||||
};
|
||||
|
||||
class nsCycleCollectionTraversalCallback;
|
||||
|
||||
struct MOZ_STACK_CLASS nsBaseHashtableCCTraversalData
|
||||
{
|
||||
nsBaseHashtableCCTraversalData(nsCycleCollectionTraversalCallback& aCallback,
|
||||
const char* aName,
|
||||
uint32_t aFlags)
|
||||
: mCallback(aCallback)
|
||||
, mName(aName)
|
||||
, mFlags(aFlags)
|
||||
{
|
||||
}
|
||||
|
||||
nsCycleCollectionTraversalCallback& mCallback;
|
||||
const char* mName;
|
||||
uint32_t mFlags;
|
||||
|
||||
};
|
||||
|
||||
template<typename K, typename T>
|
||||
PLDHashOperator
|
||||
ImplCycleCollectionTraverse_EnumFunc(K aKey,
|
||||
T aData,
|
||||
void* aUserData)
|
||||
{
|
||||
nsBaseHashtableCCTraversalData* userData =
|
||||
static_cast<nsBaseHashtableCCTraversalData*>(aUserData);
|
||||
|
||||
CycleCollectionNoteChild(userData->mCallback,
|
||||
aData,
|
||||
userData->mName,
|
||||
userData->mFlags);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
//
|
||||
// nsBaseHashtableET definitions
|
||||
//
|
||||
|
@ -69,10 +69,9 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
|
||||
const char* aName,
|
||||
uint32_t aFlags = 0)
|
||||
{
|
||||
nsBaseHashtableCCTraversalData userData(aCallback, aName, aFlags);
|
||||
|
||||
aField.EnumerateRead(ImplCycleCollectionTraverse_EnumFunc<typename K::KeyType, T*>,
|
||||
&userData);
|
||||
for (auto iter = aField.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
CycleCollectionNoteChild(aCallback, iter.UserData(), aName, aFlags);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -84,10 +84,9 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
|
||||
const char* aName,
|
||||
uint32_t aFlags = 0)
|
||||
{
|
||||
nsBaseHashtableCCTraversalData userData(aCallback, aName, aFlags);
|
||||
|
||||
aField.EnumerateRead(ImplCycleCollectionTraverse_EnumFunc<typename K::KeyType, T*>,
|
||||
&userData);
|
||||
for (auto iter = aField.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
CycleCollectionNoteChild(aCallback, iter.UserData(), aName, aFlags);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user