diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 9819d2efe86e..a97b89fa4b64 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -19,6 +19,7 @@ #endif #include "js/TypeDecls.h" +#include "js/Value.h" #include "js/RootingAPI.h" #include "mozilla/Assertions.h" #include "mozilla/EventForwards.h" @@ -1637,7 +1638,7 @@ public: static nsresult WrapNative(JSContext *cx, JS::Handle scope, nsISupports *native, const nsIID* aIID, - JS::Value *vp, + JS::MutableHandle vp, // If non-null aHolder will keep the Value alive // while there's a ref to it nsIXPConnectJSObjectHolder** aHolder = nullptr, @@ -1649,7 +1650,7 @@ public: // Same as the WrapNative above, but use this one if aIID is nsISupports' IID. static nsresult WrapNative(JSContext *cx, JS::Handle scope, - nsISupports *native, JS::Value *vp, + nsISupports *native, JS::MutableHandle vp, // If non-null aHolder will keep the Value alive // while there's a ref to it nsIXPConnectJSObjectHolder** aHolder = nullptr, @@ -1660,7 +1661,7 @@ public: } static nsresult WrapNative(JSContext *cx, JS::Handle scope, nsISupports *native, nsWrapperCache *cache, - JS::Value *vp, + JS::MutableHandle vp, // If non-null aHolder will keep the Value alive // while there's a ref to it nsIXPConnectJSObjectHolder** aHolder = nullptr, @@ -2091,7 +2092,7 @@ private: static nsresult WrapNative(JSContext *cx, JS::Handle scope, nsISupports *native, nsWrapperCache *cache, - const nsIID* aIID, JS::Value *vp, + const nsIID* aIID, JS::MutableHandle vp, nsIXPConnectJSObjectHolder** aHolder, bool aAllowWrapping); diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index aade5752a711..c16272523195 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -5659,14 +5659,14 @@ nsContentUtils::DispatchXULCommand(nsIContent* aTarget, nsresult nsContentUtils::WrapNative(JSContext *cx, JS::Handle scope, nsISupports *native, nsWrapperCache *cache, - const nsIID* aIID, JS::Value *vp, + const nsIID* aIID, JS::MutableHandleValue vp, nsIXPConnectJSObjectHolder **aHolder, bool aAllowWrapping) { if (!native) { NS_ASSERTION(!aHolder || !*aHolder, "*aHolder should be null!"); - *vp = JSVAL_NULL; + vp.setNull(); return NS_OK; } @@ -5685,7 +5685,7 @@ nsContentUtils::WrapNative(JSContext *cx, JS::Handle scope, nsresult rv = NS_OK; AutoPushJSContext context(cx); rv = sXPConnect->WrapNativeToJSVal(context, scope, native, cache, aIID, - aAllowWrapping, vp, aHolder); + aAllowWrapping, vp.address(), aHolder); return rv; } @@ -5728,8 +5728,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx, return NS_ERROR_OUT_OF_MEMORY; } JS::Rooted scope(aCx, JS::CurrentGlobalOrNull(aCx)); - return nsContentUtils::WrapNative(aCx, scope, blob, aBlob.address(), nullptr, - true); + return nsContentUtils::WrapNative(aCx, scope, blob, aBlob, nullptr, true); } void diff --git a/content/base/src/nsDOMFileReader.cpp b/content/base/src/nsDOMFileReader.cpp index 81b3a487f8bd..45a020d91014 100644 --- a/content/base/src/nsDOMFileReader.cpp +++ b/content/base/src/nsDOMFileReader.cpp @@ -206,9 +206,11 @@ nsDOMFileReader::GetResult(JSContext* aCx, JS::Value* aResult) } nsString tmpResult = mResult; - if (!xpc::StringToJsval(aCx, tmpResult, aResult)) { + JS::Rooted result(aCx); + if (!xpc::StringToJsval(aCx, tmpResult, &result)) { return NS_ERROR_FAILURE; } + *aResult = result; return NS_OK; } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index c5462b871195..b9fed24293ec 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -5167,7 +5167,7 @@ CustomElementConstructor(JSContext *aCx, unsigned aArgc, JS::Value* aVp) nsresult rv = document->CreateElem(elemName, nullptr, kNameSpaceID_XHTML, getter_AddRefs(newElement)); rv = nsContentUtils::WrapNative(aCx, global, newElement, newElement, - args.rval().address()); + args.rval()); NS_ENSURE_SUCCESS(rv, false); return true; @@ -6732,7 +6732,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv) JS::Rooted global(cx, GetScopeObject()->GetGlobalJSObject()); JS::Rooted v(cx); - rv = nsContentUtils::WrapNative(cx, global, this, this, v.address(), + rv = nsContentUtils::WrapNative(cx, global, this, this, &v, nullptr, /* aAllowWrapping = */ false); if (rv.Failed()) return nullptr; @@ -11345,7 +11345,7 @@ nsIDocument::WrapObject(JSContext *aCx, JS::Handle aScope) nsCOMPtr holder; nsresult rv = nsContentUtils::WrapNative(aCx, obj, win, &NS_GET_IID(nsIDOMWindow), - winVal.address(), + &winVal, getter_AddRefs(holder), false); if (NS_FAILED(rv)) { diff --git a/content/base/src/nsFrameMessageManager.cpp b/content/base/src/nsFrameMessageManager.cpp index ef4f09f4a9bb..2c67070099fd 100644 --- a/content/base/src/nsFrameMessageManager.cpp +++ b/content/base/src/nsFrameMessageManager.cpp @@ -832,7 +832,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget, JS::Rooted targetv(ctx); JS::Rooted global(ctx, JS_GetGlobalForObject(ctx, object)); - nsContentUtils::WrapNative(ctx, global, aTarget, targetv.address(), + nsContentUtils::WrapNative(ctx, global, aTarget, &targetv, nullptr, true); JS::RootedObject cpows(ctx); @@ -888,7 +888,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget, } JS::Rooted global(ctx, JS_GetGlobalForObject(ctx, object)); nsContentUtils::WrapNative(ctx, global, defaultThisValue, - thisValue.address(), nullptr, true); + &thisValue, nullptr, true); } else { // If the listener is a JS object which has receiveMessage function: if (!JS_GetProperty(ctx, object, "receiveMessage", &funval) || diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index b3cd9a42407d..847386726344 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -966,7 +966,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv) if (aRv.Failed()) { return JSVAL_NULL; } - JS::Value result; + JS::Rooted result(aCx); if (!xpc::StringToJsval(aCx, str, &result)) { aRv.Throw(NS_ERROR_OUT_OF_MEMORY); return JSVAL_NULL; @@ -1014,7 +1014,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv) JS::Rooted result(aCx, JSVAL_NULL); JS::Rooted scope(aCx, JS::CurrentGlobalOrNull(aCx)); - aRv = nsContentUtils::WrapNative(aCx, scope, mResponseBlob, result.address(), + aRv = nsContentUtils::WrapNative(aCx, scope, mResponseBlob, &result, nullptr, true); return result; } @@ -1026,7 +1026,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv) JS::Rooted scope(aCx, JS::CurrentGlobalOrNull(aCx)); JS::Rooted result(aCx, JSVAL_NULL); - aRv = nsContentUtils::WrapNative(aCx, scope, mResponseXML, result.address(), + aRv = nsContentUtils::WrapNative(aCx, scope, mResponseXML, &result, nullptr, true); return result; } @@ -3659,7 +3659,7 @@ nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSID* aIID, ErrorResult& aRv) JS::Rooted wrapper(aCx, GetWrapper()); JSAutoCompartment ac(aCx, wrapper); JS::Rooted global(aCx, JS_GetGlobalForObject(aCx, wrapper)); - aRv = nsContentUtils::WrapNative(aCx, global, result, iid, v.address()); + aRv = nsContentUtils::WrapNative(aCx, global, result, iid, &v); return aRv.Failed() ? JSVAL_NULL : v; } diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 1b504e67da47..edbda94878c6 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -3155,7 +3155,7 @@ nsGenericHTMLElement::GetItemValue(JSContext* aCx, JSObject* aScope, nsString string; GetItemValueText(string); - JS::Value v; + JS::Rooted v(aCx); if (!xpc::NonVoidStringToJsval(aCx, string, &v)) { aError.Throw(NS_ERROR_FAILURE); return JS::UndefinedValue(); diff --git a/content/xbl/src/nsXBLProtoImpl.cpp b/content/xbl/src/nsXBLProtoImpl.cpp index af61a9eb1ef9..19e592de327a 100644 --- a/content/xbl/src/nsXBLProtoImpl.cpp +++ b/content/xbl/src/nsXBLProtoImpl.cpp @@ -166,7 +166,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding, dom::XULElementBinding::GetConstructorObject(cx, global, defineOnGlobal); } - rv = nsContentUtils::WrapNative(cx, global, aBoundElement, v.address(), + rv = nsContentUtils::WrapNative(cx, global, aBoundElement, &v, getter_AddRefs(wrapper)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/xbl/src/nsXBLProtoImplMethod.cpp b/content/xbl/src/nsXBLProtoImplMethod.cpp index 01f556b7b565..4fa4d022c5e6 100644 --- a/content/xbl/src/nsXBLProtoImplMethod.cpp +++ b/content/xbl/src/nsXBLProtoImplMethod.cpp @@ -309,7 +309,7 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement) nsCOMPtr wrapper; JS::Rooted v(cx); nsresult rv = - nsContentUtils::WrapNative(cx, globalObject, aBoundElement, v.address(), + nsContentUtils::WrapNative(cx, globalObject, aBoundElement, &v, getter_AddRefs(wrapper)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/xbl/src/nsXBLPrototypeHandler.cpp b/content/xbl/src/nsXBLPrototypeHandler.cpp index 2a4f8d4f5747..56a2014d9b8b 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -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 targetV(cx, JS::UndefinedValue()); - rv = nsContentUtils::WrapNative(cx, scopeObject, scriptTarget, targetV.address(), nullptr, + rv = nsContentUtils::WrapNative(cx, scopeObject, scriptTarget, &targetV, nullptr, /* aAllowWrapping = */ true); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index 5ba8fb21ed89..ff7ff8ee505b 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -1385,7 +1385,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot() JS::Rooted scope(jscontext, global->GetGlobalJSObject()); JS::Rooted v(jscontext); nsCOMPtr wrapper; - rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, v.address(), + rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, &v, getter_AddRefs(wrapper)); NS_ENSURE_SUCCESS(rv, rv); @@ -1396,7 +1396,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot() JS::Rooted jsdatabase(jscontext); rv = nsContentUtils::WrapNative(jscontext, scope, mDB, &NS_GET_IID(nsIRDFCompositeDataSource), - jsdatabase.address(), getter_AddRefs(wrapper)); + &jsdatabase, getter_AddRefs(wrapper)); NS_ENSURE_SUCCESS(rv, rv); bool ok; @@ -1413,7 +1413,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot() rv = nsContentUtils::WrapNative(jscontext, jselement, static_cast(this), &NS_GET_IID(nsIXULTemplateBuilder), - jsbuilder.address(), getter_AddRefs(wrapper)); + &jsbuilder, getter_AddRefs(wrapper)); NS_ENSURE_SUCCESS(rv, rv); bool ok;