mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 956455, part 1 - WrapNative's holder argument is unnecessary. r=smaug
This commit is contained in:
parent
b55f96119e
commit
bd11c4fff8
@ -86,7 +86,6 @@ class nsIURI;
|
||||
class nsIWidget;
|
||||
class nsIWordBreaker;
|
||||
class nsIXPConnect;
|
||||
class nsIXPConnectJSObjectHolder;
|
||||
class nsNodeInfoManager;
|
||||
class nsPIDOMWindow;
|
||||
class nsPresContext;
|
||||
@ -1641,36 +1640,24 @@ public:
|
||||
static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, const nsIID* aIID,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
// while there's a ref to it
|
||||
nsIXPConnectJSObjectHolder** aHolder = nullptr,
|
||||
bool aAllowWrapping = false)
|
||||
{
|
||||
return WrapNative(cx, scope, native, nullptr, aIID, vp, aHolder,
|
||||
aAllowWrapping);
|
||||
return WrapNative(cx, scope, native, nullptr, aIID, vp, aAllowWrapping);
|
||||
}
|
||||
|
||||
// Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
|
||||
static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, JS::MutableHandle<JS::Value> vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
// while there's a ref to it
|
||||
nsIXPConnectJSObjectHolder** aHolder = nullptr,
|
||||
bool aAllowWrapping = false)
|
||||
{
|
||||
return WrapNative(cx, scope, native, nullptr, nullptr, vp, aHolder,
|
||||
aAllowWrapping);
|
||||
return WrapNative(cx, scope, native, nullptr, nullptr, vp, aAllowWrapping);
|
||||
}
|
||||
static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
// while there's a ref to it
|
||||
nsIXPConnectJSObjectHolder** aHolder = nullptr,
|
||||
bool aAllowWrapping = false)
|
||||
{
|
||||
return WrapNative(cx, scope, native, cache, nullptr, vp, aHolder,
|
||||
aAllowWrapping);
|
||||
return WrapNative(cx, scope, native, cache, nullptr, vp, aAllowWrapping);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2133,7 +2120,6 @@ private:
|
||||
static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
const nsIID* aIID, JS::MutableHandle<JS::Value> vp,
|
||||
nsIXPConnectJSObjectHolder** aHolder,
|
||||
bool aAllowWrapping);
|
||||
|
||||
static nsresult DispatchEvent(nsIDocument* aDoc,
|
||||
|
@ -5613,12 +5613,9 @@ nsresult
|
||||
nsContentUtils::WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
const nsIID* aIID, JS::MutableHandle<JS::Value> vp,
|
||||
nsIXPConnectJSObjectHolder **aHolder,
|
||||
bool aAllowWrapping)
|
||||
{
|
||||
if (!native) {
|
||||
NS_ASSERTION(!aHolder || !*aHolder, "*aHolder should be null!");
|
||||
|
||||
vp.setNull();
|
||||
|
||||
return NS_OK;
|
||||
@ -5638,7 +5635,7 @@ nsContentUtils::WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsresult rv = NS_OK;
|
||||
AutoPushJSContext context(cx);
|
||||
rv = sXPConnect->WrapNativeToJSVal(context, scope, native, cache, aIID,
|
||||
aAllowWrapping, vp.address(), aHolder);
|
||||
aAllowWrapping, vp.address(), nullptr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -5681,7 +5678,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
return nsContentUtils::WrapNative(aCx, scope, blob, aBlob, nullptr, true);
|
||||
return nsContentUtils::WrapNative(aCx, scope, blob, aBlob, true);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -6805,7 +6805,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
|
||||
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
rv = nsContentUtils::WrapNative(cx, global, this, this, &v,
|
||||
nullptr, /* aAllowWrapping = */ false);
|
||||
/* aAllowWrapping = */ false);
|
||||
if (rv.Failed())
|
||||
return nullptr;
|
||||
newScope = &v.toObject();
|
||||
@ -11469,11 +11469,9 @@ nsIDocument::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
|
||||
JS::Rooted<JS::Value> winVal(aCx);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, obj, win,
|
||||
&NS_GET_IID(nsIDOMWindow),
|
||||
&winVal,
|
||||
getter_AddRefs(holder),
|
||||
false);
|
||||
if (NS_FAILED(rv)) {
|
||||
Throw(aCx, rv);
|
||||
|
@ -926,8 +926,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
|
||||
JS::Rooted<JS::Value> targetv(ctx);
|
||||
JS::Rooted<JSObject*> global(ctx, JS_GetGlobalForObject(ctx, object));
|
||||
nsContentUtils::WrapNative(ctx, global, aTarget, &targetv,
|
||||
nullptr, true);
|
||||
nsContentUtils::WrapNative(ctx, global, aTarget, &targetv, true);
|
||||
|
||||
JS::Rooted<JSObject*> cpows(ctx);
|
||||
if (aCpows) {
|
||||
@ -1017,8 +1016,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
defaultThisValue = aTarget;
|
||||
}
|
||||
JS::Rooted<JSObject*> global(ctx, JS_GetGlobalForObject(ctx, object));
|
||||
nsContentUtils::WrapNative(ctx, global, defaultThisValue,
|
||||
&thisValue, nullptr, true);
|
||||
nsContentUtils::WrapNative(ctx, global, defaultThisValue, &thisValue, true);
|
||||
} else {
|
||||
// If the listener is a JS object which has receiveMessage function:
|
||||
if (!JS_GetProperty(ctx, object, "receiveMessage", &funval) ||
|
||||
|
@ -990,7 +990,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
|
||||
JS::Rooted<JS::Value> result(aCx, JSVAL_NULL);
|
||||
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
aRv = nsContentUtils::WrapNative(aCx, scope, mResponseBlob, &result,
|
||||
nullptr, true);
|
||||
true);
|
||||
return result;
|
||||
}
|
||||
case XML_HTTP_RESPONSE_TYPE_DOCUMENT:
|
||||
@ -1002,7 +1002,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
|
||||
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
JS::Rooted<JS::Value> result(aCx, JSVAL_NULL);
|
||||
aRv = nsContentUtils::WrapNative(aCx, scope, mResponseXML, &result,
|
||||
nullptr, true);
|
||||
true);
|
||||
return result;
|
||||
}
|
||||
case XML_HTTP_RESPONSE_TYPE_JSON:
|
||||
|
@ -295,11 +295,9 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
|
||||
|
||||
JS::Rooted<JSObject*> globalObject(cx, global->GetGlobalJSObject());
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(cx, globalObject, aBoundElement, &v,
|
||||
getter_AddRefs(wrapper));
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, globalObject, aBoundElement, &v);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Use nsCxPusher to make sure we call ScriptEvaluated when we're done.
|
||||
|
@ -307,7 +307,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
|
||||
// scope if one doesn't already exist, and potentially wraps it cross-
|
||||
// compartment into our scope (via aAllowWrapping=true).
|
||||
JS::Rooted<JS::Value> targetV(cx, JS::UndefinedValue());
|
||||
rv = nsContentUtils::WrapNative(cx, scopeObject, scriptTarget, &targetV, nullptr,
|
||||
rv = nsContentUtils::WrapNative(cx, scopeObject, scriptTarget, &targetV,
|
||||
/* aAllowWrapping = */ true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -1390,9 +1390,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
||||
|
||||
JS::Rooted<JSObject*> scope(jscontext, global->GetGlobalJSObject());
|
||||
JS::Rooted<JS::Value> v(jscontext);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, &v,
|
||||
getter_AddRefs(wrapper));
|
||||
rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JSObject*> jselement(jscontext, JSVAL_TO_OBJECT(v));
|
||||
@ -1402,7 +1400,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
||||
JS::Rooted<JS::Value> jsdatabase(jscontext);
|
||||
rv = nsContentUtils::WrapNative(jscontext, scope, mDB,
|
||||
&NS_GET_IID(nsIRDFCompositeDataSource),
|
||||
&jsdatabase, getter_AddRefs(wrapper));
|
||||
&jsdatabase);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool ok;
|
||||
@ -1415,11 +1413,10 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
||||
{
|
||||
// builder
|
||||
JS::Rooted<JS::Value> jsbuilder(jscontext);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
rv = nsContentUtils::WrapNative(jscontext, jselement,
|
||||
static_cast<nsIXULTemplateBuilder*>(this),
|
||||
&NS_GET_IID(nsIXULTemplateBuilder),
|
||||
&jsbuilder, getter_AddRefs(wrapper));
|
||||
&jsbuilder);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool ok;
|
||||
|
@ -121,10 +121,8 @@ PostMessageReadStructuredClone(JSContext* cx,
|
||||
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
if (global) {
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, global, supports,
|
||||
&val,
|
||||
getter_AddRefs(wrapper)))) {
|
||||
&val))) {
|
||||
return JSVAL_TO_OBJECT(val);
|
||||
}
|
||||
}
|
||||
|
@ -1586,9 +1586,7 @@ Navigator::DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
||||
}
|
||||
|
||||
if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
rv = nsContentUtils::WrapNative(aCx, aObject, native, &prop_val,
|
||||
getter_AddRefs(holder), true);
|
||||
rv = nsContentUtils::WrapNative(aCx, aObject, native, &prop_val, true);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return Throw(aCx, rv);
|
||||
|
@ -7553,10 +7553,8 @@ PostMessageReadStructuredClone(JSContext* cx,
|
||||
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
if (global) {
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, global, supports,
|
||||
&val,
|
||||
getter_AddRefs(wrapper)))) {
|
||||
&val))) {
|
||||
return val.toObjectOrNull();
|
||||
}
|
||||
}
|
||||
|
@ -1272,10 +1272,8 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
|
||||
NS_ASSERTION(prim == nullptr,
|
||||
"Don't pass nsISupportsPrimitives - use nsIVariant!");
|
||||
#endif
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
rv = nsContentUtils::WrapNative(cx, aScope, arg, &v,
|
||||
getter_AddRefs(wrapper));
|
||||
rv = nsContentUtils::WrapNative(cx, aScope, arg, &v);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*thisval = v;
|
||||
}
|
||||
@ -1470,12 +1468,10 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
||||
|
||||
AutoFree iidGuard(iid); // Free iid upon destruction.
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
JS::Rooted<JSObject*> global(cx, GetWindowProxy());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, global,
|
||||
data, iid, &v,
|
||||
getter_AddRefs(wrapper));
|
||||
data, iid, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aArgv = v;
|
||||
|
@ -32,8 +32,7 @@ nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::RootedValue wrappedVal(aCx);
|
||||
rv = nsContentUtils::WrapNative(aCx, global, obj, &wrappedVal,
|
||||
nullptr, true);
|
||||
rv = nsContentUtils::WrapNative(aCx, global, obj, &wrappedVal, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!JS_SetElement(aCx, arrayObj, index, &wrappedVal)) {
|
||||
|
Loading…
Reference in New Issue
Block a user