Bug 886408 - Move nsContentUtils::ReleaseWrapper into nsWrapperCache; r=mccr8

This commit is contained in:
Ms2ger 2013-08-02 09:04:01 +02:00
parent 061d88874c
commit 62183dfe63
14 changed files with 32 additions and 33 deletions

View File

@ -1278,9 +1278,6 @@ public:
mozilla::DeferredFinalizeFunction aFunc,
void* aThing);
static void ReleaseWrapper(void* aScriptObjectHolder,
nsWrapperCache* aCache);
/*
* Notify when the first XUL menu is opened and when the all XUL menus are
* closed. At opening, aInstalling should be TRUE, otherwise, it should be

View File

@ -989,7 +989,7 @@ FragmentOrElement::DestroyContent()
// XXX We really should let cycle collection do this, but that currently still
// leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684).
nsContentUtils::ReleaseWrapper(this, this);
ReleaseWrapper(this);
uint32_t i, count = mAttrsAndChildren.ChildCount();
for (i = 0; i < count; ++i) {

View File

@ -6290,24 +6290,6 @@ nsContentUtils::IsInPointerLockContext(nsIDOMWindow* aWin)
return top == lockTop;
}
// static
void
nsContentUtils::ReleaseWrapper(void* aScriptObjectHolder,
nsWrapperCache* aCache)
{
if (aCache->PreservingWrapper()) {
// PreserveWrapper puts new DOM bindings in the JS holders hash, but they
// can also be in the DOM expando hash, so we need to try to remove them
// from both here.
JSObject* obj = aCache->GetWrapperPreserveColor();
if (aCache->IsDOMBinding() && obj && js::IsProxy(obj)) {
DOMProxyHandler::GetAndClearExpandoObject(obj);
}
aCache->SetPreservingWrapper(false);
DropJSObjects(aScriptObjectHolder);
}
}
// static
int32_t
nsContentUtils::GetAdjustedOffsetInTextControl(nsIFrame* aOffsetFrame,

View File

@ -7788,7 +7788,7 @@ nsDocument::Destroy()
// XXX We really should let cycle collection do this, but that currently still
// leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684).
nsContentUtils::ReleaseWrapper(static_cast<nsINode*>(this), this);
ReleaseWrapper(static_cast<nsINode*>(this));
}
void

View File

@ -694,7 +694,7 @@ nsGenericDOMDataNode::DestroyContent()
{
// XXX We really should let cycle collection do this, but that currently still
// leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684).
nsContentUtils::ReleaseWrapper(this, this);
ReleaseWrapper(this);
}
#ifdef DEBUG

View File

@ -1254,9 +1254,9 @@ nsINode::Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb)
/* static */
void
nsINode::Unlink(nsINode *tmp)
nsINode::Unlink(nsINode* tmp)
{
nsContentUtils::ReleaseWrapper(tmp, tmp);
tmp->ReleaseWrapper(tmp);
nsSlots *slots = tmp->GetExistingSlots();
if (slots) {

View File

@ -260,7 +260,7 @@ nsInProcessTabChildGlobal::DelayedDisconnect()
}
if (!mLoadingScript) {
nsContentUtils::ReleaseWrapper(static_cast<EventTarget*>(this), this);
ReleaseWrapper(static_cast<EventTarget*>(this));
mGlobal = nullptr;
} else {
mDelayedDisconnect = true;

View File

@ -260,7 +260,7 @@ nsNodeUtils::LastRelease(nsINode* aNode)
}
}
nsContentUtils::ReleaseWrapper(aNode, aNode);
aNode->ReleaseWrapper(aNode);
}
struct MOZ_STACK_CLASS nsHandlerData

View File

@ -83,7 +83,7 @@ nsDOMEventTargetHelper::~nsDOMEventTargetHelper()
if (mListenerManager) {
mListenerManager->Disconnect();
}
nsContentUtils::ReleaseWrapper(this, this);
ReleaseWrapper(this);
}
void

View File

@ -6,6 +6,8 @@
#include "nsWrapperCacheInlines.h"
#include "jsproxy.h"
#include "mozilla/dom/DOMJSProxyHandler.h"
#include "nsCycleCollectionTraversalCallback.h"
#include "nsCycleCollector.h"
@ -19,6 +21,22 @@ nsWrapperCache::HoldJSObjects(void* aScriptObjectHolder,
cyclecollector::AddJSHolder(aScriptObjectHolder, aTracer);
}
void
nsWrapperCache::ReleaseWrapper(void* aScriptObjectHolder)
{
if (PreservingWrapper()) {
// PreserveWrapper puts new DOM bindings in the JS holders hash, but they
// can also be in the DOM expando hash, so we need to try to remove them
// from both here.
JSObject* obj = GetWrapperPreserveColor();
if (IsDOMBinding() && obj && js::IsProxy(obj)) {
DOMProxyHandler::GetAndClearExpandoObject(obj);
}
SetPreservingWrapper(false);
cyclecollector::RemoveJSHolder(aScriptObjectHolder);
}
}
#ifdef DEBUG
class DebugWrapperTraversalCallback : public nsCycleCollectionTraversalCallback

View File

@ -244,6 +244,8 @@ public:
#endif
}
void ReleaseWrapper(void* aScriptObjectHolder);
private:
JSObject *GetWrapperJSObject() const
{
@ -339,7 +341,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID)
tmp->TraceWrapper(aCallbacks, aClosure);
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER \
nsContentUtils::ReleaseWrapper(p, tmp);
tmp->ReleaseWrapper(p);
#define NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(_class) \
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_class) \

View File

@ -39,7 +39,7 @@ NS_IMPL_RELEASE_INHERITED(IDBWrapperCache, nsDOMEventTargetHelper)
IDBWrapperCache::~IDBWrapperCache()
{
mScriptOwner = nullptr;
nsContentUtils::ReleaseWrapper(this, this);
ReleaseWrapper(this);
NS_DROP_JS_OBJECTS(this, IDBWrapperCache);
}

View File

@ -1173,7 +1173,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMCSSStyleRule)
// Unlink the wrapper for our declaraton. This just expands out
// NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER which we can't use
// directly because the wrapper is on the declaration, not on us.
nsContentUtils::ReleaseWrapper(static_cast<nsISupports*>(p), tmp->DOMDeclaration());
tmp->DOMDeclaration()->ReleaseWrapper(static_cast<nsISupports*>(p));
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMCSSStyleRule)

View File

@ -1760,7 +1760,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSFontFaceRule)
// Unlink the wrapper for our declaraton. This just expands out
// NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER which we can't use
// directly because the wrapper is on the declaration, not on us.
nsContentUtils::ReleaseWrapper(static_cast<nsISupports*>(p), &tmp->mDecl);
tmp->mDecl.ReleaseWrapper(static_cast<nsISupports*>(p));
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSFontFaceRule)