Bug 823348 - Use EnsureCompartmentPrivate In Rewrap and stop checking for null. r=mrbkap

This commit is contained in:
Bobby Holley 2013-01-23 06:04:39 +01:00
parent 72ddba04a7
commit 1aedd25af4
3 changed files with 12 additions and 5 deletions

View File

@ -223,7 +223,12 @@ CompartmentPrivate::~CompartmentPrivate()
CompartmentPrivate*
EnsureCompartmentPrivate(JSObject *obj)
{
JSCompartment *c = js::GetObjectCompartment(obj);
return EnsureCompartmentPrivate(js::GetObjectCompartment(obj));
}
CompartmentPrivate*
EnsureCompartmentPrivate(JSCompartment *c)
{
CompartmentPrivate *priv = GetCompartmentPrivate(c);
if (priv)
return priv;

View File

@ -4342,6 +4342,9 @@ private:
CompartmentPrivate*
EnsureCompartmentPrivate(JSObject *obj);
CompartmentPrivate*
EnsureCompartmentPrivate(JSCompartment *c);
inline CompartmentPrivate*
GetCompartmentPrivate(JSCompartment *compartment)
{

View File

@ -335,7 +335,7 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *existing, JSObject *obj,
JSObject *proxyProto = wrappedProto;
Wrapper *wrapper;
CompartmentPrivate *targetdata = GetCompartmentPrivate(target);
CompartmentPrivate *targetdata = EnsureCompartmentPrivate(target);
if (AccessCheck::isChrome(target)) {
if (AccessCheck::isChrome(origin)) {
wrapper = &CrossCompartmentWrapper::singleton;
@ -368,8 +368,7 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *existing, JSObject *obj,
}
XPCWrappedNative *wn;
if (targetdata &&
(wn = GetWrappedNative(cx, obj)) &&
if ((wn = GetWrappedNative(cx, obj)) &&
wn->HasProto() && wn->GetProto()->ClassIsDOMObject()) {
wrapper = &FilteringWrapper<SecurityXrayXPCWN, CrossOriginAccessiblePropertiesOnly>::singleton;
} else if (mozilla::dom::UseDOMXray(obj)) {
@ -429,7 +428,7 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *existing, JSObject *obj,
} else if (IsComponentsObject(obj)) {
wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper,
ComponentsObjectPolicy>::singleton;
} else if (!targetdata || !targetdata->wantXrays ||
} else if (!targetdata->wantXrays ||
(type = GetXrayType(obj)) == NotXray) {
wrapper = &CrossCompartmentWrapper::singleton;
} else if (type == XrayForDOMObject) {