Bug 991742 part 3. Remove the "scope" argument of WrapNativeParent(). r=bholley

This commit is contained in:
Boris Zbarsky 2014-04-08 18:27:15 -04:00
parent 82846a8e3e
commit 9f72e9c2b1
2 changed files with 11 additions and 9 deletions

View File

@ -1356,12 +1356,11 @@ struct WrapNativeParentHelper<T, false >
// Wrapping of our native parent.
template<typename T>
static inline JSObject*
WrapNativeParent(JSContext* cx, JS::Handle<JSObject*> scope, T* p,
nsWrapperCache* cache, bool useXBLScope = false)
WrapNativeParent(JSContext* cx, T* p, nsWrapperCache* cache,
bool useXBLScope = false)
{
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
if (!p) {
return scope;
return JS::CurrentGlobalOrNull(cx);
}
JSObject* parent = WrapNativeParentHelper<T>::Wrap(cx, p, cache);
@ -1388,9 +1387,9 @@ WrapNativeParent(JSContext* cx, JS::Handle<JSObject*> scope, T* p,
// things like the nsWrapperCache for it.
template<typename T>
static inline JSObject*
WrapNativeParent(JSContext* cx, JS::Handle<JSObject*> scope, const T& p)
WrapNativeParent(JSContext* cx, const T& p)
{
return WrapNativeParent(cx, scope, GetParentPointer(p), GetWrapperCache(p), GetUseXBLScope(p));
return WrapNativeParent(cx, GetParentPointer(p), GetWrapperCache(p), GetUseXBLScope(p));
}
// A way to differentiate between nodes, which use the parent object
@ -1416,10 +1415,11 @@ struct GetParentObject
{
static JSObject* Get(JSContext* cx, JS::Handle<JSObject*> obj)
{
MOZ_ASSERT(js::IsObjectInContextCompartment(obj, cx));
T* native = UnwrapDOMObject<T>(obj);
return
GetRealParentObject(native,
WrapNativeParent(cx, obj, native->GetParentObject()));
WrapNativeParent(cx, native->GetParentObject()));
}
};
@ -1456,7 +1456,8 @@ WrapCallThisObject(JSContext* cx, JS::Handle<JSObject*> scope, const T& p)
if (!obj) {
// WrapNativeParent is a bit of a Swiss army knife that will
// wrap anything for us.
obj = WrapNativeParent(cx, scope, p);
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
obj = WrapNativeParent(cx, p);
if (!obj) {
return nullptr;
}

View File

@ -2705,9 +2705,10 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
' "nsISupports must be on our primary inheritance chain");\n')
return """%s
%s
MOZ_ASSERT(js::IsObjectInContextCompartment(aScope, aCx));
JS::Rooted<JSObject*> parent(aCx,
GetRealParentObject(aObject,
WrapNativeParent(aCx, aScope, aObject->GetParentObject())));
WrapNativeParent(aCx, aObject->GetParentObject())));
if (!parent) {
return nullptr;
}