mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 993889 part 1. Remove "scope" argument from nsContentUtils::WrapNative. r=bholley
This commit is contained in:
parent
23b3461fe0
commit
67f4d02e6f
@ -1649,29 +1649,28 @@ public:
|
||||
static bool CanAccessNativeAnon();
|
||||
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, const nsIID* aIID,
|
||||
JS::MutableHandle<JS::Value> vp)
|
||||
static nsresult WrapNative(JSContext *cx, nsISupports *native,
|
||||
const nsIID* aIID, JS::MutableHandle<JS::Value> vp)
|
||||
{
|
||||
return WrapNative(cx, scope, native, nullptr, aIID, vp, true);
|
||||
return WrapNative(cx, native, nullptr, aIID, vp, true);
|
||||
}
|
||||
|
||||
// Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
{
|
||||
return WrapNative(cx, scope, native, nullptr, nullptr, vp, aAllowWrapping);
|
||||
}
|
||||
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
static nsresult WrapNative(JSContext *cx, nsISupports *native,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
{
|
||||
return WrapNative(cx, scope, native, cache, nullptr, vp, aAllowWrapping);
|
||||
return WrapNative(cx, native, nullptr, nullptr, vp, aAllowWrapping);
|
||||
}
|
||||
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
static nsresult WrapNative(JSContext *cx, nsISupports *native,
|
||||
nsWrapperCache *cache,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
{
|
||||
return WrapNative(cx, native, cache, nullptr, vp, aAllowWrapping);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2131,9 +2130,9 @@ private:
|
||||
static bool CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
||||
static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
const nsIID* aIID, JS::MutableHandle<JS::Value> vp,
|
||||
static nsresult WrapNative(JSContext *cx, nsISupports *native,
|
||||
nsWrapperCache *cache, const nsIID* aIID,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping);
|
||||
|
||||
static nsresult DispatchEvent(nsIDocument* aDoc,
|
||||
|
@ -5641,10 +5641,9 @@ nsContentUtils::DispatchXULCommand(nsIContent* aTarget,
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
const nsIID* aIID, JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping)
|
||||
nsContentUtils::WrapNative(JSContext *cx, nsISupports *native,
|
||||
nsWrapperCache *cache, const nsIID* aIID,
|
||||
JS::MutableHandle<JS::Value> vp, bool aAllowWrapping)
|
||||
{
|
||||
if (!native) {
|
||||
vp.setNull();
|
||||
@ -5652,6 +5651,8 @@ nsContentUtils::WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> scope(cx, JS::CurrentGlobalOrNull(cx));
|
||||
|
||||
JSObject *wrapper = xpc_FastGetCachedWrapper(cache, scope, vp);
|
||||
if (wrapper) {
|
||||
return NS_OK;
|
||||
@ -5708,8 +5709,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
|
||||
} else {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
return nsContentUtils::WrapNative(aCx, scope, blob, aBlob);
|
||||
return nsContentUtils::WrapNative(aCx, blob, aBlob);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5509,8 +5509,7 @@ nsDocument::CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value*
|
||||
return true;
|
||||
}
|
||||
|
||||
rv = nsContentUtils::WrapNative(aCx, global, newElement, newElement,
|
||||
args.rval());
|
||||
rv = nsContentUtils::WrapNative(aCx, newElement, newElement, args.rval());
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
|
||||
return true;
|
||||
@ -7428,14 +7427,13 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
|
||||
if (!sameDocument) {
|
||||
newScope = GetWrapper();
|
||||
if (!newScope && GetScopeObject() && GetScopeObject()->GetGlobalJSObject()) {
|
||||
// We need to pass some sort of scope object to WrapNative. It's kind of
|
||||
// irrelevant, given that we're passing aAllowWrapping = false, and
|
||||
// documents should always insist on being wrapped in an canonical
|
||||
// scope. But we try to pass something sane anyway.
|
||||
JS::Rooted<JSObject*> global(cx, GetScopeObject()->GetGlobalJSObject());
|
||||
|
||||
// Make sure cx is in a semi-sane compartment before we call WrapNative.
|
||||
// It's kind of irrelevant, given that we're passing aAllowWrapping =
|
||||
// false, and documents should always insist on being wrapped in an
|
||||
// canonical scope. But we try to pass something sane anyway.
|
||||
JSAutoCompartment ac(cx, GetScopeObject()->GetGlobalJSObject());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
rv = nsContentUtils::WrapNative(cx, global, this, this, &v,
|
||||
rv = nsContentUtils::WrapNative(cx, this, this, &v,
|
||||
/* aAllowWrapping = */ false);
|
||||
if (rv.Failed())
|
||||
return nullptr;
|
||||
@ -12152,8 +12150,7 @@ nsIDocument::WrapObject(JSContext *aCx)
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
|
||||
JS::Rooted<JS::Value> winVal(aCx);
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, obj, win,
|
||||
&NS_GET_IID(nsIDOMWindow),
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, win, &NS_GET_IID(nsIDOMWindow),
|
||||
&winVal);
|
||||
if (NS_FAILED(rv)) {
|
||||
Throw(aCx, rv);
|
||||
|
@ -927,8 +927,8 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
NS_ENSURE_TRUE(param, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::Rooted<JS::Value> targetv(cx);
|
||||
JS::Rooted<JSObject*> global(cx, JS_GetGlobalForObject(cx, object));
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, global, aTarget, &targetv);
|
||||
js::AssertSameCompartment(cx, object);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, aTarget, &targetv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JSObject*> cpows(cx);
|
||||
@ -1018,8 +1018,8 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
} else {
|
||||
defaultThisValue = aTarget;
|
||||
}
|
||||
JS::Rooted<JSObject*> global(cx, JS_GetGlobalForObject(cx, object));
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, global, defaultThisValue, &thisValue);
|
||||
js::AssertSameCompartment(cx, object);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, defaultThisValue, &thisValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
// If the listener is a JS object which has receiveMessage function:
|
||||
|
@ -1027,8 +1027,9 @@ nsScriptLoader::FillCompileOptionsForRequest(nsScriptLoadRequest *aRequest,
|
||||
// compartments with it... and in particular, it will compile in the
|
||||
// compartment of aScopeChain, so we want to wrap into that compartment as
|
||||
// well.
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, aScopeChain,
|
||||
aRequest->mElement, &elementVal,
|
||||
JSAutoCompartment ac(cx, aScopeChain);
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, aRequest->mElement,
|
||||
&elementVal,
|
||||
/* aAllowWrapping = */ true))) {
|
||||
MOZ_ASSERT(elementVal.isObject());
|
||||
aOptions->setElement(&elementVal.toObject());
|
||||
|
@ -991,9 +991,8 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
|
||||
return JSVAL_NULL;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> result(aCx, JSVAL_NULL);
|
||||
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
aRv = nsContentUtils::WrapNative(aCx, scope, mResponseBlob, &result);
|
||||
JS::Rooted<JS::Value> result(aCx);
|
||||
aRv = nsContentUtils::WrapNative(aCx, mResponseBlob, &result);
|
||||
return result;
|
||||
}
|
||||
case XML_HTTP_RESPONSE_TYPE_DOCUMENT:
|
||||
@ -1002,9 +1001,8 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
|
||||
return JSVAL_NULL;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
JS::Rooted<JS::Value> result(aCx, JSVAL_NULL);
|
||||
aRv = nsContentUtils::WrapNative(aCx, scope, mResponseXML, &result);
|
||||
JS::Rooted<JS::Value> result(aCx);
|
||||
aRv = nsContentUtils::WrapNative(aCx, mResponseXML, &result);
|
||||
return result;
|
||||
}
|
||||
case XML_HTTP_RESPONSE_TYPE_JSON:
|
||||
|
@ -1388,9 +1388,8 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
||||
AutoEntryScript entryScript(innerWin, true);
|
||||
JSContext* jscontext = entryScript.cx();
|
||||
|
||||
JS::Rooted<JSObject*> scope(jscontext, global->GetGlobalJSObject());
|
||||
JS::Rooted<JS::Value> v(jscontext);
|
||||
rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, &v);
|
||||
rv = nsContentUtils::WrapNative(jscontext, mRoot, mRoot, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JSObject*> jselement(jscontext, JSVAL_TO_OBJECT(v));
|
||||
@ -1398,7 +1397,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
||||
if (mDB) {
|
||||
// database
|
||||
JS::Rooted<JS::Value> jsdatabase(jscontext);
|
||||
rv = nsContentUtils::WrapNative(jscontext, scope, mDB,
|
||||
rv = nsContentUtils::WrapNative(jscontext, mDB,
|
||||
&NS_GET_IID(nsIRDFCompositeDataSource),
|
||||
&jsdatabase);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -1412,7 +1411,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
||||
{
|
||||
// builder
|
||||
JS::Rooted<JS::Value> jsbuilder(jscontext);
|
||||
rv = nsContentUtils::WrapNative(jscontext, jselement,
|
||||
rv = nsContentUtils::WrapNative(jscontext,
|
||||
static_cast<nsIXULTemplateBuilder*>(this),
|
||||
&NS_GET_IID(nsIXULTemplateBuilder),
|
||||
&jsbuilder);
|
||||
|
@ -107,13 +107,9 @@ PostMessageReadStructuredClone(JSContext* cx,
|
||||
|
||||
nsISupports* supports;
|
||||
if (JS_ReadBytes(reader, &supports, sizeof(supports))) {
|
||||
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
if (global) {
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, global, supports,
|
||||
&val))) {
|
||||
return JSVAL_TO_OBJECT(val);
|
||||
}
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, supports, &val))) {
|
||||
return JSVAL_TO_OBJECT(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1942,7 +1942,7 @@ Navigator::DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
||||
// of naviObj, especially since we plan to cache that object.
|
||||
JSAutoCompartment ac(aCx, naviObj);
|
||||
|
||||
rv = nsContentUtils::WrapNative(aCx, naviObj, native, &prop_val);
|
||||
rv = nsContentUtils::WrapNative(aCx, native, &prop_val);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return Throw(aCx, rv);
|
||||
|
@ -3837,14 +3837,8 @@ nsGlobalWindow::GetContent(JSContext* aCx, ErrorResult& aError)
|
||||
}
|
||||
|
||||
if (content) {
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
if (!global) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> val(aCx);
|
||||
aError = nsContentUtils::WrapNative(aCx, global, content, &val);
|
||||
aError = nsContentUtils::WrapNative(aCx, content, &val);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -7664,13 +7658,9 @@ PostMessageReadStructuredClone(JSContext* cx,
|
||||
|
||||
nsISupports* supports;
|
||||
if (JS_ReadBytes(reader, &supports, sizeof(supports))) {
|
||||
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
if (global) {
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, global, supports,
|
||||
&val))) {
|
||||
return val.toObjectOrNull();
|
||||
}
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, supports, &val))) {
|
||||
return val.toObjectOrNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1087,7 +1087,8 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports* aArgs,
|
||||
NS_ASSERTION(prim == nullptr,
|
||||
"Don't pass nsISupportsPrimitives - use nsIVariant!");
|
||||
#endif
|
||||
rv = nsContentUtils::WrapNative(cx, aScope, arg, thisVal);
|
||||
JSAutoCompartment ac(cx, aScope);
|
||||
rv = nsContentUtils::WrapNative(cx, arg, thisVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1275,10 +1276,10 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
||||
|
||||
AutoFree iidGuard(iid); // Free iid upon destruction.
|
||||
|
||||
JS::Rooted<JSObject*> global(cx, GetWindowProxy());
|
||||
JS::Rooted<JSObject*> scope(cx, GetWindowProxy());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, global,
|
||||
data, iid, &v);
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, data, iid, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aArgv = v;
|
||||
|
@ -76,8 +76,9 @@ public:
|
||||
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
|
||||
JS::Rooted<JSObject*> global(cx, sc->GetWindowProxy());
|
||||
rv = nsContentUtils::WrapNative(cx, global, adapter, aValue);
|
||||
JS::Rooted<JSObject*> scope(cx, sc->GetWindowProxy());
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
rv = nsContentUtils::WrapNative(cx, adapter, aValue);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("Cannot create native object!");
|
||||
SetError(NS_LITERAL_STRING("BluetoothNativeObjectError"));
|
||||
|
@ -1651,8 +1651,7 @@ InterfaceToJsval(nsPIDOMWindow* aWindow,
|
||||
|
||||
|
||||
JS::Rooted<JS::Value> someJsVal(cx);
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(cx, scopeObj, aObject, aIID, &someJsVal);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, aObject, aIID, &someJsVal);
|
||||
if (NS_FAILED(rv)) {
|
||||
return JSVAL_NULL;
|
||||
}
|
||||
|
@ -863,7 +863,7 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
{
|
||||
JSAutoCompartment ac(cx, wrapScope);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, wrapScope, mTarget, &v,
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, mTarget, &v,
|
||||
/* aAllowWrapping = */ false);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -194,7 +194,9 @@ ArchiveRequest::GetFilenamesResult(JSContext* aCx,
|
||||
str = JS_NewUCStringCopyZ(aCx, filename.get());
|
||||
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (NS_FAILED(rv) || !JS_SetElement(aCx, array, i, str)) {
|
||||
if (NS_FAILED(rv) ||
|
||||
!JS_DefineElement(aCx, array, i, JS::StringValue(str), nullptr, nullptr,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
@ -220,9 +222,8 @@ ArchiveRequest::GetFileResult(JSContext* aCx,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (filename == mFilename) {
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
return nsContentUtils::WrapNative(aCx, global, file,
|
||||
&NS_GET_IID(nsIDOMFile), aValue);
|
||||
return nsContentUtils::WrapNative(aCx, file, &NS_GET_IID(nsIDOMFile),
|
||||
aValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,11 +244,11 @@ ArchiveRequest::GetFilesResult(JSContext* aCx,
|
||||
nsCOMPtr<nsIDOMFile> file = aFileList[i];
|
||||
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
|
||||
&NS_GET_IID(nsIDOMFile),
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, file, &NS_GET_IID(nsIDOMFile),
|
||||
&value);
|
||||
if (NS_FAILED(rv) || !JS_SetElement(aCx, array, i, value)) {
|
||||
if (NS_FAILED(rv) ||
|
||||
!JS_DefineElement(aCx, array, i, value, nullptr, nullptr,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -188,10 +188,8 @@ GetFileHelper::GetSuccessResult(JSContext* aCx,
|
||||
nsCOMPtr<nsIDOMFile> domFile =
|
||||
mFileHandle->CreateFileObject(mLockedFile, mParams->Size());
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, global, domFile,
|
||||
&NS_GET_IID(nsIDOMFile), aVal);
|
||||
nsContentUtils::WrapNative(aCx, domFile, &NS_GET_IID(nsIDOMFile), aVal);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -121,12 +121,7 @@ HelperBase::WrapNative(JSContext* aCx,
|
||||
NS_ASSERTION(aResult.address(), "Null pointer!");
|
||||
NS_ASSERTION(mRequest, "Null request!");
|
||||
|
||||
nsRefPtr<IDBWrapperCache> wrapper = static_cast<IDBWrapperCache*>(mRequest);
|
||||
JS::Rooted<JSObject*> global(aCx, wrapper->GetParentObject());
|
||||
NS_ASSERTION(global, "This should never be null!");
|
||||
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, global, aNative, aResult);
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, aNative, aResult);
|
||||
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -830,9 +830,7 @@ public:
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> wrappedBlob(aCx);
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
rv = nsContentUtils::WrapNative(aCx, global, domBlob,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
rv = nsContentUtils::WrapNative(aCx, domBlob, &NS_GET_IID(nsIDOMBlob),
|
||||
&wrappedBlob);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to wrap native!");
|
||||
@ -857,9 +855,7 @@ public:
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> wrappedFile(aCx);
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
rv = nsContentUtils::WrapNative(aCx, global, domFile,
|
||||
&NS_GET_IID(nsIDOMFile),
|
||||
rv = nsContentUtils::WrapNative(aCx, domFile, &NS_GET_IID(nsIDOMFile),
|
||||
&wrappedFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to wrap native!");
|
||||
|
@ -55,9 +55,7 @@ Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
||||
#endif
|
||||
|
||||
JS::Rooted<JS::Value> wrappedFile(aCx);
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
|
||||
&NS_GET_IID(nsIDOMFile),
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, file, &NS_GET_IID(nsIDOMFile),
|
||||
&wrappedFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
Error(aCx, nsIDOMDOMException::DATA_CLONE_ERR);
|
||||
@ -84,9 +82,7 @@ Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
||||
#endif
|
||||
|
||||
JS::Rooted<JS::Value> wrappedBlob(aCx);
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, global, blob,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, blob, &NS_GET_IID(nsIDOMBlob),
|
||||
&wrappedBlob);
|
||||
if (NS_FAILED(rv)) {
|
||||
Error(aCx, nsIDOMDOMException::DATA_CLONE_ERR);
|
||||
|
@ -637,9 +637,7 @@ MmsMessage::GetAttachments(JSContext* aCx, JS::MutableHandle<JS::Value> aAttachm
|
||||
}
|
||||
|
||||
// Get |attachment.mContent|.
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx,
|
||||
global,
|
||||
attachment.content,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
&tmpJsVal);
|
||||
|
@ -71,7 +71,7 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage, bool aAsync)
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> wrappedMessage(cx);
|
||||
rv = nsContentUtils::WrapNative(cx, global, aMessage, &wrappedMessage);
|
||||
rv = nsContentUtils::WrapNative(cx, aMessage, &wrappedMessage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NotifySuccess(wrappedMessage, aAsync);
|
||||
|
@ -73,7 +73,7 @@ MobileMessageCursorCallback::NotifyCursorResult(nsISupports* aResult)
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> wrappedResult(cx);
|
||||
rv = nsContentUtils::WrapNative(cx, global, aResult, &wrappedResult);
|
||||
rv = nsContentUtils::WrapNative(cx, aResult, &wrappedResult);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDOMCursor->FireSuccess(wrappedResult);
|
||||
|
@ -148,9 +148,9 @@ MobileMessageManager::Send(JSContext* aCx, JS::Handle<JSObject*> aGlobal,
|
||||
false, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx, aGlobal);
|
||||
js::AssertSameCompartment(aCx, aGlobal);
|
||||
JS::Rooted<JS::Value> rval(aCx);
|
||||
rv = nsContentUtils::WrapNative(aCx, global,
|
||||
rv = nsContentUtils::WrapNative(aCx,
|
||||
static_cast<nsIDOMDOMRequest*>(request.get()),
|
||||
&rval);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -59,9 +59,7 @@ MmsAttachmentDataToJSObject(JSContext* aContext,
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob = static_cast<BlobParent*>(aAttachment.contentParent())->GetBlob();
|
||||
JS::Rooted<JS::Value> content(aContext);
|
||||
JS::Rooted<JSObject*> global(aContext, JS::CurrentGlobalOrNull(aContext));
|
||||
nsresult rv = nsContentUtils::WrapNative(aContext,
|
||||
global,
|
||||
blob,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
&content);
|
||||
|
@ -254,9 +254,7 @@ private:
|
||||
JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, scope, &aArgument, aValue);
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, &aArgument, aValue);
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
|
@ -479,8 +479,7 @@ struct MainThreadWorkerStructuredCloneCallbacks
|
||||
// nsIDOMFiles should be threadsafe, thus we will use the same instance
|
||||
// on the main thread.
|
||||
JS::Rooted<JS::Value> wrappedFile(aCx);
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, file,
|
||||
&NS_GET_IID(nsIDOMFile),
|
||||
&wrappedFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -513,8 +512,7 @@ struct MainThreadWorkerStructuredCloneCallbacks
|
||||
// nsIDOMBlobs should be threadsafe, thus we will use the same instance
|
||||
// on the main thread.
|
||||
JS::Rooted<JS::Value> wrappedBlob(aCx);
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, global, blob,
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, blob,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
&wrappedBlob);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -178,7 +178,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
||||
bool defineOnGlobal = dom::XULElementBinding::ConstructorEnabled(cx, global);
|
||||
dom::XULElementBinding::GetConstructorObject(cx, global, defineOnGlobal);
|
||||
|
||||
rv = nsContentUtils::WrapNative(cx, global, aBoundElement, &v,
|
||||
rv = nsContentUtils::WrapNative(cx, aBoundElement, &v,
|
||||
/* aAllowWrapping = */ false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -296,8 +296,7 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
|
||||
JS::Rooted<JSObject*> globalObject(cx, global->GetGlobalJSObject());
|
||||
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, globalObject, aBoundElement, &v);
|
||||
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, aBoundElement, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Use nsCxPusher to make sure we call ScriptEvaluated when we're done.
|
||||
|
@ -305,7 +305,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);
|
||||
rv = nsContentUtils::WrapNative(cx, scriptTarget, &targetV);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Next, clone the generic handler to be parented to the target.
|
||||
|
@ -23,16 +23,13 @@ nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
for (uint32_t index = 0; index < aSourceArray.Length(); index++) {
|
||||
nsCOMPtr<nsISupports> obj;
|
||||
nsresult rv = aSourceArray[index]->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(obj));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::RootedValue wrappedVal(aCx);
|
||||
rv = nsContentUtils::WrapNative(aCx, global, obj, &wrappedVal);
|
||||
rv = nsContentUtils::WrapNative(aCx, obj, &wrappedVal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!JS_SetElement(aCx, arrayObj, index, wrappedVal)) {
|
||||
|
@ -219,7 +219,7 @@ CreateXMLHttpRequest(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
|
||||
rv = nsContentUtils::WrapNative(cx, global, xhr, args.rval());
|
||||
rv = nsContentUtils::WrapNative(cx, xhr, args.rval());
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
|
||||
|
@ -3485,12 +3485,9 @@ CloneIntoReadStructuredClone(JSContext *cx,
|
||||
|
||||
nsISupports *supports;
|
||||
if (JS_ReadBytes(reader, &supports, sizeof(supports))) {
|
||||
RootedObject global(cx, CurrentGlobalOrNull(cx));
|
||||
if (global) {
|
||||
RootedValue val(cx);
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, global, supports, &val)))
|
||||
return val.toObjectOrNull();
|
||||
}
|
||||
RootedValue val(cx);
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, supports, &val)))
|
||||
return val.toObjectOrNull();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,9 +70,8 @@ xpcJSWeakReference::Get(JSContext* aCx, MutableHandleValue aRetval)
|
||||
if (!wrappedObj) {
|
||||
// We have a generic XPCOM object that supports weak references here.
|
||||
// Wrap it and pass it out.
|
||||
RootedObject global(aCx, CurrentGlobalOrNull(aCx));
|
||||
return nsContentUtils::WrapNative(aCx, global,
|
||||
supports, &NS_GET_IID(nsISupports),
|
||||
return nsContentUtils::WrapNative(aCx, supports,
|
||||
&NS_GET_IID(nsISupports),
|
||||
aRetval);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user