Backed out changeset 1ca5723f69d4 (bug 1186780) for dom crashes

This commit is contained in:
Carsten "Tomcat" Book 2015-07-27 08:01:09 +02:00
parent 3c65c2febb
commit 32eafbd4af
6 changed files with 95 additions and 20 deletions

View File

@ -28,11 +28,11 @@ DataContainerEvent::DataContainerEvent(EventTarget* aOwner,
NS_IMPL_CYCLE_COLLECTION_CLASS(DataContainerEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DataContainerEvent, Event)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
tmp->mData.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DataContainerEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
tmp->mData.EnumerateRead(TraverseEntry, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_ADDREF_INHERITED(DataContainerEvent, Event)
@ -81,6 +81,18 @@ 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

View File

@ -51,6 +51,9 @@ protected:
~DataContainerEvent() {}
private:
static PLDHashOperator
TraverseEntry(const nsAString& aKey, nsIVariant* aDataItem, void* aUserArg);
nsInterfaceHashtable<nsStringHashKey, nsIVariant> mData;
};

View File

@ -39,14 +39,42 @@ 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) {
for (auto iter = tmp->mBindingTable->ConstIter();
!iter.Done(); iter.Next()) {
iter.UserData()->Unlink();
}
tmp->mBindingTable->EnumerateRead(UnlinkProto, nullptr);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -58,19 +86,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXBLDocumentInfo)
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
if (tmp->mBindingTable) {
for (auto iter = tmp->mBindingTable->ConstIter();
!iter.Done(); iter.Next()) {
iter.UserData()->Traverse(cb);
}
tmp->mBindingTable->EnumerateRead(TraverseProtos, &cb);
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsXBLDocumentInfo)
if (tmp->mBindingTable) {
for (auto iter = tmp->mBindingTable->ConstIter();
!iter.Done(); iter.Next()) {
iter.UserData()->Trace(aCallbacks, aClosure);
}
ProtoTracer closure = { aCallbacks, aClosure };
tmp->mBindingTable->EnumerateRead(TraceProtos, &closure);
}
NS_IMPL_CYCLE_COLLECTION_TRACE_END

View File

@ -343,6 +343,41 @@ 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
//

View File

@ -69,9 +69,10 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
const char* aName,
uint32_t aFlags = 0)
{
for (auto iter = aField.ConstIter(); !iter.Done(); iter.Next()) {
CycleCollectionNoteChild(aCallback, iter.UserData(), aName, aFlags);
}
nsBaseHashtableCCTraversalData userData(aCallback, aName, aFlags);
aField.EnumerateRead(ImplCycleCollectionTraverse_EnumFunc<typename K::KeyType, T*>,
&userData);
}
//

View File

@ -84,9 +84,10 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
const char* aName,
uint32_t aFlags = 0)
{
for (auto iter = aField.ConstIter(); !iter.Done(); iter.Next()) {
CycleCollectionNoteChild(aCallback, iter.UserData(), aName, aFlags);
}
nsBaseHashtableCCTraversalData userData(aCallback, aName, aFlags);
aField.EnumerateRead(ImplCycleCollectionTraverse_EnumFunc<typename K::KeyType, T*>,
&userData);
}
//