mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 973780 - Implement an expando WeakMap on XPCWrappedNativeScope. r=mccr8
This commit is contained in:
parent
905f063f82
commit
39dc4e0757
@ -302,6 +302,9 @@ XPCWrappedNativeScope::~XPCWrappedNativeScope()
|
||||
// XXX might not want to do this at xpconnect shutdown time???
|
||||
mComponents = nullptr;
|
||||
|
||||
if (mXrayExpandos.initialized())
|
||||
mXrayExpandos.destroy();
|
||||
|
||||
JSRuntime *rt = XPCJSRuntime::Get()->Runtime();
|
||||
mXBLScope.finalize(rt);
|
||||
mGlobalJSObject.finalize(rt);
|
||||
@ -599,6 +602,27 @@ XPCWrappedNativeScope::RemoveWrappedNativeProtos()
|
||||
GetRuntime()->GetDetachedWrappedNativeProtoMap());
|
||||
}
|
||||
|
||||
JSObject *
|
||||
XPCWrappedNativeScope::GetExpandoChain(JSObject *target)
|
||||
{
|
||||
MOZ_ASSERT(GetObjectScope(target) == this);
|
||||
if (!mXrayExpandos.initialized())
|
||||
return nullptr;
|
||||
return mXrayExpandos.lookup(target);
|
||||
}
|
||||
|
||||
bool
|
||||
XPCWrappedNativeScope::SetExpandoChain(JSContext *cx, HandleObject target,
|
||||
HandleObject chain)
|
||||
{
|
||||
MOZ_ASSERT(GetObjectScope(target) == this);
|
||||
MOZ_ASSERT(js::IsObjectInContextCompartment(target, cx));
|
||||
MOZ_ASSERT_IF(chain, GetObjectScope(chain) == this);
|
||||
if (!mXrayExpandos.initialized() && !mXrayExpandos.init(cx))
|
||||
return false;
|
||||
return mXrayExpandos.put(target, chain);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
// static
|
||||
|
@ -90,6 +90,7 @@
|
||||
|
||||
#include "xpcpublic.h"
|
||||
#include "js/Tracer.h"
|
||||
#include "js/WeakMapPtr.h"
|
||||
#include "pldhash.h"
|
||||
#include "nscore.h"
|
||||
#include "nsXPCOM.h"
|
||||
@ -1036,6 +1037,12 @@ public:
|
||||
return nsJSPrincipals::get(JS_GetCompartmentPrincipals(c));
|
||||
}
|
||||
|
||||
JSObject*
|
||||
GetExpandoChain(JSObject *target);
|
||||
|
||||
bool
|
||||
SetExpandoChain(JSContext *cx, JS::HandleObject target, JS::HandleObject chain);
|
||||
|
||||
void RemoveWrappedNativeProtos();
|
||||
|
||||
static void
|
||||
@ -1049,6 +1056,8 @@ public:
|
||||
mGlobalJSObject.trace(trc, "XPCWrappedNativeScope::mGlobalJSObject");
|
||||
if (mXBLScope)
|
||||
mXBLScope.trace(trc, "XPCWrappedNativeScope::mXBLScope");
|
||||
if (mXrayExpandos.initialized())
|
||||
mXrayExpandos.trace(trc);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1168,6 +1177,8 @@ private:
|
||||
|
||||
nsAutoPtr<DOMExpandoSet> mDOMExpandoSet;
|
||||
|
||||
JS::WeakMapPtr<JSObject*, JSObject*> mXrayExpandos;
|
||||
|
||||
bool mIsXBLScope;
|
||||
|
||||
// For remote XUL domains, we run all XBL in the content scope for compat
|
||||
|
Loading…
Reference in New Issue
Block a user