Bug 939294 - Change xpidl jsval to handles. r=gabor,bz,khuey,bsmedberg,terrence

This commit is contained in:
Tom Schuster 2014-01-09 18:39:36 +01:00
parent fab9cbb122
commit e64b35e141
111 changed files with 593 additions and 601 deletions

View File

@ -1489,7 +1489,7 @@ nsScriptSecurityManager::GetSubjectPrincipal(JSContext *cx,
}
NS_IMETHODIMP
nsScriptSecurityManager::GetObjectPrincipal(const JS::Value &aObjectVal,
nsScriptSecurityManager::GetObjectPrincipal(JS::Handle<JS::Value> aObjectVal,
JSContext *aCx,
nsIPrincipal **result)
{

View File

@ -296,7 +296,7 @@ public:
// Overrides
NS_IMETHOD GetSize(uint64_t* aSize) MOZ_OVERRIDE;
NS_IMETHOD GetType(nsAString& aType) MOZ_OVERRIDE;
NS_IMETHOD GetLastModifiedDate(JSContext* cx, JS::Value* aLastModifiedDate) MOZ_OVERRIDE;
NS_IMETHOD GetLastModifiedDate(JSContext* cx, JS::MutableHandle<JS::Value> aLastModifiedDate) MOZ_OVERRIDE;
NS_IMETHOD GetMozLastModifiedDate(uint64_t* aLastModifiedDate) MOZ_OVERRIDE;
NS_IMETHOD GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE;
NS_IMETHOD GetInternalStream(nsIInputStream**) MOZ_OVERRIDE;

View File

@ -48,12 +48,12 @@ public:
return mError;
}
NS_METHOD GetOnabort(JSContext* aCx, JS::Value* aValue);
NS_METHOD SetOnabort(JSContext* aCx, const JS::Value& aValue);
NS_METHOD GetOnerror(JSContext* aCx, JS::Value* aValue);
NS_METHOD SetOnerror(JSContext* aCx, const JS::Value& aValue);
NS_METHOD GetOnprogress(JSContext* aCx, JS::Value* aValue);
NS_METHOD SetOnprogress(JSContext* aCx, const JS::Value& aValue);
NS_METHOD GetOnabort(JSContext* aCx, JS::MutableHandle<JS::Value> aValue);
NS_METHOD SetOnabort(JSContext* aCx, JS::Handle<JS::Value> aValue);
NS_METHOD GetOnerror(JSContext* aCx, JS::MutableHandle<JS::Value> aValue);
NS_METHOD SetOnerror(JSContext* aCx, JS::Handle<JS::Value> aValue);
NS_METHOD GetOnprogress(JSContext* aCx, JS::MutableHandle<JS::Value> aValue);
NS_METHOD SetOnprogress(JSContext* aCx, JS::Handle<JS::Value> aValue);
IMPL_EVENT_HANDLER(abort)
IMPL_EVENT_HANDLER(error)

View File

@ -5635,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());
aAllowWrapping, vp);
return rv;
}

View File

@ -136,10 +136,13 @@ nsDOMFileBase::GetPath(nsAString &aPath)
}
NS_IMETHODIMP
nsDOMFileBase::GetLastModifiedDate(JSContext* cx, JS::Value *aLastModifiedDate)
nsDOMFileBase::GetLastModifiedDate(JSContext* cx, JS::MutableHandle<JS::Value> aLastModifiedDate)
{
JSObject* date = JS_NewDateObjectMsec(cx, JS_Now() / PR_USEC_PER_MSEC);
aLastModifiedDate->setObject(*date);
JS::Rooted<JSObject*> date(cx, JS_NewDateObjectMsec(cx, JS_Now() / PR_USEC_PER_MSEC));
if (!date) {
return NS_ERROR_OUT_OF_MEMORY;
}
aLastModifiedDate.setObject(*date);
return NS_OK;
}
@ -502,7 +505,7 @@ nsDOMFileFile::GetMozFullPathInternal(nsAString &aFilename)
}
NS_IMETHODIMP
nsDOMFileFile::GetLastModifiedDate(JSContext* cx, JS::Value* aLastModifiedDate)
nsDOMFileFile::GetLastModifiedDate(JSContext* cx, JS::MutableHandle<JS::Value> aLastModifiedDate)
{
NS_ASSERTION(mIsFile, "Should only be called on files");
@ -517,11 +520,11 @@ nsDOMFileFile::GetLastModifiedDate(JSContext* cx, JS::Value* aLastModifiedDate)
JSObject* date = JS_NewDateObjectMsec(cx, msecs);
if (date) {
aLastModifiedDate->setObject(*date);
aLastModifiedDate.setObject(*date);
}
else {
date = JS_NewDateObjectMsec(cx, JS_Now() / PR_USEC_PER_MSEC);
aLastModifiedDate->setObject(*date);
aLastModifiedDate.setObject(*date);
}
return NS_OK;

View File

@ -184,12 +184,12 @@ JS::Value
nsDOMFileReader::GetResult(JSContext* aCx, ErrorResult& aRv)
{
JS::Rooted<JS::Value> result(aCx);
aRv = GetResult(aCx, result.address());
aRv = GetResult(aCx, &result);
return result;
}
NS_IMETHODIMP
nsDOMFileReader::GetResult(JSContext* aCx, JS::Value* aResult)
nsDOMFileReader::GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult)
{
JS::Rooted<JS::Value> result(aCx);
if (mDataFormat == FILE_AS_ARRAYBUFFER) {
@ -201,15 +201,14 @@ nsDOMFileReader::GetResult(JSContext* aCx, JS::Value* aResult)
if (!JS_WrapValue(aCx, &result)) {
return NS_ERROR_FAILURE;
}
*aResult = result;
aResult.set(result);
return NS_OK;
}
nsString tmpResult = mResult;
if (!xpc::StringToJsval(aCx, tmpResult, &result)) {
if (!xpc::StringToJsval(aCx, tmpResult, aResult)) {
return NS_ERROR_FAILURE;
}
*aResult = result;
return NS_OK;
}

View File

@ -447,7 +447,7 @@ nsFrameMessageManager::RemoveDelayedFrameScript(const nsAString& aURL)
}
NS_IMETHODIMP
nsFrameMessageManager::GetDelayedFrameScripts(JSContext* aCx, JS::Value* aList)
nsFrameMessageManager::GetDelayedFrameScripts(JSContext* aCx, JS::MutableHandle<JS::Value> aList)
{
// Frame message managers may return an incomplete list because scripts
// that were loaded after it was connected are not added to the list.
@ -478,8 +478,7 @@ nsFrameMessageManager::GetDelayedFrameScripts(JSContext* aCx, JS::Value* aList)
NS_ERROR_OUT_OF_MEMORY);
}
*aList = JS::ObjectValue(*array);
aList.setObject(*array);
return NS_OK;
}
@ -527,12 +526,12 @@ static bool sSendingSyncMessage = false;
NS_IMETHODIMP
nsFrameMessageManager::SendSyncMessage(const nsAString& aMessageName,
const JS::Value& aJSON,
const JS::Value& aObjects,
JS::Handle<JS::Value> aJSON,
JS::Handle<JS::Value> aObjects,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aRetval)
JS::MutableHandle<JS::Value> aRetval)
{
return SendMessage(aMessageName, aJSON, aObjects, aPrincipal, aCx, aArgc,
aRetval, true);
@ -540,12 +539,12 @@ nsFrameMessageManager::SendSyncMessage(const nsAString& aMessageName,
NS_IMETHODIMP
nsFrameMessageManager::SendRpcMessage(const nsAString& aMessageName,
const JS::Value& aJSON,
const JS::Value& aObjects,
JS::Handle<JS::Value> aJSON,
JS::Handle<JS::Value> aObjects,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aRetval)
JS::MutableHandle<JS::Value> aRetval)
{
return SendMessage(aMessageName, aJSON, aObjects, aPrincipal, aCx, aArgc,
aRetval, false);
@ -553,19 +552,19 @@ nsFrameMessageManager::SendRpcMessage(const nsAString& aMessageName,
nsresult
nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
const JS::Value& aJSON,
const JS::Value& aObjects,
JS::Handle<JS::Value> aJSON,
JS::Handle<JS::Value> aObjects,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aRetval,
JS::MutableHandle<JS::Value> aRetval,
bool aIsSync)
{
NS_ASSERTION(!IsGlobal(), "Should not call SendSyncMessage in chrome");
NS_ASSERTION(!IsWindowLevel(), "Should not call SendSyncMessage in chrome");
NS_ASSERTION(!mParentManager, "Should not have parent manager in content!");
*aRetval = JSVAL_VOID;
aRetval.setUndefined();
NS_ENSURE_TRUE(mCallback, NS_ERROR_NOT_INITIALIZED);
if (sSendingSyncMessage && aIsSync) {
@ -618,7 +617,7 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
NS_ERROR_OUT_OF_MEMORY);
}
*aRetval = OBJECT_TO_JSVAL(dataArray);
aRetval.setObject(*dataArray);
return NS_OK;
}
@ -678,8 +677,8 @@ nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName,
NS_IMETHODIMP
nsFrameMessageManager::SendAsyncMessage(const nsAString& aMessageName,
const JS::Value& aJSON,
const JS::Value& aObjects,
JS::Handle<JS::Value> aJSON,
JS::Handle<JS::Value> aObjects,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc)
@ -693,8 +692,8 @@ nsFrameMessageManager::SendAsyncMessage(const nsAString& aMessageName,
NS_IMETHODIMP
nsFrameMessageManager::BroadcastAsyncMessage(const nsAString& aMessageName,
const JS::Value& aJSON,
const JS::Value& aObjects,
JS::Handle<JS::Value> aJSON,
JS::Handle<JS::Value> aObjects,
JSContext* aCx,
uint8_t aArgc)
{

View File

@ -271,12 +271,12 @@ public:
}
private:
nsresult SendMessage(const nsAString& aMessageName,
const JS::Value& aJSON,
const JS::Value& aObjects,
JS::Handle<JS::Value> aJSON,
JS::Handle<JS::Value> aObjects,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aRetval,
JS::MutableHandle<JS::Value> aRetval,
bool aIsSync);
protected:
friend class MMListenerRemover;

View File

@ -704,8 +704,7 @@ nsINode::SetUserData(JSContext* aCx, const nsAString& aKey,
{
nsCOMPtr<nsIVariant> data;
JS::Rooted<JS::Value> dataVal(aCx, aData);
aError = nsContentUtils::XPConnect()->JSValToVariant(aCx, dataVal.address(),
getter_AddRefs(data));
aError = nsContentUtils::XPConnect()->JSValToVariant(aCx, dataVal, getter_AddRefs(data));
if (aError.Failed()) {
return JS::UndefinedValue();
}
@ -723,7 +722,7 @@ nsINode::SetUserData(JSContext* aCx, const nsAString& aKey,
JS::Rooted<JS::Value> result(aCx);
JSAutoCompartment ac(aCx, GetWrapper());
aError = nsContentUtils::XPConnect()->VariantToJS(aCx, GetWrapper(), oldData,
result.address());
&result);
return result;
}
@ -750,7 +749,7 @@ nsINode::GetUserData(JSContext* aCx, const nsAString& aKey, ErrorResult& aError)
JS::Rooted<JS::Value> result(aCx);
JSAutoCompartment ac(aCx, GetWrapper());
aError = nsContentUtils::XPConnect()->VariantToJS(aCx, GetWrapper(), data,
result.address());
&result);
return result;
}

View File

@ -41,12 +41,12 @@ public:
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
const JS::Value& aObject,
const JS::Value& aRemote,
JS::Handle<JS::Value> aObject,
JS::Handle<JS::Value> aRemote,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aRetval)
JS::MutableHandle<JS::Value> aRetval)
{
return mMessageManager
? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
@ -54,12 +54,12 @@ public:
: NS_ERROR_NULL_POINTER;
}
NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
const JS::Value& aObject,
const JS::Value& aRemote,
JS::Handle<JS::Value> aObject,
JS::Handle<JS::Value> aRemote,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aRetval)
JS::MutableHandle<JS::Value> aRetval)
{
return mMessageManager
? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,

View File

@ -921,10 +921,10 @@ nsXMLHttpRequest::SetResponseType(nsXMLHttpRequest::ResponseTypeEnum aResponseTy
/* readonly attribute jsval response; */
NS_IMETHODIMP
nsXMLHttpRequest::GetResponse(JSContext *aCx, JS::Value *aResult)
nsXMLHttpRequest::GetResponse(JSContext *aCx, JS::MutableHandle<JS::Value> aResult)
{
ErrorResult rv;
*aResult = GetResponse(aCx, rv);
aResult.set(GetResponse(aCx, rv));
return rv.ErrorCode();
}
@ -2407,7 +2407,7 @@ GetRequestBody(nsIVariant* aBody, nsIInputStream** aResult, uint64_t* aContentLe
AutoSafeJSContext cx;
JS::Rooted<JS::Value> realVal(cx);
nsresult rv = aBody->GetAsJSVal(realVal.address());
nsresult rv = aBody->GetAsJSVal(&realVal);
if (NS_SUCCEEDED(rv) && !JSVAL_IS_PRIMITIVE(realVal)) {
JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(realVal));
if (JS_IsArrayBufferObject(obj)) {

View File

@ -327,7 +327,7 @@ HTMLCanvasElement::ParseAttribute(int32_t aNamespaceID,
// HTMLCanvasElement::toDataURL
NS_IMETHODIMP
HTMLCanvasElement::ToDataURL(const nsAString& aType, const JS::Value& aParams,
HTMLCanvasElement::ToDataURL(const nsAString& aType, JS::Handle<JS::Value> aParams,
JSContext* aCx, nsAString& aDataURL)
{
// do a trust check if this is a write-only canvas

View File

@ -1642,14 +1642,14 @@ HTMLMediaElement::MozGetMetadata(JSContext* cx, ErrorResult& aRv)
}
NS_IMETHODIMP
HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::Value* aValue)
HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::MutableHandle<JS::Value> aValue)
{
ErrorResult rv;
JSObject* obj = MozGetMetadata(cx, rv);
if (!rv.Failed()) {
MOZ_ASSERT(obj);
*aValue = JS::ObjectValue(*obj);
aValue.setObject(*obj);
}
return rv.ErrorCode();

View File

@ -155,7 +155,7 @@ WebVTTListener::OnDataAvailable(nsIRequest* aRequest,
}
NS_IMETHODIMP
WebVTTListener::OnCue(const JS::Value &aCue, JSContext* aCx)
WebVTTListener::OnCue(JS::Handle<JS::Value> aCue, JSContext* aCx)
{
if (!aCue.isObject()) {
return NS_ERROR_FAILURE;
@ -173,7 +173,7 @@ WebVTTListener::OnCue(const JS::Value &aCue, JSContext* aCx)
NS_IMETHODIMP
WebVTTListener::OnRegion(const JS::Value &aRegion, JSContext* aCx)
WebVTTListener::OnRegion(JS::Handle<JS::Value> aRegion, JSContext* aCx)
{
if (!aRegion.isObject()) {
return NS_ERROR_FAILURE;

View File

@ -152,7 +152,7 @@ SpeechTaskChild::Setup(nsISpeechTaskCallback* aCallback,
}
NS_IMETHODIMP
SpeechTaskChild::SendAudio(const JS::Value& aData, const JS::Value& aLandmarks,
SpeechTaskChild::SendAudio(JS::Handle<JS::Value> aData, JS::Handle<JS::Value> aLandmarks,
JSContext* aCx)
{
MOZ_CRASH("Should never be called from child");

View File

@ -79,7 +79,7 @@ public:
NS_IMETHOD Setup(nsISpeechTaskCallback* aCallback,
uint32_t aChannels, uint32_t aRate, uint8_t argc) MOZ_OVERRIDE;
NS_IMETHOD SendAudio(const JS::Value& aData, const JS::Value& aLandmarks,
NS_IMETHOD SendAudio(JS::Handle<JS::Value> aData, JS::Handle<JS::Value> aLandmarks,
JSContext* aCx) MOZ_OVERRIDE;
NS_IMETHOD SendAudioNative(int16_t* aData, uint32_t aDataLen) MOZ_OVERRIDE;

View File

@ -156,7 +156,7 @@ nsSpeechTask::Setup(nsISpeechTaskCallback* aCallback,
}
NS_IMETHODIMP
nsSpeechTask::SendAudio(const JS::Value& aData, const JS::Value& aLandmarks,
nsSpeechTask::SendAudio(JS::Handle<JS::Value> aData, JS::Handle<JS::Value> aLandmarks,
JSContext* aCx)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);

View File

@ -10455,7 +10455,7 @@ nsDocShell::SetReferrerURI(nsIURI * aURI)
//*****************************************************************************
NS_IMETHODIMP
nsDocShell::AddState(const JS::Value &aData, const nsAString& aTitle,
nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
const nsAString& aURL, bool aReplace, JSContext* aCx)
{
// Implements History.pushState and History.replaceState

View File

@ -80,9 +80,9 @@ DOMRequest::GetReadyState(nsAString& aReadyState)
}
NS_IMETHODIMP
DOMRequest::GetResult(JS::Value* aResult)
DOMRequest::GetResult(JS::MutableHandle<JS::Value> aResult)
{
*aResult = Result();
aResult.set(Result());
return NS_OK;
}
@ -202,11 +202,10 @@ DOMRequestService::CreateCursor(nsIDOMWindow* aWindow,
NS_IMETHODIMP
DOMRequestService::FireSuccess(nsIDOMDOMRequest* aRequest,
const JS::Value& aResult)
JS::Handle<JS::Value> aResult)
{
NS_ENSURE_STATE(aRequest);
static_cast<DOMRequest*>(aRequest)->
FireSuccess(JS::Handle<JS::Value>::fromMarkedLocation(&aResult));
static_cast<DOMRequest*>(aRequest)->FireSuccess(aResult);
return NS_OK;
}
@ -316,7 +315,7 @@ private:
NS_IMETHODIMP
DOMRequestService::FireSuccessAsync(nsIDOMDOMRequest* aRequest,
const JS::Value& aResult)
JS::Handle<JS::Value> aResult)
{
NS_ENSURE_STATE(aRequest);
return FireSuccessAsyncTask::Dispatch(static_cast<DOMRequest*>(aRequest), aResult);

View File

@ -1321,7 +1321,7 @@ Navigator::EnsureMessagesManager()
// We don't do anything with the return value.
AutoJSContext cx;
JS::Rooted<JS::Value> prop_val(cx);
rv = gpi->Init(mWindow, prop_val.address());
rv = gpi->Init(mWindow, &prop_val);
NS_ENSURE_SUCCESS(rv, rv);
mMessagesManager = messageManager.forget();
@ -1578,7 +1578,7 @@ Navigator::DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
return Throw(aCx, NS_ERROR_UNEXPECTED);
}
rv = gpi->Init(mWindow, prop_val.address());
rv = gpi->Init(mWindow, &prop_val);
if (NS_FAILED(rv)) {
return Throw(aCx, rv);
}

View File

@ -617,7 +617,7 @@ WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
return nsDOMClassInfo::XPConnect()->WrapNativeToJSVal(cx, scope, native,
cache, aIID,
aAllowWrapping, vp.address());
aAllowWrapping, vp);
}
static inline nsresult
@ -1662,7 +1662,7 @@ nsDOMClassInfo::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
NS_IMETHODIMP
nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, const jsval &val, bool *bp,
JSObject *obj, JS::Handle<JS::Value> val, bool *bp,
bool *_retval)
{
NS_WARNING("nsDOMClassInfo::HasInstance Don't call me!");
@ -3134,7 +3134,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
if (gpi) {
rv = gpi->Init(aWin, prop_val.address());
rv = gpi->Init(aWin, &prop_val);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -4508,7 +4508,7 @@ nsDOMConstructorSH::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
NS_IMETHODIMP
nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *aObj, const jsval &val,
JSContext *cx, JSObject *aObj, JS::Handle<JS::Value> val,
bool *bp, bool *_retval)
{
JS::Rooted<JSObject*> obj(cx, aObj);

View File

@ -574,7 +574,7 @@ public:
JSObject *obj, const JS::CallArgs &args, bool *_retval) MOZ_OVERRIDE;
NS_IMETHOD HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, const JS::Value &val, bool *bp,
JSObject *obj, JS::Handle<JS::Value> val, bool *bp,
bool *_retval);
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)

View File

@ -2135,7 +2135,8 @@ nsDOMWindowUtils::SendContentCommandEvent(const nsAString& aType,
}
NS_IMETHODIMP
nsDOMWindowUtils::GetClassName(const JS::Value& aObject, JSContext* aCx, char** aName)
nsDOMWindowUtils::GetClassName(JS::Handle<JS::Value> aObject, JSContext* aCx,
char** aName)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
@ -2220,29 +2221,29 @@ nsDOMWindowUtils::IsInModalState(bool *retval)
}
NS_IMETHODIMP
nsDOMWindowUtils::GetParent(const JS::Value& aObject,
nsDOMWindowUtils::GetParent(JS::Handle<JS::Value> aObject,
JSContext* aCx,
JS::Value* aParent)
JS::MutableHandle<JS::Value> aParent)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
// First argument must be an object.
if (JSVAL_IS_PRIMITIVE(aObject)) {
if (aObject.isPrimitive()) {
return NS_ERROR_XPC_BAD_CONVERT_JS;
}
JS::Rooted<JSObject*> parent(aCx, JS_GetParent(JSVAL_TO_OBJECT(aObject)));
*aParent = OBJECT_TO_JSVAL(parent);
JS::Rooted<JSObject*> parent(aCx, JS_GetParent(&aObject.toObject()));
// Outerize if necessary.
if (parent) {
if (JSObjectOp outerize = js::GetObjectClass(parent)->ext.outerObject) {
*aParent = OBJECT_TO_JSVAL(outerize(aCx, parent));
parent = outerize(aCx, parent);
}
}
aParent.setObject(*parent);
return NS_OK;
}
@ -2867,8 +2868,8 @@ GetFileOrBlob(const nsAString& aName, const JS::Value& aBlobParts,
}
NS_IMETHODIMP
nsDOMWindowUtils::GetFile(const nsAString& aName, const JS::Value& aBlobParts,
const JS::Value& aParameters, JSContext* aCx,
nsDOMWindowUtils::GetFile(const nsAString& aName, JS::Handle<JS::Value> aBlobParts,
JS::Handle<JS::Value> aParameters, JSContext* aCx,
uint8_t aOptionalArgCount, nsIDOMFile** aResult)
{
if (!nsContentUtils::IsCallerChrome()) {
@ -2887,8 +2888,8 @@ nsDOMWindowUtils::GetFile(const nsAString& aName, const JS::Value& aBlobParts,
}
NS_IMETHODIMP
nsDOMWindowUtils::GetBlob(const JS::Value& aBlobParts,
const JS::Value& aParameters, JSContext* aCx,
nsDOMWindowUtils::GetBlob(JS::Handle<JS::Value> aBlobParts,
JS::Handle<JS::Value> aParameters, JSContext* aCx,
uint8_t aOptionalArgCount, nsIDOMBlob** aResult)
{
if (!nsContentUtils::IsCallerChrome()) {
@ -2907,7 +2908,7 @@ nsDOMWindowUtils::GetBlob(const JS::Value& aBlobParts,
}
NS_IMETHODIMP
nsDOMWindowUtils::GetFileId(const JS::Value& aFile, JSContext* aCx,
nsDOMWindowUtils::GetFileId(JS::Handle<JS::Value> aFile, JSContext* aCx,
int64_t* aResult)
{
if (!nsContentUtils::IsCallerChrome()) {
@ -2939,7 +2940,7 @@ nsDOMWindowUtils::GetFileId(const JS::Value& aFile, JSContext* aCx,
NS_IMETHODIMP
nsDOMWindowUtils::GetFileReferences(const nsAString& aDatabaseName, int64_t aId,
const jsval& aOptions,
JS::Handle<JS::Value> aOptions,
int32_t* aRefCnt, int32_t* aDBRefCnt,
int32_t* aSliceRefCnt, JSContext* aCx,
bool* aResult)
@ -3097,7 +3098,7 @@ nsDOMWindowUtils::GetPaintingSuppressed(bool *aPaintingSuppressed)
}
NS_IMETHODIMP
nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::Value* aPlugins)
nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::MutableHandle<JS::Value> aPlugins)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
@ -3115,7 +3116,7 @@ nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::Value* aPlugins)
nsresult rv = nsTArrayToJSArray(cx, plugins, jsPlugins.address());
NS_ENSURE_SUCCESS(rv, rv);
*aPlugins = OBJECT_TO_JSVAL(jsPlugins);
aPlugins.setObject(*jsPlugins);
return NS_OK;
}

View File

@ -3752,7 +3752,7 @@ nsGlobalWindow::GetContent(JSContext* aCx, ErrorResult& aError)
}
JS::Rooted<JS::Value> val(aCx, JS::NullValue());
aError = treeOwner->GetContentWindow(aCx, val.address());
aError = treeOwner->GetContentWindow(aCx, &val);
if (aError.Failed()) {
return nullptr;
}
@ -3818,12 +3818,12 @@ nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
}
NS_IMETHODIMP
nsGlobalWindow::GetScriptableContent(JSContext* aCx, JS::Value* aVal)
nsGlobalWindow::GetScriptableContent(JSContext* aCx, JS::MutableHandle<JS::Value> aVal)
{
ErrorResult rv;
JS::Rooted<JSObject*> content(aCx, GetContent(aCx, rv));
if (!rv.Failed()) {
*aVal = JS::ObjectOrNullValue(content);
aVal.setObjectOrNull(content);
}
return rv.ErrorCode();
@ -4955,7 +4955,7 @@ nsGlobalWindow::RequestAnimationFrame(const nsIDocument::FrameRequestCallbackHol
}
NS_IMETHODIMP
nsGlobalWindow::RequestAnimationFrame(const JS::Value& aCallback,
nsGlobalWindow::RequestAnimationFrame(JS::Handle<JS::Value> aCallback,
JSContext* cx,
int32_t* aHandle)
{
@ -7950,15 +7950,13 @@ nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
}
NS_IMETHODIMP
nsGlobalWindow::PostMessageMoz(const JS::Value& aMessage,
nsGlobalWindow::PostMessageMoz(JS::Handle<JS::Value> aMessage,
const nsAString& aOrigin,
const JS::Value& aTransfer,
JS::Handle<JS::Value> aTransfer,
JSContext* aCx)
{
JS::Rooted<JS::Value> message(aCx, aMessage);
JS::Rooted<JS::Value> transfer(aCx, aTransfer);
ErrorResult rv;
PostMessageMoz(aCx, message, aOrigin, transfer, rv);
PostMessageMoz(aCx, aMessage, aOrigin, aTransfer, rv);
return rv.ErrorCode();
}
@ -8783,7 +8781,7 @@ nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
nsCOMPtr<nsIVariant> args;
if (aArgument.WasPassed()) {
aError = nsContentUtils::XPConnect()->JSToVariant(aCx,
aArgument.Value().get(),
aArgument.Value(),
getter_AddRefs(args));
} else {
args = CreateVoidVariant();
@ -8798,7 +8796,7 @@ nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
if (retVal) {
aError = nsContentUtils::XPConnect()->VariantToJS(aCx,
FastGetGlobalJSObject(),
retVal, result.address());
retVal, &result);
} else {
result = JS::NullValue();
}
@ -13279,13 +13277,13 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
#define EVENT(name_, id_, type_, struct_) \
NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx, \
JS::Value *vp) { \
JS::MutableHandle<JS::Value> vp) { \
EventHandlerNonNull* h = GetOn##name_(); \
vp->setObjectOrNull(h ? h->Callable().get() : nullptr); \
vp.setObjectOrNull(h ? h->Callable().get() : nullptr); \
return NS_OK; \
} \
NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx, \
const JS::Value &v) { \
JS::Handle<JS::Value> v) { \
nsRefPtr<EventHandlerNonNull> handler; \
JS::Rooted<JSObject*> callable(cx); \
if (v.isObject() && \
@ -13297,20 +13295,20 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
}
#define ERROR_EVENT(name_, id_, type_, struct_) \
NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx, \
JS::Value *vp) { \
JS::MutableHandle<JS::Value> vp) { \
nsEventListenerManager *elm = GetExistingListenerManager(); \
if (elm) { \
OnErrorEventHandlerNonNull* h = elm->GetOnErrorEventHandler(); \
if (h) { \
*vp = JS::ObjectValue(*h->Callable()); \
vp.setObject(*h->Callable()); \
return NS_OK; \
} \
} \
*vp = JSVAL_NULL; \
vp.setNull(); \
return NS_OK; \
} \
NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx, \
const JS::Value &v) { \
JS::Handle<JS::Value> v) { \
nsEventListenerManager *elm = GetOrCreateListenerManager(); \
if (!elm) { \
return NS_ERROR_OUT_OF_MEMORY; \
@ -13327,21 +13325,21 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
}
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx, \
JS::Value *vp) { \
JS::MutableHandle<JS::Value> vp) { \
nsEventListenerManager *elm = GetExistingListenerManager(); \
if (elm) { \
OnBeforeUnloadEventHandlerNonNull* h = \
elm->GetOnBeforeUnloadEventHandler(); \
if (h) { \
*vp = JS::ObjectValue(*h->Callable()); \
vp.setObject(*h->Callable()); \
return NS_OK; \
} \
} \
*vp = JSVAL_NULL; \
vp.setNull(); \
return NS_OK; \
} \
NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx, \
const JS::Value &v) { \
JS::Handle<JS::Value> v) { \
nsEventListenerManager *elm = GetOrCreateListenerManager(); \
if (!elm) { \
return NS_ERROR_OUT_OF_MEMORY; \

View File

@ -125,7 +125,7 @@ nsHistory::GetState(JSContext* aCx, ErrorResult& aRv) const
if (variant) {
JS::Rooted<JS::Value> jsData(aCx);
aRv = variant->GetAsJSVal(jsData.address());
aRv = variant->GetAsJSVal(&jsData);
if (aRv.Failed()) {
return JS::UndefinedValue();

View File

@ -1256,7 +1256,9 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
}
nsCOMPtr<nsIVariant> variant(do_QueryInterface(arg));
if (variant != nullptr) {
rv = xpc->VariantToJS(cx, aScope, variant, thisval);
JS::Rooted<JS::Value> temp(cx);
rv = xpc->VariantToJS(cx, aScope, variant, &temp);
*thisval = temp.get();
} else {
// And finally, support the nsISupportsPrimitives supplied
// by the AppShell. It generally will pass only strings, but
@ -1283,7 +1285,9 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
} else {
nsCOMPtr<nsIVariant> variant = do_QueryInterface(aArgs);
if (variant) {
rv = xpc->VariantToJS(cx, aScope, variant, argv);
JS::Rooted<JS::Value> temp(cx);
rv = xpc->VariantToJS(cx, aScope, variant, &temp);
*argv = temp.get();
} else {
NS_ERROR("Not an array, not an interface?");
rv = NS_ERROR_UNEXPECTED;

View File

@ -238,11 +238,9 @@ nsScreen::GetLockOrientationPermission() const
}
NS_IMETHODIMP
nsScreen::MozLockOrientation(const JS::Value& aOrientation_, JSContext* aCx,
nsScreen::MozLockOrientation(JS::Handle<JS::Value> aOrientation, JSContext* aCx,
bool* aReturn)
{
JS::Rooted<JS::Value> aOrientation(aCx, aOrientation_);
if (aOrientation.isObject()) {
JS::Rooted<JSObject*> seq(aCx, &aOrientation.toObject());
if (IsArrayLike(aCx, seq)) {

View File

@ -39,7 +39,7 @@ nsStructuredCloneContainer::~nsStructuredCloneContainer()
}
nsresult
nsStructuredCloneContainer::InitFromJSVal(const JS::Value & aData,
nsStructuredCloneContainer::InitFromJSVal(JS::Handle<JS::Value> aData,
JSContext* aCx)
{
NS_ENSURE_STATE(!mData);
@ -124,8 +124,7 @@ nsStructuredCloneContainer::DeserializeToVariant(JSContext *aCx,
nsCOMPtr<nsIVariant> varStateObj;
nsCOMPtr<nsIXPConnect> xpconnect = do_GetService(nsIXPConnect::GetCID());
NS_ENSURE_STATE(xpconnect);
xpconnect->JSValToVariant(aCx, jsStateObj.address(),
getter_AddRefs(varStateObj));
xpconnect->JSValToVariant(aCx, jsStateObj, getter_AddRefs(varStateObj));
NS_ENSURE_STATE(varStateObj);
NS_ADDREF(*aData = varStateObj);

View File

@ -2034,7 +2034,7 @@ ConstructJSImplementation(JSContext* aCx, const char* aContractId,
do_QueryInterface(implISupports);
if (gpi) {
JS::Rooted<JS::Value> initReturn(aCx);
nsresult rv = gpi->Init(window, initReturn.address());
nsresult rv = gpi->Init(window, &initReturn);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;

View File

@ -12,6 +12,8 @@
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "nsServiceManagerUtils.h"
#include "js/Value.h"
USING_BLUETOOTH_NAMESPACE
already_AddRefed<mozilla::dom::DOMRequest>
@ -26,7 +28,7 @@ BluetoothPropertyContainer::FirePropertyAlreadySet(nsPIDOMWindow* aOwner,
}
nsRefPtr<mozilla::dom::DOMRequest> request = new DOMRequest(aOwner);
rs->FireSuccess(request, JS::UndefinedValue());
rs->FireSuccess(request, JS::UndefinedHandleValue);
return request.forget();
}

View File

@ -246,7 +246,7 @@ class BluetoothService::StartupTask : public nsISettingsServiceCallback
public:
NS_DECL_ISUPPORTS
NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
MOZ_ASSERT(NS_IsMainThread());
@ -857,7 +857,7 @@ BluetoothService::Notify(const BluetoothSignal& aData)
do_GetService("@mozilla.org/system-message-internal;1");
NS_ENSURE_TRUE_VOID(systemMessenger);
systemMessenger->BroadcastMessage(type,
OBJECT_TO_JSVAL(obj),
JS::UndefinedValue());
JS::Rooted<JS::Value> value(cx, JS::ObjectValue(*obj));
systemMessenger->BroadcastMessage(type, value,
JS::UndefinedHandleValue);
}

View File

@ -205,7 +205,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD
Handle(const nsAString& aName, const JS::Value& aResult)
Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
MOZ_ASSERT(NS_IsMainThread());
@ -852,7 +852,9 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
mService = (regState.EqualsLiteral("registered")) ? 1 : 0;
// Signal
JS::Value value;
JSContext* cx = nsContentUtils::GetSafeJSContext();
NS_ENSURE_TRUE_VOID(cx);
JS::Rooted<JS::Value> value(cx);
voiceInfo->GetRelSignalStrength(&value);
NS_ENSURE_TRUE_VOID(value.isNumber());
mSignal = (int)ceil(value.toNumber() / 20.0);

View File

@ -128,9 +128,9 @@ BroadcastSystemMessage(const nsAString& aType,
do_GetService("@mozilla.org/system-message-internal;1");
NS_ENSURE_TRUE(systemMessenger, false);
systemMessenger->BroadcastMessage(aType,
OBJECT_TO_JSVAL(obj),
JS::UndefinedValue());
JS::Rooted<JS::Value> value(cx, JS::ObjectValue(*obj));
systemMessenger->BroadcastMessage(aType, value,
JS::UndefinedHandleValue);
return true;
}

View File

@ -162,7 +162,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD
Handle(const nsAString& aName, const JS::Value& aResult)
Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
MOZ_ASSERT(NS_IsMainThread());
@ -620,7 +620,9 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
}
UpdateCIND(CINDType::SERVICE, service);
JS::Value value;
JSContext* cx = nsContentUtils::GetSafeJSContext();
NS_ENSURE_TRUE_VOID(cx);
JS::Rooted<JS::Value> value(cx);
voiceInfo->GetRelSignalStrength(&value);
NS_ENSURE_TRUE_VOID(value.isNumber());
uint8_t signal = ceil(value.toNumber() / 20.0);

View File

@ -126,9 +126,9 @@ BroadcastSystemMessage(const nsAString& aType,
do_GetService("@mozilla.org/system-message-internal;1");
NS_ENSURE_TRUE(systemMessenger, false);
systemMessenger->BroadcastMessage(aType,
OBJECT_TO_JSVAL(obj),
JS::UndefinedValue());
JS::Rooted<JS::Value> value(cx, JS::ObjectValue(*obj));
systemMessenger->BroadcastMessage(aType, value,
JS::UndefinedHandleValue);
return true;
}

View File

@ -161,89 +161,101 @@ DOMCameraCapabilities::ParameterListToNewArray(JSContext* aCx,
}
nsresult
DOMCameraCapabilities::StringListToNewObject(JSContext* aCx, JS::Value* aArray, uint32_t aKey)
DOMCameraCapabilities::StringListToNewObject(JSContext* aCx,
JS::MutableHandle<JS::Value> aArray,
uint32_t aKey)
{
JS::Rooted<JSObject*> array(aCx);
nsresult rv = ParameterListToNewArray(aCx, &array, aKey, ParseStringItemAndAdd);
NS_ENSURE_SUCCESS(rv, rv);
*aArray = OBJECT_TO_JSVAL(array);
aArray.setObject(*array);
return NS_OK;
}
nsresult
DOMCameraCapabilities::DimensionListToNewObject(JSContext* aCx, JS::Value* aArray, uint32_t aKey)
DOMCameraCapabilities::DimensionListToNewObject(JSContext* aCx,
JS::MutableHandle<JS::Value> aArray,
uint32_t aKey)
{
JS::Rooted<JSObject*> array(aCx);
nsresult rv;
rv = ParameterListToNewArray(aCx, &array, aKey, ParseDimensionItemAndAdd);
nsresult rv = ParameterListToNewArray(aCx, &array, aKey, ParseDimensionItemAndAdd);
NS_ENSURE_SUCCESS(rv, rv);
*aArray = OBJECT_TO_JSVAL(array);
aArray.setObject(*array);
return NS_OK;
}
/* readonly attribute jsval previewSizes; */
NS_IMETHODIMP
DOMCameraCapabilities::GetPreviewSizes(JSContext* cx, JS::Value* aPreviewSizes)
DOMCameraCapabilities::GetPreviewSizes(JSContext* cx,
JS::MutableHandle<JS::Value> aPreviewSizes)
{
return DimensionListToNewObject(cx, aPreviewSizes, CAMERA_PARAM_SUPPORTED_PREVIEWSIZES);
}
/* readonly attribute jsval pictureSizes; */
NS_IMETHODIMP
DOMCameraCapabilities::GetPictureSizes(JSContext* cx, JS::Value* aPictureSizes)
DOMCameraCapabilities::GetPictureSizes(JSContext* cx,
JS::MutableHandle<JS::Value> aPictureSizes)
{
return DimensionListToNewObject(cx, aPictureSizes, CAMERA_PARAM_SUPPORTED_PICTURESIZES);
}
/* readonly attribute jsval thumbnailSizes; */
NS_IMETHODIMP
DOMCameraCapabilities::GetThumbnailSizes(JSContext* cx, JS::Value* aThumbnailSizes)
DOMCameraCapabilities::GetThumbnailSizes(JSContext* cx,
JS::MutableHandle<JS::Value> aThumbnailSizes)
{
return DimensionListToNewObject(cx, aThumbnailSizes, CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES);
}
/* readonly attribute jsval fileFormats; */
NS_IMETHODIMP
DOMCameraCapabilities::GetFileFormats(JSContext* cx, JS::Value* aFileFormats)
DOMCameraCapabilities::GetFileFormats(JSContext* cx,
JS::MutableHandle<JS::Value> aFileFormats)
{
return StringListToNewObject(cx, aFileFormats, CAMERA_PARAM_SUPPORTED_PICTUREFORMATS);
}
/* readonly attribute jsval whiteBalanceModes; */
NS_IMETHODIMP
DOMCameraCapabilities::GetWhiteBalanceModes(JSContext* cx, JS::Value* aWhiteBalanceModes)
DOMCameraCapabilities::GetWhiteBalanceModes(JSContext* cx,
JS::MutableHandle<JS::Value> aWhiteBalanceModes)
{
return StringListToNewObject(cx, aWhiteBalanceModes, CAMERA_PARAM_SUPPORTED_WHITEBALANCES);
}
/* readonly attribute jsval sceneModes; */
NS_IMETHODIMP
DOMCameraCapabilities::GetSceneModes(JSContext* cx, JS::Value* aSceneModes)
DOMCameraCapabilities::GetSceneModes(JSContext* cx,
JS::MutableHandle<JS::Value> aSceneModes)
{
return StringListToNewObject(cx, aSceneModes, CAMERA_PARAM_SUPPORTED_SCENEMODES);
}
/* readonly attribute jsval effects; */
NS_IMETHODIMP
DOMCameraCapabilities::GetEffects(JSContext* cx, JS::Value* aEffects)
DOMCameraCapabilities::GetEffects(JSContext* cx,
JS::MutableHandle<JS::Value> aEffects)
{
return StringListToNewObject(cx, aEffects, CAMERA_PARAM_SUPPORTED_EFFECTS);
}
/* readonly attribute jsval flashModes; */
NS_IMETHODIMP
DOMCameraCapabilities::GetFlashModes(JSContext* cx, JS::Value* aFlashModes)
DOMCameraCapabilities::GetFlashModes(JSContext* cx,
JS::MutableHandle<JS::Value> aFlashModes)
{
return StringListToNewObject(cx, aFlashModes, CAMERA_PARAM_SUPPORTED_FLASHMODES);
}
/* readonly attribute jsval focusModes; */
NS_IMETHODIMP
DOMCameraCapabilities::GetFocusModes(JSContext* cx, JS::Value* aFocusModes)
DOMCameraCapabilities::GetFocusModes(JSContext* cx,
JS::MutableHandle<JS::Value> aFocusModes)
{
return StringListToNewObject(cx, aFocusModes, CAMERA_PARAM_SUPPORTED_FOCUSMODES);
}
@ -335,14 +347,14 @@ DOMCameraCapabilities::GetMaxMeteringAreas(JSContext* cx, int32_t* aMaxMeteringA
/* readonly attribute jsval zoomRatios; */
NS_IMETHODIMP
DOMCameraCapabilities::GetZoomRatios(JSContext* cx, JS::Value* aZoomRatios)
DOMCameraCapabilities::GetZoomRatios(JSContext* cx, JS::MutableHandle<JS::Value> aZoomRatios)
{
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
const char* value = mCamera->GetParameterConstChar(CAMERA_PARAM_SUPPORTED_ZOOM);
if (!value || strcmp(value, "true") != 0) {
// if zoom is not supported, return a null object
*aZoomRatios = JSVAL_NULL;
aZoomRatios.setNull();
return NS_OK;
}
@ -351,13 +363,13 @@ DOMCameraCapabilities::GetZoomRatios(JSContext* cx, JS::Value* aZoomRatios)
nsresult rv = ParameterListToNewArray(cx, &array, CAMERA_PARAM_SUPPORTED_ZOOMRATIOS, ParseZoomRatioItemAndAdd);
NS_ENSURE_SUCCESS(rv, rv);
*aZoomRatios = OBJECT_TO_JSVAL(array);
aZoomRatios.setObject(*array);
return NS_OK;
}
/* readonly attribute jsval videoSizes; */
NS_IMETHODIMP
DOMCameraCapabilities::GetVideoSizes(JSContext* cx, JS::Value* aVideoSizes)
DOMCameraCapabilities::GetVideoSizes(JSContext* cx, JS::MutableHandle<JS::Value> aVideoSizes)
{
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
@ -365,8 +377,8 @@ DOMCameraCapabilities::GetVideoSizes(JSContext* cx, JS::Value* aVideoSizes)
nsresult rv = mCamera->GetVideoSizes(sizes);
NS_ENSURE_SUCCESS(rv, rv);
if (sizes.Length() == 0) {
// video recording not supported, return a null object
*aVideoSizes = JSVAL_NULL;
// video recording not supported, return null
aVideoSizes.setNull();
return NS_OK;
}
@ -392,19 +404,19 @@ DOMCameraCapabilities::GetVideoSizes(JSContext* cx, JS::Value* aVideoSizes)
}
}
*aVideoSizes = OBJECT_TO_JSVAL(array);
aVideoSizes.setObject(*array);
return NS_OK;
}
/* readonly attribute jsval recorderProfiles; */
NS_IMETHODIMP
DOMCameraCapabilities::GetRecorderProfiles(JSContext* cx, JS::Value* aRecorderProfiles)
DOMCameraCapabilities::GetRecorderProfiles(JSContext* cx, JS::MutableHandle<JS::Value> aRecorderProfiles)
{
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
nsRefPtr<RecorderProfileManager> profileMgr = mCamera->GetRecorderProfileManager();
if (!profileMgr) {
*aRecorderProfiles = JSVAL_NULL;
aRecorderProfiles.setNull();
return NS_OK;
}
@ -412,6 +424,6 @@ DOMCameraCapabilities::GetRecorderProfiles(JSContext* cx, JS::Value* aRecorderPr
nsresult rv = profileMgr->GetJsObject(cx, o.address());
NS_ENSURE_SUCCESS(rv, rv);
*aRecorderProfiles = OBJECT_TO_JSVAL(o);
aRecorderProfiles.setObject(*o);
return NS_OK;
}

View File

@ -32,8 +32,12 @@ public:
uint32_t aKey,
ParseItemAndAddFunc aParseItemAndAdd
);
nsresult StringListToNewObject(JSContext* aCx, JS::Value* aArray, uint32_t aKey);
nsresult DimensionListToNewObject(JSContext* aCx, JS::Value* aArray, uint32_t aKey);
nsresult StringListToNewObject(JSContext* aCx,
JS::MutableHandle<JS::Value> aArray,
uint32_t aKey);
nsresult DimensionListToNewObject(JSContext* aCx,
JS::MutableHandle<JS::Value> aArray,
uint32_t aKey);
private:
DOMCameraCapabilities(const DOMCameraCapabilities&) MOZ_DELETE;

View File

@ -172,24 +172,26 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsDOMEventTargetHelper,
// XPIDL event handlers
#define NS_IMPL_EVENT_HANDLER(_class, _event) \
NS_IMETHODIMP _class::GetOn##_event(JSContext* aCx, JS::Value* aValue) \
NS_IMETHODIMP _class::GetOn##_event(JSContext* aCx, \
JS::MutableHandle<JS::Value> aValue) \
{ \
GetEventHandler(nsGkAtoms::on##_event, aCx, aValue); \
GetEventHandler(nsGkAtoms::on##_event, aCx, aValue.address()); \
return NS_OK; \
} \
NS_IMETHODIMP _class::SetOn##_event(JSContext* aCx, \
const JS::Value& aValue) \
JS::Handle<JS::Value> aValue) \
{ \
return SetEventHandler(nsGkAtoms::on##_event, aCx, aValue); \
}
#define NS_IMPL_FORWARD_EVENT_HANDLER(_class, _event, _baseclass) \
NS_IMETHODIMP _class::GetOn##_event(JSContext* aCx, JS::Value* aValue) \
NS_IMETHODIMP _class::GetOn##_event(JSContext* aCx, \
JS::MutableHandle<JS::Value> aValue) \
{ \
return _baseclass::GetOn##_event(aCx, aValue); \
} \
NS_IMETHODIMP _class::SetOn##_event(JSContext* aCx, \
const JS::Value& aValue) \
JS::Handle<JS::Value> aValue) \
{ \
return _baseclass::SetOn##_event(aCx, aValue); \
}

View File

@ -63,10 +63,10 @@ nsDOMMessageEvent::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
}
NS_IMETHODIMP
nsDOMMessageEvent::GetData(JSContext* aCx, JS::Value* aData)
nsDOMMessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
{
ErrorResult rv;
*aData = GetData(aCx, rv);
aData.set(GetData(aCx, rv));
return rv.ErrorCode();
}
@ -171,7 +171,7 @@ NS_IMETHODIMP
nsDOMMessageEvent::InitMessageEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
const JS::Value& aData,
JS::Handle<JS::Value> aData,
const nsAString& aOrigin,
const nsAString& aLastEventId,
nsIDOMWindow* aSource)

View File

@ -66,7 +66,7 @@ nsDOMNotifyAudioAvailableEvent::~nsDOMNotifyAudioAvailableEvent()
}
NS_IMETHODIMP
nsDOMNotifyAudioAvailableEvent::GetFrameBuffer(JSContext* aCx, JS::Value* aResult)
nsDOMNotifyAudioAvailableEvent::GetFrameBuffer(JSContext* aCx, JS::MutableHandle<JS::Value> aResult)
{
if (!mAllowAudioData) {
// Media is not same-origin, don't allow the data out.
@ -74,7 +74,7 @@ nsDOMNotifyAudioAvailableEvent::GetFrameBuffer(JSContext* aCx, JS::Value* aResul
}
if (mCachedArray) {
*aResult = OBJECT_TO_JSVAL(mCachedArray);
aResult.setObject(*mCachedArray);
return NS_OK;
}
@ -88,7 +88,7 @@ nsDOMNotifyAudioAvailableEvent::GetFrameBuffer(JSContext* aCx, JS::Value* aResul
}
memcpy(JS_GetFloat32ArrayData(mCachedArray), mFrameBuffer.get(), mFrameBufferLength * sizeof(float));
*aResult = OBJECT_TO_JSVAL(mCachedArray);
aResult.setObject(*mCachedArray);
return NS_OK;
}

View File

@ -51,7 +51,7 @@ public:
JSObject* GetFrameBuffer(JSContext* aCx, mozilla::ErrorResult& aRv)
{
JS::Rooted<JS::Value> dummy(aCx);
aRv = GetFrameBuffer(aCx, dummy.address());
aRv = GetFrameBuffer(aCx, &dummy);
return mCachedArray;
}

View File

@ -65,10 +65,11 @@ nsEventListenerInfo::GetInSystemEventGroup(bool* aInSystemEventGroup)
}
NS_IMETHODIMP
nsEventListenerInfo::GetListenerObject(JSContext* aCx, JS::Value* aObject)
nsEventListenerInfo::GetListenerObject(JSContext* aCx,
JS::MutableHandle<JS::Value> aObject)
{
mozilla::Maybe<JSAutoCompartment> ac;
GetJSVal(aCx, ac, aObject);
GetJSVal(aCx, ac, aObject.address());
return NS_OK;
}

View File

@ -491,34 +491,33 @@ LockedFile::GetActive(bool* aActive)
NS_IMETHODIMP
LockedFile::GetLocation(JSContext* aCx,
JS::Value* aLocation)
JS::MutableHandle<JS::Value> aLocation)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (mLocation == UINT64_MAX) {
*aLocation = JSVAL_NULL;
aLocation.setNull();
}
else {
*aLocation = JS_NumberValue(double(mLocation));
aLocation.setDouble(double(mLocation));
}
return NS_OK;
}
NS_IMETHODIMP
LockedFile::SetLocation(JSContext* aCx,
const JS::Value& aLocation)
JS::Handle<JS::Value> aLocation)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
// Null means the end-of-file.
if (JSVAL_IS_NULL(aLocation)) {
if (aLocation.isNull()) {
mLocation = UINT64_MAX;
return NS_OK;
}
uint64_t location;
JS::Rooted<JS::Value> value(aCx, aLocation);
if (!JS::ToUint64(aCx, value, &location)) {
if (!JS::ToUint64(aCx, aLocation, &location)) {
return NS_ERROR_TYPE_ERR;
}
@ -527,7 +526,7 @@ LockedFile::SetLocation(JSContext* aCx,
}
NS_IMETHODIMP
LockedFile::GetMetadata(const JS::Value& aParameters,
LockedFile::GetMetadata(JS::Handle<JS::Value> aParameters,
JSContext* aCx,
nsISupports** _retval)
{
@ -546,7 +545,7 @@ LockedFile::GetMetadata(const JS::Value& aParameters,
// Get optional arguments.
if (!JSVAL_IS_VOID(aParameters) && !JSVAL_IS_NULL(aParameters)) {
nsresult rv = params->Init(aCx, &aParameters);
nsresult rv = params->Init(aCx, aParameters);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
if (!params->IsConfigured()) {
@ -658,7 +657,7 @@ LockedFile::ReadAsText(uint64_t aSize,
}
NS_IMETHODIMP
LockedFile::Write(const JS::Value& aValue,
LockedFile::Write(JS::Handle<JS::Value> aValue,
JSContext* aCx,
nsISupports** _retval)
{
@ -668,7 +667,7 @@ LockedFile::Write(const JS::Value& aValue,
}
NS_IMETHODIMP
LockedFile::Append(const JS::Value& aValue,
LockedFile::Append(JS::Handle<JS::Value> aValue,
JSContext* aCx,
nsISupports** _retval)
{

View File

@ -31,9 +31,9 @@ public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MetadataParameters)
nsresult
Init(JSContext* aCx, const JS::Value* aVal)
Init(JSContext* aCx, JS::Handle<JS::Value> aVal)
{
return mConfig.Init(aCx, aVal);
return mConfig.Init(aCx, aVal.address());
}
void

View File

@ -137,7 +137,7 @@ public:
: mPendingRequest(aPendingRequest) { }
NS_IMETHOD
Handle(const nsAString& aName, const JS::Value& aResult)
Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
FMRadioService* fmRadioService = FMRadioService::Singleton();
MOZ_ASSERT(mPendingRequest == fmRadioService->mPendingRequest);

View File

@ -56,7 +56,7 @@ Icc::NotifyStkEvent(const nsAString& aName, const nsAString& aMessage)
if (!aMessage.IsEmpty()) {
nsCOMPtr<nsIJSON> json(new nsJSON());
nsresult rv = json->DecodeToJSVal(aMessage, cx, value.address());
nsresult rv = json->DecodeToJSVal(aMessage, cx, &value);
NS_ENSURE_SUCCESS(rv, rv);
} else {
value = JS::NullValue();
@ -115,8 +115,8 @@ Icc::GetCardState(nsString& aCardState) const
}
void
Icc::SendStkResponse(const JSContext* aCx, const JS::Value& aCommand,
const JS::Value& aResponse, ErrorResult& aRv)
Icc::SendStkResponse(const JSContext* aCx, JS::Handle<JS::Value> aCommand,
JS::Handle<JS::Value> aResponse, ErrorResult& aRv)
{
if (!mProvider) {
aRv.Throw(NS_ERROR_FAILURE);
@ -149,7 +149,7 @@ Icc::SendStkMenuSelection(uint16_t aItemIdentifier, bool aHelpRequested,
}
void
Icc::SendStkTimerExpiration(const JSContext* aCx, const JS::Value& aTimer,
Icc::SendStkTimerExpiration(const JSContext* aCx, JS::Handle<JS::Value> aTimer,
ErrorResult& aRv)
{
if (!mProvider) {
@ -165,7 +165,7 @@ Icc::SendStkTimerExpiration(const JSContext* aCx, const JS::Value& aTimer,
}
void
Icc::SendStkEventDownload(const JSContext* aCx, const JS::Value& aEvent,
Icc::SendStkEventDownload(const JSContext* aCx, JS::Handle<JS::Value> aEvent,
ErrorResult& aRv)
{
if (!mProvider) {
@ -199,7 +199,7 @@ Icc::GetCardLock(const nsAString& aLockType, ErrorResult& aRv)
}
already_AddRefed<nsISupports>
Icc::UnlockCardLock(const JSContext* aCx, const JS::Value& aInfo,
Icc::UnlockCardLock(const JSContext* aCx, JS::Handle<JS::Value> aInfo,
ErrorResult& aRv)
{
if (!mProvider) {
@ -219,7 +219,8 @@ Icc::UnlockCardLock(const JSContext* aCx, const JS::Value& aInfo,
}
already_AddRefed<nsISupports>
Icc::SetCardLock(const JSContext* aCx, const JS::Value& aInfo, ErrorResult& aRv)
Icc::SetCardLock(const JSContext* aCx, JS::Handle<JS::Value> aInfo,
ErrorResult& aRv)
{
if (!mProvider) {
aRv.Throw(NS_ERROR_FAILURE);
@ -279,7 +280,7 @@ Icc::ReadContacts(const nsAString& aContactType, ErrorResult& aRv)
already_AddRefed<nsISupports>
Icc::UpdateContact(const JSContext* aCx, const nsAString& aContactType,
const JS::Value& aContact, const nsAString& aPin2,
JS::Handle<JS::Value> aContact, const nsAString& aPin2,
ErrorResult& aRv)
{
if (!mProvider) {
@ -319,8 +320,8 @@ Icc::IccOpenChannel(const nsAString& aAid, ErrorResult& aRv)
}
already_AddRefed<nsISupports>
Icc::IccExchangeAPDU(const JSContext* aCx, int32_t aChannel, const jsval& aApdu,
ErrorResult& aRv)
Icc::IccExchangeAPDU(const JSContext* aCx, int32_t aChannel,
JS::Handle<JS::Value> aApdu, ErrorResult& aRv)
{
if (!mProvider) {
aRv.Throw(NS_ERROR_FAILURE);

View File

@ -51,30 +51,31 @@ public:
GetCardState(nsString& aCardState) const;
void
SendStkResponse(const JSContext* aCx, const JS::Value& aCommand,
const JS::Value& aResponse, ErrorResult& aRv);
SendStkResponse(const JSContext* aCx, JS::Handle<JS::Value> aCommand,
JS::Handle<JS::Value> aResponse, ErrorResult& aRv);
void
SendStkMenuSelection(uint16_t aItemIdentifier, bool aHelpRequested,
ErrorResult& aRv);
void
SendStkTimerExpiration(const JSContext* aCx, const JS::Value& aTimer,
SendStkTimerExpiration(const JSContext* aCx, JS::Handle<JS::Value> aTimer,
ErrorResult& aRv);
void
SendStkEventDownload(const JSContext* aCx, const JS::Value& aEvent,
SendStkEventDownload(const JSContext* aCx, JS::Handle<JS::Value> aEvent,
ErrorResult& aRv);
already_AddRefed<nsISupports>
GetCardLock(const nsAString& aLockType, ErrorResult& aRv);
already_AddRefed<nsISupports>
UnlockCardLock(const JSContext* aCx, const JS::Value& aInfo,
UnlockCardLock(const JSContext* aCx, JS::Handle<JS::Value> aInfo,
ErrorResult& aRv);
already_AddRefed<nsISupports>
SetCardLock(const JSContext* aCx, const JS::Value& aInfo, ErrorResult& aRv);
SetCardLock(const JSContext* aCx, JS::Handle<JS::Value> aInfo,
ErrorResult& aRv);
already_AddRefed<nsISupports>
GetCardLockRetryCount(const nsAString& aLockType, ErrorResult& aRv);
@ -84,15 +85,15 @@ public:
already_AddRefed<nsISupports>
UpdateContact(const JSContext* aCx, const nsAString& aContactType,
const JS::Value& aContact, const nsAString& aPin2,
JS::Handle<JS::Value> aContact, const nsAString& aPin2,
ErrorResult& aRv);
already_AddRefed<nsISupports>
IccOpenChannel(const nsAString& aAid, ErrorResult& aRv);
already_AddRefed<nsISupports>
IccExchangeAPDU(const JSContext* aCx, int32_t aChannel, const jsval& aApdu,
ErrorResult& aRv);
IccExchangeAPDU(const JSContext* aCx, int32_t aChannel,
JS::Handle<JS::Value> aApdu, ErrorResult& aRv);
already_AddRefed<nsISupports>
IccCloseChannel(int32_t aChannel, ErrorResult& aRv);

View File

@ -130,7 +130,7 @@ IccManager::Unroot()
// nsIDOMMozIccManager
NS_IMETHODIMP
IccManager::GetIccIds(JS::Value* aIccIds)
IccManager::GetIccIds(JS::MutableHandle<JS::Value> aIccIds)
{
if (!mJsIccIds) {
nsTArray<nsString> iccIds;
@ -154,7 +154,7 @@ IccManager::GetIccIds(JS::Value* aIccIds)
Root();
}
aIccIds->setObject(*mJsIccIds);
aIccIds.setObject(*mJsIccIds);
return NS_OK;
}

View File

@ -646,7 +646,7 @@ NS_IMPL_QUERY_INTERFACE2(IndexedDatabaseManager, nsIIndexedDatabaseManager,
nsIObserver)
NS_IMETHODIMP
IndexedDatabaseManager::InitWindowless(const jsval& aGlobal, JSContext* aCx)
IndexedDatabaseManager::InitWindowless(JS::Handle<JS::Value> aGlobal, JSContext* aCx)
{
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);

View File

@ -1053,16 +1053,17 @@ public:
}
NS_IMETHOD
GetLastModifiedDate(JSContext* cx, JS::Value* aLastModifiedDate) MOZ_OVERRIDE
GetLastModifiedDate(JSContext* cx,
JS::MutableHandle<JS::Value> aLastModifiedDate) MOZ_OVERRIDE
{
if (IsDateUnknown()) {
aLastModifiedDate->setNull();
aLastModifiedDate.setNull();
} else {
JSObject* date = JS_NewDateObjectMsec(cx, mLastModificationDate);
if (!date) {
return NS_ERROR_OUT_OF_MEMORY;
}
aLastModifiedDate->setObject(*date);
aLastModifiedDate.setObject(*date);
}
return NS_OK;
}

View File

@ -62,12 +62,12 @@ public:
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
const JS::Value& aObject,
const JS::Value& aRemote,
JS::Handle<JS::Value> aObject,
JS::Handle<JS::Value> aRemote,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aRetval)
JS::MutableHandle<JS::Value> aRetval)
{
return mMessageManager
? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
@ -75,12 +75,12 @@ public:
: NS_ERROR_NULL_POINTER;
}
NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
const JS::Value& aObject,
const JS::Value& aRemote,
JS::Handle<JS::Value> aObject,
JS::Handle<JS::Value> aRemote,
nsIPrincipal* aPrincipal,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aRetval)
JS::MutableHandle<JS::Value> aRetval)
{
return mMessageManager
? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,

View File

@ -471,14 +471,14 @@ MmsMessage::GetDelivery(nsAString& aDelivery)
}
NS_IMETHODIMP
MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::Value* aDeliveryInfo)
MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aDeliveryInfo)
{
// TODO Bug 850525 It'd be better to depend on the delivery of MmsMessage
// to return a more correct value. Ex, if .delivery = 'received', we should
// also make .deliveryInfo = null, since the .deliveryInfo is useless.
uint32_t length = mDeliveryInfo.Length();
if (length == 0) {
*aDeliveryInfo = JSVAL_NULL;
aDeliveryInfo.setNull();
return NS_OK;
}
@ -552,7 +552,7 @@ MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::Value* aDeliveryInfo)
}
}
aDeliveryInfo->setObject(*deliveryInfo);
aDeliveryInfo.setObject(*deliveryInfo);
return NS_OK;
}
@ -564,13 +564,13 @@ MmsMessage::GetSender(nsAString& aSender)
}
NS_IMETHODIMP
MmsMessage::GetReceivers(JSContext* aCx, JS::Value* aReceivers)
MmsMessage::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers)
{
JS::Rooted<JSObject*> reveiversObj(aCx);
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, reveiversObj.address());
NS_ENSURE_SUCCESS(rv, rv);
aReceivers->setObject(*reveiversObj);
aReceivers.setObject(*reveiversObj);
return NS_OK;
}
@ -610,7 +610,7 @@ MmsMessage::GetSmil(nsAString& aSmil)
}
NS_IMETHODIMP
MmsMessage::GetAttachments(JSContext* aCx, JS::Value* aAttachments)
MmsMessage::GetAttachments(JSContext* aCx, JS::MutableHandle<JS::Value> aAttachments)
{
uint32_t length = mAttachments.Length();
@ -672,7 +672,7 @@ MmsMessage::GetAttachments(JSContext* aCx, JS::Value* aAttachments)
}
}
aAttachments->setObject(*attachments);
aAttachments.setObject(*attachments);
return NS_OK;
}

View File

@ -163,14 +163,13 @@ MobileMessageManager::Send(JSContext* aCx, JS::Handle<JSObject*> aGlobal,
}
NS_IMETHODIMP
MobileMessageManager::Send(const JS::Value& aNumber_,
MobileMessageManager::Send(JS::Handle<JS::Value> aNumber,
const nsAString& aMessage,
const JS::Value& aSendParams,
JS::Handle<JS::Value> aSendParams,
JSContext* aCx,
uint8_t aArgc,
JS::Value* aReturn)
JS::MutableHandle<JS::Value> aReturn)
{
JS::Rooted<JS::Value> aNumber(aCx, aNumber_);
if (!aNumber.isString() &&
!(aNumber.isObject() && JS_IsArrayObject(aCx, &aNumber.toObject()))) {
return NS_ERROR_INVALID_ARG;
@ -210,7 +209,7 @@ MobileMessageManager::Send(const JS::Value& aNumber_,
if (aNumber.isString()) {
JS::Rooted<JSString*> str(aCx, aNumber.toString());
return Send(aCx, global, serviceId, str, aMessage, aReturn);
return Send(aCx, global, serviceId, str, aMessage, aReturn.address());
}
// Must be an array then.
@ -248,13 +247,13 @@ MobileMessageManager::Send(const JS::Value& aNumber_,
return NS_ERROR_FAILURE;
}
aReturn->setObject(*obj);
aReturn.setObject(*obj);
return NS_OK;
}
NS_IMETHODIMP
MobileMessageManager::SendMMS(const JS::Value& aParams,
const JS::Value& aSendParams,
MobileMessageManager::SendMMS(JS::Handle<JS::Value> aParams,
JS::Handle<JS::Value> aSendParams,
JSContext* aCx,
uint8_t aArgc,
nsIDOMDOMRequest** aRequest)
@ -323,7 +322,7 @@ MobileMessageManager::GetMessageId(JSContext* aCx,
}
NS_IMETHODIMP
MobileMessageManager::Delete(const JS::Value& aParam, JSContext* aCx,
MobileMessageManager::Delete(JS::Handle<JS::Value> aParam, JSContext* aCx,
nsIDOMDOMRequest** aRequest)
{
// We expect Int32, SmsMessage, MmsMessage, Int32[], SmsMessage[], MmsMessage[]

View File

@ -38,9 +38,9 @@ MobileMessageService::CreateSmsMessage(int32_t aId,
const nsAString& aReceiver,
const nsAString& aBody,
const nsAString& aMessageClass,
const JS::Value& aTimestamp,
const JS::Value& aSentTimestamp,
const JS::Value& aDeliveryTimestamp,
JS::Handle<JS::Value> aTimestamp,
JS::Handle<JS::Value> aSentTimestamp,
JS::Handle<JS::Value> aDeliveryTimestamp,
const bool aRead,
JSContext* aCx,
nsIDOMMozSmsMessage** aMessage)
@ -67,16 +67,16 @@ MobileMessageService::CreateMmsMessage(int32_t aId,
uint64_t aThreadId,
const nsAString& aIccId,
const nsAString& aDelivery,
const JS::Value& aDeliveryInfo,
JS::Handle<JS::Value> aDeliveryInfo,
const nsAString& aSender,
const JS::Value& aReceivers,
const JS::Value& aTimestamp,
const JS::Value& aSentTimestamp,
JS::Handle<JS::Value> aReceivers,
JS::Handle<JS::Value> aTimestamp,
JS::Handle<JS::Value> aSentTimestamp,
bool aRead,
const nsAString& aSubject,
const nsAString& aSmil,
const JS::Value& aAttachments,
const JS::Value& aExpiryDate,
JS::Handle<JS::Value> aAttachments,
JS::Handle<JS::Value> aExpiryDate,
bool aReadReportRequested,
JSContext* aCx,
nsIDOMMozMmsMessage** aMessage)
@ -114,8 +114,8 @@ MobileMessageService::CreateSmsSegmentInfo(int32_t aSegments,
NS_IMETHODIMP
MobileMessageService::CreateThread(uint64_t aId,
const JS::Value& aParticipants,
const JS::Value& aTimestamp,
JS::Handle<JS::Value> aParticipants,
JS::Handle<JS::Value> aTimestamp,
const nsAString& aLastMessageSubject,
const nsAString& aBody,
uint64_t aUnreadCount,

View File

@ -162,14 +162,14 @@ MobileMessageThread::GetUnreadCount(uint64_t* aUnreadCount)
NS_IMETHODIMP
MobileMessageThread::GetParticipants(JSContext* aCx,
JS::Value* aParticipants)
JS::MutableHandle<JS::Value> aParticipants)
{
JS::Rooted<JSObject*> obj(aCx);
nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), obj.address());
NS_ENSURE_SUCCESS(rv, rv);
aParticipants->setObject(*obj);
aParticipants.setObject(*obj);
return NS_OK;
}

View File

@ -51,23 +51,23 @@ SmsFilter::NewSmsFilter(nsISupports** aSmsFilter)
}
NS_IMETHODIMP
SmsFilter::GetStartDate(JSContext* aCx, JS::Value* aStartDate)
SmsFilter::GetStartDate(JSContext* aCx, JS::MutableHandle<JS::Value> aStartDate)
{
if (mData.startDate() == 0) {
*aStartDate = JSVAL_NULL;
aStartDate.setNull();
return NS_OK;
}
aStartDate->setObjectOrNull(JS_NewDateObjectMsec(aCx, mData.startDate()));
NS_ENSURE_TRUE(aStartDate->isObject(), NS_ERROR_FAILURE);
aStartDate.setObjectOrNull(JS_NewDateObjectMsec(aCx, mData.startDate()));
NS_ENSURE_TRUE(aStartDate.isObject(), NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetStartDate(JSContext* aCx, const JS::Value& aStartDate)
SmsFilter::SetStartDate(JSContext* aCx, JS::Handle<JS::Value> aStartDate)
{
if (aStartDate == JSVAL_NULL) {
if (aStartDate.isNull()) {
mData.startDate() = 0;
return NS_OK;
}
@ -86,23 +86,23 @@ SmsFilter::SetStartDate(JSContext* aCx, const JS::Value& aStartDate)
}
NS_IMETHODIMP
SmsFilter::GetEndDate(JSContext* aCx, JS::Value* aEndDate)
SmsFilter::GetEndDate(JSContext* aCx, JS::MutableHandle<JS::Value> aEndDate)
{
if (mData.endDate() == 0) {
*aEndDate = JSVAL_NULL;
aEndDate.setNull();
return NS_OK;
}
aEndDate->setObjectOrNull(JS_NewDateObjectMsec(aCx, mData.endDate()));
NS_ENSURE_TRUE(aEndDate->isObject(), NS_ERROR_FAILURE);
aEndDate.setObjectOrNull(JS_NewDateObjectMsec(aCx, mData.endDate()));
NS_ENSURE_TRUE(aEndDate.isObject(), NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetEndDate(JSContext* aCx, const JS::Value& aEndDate)
SmsFilter::SetEndDate(JSContext* aCx, JS::Handle<JS::Value> aEndDate)
{
if (aEndDate == JSVAL_NULL) {
if (aEndDate.isNull()) {
mData.endDate() = 0;
return NS_OK;
}
@ -121,12 +121,12 @@ SmsFilter::SetEndDate(JSContext* aCx, const JS::Value& aEndDate)
}
NS_IMETHODIMP
SmsFilter::GetNumbers(JSContext* aCx, JS::Value* aNumbers)
SmsFilter::GetNumbers(JSContext* aCx, JS::MutableHandle<JS::Value> aNumbers)
{
uint32_t length = mData.numbers().Length();
if (length == 0) {
*aNumbers = JSVAL_NULL;
aNumbers.setNull();
return NS_OK;
}
@ -150,14 +150,14 @@ SmsFilter::GetNumbers(JSContext* aCx, JS::Value* aNumbers)
return NS_ERROR_FAILURE;
}
aNumbers->setObject(*obj);
aNumbers.setObject(*obj);
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetNumbers(JSContext* aCx, const JS::Value& aNumbers)
SmsFilter::SetNumbers(JSContext* aCx, JS::Handle<JS::Value> aNumbers)
{
if (aNumbers == JSVAL_NULL) {
if (aNumbers.isNull()) {
mData.numbers().Clear();
return NS_OK;
}
@ -241,22 +241,21 @@ SmsFilter::SetDelivery(const nsAString& aDelivery)
}
NS_IMETHODIMP
SmsFilter::GetRead(JSContext* aCx, JS::Value* aRead)
SmsFilter::GetRead(JSContext* aCx, JS::MutableHandle<JS::Value> aRead)
{
if (mData.read() == eReadState_Unknown) {
*aRead = JSVAL_NULL;
aRead.setNull();
return NS_OK;
}
aRead->setBoolean(mData.read());
aRead.setBoolean(mData.read());
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetRead(JSContext* aCx, const JS::Value& aRead)
SmsFilter::SetRead(JSContext* aCx, JS::Handle<JS::Value> aRead)
{
if (aRead == JSVAL_NULL) {
if (aRead.isNull()) {
mData.read() = eReadState_Unknown;
return NS_OK;
}
@ -270,22 +269,21 @@ SmsFilter::SetRead(JSContext* aCx, const JS::Value& aRead)
}
NS_IMETHODIMP
SmsFilter::GetThreadId(JSContext* aCx, JS::Value* aThreadId)
SmsFilter::GetThreadId(JSContext* aCx, JS::MutableHandle<JS::Value> aThreadId)
{
if (!mData.threadId()) {
*aThreadId = JSVAL_NULL;
aThreadId.setNull();
return NS_OK;
}
aThreadId->setNumber(static_cast<double>(mData.threadId()));
aThreadId.setNumber(static_cast<double>(mData.threadId()));
return NS_OK;
}
NS_IMETHODIMP
SmsFilter::SetThreadId(JSContext* aCx, const JS::Value& aThreadId)
SmsFilter::SetThreadId(JSContext* aCx, JS::Handle<JS::Value> aThreadId)
{
if (aThreadId == JSVAL_NULL) {
if (aThreadId.isNull()) {
mData.threadId() = 0;
return NS_OK;
}

View File

@ -315,7 +315,7 @@ SmsIPCService::GetMmsDefaultServiceId(uint32_t* aServiceId)
NS_IMETHODIMP
SmsIPCService::Send(uint32_t aServiceId,
const JS::Value& aParameters,
JS::Handle<JS::Value> aParameters,
nsIMobileMessageCallback *aRequest)
{
SendMmsMessageRequest req;

View File

@ -442,7 +442,7 @@ MobileConnection::SetCallForwardingOption(nsIDOMMozMobileCFInfo* aCFInfo,
}
NS_IMETHODIMP
MobileConnection::GetCallBarringOption(const JS::Value& aOption,
MobileConnection::GetCallBarringOption(JS::Handle<JS::Value> aOption,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
@ -459,7 +459,7 @@ MobileConnection::GetCallBarringOption(const JS::Value& aOption,
}
NS_IMETHODIMP
MobileConnection::SetCallBarringOption(const JS::Value& aOption,
MobileConnection::SetCallBarringOption(JS::Handle<JS::Value> aOption,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
@ -476,7 +476,7 @@ MobileConnection::SetCallBarringOption(const JS::Value& aOption,
}
NS_IMETHODIMP
MobileConnection::ChangeCallBarringPassword(const JS::Value& aInfo,
MobileConnection::ChangeCallBarringPassword(JS::Handle<JS::Value> aInfo,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;

View File

@ -80,7 +80,7 @@ NS_IMETHODIMP
TCPSocketChild::SendOpen(nsITCPSocketInternal* aSocket,
const nsAString& aHost, uint16_t aPort,
bool aUseSSL, const nsAString& aBinaryType,
nsIDOMWindow* aWindow, const JS::Value& aWindowObj,
nsIDOMWindow* aWindow, JS::Handle<JS::Value> aWindowObj,
JSContext* aCx)
{
mSocket = aSocket;
@ -198,7 +198,7 @@ TCPSocketChild::SendClose()
}
NS_IMETHODIMP
TCPSocketChild::SendSend(const JS::Value& aData,
TCPSocketChild::SendSend(JS::Handle<JS::Value> aData,
uint32_t aByteOffset,
uint32_t aByteLength,
uint32_t aTrackingNumber,
@ -234,7 +234,7 @@ TCPSocketChild::SendSend(const JS::Value& aData,
NS_IMETHODIMP
TCPSocketChild::SetSocketAndWindow(nsITCPSocketInternal *aSocket,
const JS::Value& aWindowObj,
JS::Handle<JS::Value> aWindowObj,
JSContext* aCx)
{
mSocket = aSocket;

View File

@ -121,7 +121,7 @@ TCPSocketParent::RecvOpen(const nsString& aHost, const uint16_t& aPort, const bo
}
NS_IMETHODIMP
TCPSocketParent::InitJS(const JS::Value& aIntermediary, JSContext* aCx)
TCPSocketParent::InitJS(JS::Handle<JS::Value> aIntermediary, JSContext* aCx)
{
MOZ_ASSERT(aIntermediary.isObject());
mIntermediaryObj = &aIntermediary.toObject();
@ -195,7 +195,7 @@ TCPSocketParent::RecvClose()
}
NS_IMETHODIMP
TCPSocketParent::SendEvent(const nsAString& aType, const JS::Value& aDataVal,
TCPSocketParent::SendEvent(const nsAString& aType, JS::Handle<JS::Value> aDataVal,
const nsAString& aReadyState, JSContext* aCx)
{
if (!mIPCOpen) {

View File

@ -130,7 +130,7 @@ public:
MOZ_COUNT_DTOR(GeolocationSettingsCallback);
}
NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
MOZ_ASSERT(NS_IsMainThread());

View File

@ -59,7 +59,7 @@ WarnDeprecatedMethod(DeprecationWarning warning)
}
NS_IMETHODIMP
nsJSON::Encode(const JS::Value& aValue, JSContext* cx, uint8_t aArgc,
nsJSON::Encode(JS::Handle<JS::Value> aValue, JSContext* cx, uint8_t aArgc,
nsAString &aJSON)
{
// This function should only be called from JS.
@ -112,7 +112,7 @@ NS_IMETHODIMP
nsJSON::EncodeToStream(nsIOutputStream *aStream,
const char* aCharset,
const bool aWriteBOM,
const JS::Value& val,
JS::Handle<JS::Value> val,
JSContext* cx,
uint8_t aArgc)
{
@ -359,7 +359,8 @@ nsJSONWriter::WriteToStream(nsIOutputStream *aStream,
}
NS_IMETHODIMP
nsJSON::Decode(const nsAString& json, JSContext* cx, JS::Value* aRetval)
nsJSON::Decode(const nsAString& json, JSContext* cx,
JS::MutableHandle<JS::Value> aRetval)
{
nsresult rv = WarnDeprecatedMethod(DecodeWarning);
if (NS_FAILED(rv))
@ -378,21 +379,19 @@ nsJSON::Decode(const nsAString& json, JSContext* cx, JS::Value* aRetval)
NS_IMETHODIMP
nsJSON::DecodeFromStream(nsIInputStream *aStream, int32_t aContentLength,
JSContext* cx, JS::Value* aRetval)
JSContext* cx, JS::MutableHandle<JS::Value> aRetval)
{
return DecodeInternal(cx, aStream, aContentLength, true, aRetval);
}
NS_IMETHODIMP
nsJSON::DecodeToJSVal(const nsAString &str, JSContext *cx, JS::Value *result)
nsJSON::DecodeToJSVal(const nsAString &str, JSContext *cx,
JS::MutableHandle<JS::Value> result)
{
JS::Rooted<JS::Value> value(cx);
if (!JS_ParseJSON(cx, static_cast<const jschar*>(PromiseFlatString(str).get()),
str.Length(), &value)) {
str.Length(), result)) {
return NS_ERROR_UNEXPECTED;
}
*result = value;
return NS_OK;
}
@ -401,7 +400,7 @@ nsJSON::DecodeInternal(JSContext* cx,
nsIInputStream *aStream,
int32_t aContentLength,
bool aNeedsConverter,
JS::Value* aRetval)
JS::MutableHandle<JS::Value> aRetval)
{
// Consume the stream
nsCOMPtr<nsIChannel> jsonChannel;
@ -418,7 +417,7 @@ nsJSON::DecodeInternal(JSContext* cx,
return NS_ERROR_FAILURE;
nsRefPtr<nsJSONListener> jsonListener =
new nsJSONListener(cx, aRetval, aNeedsConverter);
new nsJSONListener(cx, aRetval.address(), aNeedsConverter);
//XXX this stream pattern should be consolidated in netwerk
rv = jsonListener->OnStartRequest(jsonChannel, nullptr);

View File

@ -59,7 +59,7 @@ protected:
nsIInputStream* aStream,
int32_t aContentLength,
bool aNeedsConverter,
JS::Value* aRetVal);
JS::MutableHandle<JS::Value> aRetVal);
nsCOMPtr<nsIURI> mURI;
};

View File

@ -293,7 +293,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
pusher.Push(cx);
rv = xpc->EvalInSandboxObject(NS_ConvertUTF8toUTF16(script),
/* filename = */ nullptr, cx,
sandboxObj, true, v.address());
sandboxObj, true, &v);
// Propagate and report exceptions that happened in the
// sandbox.

View File

@ -121,7 +121,7 @@ public:
AudioChannelVolInitCallback() {}
NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
nsCOMPtr<nsIAudioManager> audioManager =
do_GetService(NS_AUDIOMANAGER_CONTRACTID);

View File

@ -41,7 +41,7 @@ public:
SettingsServiceCallback() {}
NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
if (JSVAL_IS_INT(aResult)) {
int32_t mode = JSVAL_TO_INT(aResult);
@ -67,7 +67,7 @@ public:
CheckVolumeSettingsCallback(const nsACString& aVolumeName)
: mVolumeName(aVolumeName) {}
NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
if (JSVAL_IS_BOOLEAN(aResult)) {
bool isSharingEnabled = JSVAL_TO_BOOLEAN(aResult);
@ -119,8 +119,12 @@ AutoMounterSetting::AutoMounterSetting()
nsCOMPtr<nsISettingsServiceLock> lock;
settingsService->CreateLock(getter_AddRefs(lock));
nsCOMPtr<nsISettingsServiceCallback> callback = new SettingsServiceCallback();
lock->Set(UMS_MODE, INT_TO_JSVAL(AUTOMOUNTER_DISABLE), callback, nullptr);
lock->Set(UMS_STATUS, INT_TO_JSVAL(mStatus), nullptr, nullptr);
mozilla::AutoSafeJSContext cx;
JS::Rooted<JS::Value> value(cx);
value.setInt32(AUTOMOUNTER_DISABLE);
lock->Set(UMS_MODE, value, callback, nullptr);
value.setInt32(mStatus);
lock->Set(UMS_STATUS, value, nullptr, nullptr);
}
AutoMounterSetting::~AutoMounterSetting()
@ -193,7 +197,9 @@ public:
settingsService->CreateLock(getter_AddRefs(lock));
// lock may be null if this gets called during shutdown.
if (lock) {
lock->Set(UMS_STATUS, INT_TO_JSVAL(mStatus), nullptr, nullptr);
mozilla::AutoSafeJSContext cx;
JS::Rooted<JS::Value> value(cx, JS::Int32Value(mStatus));
lock->Set(UMS_STATUS, value, nullptr, nullptr);
}
return NS_OK;
}

View File

@ -723,7 +723,7 @@ GonkGPSGeolocationProvider::ReceiveDataCallList(nsIRILDataCallInfo** aDataCalls,
NS_IMETHODIMP
GonkGPSGeolocationProvider::Handle(const nsAString& aName,
const JS::Value& aResult)
JS::Handle<JS::Value> aResult)
{
if (aName.EqualsLiteral("ril.supl.apn")) {
JSContext *cx = nsContentUtils::GetCurrentJSContext();

View File

@ -343,15 +343,15 @@ SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult)
nsresult
SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
const JS::Value& aWorker,
JS::Handle<JS::Value> aWorker,
JSContext *aCx)
{
#ifndef MOZ_B2G_RIL
return NS_ERROR_NOT_IMPLEMENTED;
#else
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aWorker), NS_ERROR_UNEXPECTED);
NS_ENSURE_TRUE(aWorker.isObject(), NS_ERROR_UNEXPECTED);
JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker));
JSAutoCompartment ac(aCx, &aWorker.toObject());
WorkerCrossThreadDispatcher *wctd =
GetWorkerCrossThreadDispatcher(aCx, aWorker);
@ -365,15 +365,15 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
}
nsresult
SystemWorkerManager::RegisterNfcWorker(const JS::Value& aWorker,
SystemWorkerManager::RegisterNfcWorker(JS::Handle<JS::Value> aWorker,
JSContext* aCx)
{
#ifndef MOZ_NFC
return NS_ERROR_NOT_IMPLEMENTED;
#else
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aWorker), NS_ERROR_UNEXPECTED);
NS_ENSURE_TRUE(aWorker.isObject(), NS_ERROR_UNEXPECTED);
JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker));
JSAutoCompartment ac(aCx, &aWorker.toObject());
WorkerCrossThreadDispatcher* wctd =
GetWorkerCrossThreadDispatcher(aCx, aWorker);
@ -392,12 +392,12 @@ SystemWorkerManager::InitNetd(JSContext *cx)
nsCOMPtr<nsIWorkerHolder> worker = do_GetService(kNetworkServiceCID);
NS_ENSURE_TRUE(worker, NS_ERROR_FAILURE);
JS::Value workerval;
JS::Rooted<JS::Value> workerval(cx);
nsresult rv = worker->GetWorker(&workerval);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(workerval), NS_ERROR_UNEXPECTED);
NS_ENSURE_TRUE(workerval.isObject(), NS_ERROR_UNEXPECTED);
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(workerval));
JSAutoCompartment ac(cx, &workerval.toObject());
WorkerCrossThreadDispatcher *wctd =
GetWorkerCrossThreadDispatcher(cx, workerval);

View File

@ -52,7 +52,7 @@ public:
TimeZoneSettingCb() {}
NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult) {
NS_IMETHOD Handle(const nsAString &aName, JS::Handle<JS::Value> aResult) {
JSContext *cx = nsContentUtils::GetCurrentJSContext();
NS_ENSURE_TRUE(cx, NS_OK);
@ -74,7 +74,12 @@ public:
// Convert it to a JS string.
NS_ConvertUTF8toUTF16 utf16Str(curTimeZone);
JSString *jsStr = JS_NewUCStringCopyN(cx, utf16Str.get(), utf16Str.Length());
JS::Rooted<JSString*> jsStr(cx, JS_NewUCStringCopyN(cx,
utf16Str.get(),
utf16Str.Length()));
if (!jsStr) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Set the settings based on the current system timezone.
nsCOMPtr<nsISettingsServiceLock> lock;
@ -85,7 +90,8 @@ public:
return NS_OK;
}
settingsService->CreateLock(getter_AddRefs(lock));
lock->Set(TIME_TIMEZONE, STRING_TO_JSVAL(jsStr), nullptr, nullptr);
JS::Rooted<JS::Value> value(cx, JS::StringValue(jsStr));
lock->Set(TIME_TIMEZONE, value, nullptr, nullptr);
return NS_OK;
}

View File

@ -237,14 +237,14 @@ WifiProxyService::Shutdown()
}
NS_IMETHODIMP
WifiProxyService::SendCommand(const JS::Value& aOptions, const nsACString& aInterface,
WifiProxyService::SendCommand(JS::Handle<JS::Value> aOptions,
const nsACString& aInterface,
JSContext* aCx)
{
MOZ_ASSERT(NS_IsMainThread());
WifiCommandOptions options;
if (!options.Init(aCx,
JS::Handle<JS::Value>::fromMarkedLocation(&aOptions))) {
if (!options.Init(aCx, aOptions)) {
NS_WARNING("Bad dictionary passed to WifiProxyService::SendCommand");
return NS_ERROR_FAILURE;
}

View File

@ -410,12 +410,9 @@ private:
nsIDOMFile* file = GetInstancePrivate(aCx, obj, "lastModifiedDate");
MOZ_ASSERT(file);
JS::Rooted<JS::Value> value(aCx);
if (NS_FAILED(file->GetLastModifiedDate(aCx, value.address()))) {
if (NS_FAILED(file->GetLastModifiedDate(aCx, aArgs.rval()))) {
return false;
}
aArgs.rval().set(value);
return true;
}

View File

@ -1159,7 +1159,7 @@ EventRunnable::PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
}
else {
JS::Rooted<JS::Value> response(aCx);
mResponseResult = xhr->GetResponse(aCx, response.address());
mResponseResult = xhr->GetResponse(aCx, &response);
if (NS_SUCCEEDED(mResponseResult)) {
if (JSVAL_IS_UNIVERSAL(response)) {
mResponse = response;
@ -1459,8 +1459,7 @@ SendRunnable::MainThreadRun()
JS::Rooted<JS::Value> body(cx);
if (mBody.read(cx, &body, callbacks, &mClonedObjects)) {
if (NS_FAILED(xpc->JSValToVariant(cx, body.address(),
getter_AddRefs(variant)))) {
if (NS_FAILED(xpc->JSValToVariant(cx, body, getter_AddRefs(variant)))) {
rv = NS_ERROR_DOM_INVALID_STATE_ERR;
}
}

View File

@ -362,7 +362,8 @@ nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
}
NS_IMETHODIMP
nsDocShellTreeOwner::GetContentWindow(JSContext* aCx, JS::Value* aVal)
nsDocShellTreeOwner::GetContentWindow(JSContext* aCx,
JS::MutableHandle<JS::Value> aVal)
{
if (mTreeOwner)
return mTreeOwner->GetContentWindow(aCx, aVal);

View File

@ -118,7 +118,7 @@ nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
nsAutoCString script(js_buffer, length);
JS::RootedValue v(cx);
rv = xpc->EvalInSandboxObject(NS_ConvertASCIItoUTF16(script), filename, cx, autoconfigSb,
/* returnStringOnly = */ false, v.address());
/* returnStringOnly = */ false, &v);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;

View File

@ -127,12 +127,12 @@ NS_IMETHODIMP nsScriptableRegion::GetRegion(nsIntRegion* outRgn)
return NS_OK;
}
NS_IMETHODIMP nsScriptableRegion::GetRects(JSContext* aCx, JS::Value* aRects)
NS_IMETHODIMP nsScriptableRegion::GetRects(JSContext* aCx, JS::MutableHandle<JS::Value> aRects)
{
uint32_t numRects = mRegion.GetNumRects();
if (!numRects) {
*aRects = JSVAL_NULL;
aRects.setNull();
return NS_OK;
}
@ -141,7 +141,7 @@ NS_IMETHODIMP nsScriptableRegion::GetRects(JSContext* aCx, JS::Value* aRects)
return NS_ERROR_OUT_OF_MEMORY;
}
*aRects = OBJECT_TO_JSVAL(destArray);
aRects.setObject(*destArray);
uint32_t n = 0;
nsIntRegionRectIterator iter(mRegion);

View File

@ -36,7 +36,7 @@ JSDebugger::~JSDebugger()
}
NS_IMETHODIMP
JSDebugger::AddClass(const JS::Value &global, JSContext* cx)
JSDebugger::AddClass(JS::Handle<JS::Value> global, JSContext* cx)
{
nsresult rv;
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID(), &rv);

View File

@ -2364,16 +2364,14 @@ jsdValue::Refresh()
}
NS_IMETHODIMP
jsdValue::GetWrappedValue(JSContext* aCx, JS::Value* aRetval)
jsdValue::GetWrappedValue(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval)
{
ASSERT_VALID_EPHEMERAL;
JS::RootedValue value(aCx, JSD_GetValueWrappedJSVal(mCx, mValue));
if (!JS_WrapValue(aCx, &value)) {
aRetval.set(JSD_GetValueWrappedJSVal(mCx, mValue));
if (!JS_WrapValue(aCx, aRetval))
return NS_ERROR_FAILURE;
}
*aRetval = value;
return NS_OK;
}
@ -2987,7 +2985,7 @@ jsdService::ClearAllBreakpoints (void)
}
NS_IMETHODIMP
jsdService::WrapValue(const JS::Value &value, jsdIValue **_rval)
jsdService::WrapValue(JS::Handle<JS::Value> value, jsdIValue **_rval)
{
ASSERT_VALID_CONTEXT;
JSDValue *jsdv = JSD_NewValue(mCx, value);

View File

@ -26,7 +26,6 @@ class nsAXPCNativeCallContext;
[ptr] native JSClassPtr(JSClass);
[ptr] native JSFreeOpPtr(JSFreeOp);
[ptr] native JSObjectPtr(JSObject);
[ptr] native JSValPtr(JS::Value);
[ptr] native JSValConstPtr(const JS::Value);
native JSPropertyOp(JSPropertyOp);
native JSEqualityOp(JSEqualityOp);
@ -409,7 +408,7 @@ interface nsIXPConnect : nsISupports
* Wraps the given jsval in a nsIVariant and returns the new variant.
*/
nsIVariant
jSValToVariant(in JSContextPtr cx, in JSValPtr aJSVal);
jSValToVariant(in JSContextPtr cx, in jsval aJSVal);
/**
* This only succeeds if the JSObject is a nsIXPConnectWrappedNative.

View File

@ -177,7 +177,7 @@ File(JSContext *cx, unsigned argc, Value *vp)
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->WrapNativeToJSVal(cx, glob, native, nullptr,
&NS_GET_IID(nsISupports),
true, args.rval().address());
true, args.rval());
if (NS_FAILED(rv)) {
XPCThrower::Throw(rv, cx);
return false;
@ -212,7 +212,7 @@ Blob(JSContext *cx, unsigned argc, Value *vp)
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->WrapNativeToJSVal(cx, glob, native, nullptr,
&NS_GET_IID(nsISupports),
true, args.rval().address());
true, args.rval());
if (NS_FAILED(rv)) {
XPCThrower::Throw(rv, cx);
return false;
@ -1084,10 +1084,10 @@ mozJSComponentLoader::UnloadModules()
NS_IMETHODIMP
mozJSComponentLoader::Import(const nsACString& registryLocation,
const Value& targetValArg,
JSContext* cx,
HandleValue targetValArg,
JSContext *cx,
uint8_t optionalArgc,
Value* retval)
MutableHandleValue retval)
{
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
@ -1133,7 +1133,7 @@ mozJSComponentLoader::Import(const nsACString& registryLocation,
return NS_ERROR_FAILURE;
}
*retval = ObjectValue(*global);
retval.setObject(*global);
}
return rv;
}

View File

@ -184,10 +184,10 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *targetObj
NS_IMETHODIMP
mozJSSubScriptLoader::LoadSubScript(const nsAString& url,
const Value& targetArg,
HandleValue target,
const nsAString& charset,
JSContext* cx,
Value* retval)
JSContext *cx,
MutableHandleValue retval)
{
/*
* Loads a local url and evals it into the current cx
@ -202,14 +202,16 @@ mozJSSubScriptLoader::LoadSubScript(const nsAString& url,
*/
LoadSubScriptOptions options(cx);
options.charset = charset;
options.target = targetArg.isObject() ? &targetArg.toObject() : nullptr;
options.target = target.isObject() ? &target.toObject() : nullptr;
return DoLoadSubScriptWithOptions(url, options, cx, retval);
}
NS_IMETHODIMP
mozJSSubScriptLoader::LoadSubScriptWithOptions(const nsAString& url, const Value& optionsVal,
JSContext* cx, Value* retval)
mozJSSubScriptLoader::LoadSubScriptWithOptions(const nsAString& url,
HandleValue optionsVal,
JSContext *cx,
MutableHandleValue retval)
{
if (!optionsVal.isObject())
return NS_ERROR_INVALID_ARG;
@ -222,7 +224,8 @@ mozJSSubScriptLoader::LoadSubScriptWithOptions(const nsAString& url, const Value
nsresult
mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString& url,
LoadSubScriptOptions& options,
JSContext* cx, Value* retval)
JSContext *cx,
MutableHandleValue retval)
{
nsresult rv = NS_OK;
@ -346,19 +349,18 @@ mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString& url,
loader->NoteSubScript(script, targetObj);
RootedValue rval(cx);
bool ok = false;
if (function) {
ok = JS_CallFunction(cx, targetObj, function, 0, nullptr, rval.address());
ok = JS_CallFunction(cx, targetObj, function, 0, nullptr, retval.address());
} else {
ok = JS_ExecuteScriptVersion(cx, targetObj, script, rval.address(), version);
ok = JS_ExecuteScriptVersion(cx, targetObj, script, retval.address(), version);
}
if (ok) {
JSAutoCompartment rac(cx, result_obj);
if (!JS_WrapValue(cx, &rval))
if (!JS_WrapValue(cx, retval))
return NS_ERROR_UNEXPECTED;
*retval = rval;
}
if (cache && ok && writeScript) {

View File

@ -40,7 +40,8 @@ private:
nsresult DoLoadSubScriptWithOptions(const nsAString& url,
LoadSubScriptOptions& options,
JSContext* cx, JS::Value* retval);
JSContext* cx,
JS::MutableHandle<JS::Value> retval);
nsCOMPtr<nsIPrincipal> mSystemPrincipal;
};

View File

@ -170,7 +170,7 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::Construct(nsIXPConnectWrappedNative *wrapper, J
#endif
#ifndef XPC_MAP_WANT_HASINSTANCE
NS_IMETHODIMP XPC_MAP_CLASSNAME::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, const JS::Value &val, bool *bp, bool *_retval)
NS_IMETHODIMP XPC_MAP_CLASSNAME::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, JS::HandleValue val, bool *bp, bool *_retval)
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
#endif

View File

@ -1524,11 +1524,10 @@ nsXPCComponents_ID::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
NS_IMETHODIMP
nsXPCComponents_ID::HasInstance(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj,
const jsval &val, bool *bp, bool *_retval)
HandleValue val, bool *bp, bool *_retval)
{
RootedValue v(cx, val);
if (bp)
*bp = JSValIsInterfaceOfType(cx, v, NS_GET_IID(nsIJSID));
*bp = JSValIsInterfaceOfType(cx, val, NS_GET_IID(nsIJSID));
return NS_OK;
}
@ -1890,7 +1889,7 @@ nsXPCComponents_Exception::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
NS_IMETHODIMP
nsXPCComponents_Exception::HasInstance(nsIXPConnectWrappedNative *wrapper,
JSContext * cx, JSObject * obj,
const jsval &val, bool *bp,
HandleValue val, bool *bp,
bool *_retval)
{
using namespace mozilla::dom;
@ -2494,12 +2493,11 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
NS_IMETHODIMP
nsXPCComponents_Constructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
JSContext * cx, JSObject * obj,
const jsval &val, bool *bp,
HandleValue val, bool *bp,
bool *_retval)
{
RootedValue v(cx, val);
if (bp)
*bp = JSValIsInterfaceOfType(cx, v, NS_GET_IID(nsIXPCConstructor));
*bp = JSValIsInterfaceOfType(cx, val, NS_GET_IID(nsIXPCConstructor));
return NS_OK;
}
@ -2549,10 +2547,8 @@ nsXPCComponents_Utils::GetSandbox(nsIXPCComponents_utils_Sandbox **aSandbox)
/* void reportError (); */
NS_IMETHODIMP
nsXPCComponents_Utils::ReportError(const Value &errorArg, JSContext *cx)
nsXPCComponents_Utils::ReportError(HandleValue error, JSContext *cx)
{
RootedValue error(cx, errorArg);
// This function shall never fail! Silently eat any failure conditions.
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
@ -2622,16 +2618,14 @@ nsXPCComponents_Utils::ReportError(const Value &errorArg, JSContext *cx)
/* void evalInSandbox(in AString source, in nativeobj sandbox); */
NS_IMETHODIMP
nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
const Value& sandboxValArg,
const Value& versionArg,
const Value& filenameVal,
HandleValue sandboxVal,
HandleValue version,
HandleValue filenameVal,
int32_t lineNumber,
JSContext *cx,
uint8_t optionalArgc,
Value *retval)
MutableHandleValue retval)
{
RootedValue sandboxVal(cx, sandboxValArg);
RootedValue version(cx, versionArg);
RootedObject sandbox(cx);
if (!JS_ValueToObject(cx, sandboxVal, &sandbox) || !sandbox)
return NS_ERROR_INVALID_ARG;
@ -2663,8 +2657,7 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
nsXPIDLCString filename;
int32_t lineNo = (optionalArgc >= 3) ? lineNumber : 1;
if (optionalArgc >= 2) {
RootedValue value(cx, filenameVal);
JSString *filenameStr = ToString(cx, value);
JSString *filenameStr = ToString(cx, filenameVal);
if (!filenameStr)
return NS_ERROR_INVALID_ARG;
@ -2686,17 +2679,13 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
}
}
RootedValue rval(cx);
nsresult rv = xpc::EvalInSandbox(cx, sandbox, source, filename.get(), lineNo,
jsVersion, false, &rval);
NS_ENSURE_SUCCESS(rv, rv);
*retval = rval;
return NS_OK;
return xpc::EvalInSandbox(cx, sandbox, source, filename.get(), lineNo,
jsVersion, false, retval);
}
NS_IMETHODIMP
nsXPCComponents_Utils::GetSandboxMetadata(const Value &sandboxVal,
JSContext *cx, Value *rval)
nsXPCComponents_Utils::GetSandboxMetadata(HandleValue sandboxVal,
JSContext *cx, MutableHandleValue rval)
{
if (!sandboxVal.isObject())
return NS_ERROR_INVALID_ARG;
@ -2706,17 +2695,12 @@ nsXPCComponents_Utils::GetSandboxMetadata(const Value &sandboxVal,
if (!sandbox || !xpc::IsSandbox(sandbox))
return NS_ERROR_INVALID_ARG;
RootedValue metadata(cx);
nsresult rv = xpc::GetSandboxMetadata(cx, sandbox, &metadata);
NS_ENSURE_SUCCESS(rv, rv);
*rval = metadata;
return NS_OK;
return xpc::GetSandboxMetadata(cx, sandbox, rval);
}
NS_IMETHODIMP
nsXPCComponents_Utils::SetSandboxMetadata(const Value &sandboxVal,
const Value &metadataVal,
nsXPCComponents_Utils::SetSandboxMetadata(HandleValue sandboxVal,
HandleValue metadataVal,
JSContext *cx)
{
if (!sandboxVal.isObject())
@ -2727,8 +2711,7 @@ nsXPCComponents_Utils::SetSandboxMetadata(const Value &sandboxVal,
if (!sandbox || !xpc::IsSandbox(sandbox))
return NS_ERROR_INVALID_ARG;
RootedValue metadata(cx, metadataVal);
nsresult rv = xpc::SetSandboxMetadata(cx, sandbox, metadata);
nsresult rv = xpc::SetSandboxMetadata(cx, sandbox, metadataVal);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -2739,10 +2722,10 @@ nsXPCComponents_Utils::SetSandboxMetadata(const Value &sandboxVal,
*/
NS_IMETHODIMP
nsXPCComponents_Utils::Import(const nsACString& registryLocation,
const Value& targetObj,
HandleValue targetObj,
JSContext* cx,
uint8_t optionalArgc,
Value* retval)
MutableHandleValue retval)
{
nsCOMPtr<xpcIJSModuleLoader> moduleloader =
do_GetService(MOZJSCOMPONENTLOADER_CONTRACTID);
@ -2767,7 +2750,7 @@ nsXPCComponents_Utils::Unload(const nsACString & registryLocation)
* JSObject importGlobalProperties (in jsval aPropertyList);
*/
NS_IMETHODIMP
nsXPCComponents_Utils::ImportGlobalProperties(const JS::Value& aPropertyList,
nsXPCComponents_Utils::ImportGlobalProperties(HandleValue aPropertyList,
JSContext* cx)
{
RootedObject global(cx, CurrentGlobalOrNull(cx));
@ -2787,7 +2770,7 @@ nsXPCComponents_Utils::ImportGlobalProperties(const JS::Value& aPropertyList,
/* xpcIJSWeakReference getWeakReference (); */
NS_IMETHODIMP
nsXPCComponents_Utils::GetWeakReference(const Value &object, JSContext *cx,
nsXPCComponents_Utils::GetWeakReference(HandleValue object, JSContext *cx,
xpcIJSWeakReference **_retval)
{
nsRefPtr<xpcJSWeakReference> ref = new xpcJSWeakReference();
@ -2876,41 +2859,41 @@ nsXPCComponents_Utils::SchedulePreciseShrinkingGC(ScheduledGCCallback* aCallback
/* [implicit_jscontext] jsval nondeterministicGetWeakMapKeys(in jsval aMap); */
NS_IMETHODIMP
nsXPCComponents_Utils::NondeterministicGetWeakMapKeys(const Value &aMap,
nsXPCComponents_Utils::NondeterministicGetWeakMapKeys(HandleValue aMap,
JSContext *aCx,
Value *aKeys)
MutableHandleValue aKeys)
{
if (!aMap.isObject()) {
aKeys->setUndefined();
aKeys.setUndefined();
return NS_OK;
}
RootedObject objRet(aCx);
if (!JS_NondeterministicGetWeakMapKeys(aCx, &aMap.toObject(), objRet.address()))
return NS_ERROR_OUT_OF_MEMORY;
*aKeys = objRet ? ObjectValue(*objRet) : UndefinedValue();
aKeys.set(objRet ? ObjectValue(*objRet) : UndefinedValue());
return NS_OK;
}
/* void getDebugObject(); */
NS_IMETHODIMP
nsXPCComponents_Utils::GetJSTestingFunctions(JSContext *cx,
Value *retval)
MutableHandleValue retval)
{
JSObject *obj = js::GetTestingFunctions(cx);
if (!obj)
return NS_ERROR_XPC_JAVASCRIPT_ERROR;
*retval = OBJECT_TO_JSVAL(obj);
retval.setObject(*obj);
return NS_OK;
}
/* void getGlobalForObject(); */
NS_IMETHODIMP
nsXPCComponents_Utils::GetGlobalForObject(const Value& object,
nsXPCComponents_Utils::GetGlobalForObject(HandleValue object,
JSContext *cx,
Value *retval)
MutableHandleValue retval)
{
// First argument must be an object.
if (JSVAL_IS_PRIMITIVE(object))
if (object.isPrimitive())
return NS_ERROR_XPC_BAD_CONVERT_JS;
// Wrappers are parented to their the global in their home compartment. But
@ -2918,7 +2901,7 @@ nsXPCComponents_Utils::GetGlobalForObject(const Value& object,
// a wrapper for the foreign global. So we need to unwrap before getting the
// parent, enter the compartment for the duration of the call, and wrap the
// result.
Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(object));
Rooted<JSObject*> obj(cx, &object.toObject());
obj = js::UncheckedUnwrap(obj);
{
JSAutoCompartment ac(cx, obj);
@ -2928,12 +2911,11 @@ nsXPCComponents_Utils::GetGlobalForObject(const Value& object,
if (!JS_WrapObject(cx, &obj))
return NS_ERROR_FAILURE;
*retval = OBJECT_TO_JSVAL(obj);
// Outerize if necessary.
if (JSObjectOp outerize = js::GetObjectClass(obj)->ext.outerObject)
*retval = OBJECT_TO_JSVAL(outerize(cx, obj));
obj = outerize(cx, obj);
retval.setObject(*obj);
return NS_OK;
}
@ -2984,7 +2966,7 @@ xpc::CreateObjectIn(JSContext *cx, HandleValue vobj, CreateObjectInOptions &opti
/* boolean isProxy(in value vobj); */
NS_IMETHODIMP
nsXPCComponents_Utils::IsProxy(const Value &vobj, JSContext *cx, bool *rval)
nsXPCComponents_Utils::IsProxy(HandleValue vobj, JSContext *cx, bool *rval)
{
if (!vobj.isObject()) {
*rval = false;
@ -3001,40 +2983,33 @@ nsXPCComponents_Utils::IsProxy(const Value &vobj, JSContext *cx, bool *rval)
/* jsval evalInWindow(in string source, in jsval window); */
NS_IMETHODIMP
nsXPCComponents_Utils::EvalInWindow(const nsAString &source, const Value &window,
JSContext *cx, Value *rval)
nsXPCComponents_Utils::EvalInWindow(const nsAString &source, HandleValue window,
JSContext *cx, MutableHandleValue rval)
{
if (!window.isObject())
return NS_ERROR_INVALID_ARG;
RootedObject rwindow(cx, &window.toObject());
RootedValue res(cx);
if (!xpc::EvalInWindow(cx, source, rwindow, &res))
if (!xpc::EvalInWindow(cx, source, rwindow, rval))
return NS_ERROR_FAILURE;
*rval = res;
return NS_OK;
}
/* jsval exportFunction(in jsval vfunction, in jsval vscope, in jsval vname); */
NS_IMETHODIMP
nsXPCComponents_Utils::ExportFunction(const Value &vfunction, const Value &vscope,
const Value &voptions, JSContext *cx, Value *rval)
nsXPCComponents_Utils::ExportFunction(HandleValue vfunction, HandleValue vscope,
HandleValue voptions, JSContext *cx,
MutableHandleValue rval)
{
RootedValue rfunction(cx, vfunction);
RootedValue rscope(cx, vscope);
RootedValue roptions(cx, voptions);
RootedValue res(cx);
if (!xpc::ExportFunction(cx, rfunction, rscope, roptions, &res))
if (!xpc::ExportFunction(cx, vfunction, vscope, voptions, rval))
return NS_ERROR_FAILURE;
*rval = res;
return NS_OK;
}
/* jsval createObjectIn(in jsval vobj, [optional] in jsval voptions); */
NS_IMETHODIMP
nsXPCComponents_Utils::CreateObjectIn(const Value &vobj, const Value &voptions,
JSContext *cx, Value *rval)
nsXPCComponents_Utils::CreateObjectIn(HandleValue vobj, HandleValue voptions,
JSContext *cx, MutableHandleValue rval)
{
RootedObject optionsObject(cx, voptions.isObject() ? &voptions.toObject()
: nullptr);
@ -3045,18 +3020,15 @@ nsXPCComponents_Utils::CreateObjectIn(const Value &vobj, const Value &voptions,
return NS_ERROR_FAILURE;
}
RootedValue rvobj(cx, vobj);
RootedValue res(cx);
if (!xpc::CreateObjectIn(cx, rvobj, options, &res))
if (!xpc::CreateObjectIn(cx, vobj, options, rval))
return NS_ERROR_FAILURE;
*rval = res;
return NS_OK;
}
/* jsval createObjectIn(in jsval vobj); */
NS_IMETHODIMP
nsXPCComponents_Utils::CreateArrayIn(const Value &vobj, JSContext *cx, Value *rval)
nsXPCComponents_Utils::CreateArrayIn(HandleValue vobj, JSContext *cx,
MutableHandleValue rval)
{
if (!cx)
return NS_ERROR_FAILURE;
@ -3077,13 +3049,14 @@ nsXPCComponents_Utils::CreateArrayIn(const Value &vobj, JSContext *cx, Value *rv
if (!JS_WrapObject(cx, &obj))
return NS_ERROR_FAILURE;
*rval = ObjectValue(*obj);
rval.setObject(*obj);
return NS_OK;
}
/* jsval createDateIn(in jsval vobj, in long long msec); */
NS_IMETHODIMP
nsXPCComponents_Utils::CreateDateIn(const Value &vobj, int64_t msec, JSContext *cx, Value *rval)
nsXPCComponents_Utils::CreateDateIn(HandleValue vobj, int64_t msec, JSContext *cx,
MutableHandleValue rval)
{
if (!cx)
return NS_ERROR_FAILURE;
@ -3104,13 +3077,13 @@ nsXPCComponents_Utils::CreateDateIn(const Value &vobj, int64_t msec, JSContext *
if (!JS_WrapObject(cx, &obj))
return NS_ERROR_FAILURE;
*rval = ObjectValue(*obj);
rval.setObject(*obj);
return NS_OK;
}
/* void makeObjectPropsNormal(jsval vobj); */
NS_IMETHODIMP
nsXPCComponents_Utils::MakeObjectPropsNormal(const Value &vobj, JSContext *cx)
nsXPCComponents_Utils::MakeObjectPropsNormal(HandleValue vobj, JSContext *cx)
{
if (!cx)
return NS_ERROR_FAILURE;
@ -3150,22 +3123,22 @@ nsXPCComponents_Utils::MakeObjectPropsNormal(const Value &vobj, JSContext *cx)
}
NS_IMETHODIMP
nsXPCComponents_Utils::IsDeadWrapper(const jsval &obj, bool *out)
nsXPCComponents_Utils::IsDeadWrapper(HandleValue obj, bool *out)
{
*out = false;
if (JSVAL_IS_PRIMITIVE(obj))
if (obj.isPrimitive())
return NS_ERROR_INVALID_ARG;
// Make sure to unwrap first. Once a proxy is nuked, it ceases to be a
// wrapper, meaning that, if passed to another compartment, we'll generate
// a CCW for it. Make sure that IsDeadWrapper sees through the confusion.
*out = JS_IsDeadWrapper(js::CheckedUnwrap(JSVAL_TO_OBJECT(obj)));
*out = JS_IsDeadWrapper(js::CheckedUnwrap(&obj.toObject()));
return NS_OK;
}
/* void recomputerWrappers(jsval vobj); */
NS_IMETHODIMP
nsXPCComponents_Utils::RecomputeWrappers(const jsval &vobj, JSContext *cx)
nsXPCComponents_Utils::RecomputeWrappers(HandleValue vobj, JSContext *cx)
{
// Determine the compartment of the given object, if any.
JSCompartment *c = vobj.isObject()
@ -3185,7 +3158,7 @@ nsXPCComponents_Utils::RecomputeWrappers(const jsval &vobj, JSContext *cx)
/* jsval setWantXrays(jsval vscope); */
NS_IMETHODIMP
nsXPCComponents_Utils::SetWantXrays(const jsval &vscope, JSContext *cx)
nsXPCComponents_Utils::SetWantXrays(HandleValue vscope, JSContext *cx)
{
if (!vscope.isObject())
return NS_ERROR_INVALID_ARG;
@ -3200,7 +3173,7 @@ nsXPCComponents_Utils::SetWantXrays(const jsval &vscope, JSContext *cx)
/* jsval forcePrivilegedComponentsForScope(jsval vscope); */
NS_IMETHODIMP
nsXPCComponents_Utils::ForcePrivilegedComponentsForScope(const jsval &vscope,
nsXPCComponents_Utils::ForcePrivilegedComponentsForScope(HandleValue vscope,
JSContext *cx)
{
if (!vscope.isObject())
@ -3213,8 +3186,8 @@ nsXPCComponents_Utils::ForcePrivilegedComponentsForScope(const jsval &vscope,
/* jsval getComponentsForScope(jsval vscope); */
NS_IMETHODIMP
nsXPCComponents_Utils::GetComponentsForScope(const jsval &vscope, JSContext *cx,
jsval *rval)
nsXPCComponents_Utils::GetComponentsForScope(HandleValue vscope, JSContext *cx,
MutableHandleValue rval)
{
if (!vscope.isObject())
return NS_ERROR_INVALID_ARG;
@ -3225,17 +3198,17 @@ nsXPCComponents_Utils::GetComponentsForScope(const jsval &vscope, JSContext *cx,
return NS_ERROR_FAILURE;
if (!JS_WrapObject(cx, &components))
return NS_ERROR_FAILURE;
*rval = ObjectValue(*components);
rval.setObject(*components);
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::Dispatch(const jsval &runnableArg, const jsval &scope,
nsXPCComponents_Utils::Dispatch(HandleValue runnableArg, HandleValue scope,
JSContext *cx)
{
RootedValue runnable(cx, runnableArg);
// Enter the given compartment, if any, and rewrap runnable.
Maybe<JSAutoCompartment> ac;
RootedValue runnable(cx, runnableArg);
if (scope.isObject()) {
JSObject *scopeObj = js::UncheckedUnwrap(&scope.toObject());
if (!scopeObj)
@ -3291,7 +3264,7 @@ nsXPCComponents_Utils::SetGCZeal(int32_t aValue, JSContext* cx)
}
NS_IMETHODIMP
nsXPCComponents_Utils::NukeSandbox(const Value &obj, JSContext *cx)
nsXPCComponents_Utils::NukeSandbox(HandleValue obj, JSContext *cx)
{
NS_ENSURE_TRUE(obj.isObject(), NS_ERROR_INVALID_ARG);
JSObject *wrapper = &obj.toObject();
@ -3305,7 +3278,7 @@ nsXPCComponents_Utils::NukeSandbox(const Value &obj, JSContext *cx)
}
NS_IMETHODIMP
nsXPCComponents_Utils::BlockScriptForGlobal(const JS::Value &globalArg,
nsXPCComponents_Utils::BlockScriptForGlobal(HandleValue globalArg,
JSContext *cx)
{
NS_ENSURE_TRUE(globalArg.isObject(), NS_ERROR_INVALID_ARG);
@ -3321,7 +3294,7 @@ nsXPCComponents_Utils::BlockScriptForGlobal(const JS::Value &globalArg,
}
NS_IMETHODIMP
nsXPCComponents_Utils::UnblockScriptForGlobal(const JS::Value &globalArg,
nsXPCComponents_Utils::UnblockScriptForGlobal(HandleValue globalArg,
JSContext *cx)
{
NS_ENSURE_TRUE(globalArg.isObject(), NS_ERROR_INVALID_ARG);
@ -3337,7 +3310,7 @@ nsXPCComponents_Utils::UnblockScriptForGlobal(const JS::Value &globalArg,
}
NS_IMETHODIMP
nsXPCComponents_Utils::IsXrayWrapper(const Value &obj, bool* aRetval)
nsXPCComponents_Utils::IsXrayWrapper(HandleValue obj, bool* aRetval)
{
*aRetval =
obj.isObject() && xpc::WrapperFactory::IsXrayWrapper(&obj.toObject());
@ -3345,32 +3318,32 @@ nsXPCComponents_Utils::IsXrayWrapper(const Value &obj, bool* aRetval)
}
NS_IMETHODIMP
nsXPCComponents_Utils::WaiveXrays(const Value &aVal, JSContext *aCx, jsval *aRetval)
nsXPCComponents_Utils::WaiveXrays(HandleValue aVal, JSContext *aCx, MutableHandleValue aRetval)
{
RootedValue value(aCx, aVal);
if (!xpc::WrapperFactory::WaiveXrayAndWrap(aCx, &value))
return NS_ERROR_FAILURE;
*aRetval = value;
aRetval.set(value);
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::UnwaiveXrays(const Value &aVal, JSContext *aCx, jsval *aRetval)
nsXPCComponents_Utils::UnwaiveXrays(HandleValue aVal, JSContext *aCx, MutableHandleValue aRetval)
{
if (!aVal.isObject()) {
*aRetval = aVal;
aRetval.set(aVal);
return NS_OK;
}
RootedObject obj(aCx, js::UncheckedUnwrap(&aVal.toObject()));
if (!JS_WrapObject(aCx, &obj))
return NS_ERROR_FAILURE;
*aRetval = ObjectValue(*obj);
aRetval.setObject(*obj);
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::GetClassName(const Value &aObj, bool aUnwrap, JSContext *aCx, char **aRv)
nsXPCComponents_Utils::GetClassName(HandleValue aObj, bool aUnwrap, JSContext *aCx, char **aRv)
{
if (!aObj.isObject())
return NS_ERROR_INVALID_ARG;
@ -3391,8 +3364,8 @@ nsXPCComponents_Utils::GetDOMClassInfo(const nsAString& aClassName,
}
NS_IMETHODIMP
nsXPCComponents_Utils::GetIncumbentGlobal(const Value &aCallback,
JSContext *aCx, Value *aOut)
nsXPCComponents_Utils::GetIncumbentGlobal(HandleValue aCallback,
JSContext *aCx, MutableHandleValue aOut)
{
nsCOMPtr<nsIGlobalObject> global = mozilla::dom::GetIncumbentGlobal();
RootedValue globalVal(aCx);
@ -3413,7 +3386,7 @@ nsXPCComponents_Utils::GetIncumbentGlobal(const Value &aCallback,
return NS_ERROR_FAILURE;
}
*aOut = globalVal;
aOut.set(globalVal);
return NS_OK;
}
@ -3438,7 +3411,7 @@ class WrappedJSHolder : public nsISupports
NS_IMPL_ISUPPORTS0(WrappedJSHolder);
NS_IMETHODIMP
nsXPCComponents_Utils::GenerateXPCWrappedJS(const Value &aObj, const Value &aScope,
nsXPCComponents_Utils::GenerateXPCWrappedJS(HandleValue aObj, HandleValue aScope,
JSContext *aCx, nsISupports **aOut)
{
if (!aObj.isObject())
@ -3574,36 +3547,35 @@ nsXPCComponents::GetManager(nsIComponentManager * *aManager)
}
NS_IMETHODIMP
nsXPCComponents::GetLastResult(JSContext *aCx, Value *aOut)
nsXPCComponents::GetLastResult(JSContext *aCx, MutableHandleValue aOut)
{
XPCContext* xpcc = XPCContext::GetXPCContext(aCx);
if (!xpcc)
return NS_ERROR_FAILURE;
nsresult res = xpcc->GetLastResult();
*aOut = JS_NumberValue(static_cast<double>(static_cast<uint32_t>(res)));
aOut.setNumber(static_cast<uint32_t>(res));
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents::GetReturnCode(JSContext *aCx, Value *aOut)
nsXPCComponents::GetReturnCode(JSContext *aCx, MutableHandleValue aOut)
{
XPCContext* xpcc = XPCContext::GetXPCContext(aCx);
if (!xpcc)
return NS_ERROR_FAILURE;
nsresult res = xpcc->GetPendingResult();
*aOut = JS_NumberValue(static_cast<double>(static_cast<uint32_t>(res)));
aOut.setNumber(static_cast<uint32_t>(res));
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents::SetReturnCode(JSContext *aCx, const Value &aCode)
nsXPCComponents::SetReturnCode(JSContext *aCx, HandleValue aCode)
{
XPCContext* xpcc = XPCContext::GetXPCContext(aCx);
if (!xpcc)
return NS_ERROR_FAILURE;
RootedValue code(aCx, aCode);
nsresult rv;
if (!ToUint32(aCx, code, (uint32_t*)&rv))
if (!ToUint32(aCx, aCode, (uint32_t*)&rv))
return NS_ERROR_FAILURE;
xpcc->SetPendingResult(rv);
xpcc->SetLastResult(rv);
@ -3612,7 +3584,7 @@ nsXPCComponents::SetReturnCode(JSContext *aCx, const Value &aCode)
// static
/* void reportError (); */
NS_IMETHODIMP nsXPCComponents::ReportError(const Value &error, JSContext *cx)
NS_IMETHODIMP nsXPCComponents::ReportError(HandleValue error, JSContext *cx)
{
NS_WARNING("Components.reportError deprecated, use Components.utils.reportError");

View File

@ -547,15 +547,15 @@ xpc::HasInstance(JSContext *cx, HandleObject objArg, const nsID *iid, bool *bp)
NS_IMETHODIMP
nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
JSContext * cx, JSObject * /* unused */,
const jsval &val, bool *bp, bool *_retval)
HandleValue val, bool *bp, bool *_retval)
{
*bp = false;
if (JSVAL_IS_PRIMITIVE(val))
if (val.isPrimitive())
return NS_OK;
// we have a JSObject
RootedObject obj(cx, JSVAL_TO_OBJECT(val));
RootedObject obj(cx, &val.toObject());
const nsIID* iid;
mInfo->GetIIDShared(&iid);
@ -685,8 +685,8 @@ GetWrapperObject(MutableHandleObject obj)
/* nsISupports createInstance (); */
NS_IMETHODIMP
nsJSCID::CreateInstance(const JS::Value& iidval, JSContext* cx,
uint8_t optionalArgc, JS::Value* retval)
nsJSCID::CreateInstance(HandleValue iidval, JSContext* cx,
uint8_t optionalArgc, MutableHandleValue retval)
{
if (!mDetails.IsValid())
return NS_ERROR_XPC_BAD_CID;
@ -721,15 +721,15 @@ nsJSCID::CreateInstance(const JS::Value& iidval, JSContext* cx,
return NS_ERROR_XPC_CI_RETURNED_FAILURE;
rv = nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, obj, inst, nullptr, iid, true, retval);
if (NS_FAILED(rv) || JSVAL_IS_PRIMITIVE(*retval))
if (NS_FAILED(rv) || retval.isPrimitive())
return NS_ERROR_XPC_CANT_CREATE_WN;
return NS_OK;
}
/* nsISupports getService (); */
NS_IMETHODIMP
nsJSCID::GetService(const JS::Value& iidval, JSContext* cx,
uint8_t optionalArgc, JS::Value* retval)
nsJSCID::GetService(HandleValue iidval, JSContext* cx,
uint8_t optionalArgc, MutableHandleValue retval)
{
if (!mDetails.IsValid())
return NS_ERROR_XPC_BAD_CID;
@ -772,7 +772,7 @@ nsJSCID::GetService(const JS::Value& iidval, JSContext* cx,
!(instJSObj = holder->GetJSObject()))
return NS_ERROR_XPC_CANT_CREATE_WN;
*retval = OBJECT_TO_JSVAL(instJSObj);
retval.setObject(*instJSObj);
return NS_OK;
}
@ -800,7 +800,7 @@ nsJSCID::Construct(nsIXPConnectWrappedNative *wrapper,
NS_IMETHODIMP
nsJSCID::HasInstance(nsIXPConnectWrappedNative *wrapper,
JSContext * cx, JSObject * /* unused */,
const jsval &val, bool *bp, bool *_retval)
HandleValue val, bool *bp, bool *_retval)
{
*bp = false;
nsresult rv = NS_OK;

View File

@ -53,9 +53,9 @@ nsresult xpcJSWeakReference::Init(JSContext* cx, const JS::Value& object)
}
NS_IMETHODIMP
xpcJSWeakReference::Get(JSContext* aCx, JS::Value* aRetval)
xpcJSWeakReference::Get(JSContext* aCx, MutableHandleValue aRetval)
{
*aRetval = JSVAL_NULL;
aRetval.setNull();
if (!mReferent) {
return NS_OK;
@ -71,12 +71,9 @@ xpcJSWeakReference::Get(JSContext* aCx, JS::Value* aRetval)
// We have a generic XPCOM object that supports weak references here.
// Wrap it and pass it out.
RootedObject global(aCx, CurrentGlobalOrNull(aCx));
RootedValue rval(aCx);
nsresult rv = nsContentUtils::WrapNative(aCx, global,
supports, &NS_GET_IID(nsISupports),
&rval);
*aRetval = rval;
return rv;
return nsContentUtils::WrapNative(aCx, global,
supports, &NS_GET_IID(nsISupports),
aRetval);
}
JS::RootedObject obj(aCx, wrappedObj->GetJSObject());
@ -93,6 +90,6 @@ xpcJSWeakReference::Get(JSContext* aCx, JS::Value* aRetval)
return NS_ERROR_FAILURE;
}
*aRetval = OBJECT_TO_JSVAL(obj);
aRetval.setObject(*obj);
return NS_OK;
}

View File

@ -585,7 +585,7 @@ Blob(JSContext *cx, unsigned argc, jsval *vp)
JSObject* global = JS::CurrentGlobalOrNull(cx);
rv = xpc->WrapNativeToJSVal(cx, global, native, nullptr,
&NS_GET_IID(nsISupports), true,
args.rval().address());
args.rval());
if (NS_FAILED(rv)) {
JS_ReportError(cx, "Could not wrap native object!");
return false;
@ -624,7 +624,7 @@ File(JSContext *cx, unsigned argc, jsval *vp)
JSObject* global = JS::CurrentGlobalOrNull(cx);
rv = xpc->WrapNativeToJSVal(cx, global, native, nullptr,
&NS_GET_IID(nsISupports), true,
args.rval().address());
args.rval());
if (NS_FAILED(rv)) {
JS_ReportError(cx, "Could not wrap native object!");
return false;

View File

@ -365,10 +365,9 @@ bool XPCVariant::InitializeData(JSContext* cx)
}
NS_IMETHODIMP
XPCVariant::GetAsJSVal(jsval* result)
XPCVariant::GetAsJSVal(MutableHandleValue result)
{
NS_PRECONDITION(result, "null result arg.");
*result = GetJSVal();
result.set(GetJSVal());
return NS_OK;
}
@ -384,7 +383,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
AutoJSContext cx;
RootedValue realVal(cx);
nsresult rv = variant->GetAsJSVal(realVal.address());
nsresult rv = variant->GetAsJSVal(&realVal);
if (NS_SUCCEEDED(rv) &&
(JSVAL_IS_PRIMITIVE(realVal) ||

View File

@ -579,19 +579,15 @@ nsXPConnect::WrapNativeToJSVal(JSContext * aJSContext,
nsWrapperCache *aCache,
const nsIID * aIID,
bool aAllowWrapping,
jsval *aVal)
MutableHandleValue aVal)
{
MOZ_ASSERT(aJSContext, "bad param");
MOZ_ASSERT(aScopeArg, "bad param");
MOZ_ASSERT(aCOMObj, "bad param");
RootedObject aScope(aJSContext, aScopeArg);
RootedValue rval(aJSContext);
nsresult rv = NativeInterface2JSObject(aScope, aCOMObj, aCache, aIID,
aAllowWrapping, &rval, nullptr);
*aVal = rval;
return rv;
return NativeInterface2JSObject(aScope, aCOMObj, aCache, aIID,
aAllowWrapping, aVal, nullptr);
}
/* void wrapJS (in JSContextPtr aJSContext, in JSObjectPtr aJSObj, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult result); */
@ -619,13 +615,12 @@ nsXPConnect::WrapJS(JSContext * aJSContext,
NS_IMETHODIMP
nsXPConnect::JSValToVariant(JSContext *cx,
jsval *aJSVal,
HandleValue aJSVal,
nsIVariant ** aResult)
{
NS_PRECONDITION(aJSVal, "bad param");
NS_PRECONDITION(aResult, "bad param");
*aResult = XPCVariant::newVariant(cx, *aJSVal);
*aResult = XPCVariant::newVariant(cx, aJSVal);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
@ -897,19 +892,15 @@ nsXPConnect::CreateSandbox(JSContext *cx, nsIPrincipal *principal,
NS_IMETHODIMP
nsXPConnect::EvalInSandboxObject(const nsAString& source, const char *filename,
JSContext *cx, JSObject *sandboxArg,
bool returnStringOnly, JS::Value *rvalArg)
bool returnStringOnly, MutableHandleValue rval)
{
if (!sandboxArg)
return NS_ERROR_INVALID_ARG;
RootedObject sandbox(cx, sandboxArg);
RootedValue rval(cx);
nsresult rv = EvalInSandbox(cx, sandbox, source, filename ? filename :
"x-bogus://XPConnect/Sandbox", 1, JSVERSION_DEFAULT,
returnStringOnly, &rval);
NS_ENSURE_SUCCESS(rv, rv);
*rvalArg = rval;
return NS_OK;
return EvalInSandbox(cx, sandbox, source, filename ? filename :
"x-bogus://XPConnect/Sandbox", 1, JSVERSION_DEFAULT,
returnStringOnly, rval);
}
/* nsIXPConnectJSObjectHolder getWrappedNativePrototype (in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsIClassInfo aClassInfo); */
@ -1055,32 +1046,28 @@ nsXPConnect::DebugDumpEvalInJSStackFrame(uint32_t aFrameNumber, const char *aSou
/* jsval variantToJS (in JSContextPtr ctx, in JSObjectPtr scope, in nsIVariant value); */
NS_IMETHODIMP
nsXPConnect::VariantToJS(JSContext* ctx, JSObject* scopeArg, nsIVariant* value,
jsval* _retval)
MutableHandleValue _retval)
{
NS_PRECONDITION(ctx, "bad param");
NS_PRECONDITION(scopeArg, "bad param");
NS_PRECONDITION(value, "bad param");
NS_PRECONDITION(_retval, "bad param");
RootedObject scope(ctx, scopeArg);
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, ctx));
nsresult rv = NS_OK;
RootedValue rval(ctx);
if (!XPCVariant::VariantDataToJS(value, &rv, &rval)) {
if (!XPCVariant::VariantDataToJS(value, &rv, _retval)) {
if (NS_FAILED(rv))
return rv;
return NS_ERROR_FAILURE;
}
*_retval = rval;
return NS_OK;
}
/* nsIVariant JSToVariant (in JSContextPtr ctx, in jsval value); */
NS_IMETHODIMP
nsXPConnect::JSToVariant(JSContext* ctx, const jsval &value, nsIVariant** _retval)
nsXPConnect::JSToVariant(JSContext* ctx, HandleValue value, nsIVariant** _retval)
{
NS_PRECONDITION(ctx, "bad param");
NS_PRECONDITION(_retval, "bad param");
@ -1418,7 +1405,7 @@ nsXPConnect::SetDebugModeWhenPossible(bool mode, bool allowSyncDisable)
}
NS_IMETHODIMP
nsXPConnect::GetTelemetryValue(JSContext *cx, jsval *rval)
nsXPConnect::GetTelemetryValue(JSContext *cx, MutableHandleValue rval)
{
RootedObject obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
if (!obj)
@ -1436,7 +1423,7 @@ nsXPConnect::GetTelemetryValue(JSContext *cx, jsval *rval)
if (!JS_DefineProperty(cx, obj, "customIter", v, nullptr, nullptr, attrs))
return NS_ERROR_OUT_OF_MEMORY;
*rval = OBJECT_TO_JSVAL(obj);
rval.setObject(*obj);
return NS_OK;
}

View File

@ -613,8 +613,8 @@ def outParamForm(name, type):
return '&' + name
elif type.kind == 'native':
if getBuiltinOrNativeTypeName(type) == '[jsval]':
return name + '.address()'
elif type.modifier == 'ref':
return '&' + name
if type.modifier == 'ref':
return name
else:
return '&' + name

View File

@ -197,11 +197,13 @@ NS_IMETHODIMP nsXPCTestParams::TestACString(const nsACString & a, nsACString & b
STRING_METHOD_IMPL;
}
/* jsval testJsval (in jsval a, inout jsval b); */
NS_IMETHODIMP nsXPCTestParams::TestJsval(const jsval & a, jsval & b, jsval *_retval)
/* jsval testJsval (in jsval a, in jsval b); */
NS_IMETHODIMP nsXPCTestParams::TestJsval(JS::Handle<JS::Value> a,
JS::MutableHandle<JS::Value> b,
JS::MutableHandle<JS::Value> _retval)
{
*_retval = b;
b = a;
_retval.set(b);
b.set(a);
return NS_OK;
}

View File

@ -282,8 +282,7 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, HandleObject scope,
RootedValue v(cx);
nsresult rv =
nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, wrapScope, wn->Native(), nullptr,
&NS_GET_IID(nsISupports), false,
v.address());
&NS_GET_IID(nsISupports), false, &v);
NS_ENSURE_SUCCESS(rv, nullptr);
obj = JSVAL_TO_OBJECT(v);

View File

@ -616,7 +616,7 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty,
NS_IMETHODIMP
inDOMUtils::ColorNameToRGB(const nsAString& aColorName, JSContext* aCx,
JS::Value* aValue)
JS::MutableHandle<JS::Value> aValue)
{
nscolor color;
if (!NS_ColorNameToRGB(aColorName, &color)) {
@ -628,8 +628,7 @@ inDOMUtils::ColorNameToRGB(const nsAString& aColorName, JSContext* aCx,
triple.mG = NS_GET_G(color);
triple.mB = NS_GET_B(color);
if (!triple.ToObject(aCx, JS::NullPtr(),
JS::MutableHandle<JS::Value>::fromMarkedLocation(aValue))) {
if (!triple.ToObject(aCx, JS::NullPtr(), aValue)) {
return NS_ERROR_FAILURE;
}

View File

@ -30,7 +30,7 @@ ArrayBufferInputStream::~ArrayBufferInputStream()
}
NS_IMETHODIMP
ArrayBufferInputStream::SetData(const JS::Value& aBuffer,
ArrayBufferInputStream::SetData(JS::Handle<JS::Value> aBuffer,
uint32_t aByteOffset,
uint32_t aLength,
JSContext* aCx)

View File

@ -366,7 +366,7 @@ AppProtocolHandler::NewChannel(nsIURI* aUri, nsIChannel* *aResult)
mozilla::AutoSafeJSContext cx;
JS::RootedValue jsInfo(cx);
rv = appsService->GetAppInfo(NS_ConvertUTF8toUTF16(host), jsInfo.address());
rv = appsService->GetAppInfo(NS_ConvertUTF8toUTF16(host), &jsInfo);
if (NS_FAILED(rv) || !jsInfo.isObject()) {
// Return a DummyChannel.
printf_stderr("!! Creating a dummy channel for %s (no appInfo)\n", host.get());

View File

@ -220,7 +220,7 @@ Variant_base::GetAsWStringWithSize(uint32_t *,
inline
NS_IMETHODIMP
Variant_base::GetAsJSVal(JS::Value *)
Variant_base::GetAsJSVal(JS::MutableHandle<JS::Value>)
{
return NS_ERROR_CANNOT_CONVERT_DATA;
}

View File

@ -189,9 +189,8 @@ NS_IMETHODIMP
FinalizationWitnessService::Make(const char* aTopic,
const char16_t* aValue,
JSContext* aCx,
JS::Value *aRetval) {
MOZ_ASSERT(aRetval);
JS::MutableHandle<JS::Value> aRetval)
{
JS::Rooted<JSObject*> objResult(aCx, JS_NewObject(aCx, &sWitnessClass, nullptr, nullptr));
if (!objResult) {
return NS_ERROR_OUT_OF_MEMORY;
@ -206,7 +205,7 @@ FinalizationWitnessService::Make(const char* aTopic,
JS_SetReservedSlot(objResult, WITNESS_SLOT_EVENT,
JS::PrivateValue(event.forget().get()));
aRetval->setObject(*objResult);
aRetval.setObject(*objResult);
return NS_OK;
}

View File

@ -2677,7 +2677,7 @@ History::RemoveAllDownloads()
//// mozIAsyncHistory
NS_IMETHODIMP
History::GetPlacesInfo(const JS::Value& aPlaceIdentifiers,
History::GetPlacesInfo(JS::Handle<JS::Value> aPlaceIdentifiers,
mozIVisitInfoCallback* aCallback,
JSContext* aCtx) {
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
@ -2745,7 +2745,7 @@ History::GetPlacesInfo(const JS::Value& aPlaceIdentifiers,
}
NS_IMETHODIMP
History::UpdatePlaces(const JS::Value& aPlaceInfos,
History::UpdatePlaces(JS::Handle<JS::Value> aPlaceInfos,
mozIVisitInfoCallback* aCallback,
JSContext* aCtx)
{

View File

@ -88,13 +88,13 @@ PlaceInfo::GetFrecency(int64_t* _frecency)
NS_IMETHODIMP
PlaceInfo::GetVisits(JSContext* aContext,
JS::Value* _visits)
JS::MutableHandle<JS::Value> _visits)
{
// If the visits data was not provided, return null rather
// than an empty array to distinguish this case from the case
// of a place without any visit.
if (!mVisitsAvailable) {
*_visits = JSVAL_NULL;
_visits.setNull();
return NS_OK;
}
@ -124,8 +124,7 @@ PlaceInfo::GetVisits(JSContext* aContext,
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
}
*_visits = OBJECT_TO_JSVAL(visits);
_visits.setObject(*visits);
return NS_OK;
}

View File

@ -716,10 +716,10 @@ nsAppStartup::Observe(nsISupports *aSubject,
}
NS_IMETHODIMP
nsAppStartup::GetStartupInfo(JSContext* aCx, JS::Value* aRetval)
nsAppStartup::GetStartupInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval)
{
JS::Rooted<JSObject*> obj(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
*aRetval = OBJECT_TO_JSVAL(obj);
aRetval.setObject(*obj);
TimeStamp procTime = StartupTimeline::Get(StartupTimeline::PROCESS_CREATION);
TimeStamp now = TimeStamp::Now();

View File

@ -290,7 +290,8 @@ private:
bool AddSQLInfo(JSContext *cx, JS::Handle<JSObject*> rootObj, bool mainThread,
bool privateSQL);
bool GetSQLStats(JSContext *cx, JS::Value *ret, bool includePrivateSql);
bool GetSQLStats(JSContext *cx, JS::MutableHandle<JS::Value> ret,
bool includePrivateSql);
// Like GetHistogramById, but returns the underlying C++ object, not the JS one.
nsresult GetHistogramByName(const nsACString &name, Histogram **ret);
@ -680,7 +681,7 @@ JSHistogram_Clear(JSContext *cx, unsigned argc, JS::Value *vp)
}
nsresult
WrapAndReturnHistogram(Histogram *h, JSContext *cx, JS::Value *ret)
WrapAndReturnHistogram(Histogram *h, JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
static const JSClass JSHistogram_class = {
"JSHistogram", /* name */
@ -697,8 +698,8 @@ WrapAndReturnHistogram(Histogram *h, JSContext *cx, JS::Value *ret)
&& JS_DefineFunction(cx, obj, "clear", JSHistogram_Clear, 0, 0))) {
return NS_ERROR_FAILURE;
}
*ret = OBJECT_TO_JSVAL(obj);
JS_SetPrivate(obj, h);
ret.setObject(*obj);
return NS_OK;
}
@ -980,7 +981,7 @@ TelemetryImpl::InitMemoryReporter() {
NS_IMETHODIMP
TelemetryImpl::NewHistogram(const nsACString &name, const nsACString &expiration, uint32_t min,
uint32_t max, uint32_t bucketCount, uint32_t histogramType,
JSContext *cx, JS::Value *ret)
JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
Histogram *h;
nsresult rv = HistogramGet(PromiseFlatCString(name).get(), PromiseFlatCString(expiration).get(),
@ -1100,7 +1101,7 @@ TelemetryImpl::GetHistogramByName(const nsACString &name, Histogram **ret)
NS_IMETHODIMP
TelemetryImpl::HistogramFrom(const nsACString &name, const nsACString &existing_name,
JSContext *cx, JS::Value *ret)
JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
Telemetry::ID id;
nsresult rv = GetHistogramEnumId(PromiseFlatCString(existing_name).get(), &id);
@ -1243,7 +1244,7 @@ TelemetryImpl::RegisterAddonHistogram(const nsACString &id,
NS_IMETHODIMP
TelemetryImpl::GetAddonHistogram(const nsACString &id, const nsACString &name,
JSContext *cx, JS::Value *ret)
JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
AddonEntryType *addonEntry = mAddonMap.GetEntry(id);
// The given id has not been registered.
@ -1286,12 +1287,12 @@ TelemetryImpl::UnregisterAddonHistograms(const nsACString &id)
}
NS_IMETHODIMP
TelemetryImpl::GetHistogramSnapshots(JSContext *cx, JS::Value *ret)
TelemetryImpl::GetHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
if (!root_obj)
return NS_ERROR_FAILURE;
*ret = OBJECT_TO_JSVAL(root_obj);
ret.setObject(*root_obj);
// Ensure that all the HISTOGRAM_FLAG histograms have been created, so
// that their values are snapshotted.
@ -1428,9 +1429,8 @@ TelemetryImpl::AddonReflector(AddonEntryType *entry,
}
NS_IMETHODIMP
TelemetryImpl::GetAddonHistogramSnapshots(JSContext *cx, JS::Value *ret)
TelemetryImpl::GetAddonHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
*ret = JSVAL_VOID;
JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
if (!obj) {
return NS_ERROR_FAILURE;
@ -1439,17 +1439,17 @@ TelemetryImpl::GetAddonHistogramSnapshots(JSContext *cx, JS::Value *ret)
if (!mAddonMap.ReflectIntoJS(AddonReflector, cx, obj)) {
return NS_ERROR_FAILURE;
}
*ret = OBJECT_TO_JSVAL(obj);
ret.setObject(*obj);
return NS_OK;
}
bool
TelemetryImpl::GetSQLStats(JSContext *cx, JS::Value *ret, bool includePrivateSql)
TelemetryImpl::GetSQLStats(JSContext *cx, JS::MutableHandle<JS::Value> ret, bool includePrivateSql)
{
JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
if (!root_obj)
return false;
*ret = OBJECT_TO_JSVAL(root_obj);
ret.setObject(*root_obj);
MutexAutoLock hashMutex(mHashMutex);
// Add info about slow SQL queries on the main thread
@ -1463,7 +1463,7 @@ TelemetryImpl::GetSQLStats(JSContext *cx, JS::Value *ret, bool includePrivateSql
}
NS_IMETHODIMP
TelemetryImpl::GetSlowSQL(JSContext *cx, JS::Value *ret)
TelemetryImpl::GetSlowSQL(JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
if (GetSQLStats(cx, ret, false))
return NS_OK;
@ -1471,7 +1471,7 @@ TelemetryImpl::GetSlowSQL(JSContext *cx, JS::Value *ret)
}
NS_IMETHODIMP
TelemetryImpl::GetDebugSlowSQL(JSContext *cx, JS::Value *ret)
TelemetryImpl::GetDebugSlowSQL(JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
bool revealPrivateSql =
Preferences::GetBool("toolkit.telemetry.debugSlowSql", false);
@ -1488,7 +1488,7 @@ TelemetryImpl::GetMaximalNumberOfConcurrentThreads(uint32_t *ret)
}
NS_IMETHODIMP
TelemetryImpl::GetChromeHangs(JSContext *cx, JS::Value *ret)
TelemetryImpl::GetChromeHangs(JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
MutexAutoLock hangReportMutex(mHangReportsMutex);
@ -1498,7 +1498,7 @@ TelemetryImpl::GetChromeHangs(JSContext *cx, JS::Value *ret)
return NS_ERROR_FAILURE;
}
*ret = OBJECT_TO_JSVAL(fullReportObj);
ret.setObject(*fullReportObj);
JS::Rooted<JSObject*> durationArray(cx, JS_NewArrayObject(cx, 0, nullptr));
if (!durationArray) {
@ -1855,7 +1855,7 @@ CreateJSThreadHangStats(JSContext* cx, const Telemetry::ThreadHangStats& thread)
}
NS_IMETHODIMP
TelemetryImpl::GetThreadHangStats(JSContext* cx, JS::Value* ret)
TelemetryImpl::GetThreadHangStats(JSContext* cx, JS::MutableHandle<JS::Value> ret)
{
JS::RootedObject retObj(cx, JS_NewArrayObject(cx, 0, nullptr));
if (!retObj) {
@ -1872,7 +1872,7 @@ TelemetryImpl::GetThreadHangStats(JSContext* cx, JS::Value* ret)
histogram; histogram = iter.GetNext()) {
JS::RootedObject obj(cx,
CreateJSThreadHangStats(cx, *histogram));
JS::RootedValue thread(cx, OBJECT_TO_JSVAL(obj));
JS::RootedValue thread(cx, JS::ObjectValue(*obj));
if (!JS_SetElement(cx, retObj, threadIndex++, &thread)) {
return NS_ERROR_FAILURE;
}
@ -1883,12 +1883,12 @@ TelemetryImpl::GetThreadHangStats(JSContext* cx, JS::Value* ret)
for (size_t i = 0; i < mThreadHangStats.length(); i++) {
JS::RootedObject obj(cx,
CreateJSThreadHangStats(cx, mThreadHangStats[i]));
JS::RootedValue thread(cx, OBJECT_TO_JSVAL(obj));
JS::RootedValue thread(cx, JS::ObjectValue(*obj));
if (!JS_SetElement(cx, retObj, threadIndex++, &thread)) {
return NS_ERROR_FAILURE;
}
}
*ret = OBJECT_TO_JSVAL(retObj);
ret.setObject(*retObj);
return NS_OK;
}
@ -1931,7 +1931,7 @@ TelemetryImpl::ReadLateWritesStacks(nsIFile* aProfileDir)
}
NS_IMETHODIMP
TelemetryImpl::GetLateWrites(JSContext *cx, JS::Value *ret)
TelemetryImpl::GetLateWrites(JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
// The user must call AsyncReadTelemetryData first. We return an empty list
// instead of reporting a failure so that the rest of telemetry can uniformly
@ -1958,7 +1958,7 @@ TelemetryImpl::GetLateWrites(JSContext *cx, JS::Value *ret)
return NS_ERROR_FAILURE;
}
*ret = OBJECT_TO_JSVAL(report);
ret.setObject(*report);
return NS_OK;
}
@ -1986,7 +1986,8 @@ TelemetryImpl::RegisteredHistograms(uint32_t *aCount, char*** aHistograms)
}
NS_IMETHODIMP
TelemetryImpl::GetHistogramById(const nsACString &name, JSContext *cx, JS::Value *ret)
TelemetryImpl::GetHistogramById(const nsACString &name, JSContext *cx,
JS::MutableHandle<JS::Value> ret)
{
Histogram *h;
nsresult rv = GetHistogramByName(name, &h);

Some files were not shown because too many files have changed in this diff Show More