зеркало из https://github.com/mozilla/gecko-dev.git
Bug 991742 part 9. Remove the "scope" argument of WrapNewBindingObject. r=bholley
This commit is contained in:
Родитель
79dab91ff6
Коммит
feebd363fb
|
@ -26,7 +26,7 @@ WebGLContext::WebGLObjectAsJSValue(JSContext *cx, const WebGLObjectType *object,
|
|||
JS::Rooted<JS::Value> v(cx);
|
||||
JS::Rooted<JSObject*> wrapper(cx, GetWrapper());
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
if (!dom::WrapNewBindingObject(cx, wrapper, const_cast<WebGLObjectType*>(object), &v)) {
|
||||
if (!dom::WrapNewBindingObject(cx, const_cast<WebGLObjectType*>(object), &v)) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
|
|
@ -13553,13 +13553,7 @@ nsGlobalWindow::GetConsole(JSContext* aCx,
|
|||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapper());
|
||||
if (!thisObj) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(aCx, &thisObj) ||
|
||||
!WrapNewBindingObject(aCx, thisObj, console, aConsole)) {
|
||||
if (!WrapNewBindingObject(aCx, console, aConsole)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -2390,8 +2390,7 @@ ConvertExceptionToPromise(JSContext* cx,
|
|||
return false;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> wrapScope(cx, JS::CurrentGlobalOrNull(cx));
|
||||
return WrapNewBindingObject(cx, wrapScope, promise, rval);
|
||||
return WrapNewBindingObject(cx, promise, rval);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -790,8 +790,7 @@ MaybeWrapValue(JSContext* cx, JS::MutableHandle<JS::Value> rval)
|
|||
// having "value" inherit from nsWrapperCache.
|
||||
template <class T>
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
WrapNewBindingObject(JSContext* cx, JS::Handle<JSObject*> scope, T* value,
|
||||
JS::MutableHandle<JS::Value> rval)
|
||||
WrapNewBindingObject(JSContext* cx, T* value, JS::MutableHandle<JS::Value> rval)
|
||||
{
|
||||
MOZ_ASSERT(value);
|
||||
JSObject* obj = value->GetWrapperPreserveColor();
|
||||
|
@ -805,7 +804,6 @@ WrapNewBindingObject(JSContext* cx, JS::Handle<JSObject*> scope, T* value,
|
|||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
|
||||
obj = value->WrapObject(cx);
|
||||
if (!obj) {
|
||||
// At this point, obj is null, so just return false.
|
||||
|
@ -817,8 +815,7 @@ WrapNewBindingObject(JSContext* cx, JS::Handle<JSObject*> scope, T* value,
|
|||
|
||||
#ifdef DEBUG
|
||||
const DOMClass* clasp = GetDOMClass(obj);
|
||||
// clasp can be null if the cache contained a non-DOM object from a
|
||||
// different compartment than scope.
|
||||
// clasp can be null if the cache contained a non-DOM object.
|
||||
if (clasp) {
|
||||
// Some sanity asserts about our object. Specifically:
|
||||
// 1) If our class claims we're nsISupports, we better be nsISupports
|
||||
|
@ -830,13 +827,6 @@ WrapNewBindingObject(JSContext* cx, JS::Handle<JSObject*> scope, T* value,
|
|||
MOZ_ASSERT_IF(clasp->mDOMObjectIsISupports, (IsBaseOf<nsISupports, T>::value));
|
||||
MOZ_ASSERT(CheckWrapperCacheCast<T>::Check());
|
||||
}
|
||||
|
||||
// When called via XrayWrapper, we end up here while running in the
|
||||
// chrome compartment. But the obj we have would be created in
|
||||
// whatever the content compartment is. So at this point we need to
|
||||
// make sure it's correctly wrapped for the compartment of |scope|.
|
||||
// cx should already be in the compartment of |scope| here.
|
||||
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
|
||||
#endif
|
||||
|
||||
rval.set(JS::ObjectValue(*obj));
|
||||
|
@ -1495,29 +1485,39 @@ WrapCallThisObject<JS::Rooted<JSObject*>>(JSContext* cx,
|
|||
template <class T, bool isSmartPtr=HasgetMember<T>::Value>
|
||||
struct WrapNewBindingObjectHelper
|
||||
{
|
||||
static inline bool Wrap(JSContext* cx, JS::Handle<JSObject*> scope,
|
||||
const T& value, JS::MutableHandle<JS::Value> rval)
|
||||
static inline bool Wrap(JSContext* cx, const T& value,
|
||||
JS::MutableHandle<JS::Value> rval)
|
||||
{
|
||||
return WrapNewBindingObject(cx, scope, value.get(), rval);
|
||||
return WrapNewBindingObject(cx, value.get(), rval);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct WrapNewBindingObjectHelper<T, false>
|
||||
{
|
||||
static inline bool Wrap(JSContext* cx, JS::Handle<JSObject*> scope, T& value,
|
||||
static inline bool Wrap(JSContext* cx, T& value,
|
||||
JS::MutableHandle<JS::Value> rval)
|
||||
{
|
||||
return WrapNewBindingObject(cx, scope, &value, rval);
|
||||
return WrapNewBindingObject(cx, &value, rval);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline bool
|
||||
WrapNewBindingObject(JSContext* cx, T& value, JS::MutableHandle<JS::Value> rval)
|
||||
{
|
||||
return WrapNewBindingObjectHelper<T>::Wrap(cx, value, rval);
|
||||
}
|
||||
|
||||
// We need this version of WrapNewBindingObject for codegen, so it'll have the
|
||||
// same signature as WrapNewBindingNonWrapperCachedObject and
|
||||
// WrapNewBindingNonWrapperCachedOwnedObject, which still need the scope.
|
||||
template<class T>
|
||||
inline bool
|
||||
WrapNewBindingObject(JSContext* cx, JS::Handle<JSObject*> scope, T& value,
|
||||
JS::MutableHandle<JS::Value> rval)
|
||||
{
|
||||
return WrapNewBindingObjectHelper<T>::Wrap(cx, scope, value, rval);
|
||||
return WrapNewBindingObject(cx, value, rval);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -1506,7 +1506,7 @@ class CGConstructNavigatorObject(CGAbstractMethod):
|
|||
return nullptr;
|
||||
}
|
||||
JS::Rooted<JS::Value> v(aCx);
|
||||
if (!WrapNewBindingObject(aCx, aObj, result, &v)) {
|
||||
if (!WrapNewBindingObject(aCx, result, &v)) {
|
||||
//XXX Assertion disabled for now, see bug 991271.
|
||||
MOZ_ASSERT(true || JS_IsExceptionPending(aCx));
|
||||
return nullptr;
|
||||
|
@ -11402,8 +11402,9 @@ class CGJSImplMethod(CGJSImplMember):
|
|||
// Wrap the object before calling __Init so that __DOM_IMPL__ is available.
|
||||
nsCOMPtr<nsIGlobalObject> globalHolder = do_QueryInterface(window);
|
||||
JS::Rooted<JSObject*> scopeObj(cx, globalHolder->GetGlobalJSObject());
|
||||
MOZ_ASSERT(js::IsObjectInContextCompartment(scopeObj, cx));
|
||||
JS::Rooted<JS::Value> wrappedVal(cx);
|
||||
if (!WrapNewBindingObject(cx, scopeObj, impl, &wrappedVal)) {
|
||||
if (!WrapNewBindingObject(cx, impl, &wrappedVal)) {
|
||||
//XXX Assertion disabled for now, see bug 991271.
|
||||
MOZ_ASSERT(true || JS_IsExceptionPending(cx));
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
|
@ -11664,7 +11665,8 @@ class CGJSImplClass(CGBindingImplClass):
|
|||
"}\n"
|
||||
"JS::Rooted<JSObject*> arg(cx, &args[1].toObject());\n"
|
||||
"nsRefPtr<${implName}> impl = new ${implName}(arg, window);\n"
|
||||
"return WrapNewBindingObject(cx, arg, impl, args.rval());"
|
||||
"MOZ_ASSERT(js::IsObjectInContextCompartment(arg, cx));\n"
|
||||
"return WrapNewBindingObject(cx, impl, args.rval());"
|
||||
).substitute({
|
||||
"ifaceName": self.descriptor.interface.identifier.name,
|
||||
"implName": self.descriptor.name
|
||||
|
|
|
@ -90,10 +90,11 @@ ThrowExceptionObject(JSContext* aCx, Exception* aException)
|
|||
|
||||
JS::Rooted<JSObject*> glob(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
if (!glob) {
|
||||
// XXXbz Can this actually be null here?
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!WrapNewBindingObject(aCx, glob, aException, &thrown)) {
|
||||
if (!WrapNewBindingObject(aCx, aException, &thrown)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -441,7 +441,8 @@ IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx,
|
|||
MOZ_ASSERT(factory, "This should never fail for chrome!");
|
||||
|
||||
JS::Rooted<JS::Value> indexedDB(aCx);
|
||||
if (!WrapNewBindingObject(aCx, aGlobal, factory, &indexedDB)) {
|
||||
js::AssertSameCompartment(aCx, aGlobal);
|
||||
if (!WrapNewBindingObject(aCx, factory, &indexedDB)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ Promise::GetOrCreateWrapper(JSContext* aCx)
|
|||
JSAutoCompartment ac(aCx, scope);
|
||||
|
||||
JS::Rooted<JS::Value> val(aCx);
|
||||
if (!WrapNewBindingObject(aCx, scope, this, &val)) {
|
||||
if (!WrapNewBindingObject(aCx, this, &val)) {
|
||||
MOZ_ASSERT(JS_IsExceptionPending(aCx));
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ Promise::CreateFunction(JSContext* aCx, JSObject* aParent, Promise* aPromise,
|
|||
JS::Rooted<JSObject*> obj(aCx, JS_GetFunctionObject(func));
|
||||
|
||||
JS::Rooted<JS::Value> promiseObj(aCx);
|
||||
if (!dom::WrapNewBindingObject(aCx, obj, aPromise, &promiseObj)) {
|
||||
if (!dom::WrapNewBindingObject(aCx, aPromise, &promiseObj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ Promise::CreateThenableFunction(JSContext* aCx, Promise* aPromise, uint32_t aTas
|
|||
JS::Rooted<JSObject*> obj(aCx, JS_GetFunctionObject(func));
|
||||
|
||||
JS::Rooted<JS::Value> promiseObj(aCx);
|
||||
if (!dom::WrapNewBindingObject(aCx, obj, aPromise, &promiseObj)) {
|
||||
if (!dom::WrapNewBindingObject(aCx, aPromise, &promiseObj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -229,9 +229,7 @@ private:
|
|||
JSObject* aScope,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
JS::Rooted<JSObject*> scope(aCx, aScope);
|
||||
|
||||
return WrapNewBindingObject(aCx, scope, aArgument, aValue);
|
||||
return WrapNewBindingObject(aCx, aArgument, aValue);
|
||||
}
|
||||
|
||||
// Accept typed arrays built from appropriate nsTArray values
|
||||
|
|
Загрузка…
Ссылка в новой задаче