mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 797821 - Allow compartment privates to be lazily created when using them just for storing about:memory URIs. r=mrbkap
This will allow us to stop making nsXULPrototypeDocument and nsXBLDocumentInfo globals XPConnect globals.
This commit is contained in:
parent
826ce1e16b
commit
d6ecaf26fe
@ -213,11 +213,27 @@ ContextCallback(JSContext *cx, unsigned operation)
|
||||
return true;
|
||||
}
|
||||
|
||||
xpc::CompartmentPrivate::~CompartmentPrivate()
|
||||
namespace xpc {
|
||||
|
||||
CompartmentPrivate::~CompartmentPrivate()
|
||||
{
|
||||
MOZ_COUNT_DTOR(xpc::CompartmentPrivate);
|
||||
}
|
||||
|
||||
CompartmentPrivate*
|
||||
EnsureCompartmentPrivate(JSObject *obj)
|
||||
{
|
||||
JSCompartment *c = js::GetObjectCompartment(obj);
|
||||
CompartmentPrivate *priv = GetCompartmentPrivate(c);
|
||||
if (priv)
|
||||
return priv;
|
||||
priv = new CompartmentPrivate();
|
||||
JS_SetCompartmentPrivate(c, priv);
|
||||
return priv;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
CompartmentDestroyedCallback(JSFreeOp *fop, JSCompartment *compartment)
|
||||
{
|
||||
|
@ -1087,8 +1087,8 @@ CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal)
|
||||
JSObject *global = JS_NewGlobalObject(cx, clasp, nsJSPrincipals::get(principal));
|
||||
if (!global)
|
||||
return nullptr;
|
||||
EnsureCompartmentPrivate(global);
|
||||
JSCompartment *compartment = js::GetObjectCompartment(global);
|
||||
JS_SetCompartmentPrivate(compartment, new xpc::CompartmentPrivate());
|
||||
|
||||
XPCCompartmentSet& set = nsXPConnect::GetRuntimeInstance()->GetCompartmentSet();
|
||||
if (!set.put(compartment))
|
||||
@ -2403,22 +2403,14 @@ void
|
||||
SetLocationForGlobal(JSObject *global, const nsACString& location)
|
||||
{
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
CompartmentPrivate *priv = GetCompartmentPrivate(global);
|
||||
MOZ_ASSERT(priv, "No compartment private");
|
||||
|
||||
priv->SetLocation(location);
|
||||
EnsureCompartmentPrivate(global)->SetLocation(location);
|
||||
}
|
||||
|
||||
void
|
||||
SetLocationForGlobal(JSObject *global, nsIURI *locationURI)
|
||||
{
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
CompartmentPrivate *priv = GetCompartmentPrivate(global);
|
||||
MOZ_ASSERT(priv, "No compartment private");
|
||||
|
||||
priv->SetLocation(locationURI);
|
||||
EnsureCompartmentPrivate(global)->SetLocation(locationURI);
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
@ -4382,6 +4382,9 @@ private:
|
||||
nsCOMPtr<nsIURI> locationURI;
|
||||
};
|
||||
|
||||
CompartmentPrivate*
|
||||
EnsureCompartmentPrivate(JSObject *obj);
|
||||
|
||||
inline CompartmentPrivate*
|
||||
GetCompartmentPrivate(JSCompartment *compartment)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user