Bug 823348 - Uninline UniversalXPConnect management. r=mrbkap

Every time the layout of CompartmentPrivate changes, I forget to rebuild in
caps/ and spend half an hour wondering what the heck is going on. :-(
This commit is contained in:
Bobby Holley 2013-01-23 06:04:38 +01:00
parent a5faa58c98
commit 71cfd0816b
2 changed files with 38 additions and 31 deletions

View File

@ -232,6 +232,41 @@ EnsureCompartmentPrivate(JSObject *obj)
return priv;
}
bool
IsUniversalXPConnectEnabled(JSCompartment *compartment)
{
CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
if (!priv)
return false;
return priv->universalXPConnectEnabled;
}
bool
IsUniversalXPConnectEnabled(JSContext *cx)
{
JSCompartment *compartment = js::GetContextCompartment(cx);
if (!compartment)
return false;
return IsUniversalXPConnectEnabled(compartment);
}
bool
EnableUniversalXPConnect(JSContext *cx)
{
JSCompartment *compartment = js::GetContextCompartment(cx);
if (!compartment)
return true;
CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
if (!priv)
return true;
priv->universalXPConnectEnabled = true;
// Recompute all the cross-compartment wrappers leaving the newly-privileged
// compartment.
return js::RecomputeWrappers(cx, js::SingleCompartment(compartment),
js::AllCompartments());
}
}
static void

View File

@ -4361,37 +4361,9 @@ GetCompartmentPrivate(JSObject *object)
return GetCompartmentPrivate(compartment);
}
inline bool IsUniversalXPConnectEnabled(JSCompartment *compartment)
{
CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
if (!priv)
return false;
return priv->universalXPConnectEnabled;
}
inline bool IsUniversalXPConnectEnabled(JSContext *cx)
{
JSCompartment *compartment = js::GetContextCompartment(cx);
if (!compartment)
return false;
return IsUniversalXPConnectEnabled(compartment);
}
inline bool EnableUniversalXPConnect(JSContext *cx)
{
JSCompartment *compartment = js::GetContextCompartment(cx);
if (!compartment)
return true;
CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
if (!priv)
return true;
priv->universalXPConnectEnabled = true;
// Recompute all the cross-compartment wrappers leaving the newly-privileged
// compartment.
return js::RecomputeWrappers(cx, js::SingleCompartment(compartment),
js::AllCompartments());
}
bool IsUniversalXPConnectEnabled(JSCompartment *compartment);
bool IsUniversalXPConnectEnabled(JSContext *cx);
bool EnableUniversalXPConnect(JSContext *cx);
// This returns null if and only if it is called on an object in a non-XPConnect
// compartment.