Bug 1009675 part 2. Return WebIDL 'any' values as handles. r=peterv

This commit is contained in:
Boris Zbarsky 2014-06-11 16:26:52 -04:00
Родитель b058cec1b6
Коммит bc1e511e33
58 изменённых файлов: 493 добавлений и 337 удалений

Просмотреть файл

@ -1617,12 +1617,14 @@ public:
// HasAttributes is defined inline in Element.h. // HasAttributes is defined inline in Element.h.
bool HasAttributes() const; bool HasAttributes() const;
nsDOMAttributeMap* GetAttributes(); nsDOMAttributeMap* GetAttributes();
JS::Value SetUserData(JSContext* aCx, const nsAString& aKey, void SetUserData(JSContext* aCx, const nsAString& aKey,
JS::Handle<JS::Value> aData, JS::Handle<JS::Value> aData,
nsIDOMUserDataHandler* aHandler, nsIDOMUserDataHandler* aHandler,
mozilla::ErrorResult& aError); JS::MutableHandle<JS::Value> aRetval,
JS::Value GetUserData(JSContext* aCx, const nsAString& aKey, mozilla::ErrorResult& aError);
mozilla::ErrorResult& aError); void GetUserData(JSContext* aCx, const nsAString& aKey,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
// Helper method to remove this node from its parent. This is not exposed // Helper method to remove this node from its parent. This is not exposed
// through WebIDL. // through WebIDL.

Просмотреть файл

@ -146,12 +146,11 @@ nsDOMFileReader::GetReadyState(uint16_t *aReadyState)
return NS_OK; return NS_OK;
} }
JS::Value void
nsDOMFileReader::GetResult(JSContext* aCx, ErrorResult& aRv) nsDOMFileReader::GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv)
{ {
JS::Rooted<JS::Value> result(aCx); aRv = GetResult(aCx, aResult);
aRv = GetResult(aCx, &result);
return result;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -85,7 +85,8 @@ public:
// Inherited ReadyState(). // Inherited ReadyState().
JS::Value GetResult(JSContext* aCx, ErrorResult& aRv); void GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
using FileIOObject::GetError; using FileIOObject::GetError;

Просмотреть файл

@ -779,33 +779,33 @@ nsINode::SetUserData(const nsAString &aKey, nsIVariant *aData,
return NS_OK; return NS_OK;
} }
JS::Value void
nsINode::SetUserData(JSContext* aCx, const nsAString& aKey, nsINode::SetUserData(JSContext* aCx, const nsAString& aKey,
JS::Handle<JS::Value> aData, JS::Handle<JS::Value> aData,
nsIDOMUserDataHandler* aHandler, ErrorResult& aError) nsIDOMUserDataHandler* aHandler,
JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aError)
{ {
nsCOMPtr<nsIVariant> data; nsCOMPtr<nsIVariant> data;
JS::Rooted<JS::Value> dataVal(aCx, aData); aError = nsContentUtils::XPConnect()->JSValToVariant(aCx, aData, getter_AddRefs(data));
aError = nsContentUtils::XPConnect()->JSValToVariant(aCx, dataVal, getter_AddRefs(data));
if (aError.Failed()) { if (aError.Failed()) {
return JS::UndefinedValue(); return;
} }
nsCOMPtr<nsIVariant> oldData; nsCOMPtr<nsIVariant> oldData;
aError = SetUserData(aKey, data, aHandler, getter_AddRefs(oldData)); aError = SetUserData(aKey, data, aHandler, getter_AddRefs(oldData));
if (aError.Failed()) { if (aError.Failed()) {
return JS::UndefinedValue(); return;
} }
if (!oldData) { if (!oldData) {
return JS::NullValue(); aRetval.setNull();
return;
} }
JS::Rooted<JS::Value> result(aCx);
JSAutoCompartment ac(aCx, GetWrapper()); JSAutoCompartment ac(aCx, GetWrapper());
aError = nsContentUtils::XPConnect()->VariantToJS(aCx, GetWrapper(), oldData, aError = nsContentUtils::XPConnect()->VariantToJS(aCx, GetWrapper(), oldData,
&result); aRetval);
return result;
} }
nsIVariant* nsIVariant*
@ -820,19 +820,19 @@ nsINode::GetUserData(const nsAString& aKey)
return static_cast<nsIVariant*>(GetProperty(DOM_USER_DATA, key)); return static_cast<nsIVariant*>(GetProperty(DOM_USER_DATA, key));
} }
JS::Value void
nsINode::GetUserData(JSContext* aCx, const nsAString& aKey, ErrorResult& aError) nsINode::GetUserData(JSContext* aCx, const nsAString& aKey,
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aError)
{ {
nsIVariant* data = GetUserData(aKey); nsIVariant* data = GetUserData(aKey);
if (!data) { if (!data) {
return JS::NullValue(); aRetval.setNull();
return;
} }
JS::Rooted<JS::Value> result(aCx);
JSAutoCompartment ac(aCx, GetWrapper()); JSAutoCompartment ac(aCx, GetWrapper());
aError = nsContentUtils::XPConnect()->VariantToJS(aCx, GetWrapper(), data, aError = nsContentUtils::XPConnect()->VariantToJS(aCx, GetWrapper(), data,
&result); aRetval);
return result;
} }
uint16_t uint16_t

Просмотреть файл

@ -3204,10 +3204,11 @@ nsObjectLoadingContent::GetContentDocument()
return sub_doc; return sub_doc;
} }
JS::Value void
nsObjectLoadingContent::LegacyCall(JSContext* aCx, nsObjectLoadingContent::LegacyCall(JSContext* aCx,
JS::Handle<JS::Value> aThisVal, JS::Handle<JS::Value> aThisVal,
const Sequence<JS::Value>& aArguments, const Sequence<JS::Value>& aArguments,
JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aRv) ErrorResult& aRv)
{ {
nsCOMPtr<nsIContent> thisContent = nsCOMPtr<nsIContent> thisContent =
@ -3221,12 +3222,12 @@ nsObjectLoadingContent::LegacyCall(JSContext* aCx,
// this is not an Xray situation by hand. // this is not an Xray situation by hand.
if (!JS_WrapObject(aCx, &obj)) { if (!JS_WrapObject(aCx, &obj)) {
aRv.Throw(NS_ERROR_UNEXPECTED); aRv.Throw(NS_ERROR_UNEXPECTED);
return JS::UndefinedValue(); return;
} }
if (nsDOMClassInfo::ObjectIsNativeWrapper(aCx, obj)) { if (nsDOMClassInfo::ObjectIsNativeWrapper(aCx, obj)) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE); aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return JS::UndefinedValue(); return;
} }
obj = thisContent->GetWrapper(); obj = thisContent->GetWrapper();
@ -3235,33 +3236,33 @@ nsObjectLoadingContent::LegacyCall(JSContext* aCx,
JS::AutoValueVector args(aCx); JS::AutoValueVector args(aCx);
if (!args.append(aArguments.Elements(), aArguments.Length())) { if (!args.append(aArguments.Elements(), aArguments.Length())) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY); aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return JS::UndefinedValue(); return;
} }
for (size_t i = 0; i < args.length(); i++) { for (size_t i = 0; i < args.length(); i++) {
if (!JS_WrapValue(aCx, args[i])) { if (!JS_WrapValue(aCx, args[i])) {
aRv.Throw(NS_ERROR_UNEXPECTED); aRv.Throw(NS_ERROR_UNEXPECTED);
return JS::UndefinedValue(); return;
} }
} }
JS::Rooted<JS::Value> thisVal(aCx, aThisVal); JS::Rooted<JS::Value> thisVal(aCx, aThisVal);
if (!JS_WrapValue(aCx, &thisVal)) { if (!JS_WrapValue(aCx, &thisVal)) {
aRv.Throw(NS_ERROR_UNEXPECTED); aRv.Throw(NS_ERROR_UNEXPECTED);
return JS::UndefinedValue(); return;
} }
nsRefPtr<nsNPAPIPluginInstance> pi; nsRefPtr<nsNPAPIPluginInstance> pi;
nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi)); nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
aRv.Throw(rv); aRv.Throw(rv);
return JS::UndefinedValue(); return;
} }
// if there's no plugin around for this object, throw. // if there's no plugin around for this object, throw.
if (!pi) { if (!pi) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE); aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return JS::UndefinedValue(); return;
} }
JS::Rooted<JSObject*> pi_obj(aCx); JS::Rooted<JSObject*> pi_obj(aCx);
@ -3270,23 +3271,21 @@ nsObjectLoadingContent::LegacyCall(JSContext* aCx,
rv = GetPluginJSObject(aCx, obj, pi, &pi_obj, &pi_proto); rv = GetPluginJSObject(aCx, obj, pi, &pi_obj, &pi_proto);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
aRv.Throw(rv); aRv.Throw(rv);
return JS::UndefinedValue(); return;
} }
if (!pi_obj) { if (!pi_obj) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE); aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return JS::UndefinedValue(); return;
} }
JS::Rooted<JS::Value> retval(aCx); bool ok = JS::Call(aCx, thisVal, pi_obj, args, aRetval);
bool ok = JS::Call(aCx, thisVal, pi_obj, args, &retval);
if (!ok) { if (!ok) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::UndefinedValue(); return;
} }
Telemetry::Accumulate(Telemetry::PLUGIN_CALLED_DIRECTLY, true); Telemetry::Accumulate(Telemetry::PLUGIN_CALLED_DIRECTLY, true);
return retval;
} }
void void

Просмотреть файл

@ -214,9 +214,10 @@ class nsObjectLoadingContent : public nsImageLoadingContent
{ {
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
} }
JS::Value LegacyCall(JSContext* aCx, JS::Handle<JS::Value> aThisVal, void LegacyCall(JSContext* aCx, JS::Handle<JS::Value> aThisVal,
const mozilla::dom::Sequence<JS::Value>& aArguments, const mozilla::dom::Sequence<JS::Value>& aArguments,
mozilla::ErrorResult& aRv); JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aRv);
protected: protected:
/** /**

Просмотреть файл

@ -936,12 +936,14 @@ NS_IMETHODIMP
nsXMLHttpRequest::GetResponse(JSContext *aCx, JS::MutableHandle<JS::Value> aResult) nsXMLHttpRequest::GetResponse(JSContext *aCx, JS::MutableHandle<JS::Value> aResult)
{ {
ErrorResult rv; ErrorResult rv;
aResult.set(GetResponse(aCx, rv)); GetResponse(aCx, aResult, rv);
return rv.ErrorCode(); return rv.ErrorCode();
} }
JS::Value void
nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv) nsXMLHttpRequest::GetResponse(JSContext* aCx,
JS::MutableHandle<JS::Value> aResponse,
ErrorResult& aRv)
{ {
switch (mResponseType) { switch (mResponseType) {
case XML_HTTP_RESPONSE_TYPE_DEFAULT: case XML_HTTP_RESPONSE_TYPE_DEFAULT:
@ -951,14 +953,12 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
nsString str; nsString str;
aRv = GetResponseText(str); aRv = GetResponseText(str);
if (aRv.Failed()) { if (aRv.Failed()) {
return JSVAL_NULL; return;
} }
JS::Rooted<JS::Value> result(aCx); if (!xpc::StringToJsval(aCx, str, aResponse)) {
if (!xpc::StringToJsval(aCx, str, &result)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY); aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return JSVAL_NULL;
} }
return result; return;
} }
case XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER: case XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER:
@ -968,7 +968,8 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
mState & XML_HTTP_REQUEST_DONE) && mState & XML_HTTP_REQUEST_DONE) &&
!(mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER && !(mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER &&
mInLoadProgressEvent)) { mInLoadProgressEvent)) {
return JSVAL_NULL; aResponse.setNull();
return;
} }
if (!mResultArrayBuffer) { if (!mResultArrayBuffer) {
@ -977,17 +978,20 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
mResultArrayBuffer = mArrayBufferBuilder.getArrayBuffer(aCx); mResultArrayBuffer = mArrayBufferBuilder.getArrayBuffer(aCx);
if (!mResultArrayBuffer) { if (!mResultArrayBuffer) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY); aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return JSVAL_NULL; return;
} }
} }
return OBJECT_TO_JSVAL(mResultArrayBuffer); JS::ExposeObjectToActiveJS(mResultArrayBuffer);
aResponse.setObject(*mResultArrayBuffer);
return;
} }
case XML_HTTP_RESPONSE_TYPE_BLOB: case XML_HTTP_RESPONSE_TYPE_BLOB:
case XML_HTTP_RESPONSE_TYPE_MOZ_BLOB: case XML_HTTP_RESPONSE_TYPE_MOZ_BLOB:
{ {
if (!(mState & XML_HTTP_REQUEST_DONE)) { if (!(mState & XML_HTTP_REQUEST_DONE)) {
if (mResponseType != XML_HTTP_RESPONSE_TYPE_MOZ_BLOB) { if (mResponseType != XML_HTTP_RESPONSE_TYPE_MOZ_BLOB) {
return JSVAL_NULL; aResponse.setNull();
return;
} }
if (!mResponseBlob) { if (!mResponseBlob) {
@ -996,30 +1000,31 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
} }
if (!mResponseBlob) { if (!mResponseBlob) {
return JSVAL_NULL; aResponse.setNull();
return;
} }
JS::Rooted<JS::Value> result(aCx); aRv = nsContentUtils::WrapNative(aCx, mResponseBlob, aResponse);
aRv = nsContentUtils::WrapNative(aCx, mResponseBlob, &result); return;
return result;
} }
case XML_HTTP_RESPONSE_TYPE_DOCUMENT: case XML_HTTP_RESPONSE_TYPE_DOCUMENT:
{ {
if (!(mState & XML_HTTP_REQUEST_DONE) || !mResponseXML) { if (!(mState & XML_HTTP_REQUEST_DONE) || !mResponseXML) {
return JSVAL_NULL; aResponse.setNull();
return;
} }
JS::Rooted<JS::Value> result(aCx); aRv = nsContentUtils::WrapNative(aCx, mResponseXML, aResponse);
aRv = nsContentUtils::WrapNative(aCx, mResponseXML, &result); return;
return result;
} }
case XML_HTTP_RESPONSE_TYPE_JSON: case XML_HTTP_RESPONSE_TYPE_JSON:
{ {
if (!(mState & XML_HTTP_REQUEST_DONE)) { if (!(mState & XML_HTTP_REQUEST_DONE)) {
return JSVAL_NULL; aResponse.setNull();
return;
} }
if (mResultJSON == JSVAL_VOID) { if (mResultJSON.isUndefined()) {
aRv = CreateResponseParsedJSON(aCx); aRv = CreateResponseParsedJSON(aCx);
mResponseText.Truncate(); mResponseText.Truncate();
if (aRv.Failed()) { if (aRv.Failed()) {
@ -1028,16 +1033,18 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
// It would be nice to log the error to the console. That's hard to // It would be nice to log the error to the console. That's hard to
// do without calling window.onerror as a side effect, though. // do without calling window.onerror as a side effect, though.
JS_ClearPendingException(aCx); JS_ClearPendingException(aCx);
mResultJSON = JSVAL_NULL; mResultJSON.setNull();
} }
} }
return mResultJSON; JS::ExposeValueToActiveJS(mResultJSON);
aResponse.set(mResultJSON);
return;
} }
default: default:
NS_ERROR("Should not happen"); NS_ERROR("Should not happen");
} }
return JSVAL_NULL; aResponse.setNull();
} }
bool bool
@ -3757,10 +3764,12 @@ nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult)
return QueryInterface(aIID, aResult); return QueryInterface(aIID, aResult);
} }
JS::Value void
nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSID* aIID, ErrorResult& aRv) nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aRv)
{ {
return dom::GetInterface(aCx, this, aIID, aRv); dom::GetInterface(aCx, this, aIID, aRetval, aRv);
} }
nsXMLHttpRequestUpload* nsXMLHttpRequestUpload*

Просмотреть файл

@ -494,7 +494,8 @@ public:
return XMLHttpRequestResponseType(mResponseType); return XMLHttpRequestResponseType(mResponseType);
} }
void SetResponseType(XMLHttpRequestResponseType aType, ErrorResult& aRv); void SetResponseType(XMLHttpRequestResponseType aType, ErrorResult& aRv);
JS::Value GetResponse(JSContext* aCx, ErrorResult& aRv); void GetResponse(JSContext* aCx, JS::MutableHandle<JS::Value> aResponse,
ErrorResult& aRv);
void GetResponseText(nsString& aResponseText, ErrorResult& aRv); void GetResponseText(nsString& aResponseText, ErrorResult& aRv);
nsIDocument* GetResponseXML(ErrorResult& aRv); nsIDocument* GetResponseXML(ErrorResult& aRv);
@ -510,7 +511,8 @@ public:
} }
// We need a GetInterface callable from JS for chrome JS // We need a GetInterface callable from JS for chrome JS
JS::Value GetInterface(JSContext* aCx, nsIJSID* aIID, ErrorResult& aRv); void GetInterface(JSContext* aCx, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv);
// This creates a trusted readystatechange event, which is not cancelable and // This creates a trusted readystatechange event, which is not cancelable and
// doesn't bubble. // doesn't bubble.

Просмотреть файл

@ -3111,10 +3111,12 @@ CanvasRenderingContext2D::SetMozDash(JSContext* cx,
} }
} }
JS::Value void
CanvasRenderingContext2D::GetMozDash(JSContext* cx, ErrorResult& error) CanvasRenderingContext2D::GetMozDash(JSContext* cx,
JS::MutableHandle<JS::Value> retval,
ErrorResult& error)
{ {
return DashArrayToJSVal(CurrentState().dash, cx, error); DashArrayToJSVal(CurrentState().dash, cx, retval, error);
} }
void void

Просмотреть файл

@ -400,7 +400,8 @@ public:
mozilla::ErrorResult& error); mozilla::ErrorResult& error);
void GetFillRule(nsAString& fillRule); void GetFillRule(nsAString& fillRule);
void SetFillRule(const nsAString& fillRule); void SetFillRule(const nsAString& fillRule);
JS::Value GetMozDash(JSContext* cx, mozilla::ErrorResult& error); void GetMozDash(JSContext* cx, JS::MutableHandle<JS::Value> retval,
mozilla::ErrorResult& error);
void SetMozDash(JSContext* cx, const JS::Value& mozDash, void SetMozDash(JSContext* cx, const JS::Value& mozDash,
mozilla::ErrorResult& error); mozilla::ErrorResult& error);

Просмотреть файл

@ -151,18 +151,20 @@ JSValToDashArray(JSContext* cx, const JS::Value& patternArray,
} }
template<typename T> template<typename T>
JS::Value void
DashArrayToJSVal(FallibleTArray<T>& dashes, DashArrayToJSVal(FallibleTArray<T>& dashes,
JSContext* cx, mozilla::ErrorResult& rv) JSContext* cx,
JS::MutableHandle<JS::Value> retval,
mozilla::ErrorResult& rv)
{ {
if (dashes.IsEmpty()) { if (dashes.IsEmpty()) {
return JS::NullValue(); retval.setNull();
return;
} }
JS::Rooted<JS::Value> val(cx); JS::Rooted<JS::Value> val(cx);
if (!mozilla::dom::ToJSValue(cx, dashes, &val)) { if (!mozilla::dom::ToJSValue(cx, dashes, retval)) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY); rv.Throw(NS_ERROR_OUT_OF_MEMORY);
} }
return val;
} }
} }

Просмотреть файл

@ -357,9 +357,10 @@ public:
dom::Nullable< nsTArray<WebGLShader*> > &retval); dom::Nullable< nsTArray<WebGLShader*> > &retval);
GLint GetAttribLocation(WebGLProgram* prog, const nsAString& name); GLint GetAttribLocation(WebGLProgram* prog, const nsAString& name);
JS::Value GetBufferParameter(GLenum target, GLenum pname); JS::Value GetBufferParameter(GLenum target, GLenum pname);
JS::Value GetBufferParameter(JSContext* /* unused */, GLenum target, void GetBufferParameter(JSContext* /* unused */, GLenum target,
GLenum pname) { GLenum pname,
return GetBufferParameter(target, pname); JS::MutableHandle<JS::Value> retval) {
retval.set(GetBufferParameter(target, pname));
} }
GLenum GetError(); GLenum GetError();
JS::Value GetFramebufferAttachmentParameter(JSContext* cx, JS::Value GetFramebufferAttachmentParameter(JSContext* cx,
@ -367,22 +368,34 @@ public:
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
ErrorResult& rv); ErrorResult& rv);
void GetFramebufferAttachmentParameter(JSContext* cx,
GLenum target,
GLenum attachment,
GLenum pname,
JS::MutableHandle<JS::Value> retval,
ErrorResult& rv) {
retval.set(GetFramebufferAttachmentParameter(cx, target, attachment,
pname, rv));
}
JS::Value GetProgramParameter(WebGLProgram *prog, GLenum pname); JS::Value GetProgramParameter(WebGLProgram *prog, GLenum pname);
JS::Value GetProgramParameter(JSContext* /* unused */, WebGLProgram *prog, void GetProgramParameter(JSContext* /* unused */, WebGLProgram *prog,
GLenum pname) { GLenum pname,
return GetProgramParameter(prog, pname); JS::MutableHandle<JS::Value> retval) {
retval.set(GetProgramParameter(prog, pname));
} }
void GetProgramInfoLog(WebGLProgram *prog, nsACString& retval); void GetProgramInfoLog(WebGLProgram *prog, nsACString& retval);
void GetProgramInfoLog(WebGLProgram *prog, nsAString& retval); void GetProgramInfoLog(WebGLProgram *prog, nsAString& retval);
JS::Value GetRenderbufferParameter(GLenum target, GLenum pname); JS::Value GetRenderbufferParameter(GLenum target, GLenum pname);
JS::Value GetRenderbufferParameter(JSContext* /* unused */, void GetRenderbufferParameter(JSContext* /* unused */,
GLenum target, GLenum pname) { GLenum target, GLenum pname,
return GetRenderbufferParameter(target, pname); JS::MutableHandle<JS::Value> retval) {
retval.set(GetRenderbufferParameter(target, pname));
} }
JS::Value GetShaderParameter(WebGLShader *shader, GLenum pname); JS::Value GetShaderParameter(WebGLShader *shader, GLenum pname);
JS::Value GetShaderParameter(JSContext* /* unused */, WebGLShader *shader, void GetShaderParameter(JSContext* /* unused */, WebGLShader *shader,
GLenum pname) { GLenum pname,
return GetShaderParameter(shader, pname); JS::MutableHandle<JS::Value> retval) {
retval.set(GetShaderParameter(shader, pname));
} }
already_AddRefed<WebGLShaderPrecisionFormat> already_AddRefed<WebGLShaderPrecisionFormat>
GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype); GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
@ -391,12 +404,18 @@ public:
void GetShaderSource(WebGLShader *shader, nsAString& retval); void GetShaderSource(WebGLShader *shader, nsAString& retval);
void GetShaderTranslatedSource(WebGLShader *shader, nsAString& retval); void GetShaderTranslatedSource(WebGLShader *shader, nsAString& retval);
JS::Value GetTexParameter(GLenum target, GLenum pname); JS::Value GetTexParameter(GLenum target, GLenum pname);
JS::Value GetTexParameter(JSContext * /* unused */, GLenum target, void GetTexParameter(JSContext * /* unused */, GLenum target,
GLenum pname) { GLenum pname,
return GetTexParameter(target, pname); JS::MutableHandle<JS::Value> retval) {
retval.set(GetTexParameter(target, pname));
} }
JS::Value GetUniform(JSContext* cx, WebGLProgram *prog, JS::Value GetUniform(JSContext* cx, WebGLProgram *prog,
WebGLUniformLocation *location); WebGLUniformLocation *location);
void GetUniform(JSContext* cx, WebGLProgram *prog,
WebGLUniformLocation *location,
JS::MutableHandle<JS::Value> retval) {
retval.set(GetUniform(cx, prog, location));
}
already_AddRefed<WebGLUniformLocation> already_AddRefed<WebGLUniformLocation>
GetUniformLocation(WebGLProgram *prog, const nsAString& name); GetUniformLocation(WebGLProgram *prog, const nsAString& name);
void Hint(GLenum target, GLenum mode); void Hint(GLenum target, GLenum mode);
@ -691,6 +710,10 @@ public:
bool IsQuery(WebGLQuery *query); bool IsQuery(WebGLQuery *query);
already_AddRefed<WebGLQuery> GetQuery(GLenum target, GLenum pname); already_AddRefed<WebGLQuery> GetQuery(GLenum target, GLenum pname);
JS::Value GetQueryObject(JSContext* cx, WebGLQuery *query, GLenum pname); JS::Value GetQueryObject(JSContext* cx, WebGLQuery *query, GLenum pname);
void GetQueryObject(JSContext* cx, WebGLQuery *query, GLenum pname,
JS::MutableHandle<JS::Value> retval) {
retval.set(GetQueryObject(cx, query, pname));
}
private: private:
// ANY_SAMPLES_PASSED(_CONSERVATIVE) slot // ANY_SAMPLES_PASSED(_CONSERVATIVE) slot
@ -740,7 +763,12 @@ public:
void Disable(GLenum cap); void Disable(GLenum cap);
void Enable(GLenum cap); void Enable(GLenum cap);
JS::Value GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv); JS::Value GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv);
JS::Value GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index); void GetParameter(JSContext* cx, GLenum pname,
JS::MutableHandle<JS::Value> retval, ErrorResult& rv) {
retval.set(GetParameter(cx, pname, rv));
}
void GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index,
JS::MutableHandle<JS::Value> retval);
bool IsEnabled(GLenum cap); bool IsEnabled(GLenum cap);
private: private:
@ -766,6 +794,11 @@ public:
JS::Value GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname, JS::Value GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
ErrorResult& rv); ErrorResult& rv);
void GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
JS::MutableHandle<JS::Value> retval,
ErrorResult& rv) {
retval.set(GetVertexAttrib(cx, index, pname, rv));
}
WebGLsizeiptr GetVertexAttribOffset(GLuint index, GLenum pname); WebGLsizeiptr GetVertexAttribOffset(GLuint index, GLenum pname);
void VertexAttrib1f(GLuint index, GLfloat x0); void VertexAttrib1f(GLuint index, GLfloat x0);

Просмотреть файл

@ -454,11 +454,14 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
return JS::NullValue(); return JS::NullValue();
} }
JS::Value void
WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index) WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index,
JS::MutableHandle<JS::Value> retval)
{ {
if (IsContextLost()) if (IsContextLost()) {
return JS::NullValue(); retval.setNull();
return;
}
MakeContextCurrent(); MakeContextCurrent();
@ -467,9 +470,11 @@ WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
{ {
if (index >= mGLMaxTransformFeedbackSeparateAttribs) { if (index >= mGLMaxTransformFeedbackSeparateAttribs) {
ErrorInvalidValue("getParameterIndexed: index should be less than MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", index); ErrorInvalidValue("getParameterIndexed: index should be less than MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", index);
return JS::NullValue(); retval.setNull();
return;
} }
return JS::NullValue(); // See bug 903594 retval.setNull(); // See bug 903594
return;
} }
default: default:
@ -477,7 +482,7 @@ WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
} }
ErrorInvalidEnumInfo("getParameterIndexed: parameter", pname); ErrorInvalidEnumInfo("getParameterIndexed: parameter", pname);
return JS::NullValue(); retval.setNull();
} }
bool bool

Просмотреть файл

@ -426,7 +426,8 @@ PropertyNodeList::GetValues(JSContext* aCx, nsTArray<JS::Value >& aResult,
JSAutoCompartment ac(aCx, wrapper); JSAutoCompartment ac(aCx, wrapper);
uint32_t length = mElements.Length(); uint32_t length = mElements.Length();
for (uint32_t i = 0; i < length; ++i) { for (uint32_t i = 0; i < length; ++i) {
JS::Value v = mElements.ElementAt(i)->GetItemValue(aCx, wrapper, aError); JS::Rooted<JS::Value> v(aCx);
mElements.ElementAt(i)->GetItemValue(aCx, wrapper, &v, aError);
if (aError.Failed()) { if (aError.Failed()) {
return; return;
} }

Просмотреть файл

@ -3041,33 +3041,31 @@ nsGenericHTMLFormElementWithState::NodeInfoChanged(nsINodeInfo* aOldNodeInfo)
mStateKey.SetIsVoid(true); mStateKey.SetIsVoid(true);
} }
JS::Value void
nsGenericHTMLElement::GetItemValue(JSContext* aCx, JSObject* aScope, nsGenericHTMLElement::GetItemValue(JSContext* aCx, JSObject* aScope,
JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aError) ErrorResult& aError)
{ {
JS::Rooted<JSObject*> scope(aCx, aScope); JS::Rooted<JSObject*> scope(aCx, aScope);
if (!HasAttr(kNameSpaceID_None, nsGkAtoms::itemprop)) { if (!HasAttr(kNameSpaceID_None, nsGkAtoms::itemprop)) {
return JS::NullValue(); aRetval.setNull();
return;
} }
if (ItemScope()) { if (ItemScope()) {
JS::Rooted<JS::Value> v(aCx); JS::Rooted<JS::Value> v(aCx);
JSAutoCompartment ac(aCx, scope); JSAutoCompartment ac(aCx, scope);
if (!mozilla::dom::WrapObject(aCx, this, &v)) { if (!mozilla::dom::WrapObject(aCx, this, aRetval)) {
aError.Throw(NS_ERROR_FAILURE); aError.Throw(NS_ERROR_FAILURE);
return JS::UndefinedValue();
} }
return v; return;
} }
nsString string; nsString string;
GetItemValueText(string); GetItemValueText(string);
JS::Rooted<JS::Value> v(aCx); if (!xpc::NonVoidStringToJsval(aCx, string, aRetval)) {
if (!xpc::NonVoidStringToJsval(aCx, string, &v)) {
aError.Throw(NS_ERROR_FAILURE); aError.Throw(NS_ERROR_FAILURE);
return JS::UndefinedValue();
} }
return v;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -124,11 +124,13 @@ public:
return GetTokenList(nsGkAtoms::itemprop); return GetTokenList(nsGkAtoms::itemprop);
} }
mozilla::dom::HTMLPropertiesCollection* Properties(); mozilla::dom::HTMLPropertiesCollection* Properties();
JS::Value GetItemValue(JSContext* aCx, JSObject* aScope, void GetItemValue(JSContext* aCx, JSObject* aScope,
mozilla::ErrorResult& aError); JS::MutableHandle<JS::Value> aRetval,
JS::Value GetItemValue(JSContext* aCx, mozilla::ErrorResult& aError) mozilla::ErrorResult& aError);
void GetItemValue(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError)
{ {
return GetItemValue(aCx, GetWrapperPreserveColor(), aError); GetItemValue(aCx, GetWrapperPreserveColor(), aRetval, aError);
} }
void SetItemValue(JSContext* aCx, JS::Value aValue, void SetItemValue(JSContext* aCx, JS::Value aValue,
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);

Просмотреть файл

@ -83,7 +83,7 @@ DOMRequest::GetReadyState(nsAString& aReadyState)
NS_IMETHODIMP NS_IMETHODIMP
DOMRequest::GetResult(JS::MutableHandle<JS::Value> aResult) DOMRequest::GetResult(JS::MutableHandle<JS::Value> aResult)
{ {
aResult.set(Result()); GetResult(nullptr, aResult);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -49,11 +49,12 @@ public:
: DOMRequestReadyState::Pending; : DOMRequestReadyState::Pending;
} }
JS::Value Result(JSContext* = nullptr) const void GetResult(JSContext*, JS::MutableHandle<JS::Value> aRetval) const
{ {
NS_ASSERTION(mDone || mResult == JSVAL_VOID, NS_ASSERTION(mDone || mResult == JSVAL_VOID,
"Result should be undefined when pending"); "Result should be undefined when pending");
return mResult; JS::ExposeValueToActiveJS(mResult);
aRetval.set(mResult);
} }
DOMError* GetError() const DOMError* GetError() const

Просмотреть файл

@ -4503,17 +4503,17 @@ nsGlobalWindow::GetOpenerWindow(ErrorResult& aError)
return nullptr; return nullptr;
} }
JS::Value void
nsGlobalWindow::GetOpener(JSContext* aCx, ErrorResult& aError) nsGlobalWindow::GetOpener(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aError)
{ {
nsCOMPtr<nsIDOMWindow> opener = GetOpenerWindow(aError); nsCOMPtr<nsIDOMWindow> opener = GetOpenerWindow(aError);
if (aError.Failed() || !opener) { if (aError.Failed() || !opener) {
return JS::NullValue(); aRetval.setNull();
return;
} }
JS::Rooted<JS::Value> val(aCx); aError = nsContentUtils::WrapNative(aCx, opener, aRetval);
aError = nsContentUtils::WrapNative(aCx, opener, &val);
return val;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -4521,7 +4521,7 @@ nsGlobalWindow::GetScriptableOpener(JSContext* aCx,
JS::MutableHandle<JS::Value> aOpener) JS::MutableHandle<JS::Value> aOpener)
{ {
ErrorResult rv; ErrorResult rv;
aOpener.set(GetOpener(aCx, rv)); GetOpener(aCx, aOpener, rv);
return rv.ErrorCode(); return rv.ErrorCode();
} }
@ -9110,10 +9110,11 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
return retVal.forget(); return retVal.forget();
} }
JS::Value void
nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl, nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
JS::Handle<JS::Value> aArgument, JS::Handle<JS::Value> aArgument,
const nsAString& aOptions, const nsAString& aOptions,
JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aError) ErrorResult& aError)
{ {
nsCOMPtr<nsIVariant> args; nsCOMPtr<nsIVariant> args;
@ -9121,23 +9122,22 @@ nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
aArgument, aArgument,
getter_AddRefs(args)); getter_AddRefs(args));
if (aError.Failed()) { if (aError.Failed()) {
return JS::UndefinedValue(); return;
} }
nsCOMPtr<nsIVariant> retVal = ShowModalDialog(aUrl, args, aOptions, aError); nsCOMPtr<nsIVariant> retVal = ShowModalDialog(aUrl, args, aOptions, aError);
if (aError.Failed()) { if (aError.Failed()) {
return JS::UndefinedValue(); return;
} }
JS::Rooted<JS::Value> result(aCx); JS::Rooted<JS::Value> result(aCx);
if (retVal) { if (retVal) {
aError = nsContentUtils::XPConnect()->VariantToJS(aCx, aError = nsContentUtils::XPConnect()->VariantToJS(aCx,
FastGetGlobalJSObject(), FastGetGlobalJSObject(),
retVal, &result); retVal, aRetval);
} else { } else {
result = JS::NullValue(); aRetval.setNull();
} }
return result;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -10585,10 +10585,12 @@ nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink)
return *aSink ? NS_OK : NS_ERROR_NO_INTERFACE; return *aSink ? NS_OK : NS_ERROR_NO_INTERFACE;
} }
JS::Value void
nsGlobalWindow::GetInterface(JSContext* aCx, nsIJSID* aIID, ErrorResult& aError) nsGlobalWindow::GetInterface(JSContext* aCx, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aError)
{ {
return dom::GetInterface(aCx, this, aIID, aError); dom::GetInterface(aCx, this, aIID, aRetval, aError);
} }
void void
@ -12098,7 +12100,8 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
// Hold strong ref to ourselves while we call the callback. // Hold strong ref to ourselves while we call the callback.
nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this)); nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this));
ErrorResult ignored; ErrorResult ignored;
callback->Call(me, handler->GetArgs(), ignored); JS::Rooted<JS::Value> ignoredVal(CycleCollectedJSRuntime::Get()->Runtime());
callback->Call(me, handler->GetArgs(), &ignoredVal, ignored);
} }
// We ignore any failures from calling EvaluateString() on the context or // We ignore any failures from calling EvaluateString() on the context or
@ -13623,28 +13626,29 @@ NS_IMPL_ADDREF_INHERITED(nsGlobalModalWindow, nsGlobalWindow)
NS_IMPL_RELEASE_INHERITED(nsGlobalModalWindow, nsGlobalWindow) NS_IMPL_RELEASE_INHERITED(nsGlobalModalWindow, nsGlobalWindow)
JS::Value void
nsGlobalWindow::GetDialogArguments(JSContext* aCx, ErrorResult& aError) nsGlobalWindow::GetDialogArguments(JSContext* aCx,
JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aError)
{ {
FORWARD_TO_OUTER_OR_THROW(GetDialogArguments, (aCx, aError), aError, FORWARD_TO_OUTER_OR_THROW(GetDialogArguments, (aCx, aRetval, aError),
JS::UndefinedValue()); aError, );
MOZ_ASSERT(IsModalContentWindow(), MOZ_ASSERT(IsModalContentWindow(),
"This should only be called on modal windows!"); "This should only be called on modal windows!");
if (!mDialogArguments) { if (!mDialogArguments) {
MOZ_ASSERT(mIsClosed, "This window should be closed!"); MOZ_ASSERT(mIsClosed, "This window should be closed!");
return JS::UndefinedValue(); aRetval.setUndefined();
return;
} }
// This does an internal origin check, and returns undefined if the subject // This does an internal origin check, and returns undefined if the subject
// does not subsumes the origin of the arguments. // does not subsumes the origin of the arguments.
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper()); JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
JSAutoCompartment ac(aCx, wrapper); JSAutoCompartment ac(aCx, wrapper);
JS::Rooted<JS::Value> args(aCx);
mDialogArguments->Get(aCx, wrapper, nsContentUtils::SubjectPrincipal(), mDialogArguments->Get(aCx, wrapper, nsContentUtils::SubjectPrincipal(),
&args, aError); aRetval, aError);
return args;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -13658,23 +13662,25 @@ nsGlobalModalWindow::GetDialogArguments(nsIVariant **aArguments)
return mDialogArguments->Get(nsContentUtils::SubjectPrincipal(), aArguments); return mDialogArguments->Get(nsContentUtils::SubjectPrincipal(), aArguments);
} }
JS::Value void
nsGlobalWindow::GetReturnValue(JSContext* aCx, ErrorResult& aError) nsGlobalWindow::GetReturnValue(JSContext* aCx,
JS::MutableHandle<JS::Value> aReturnValue,
ErrorResult& aError)
{ {
FORWARD_TO_OUTER_OR_THROW(GetReturnValue, (aCx, aError), aError, FORWARD_TO_OUTER_OR_THROW(GetReturnValue, (aCx, aReturnValue, aError),
JS::UndefinedValue()); aError, );
MOZ_ASSERT(IsModalContentWindow(), MOZ_ASSERT(IsModalContentWindow(),
"This should only be called on modal windows!"); "This should only be called on modal windows!");
JS::Rooted<JS::Value> returnValue(aCx);
if (mReturnValue) { if (mReturnValue) {
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper()); JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
JSAutoCompartment ac(aCx, wrapper); JSAutoCompartment ac(aCx, wrapper);
mReturnValue->Get(aCx, wrapper, nsContentUtils::SubjectPrincipal(), mReturnValue->Get(aCx, wrapper, nsContentUtils::SubjectPrincipal(),
&returnValue, aError); aReturnValue, aError);
} else {
aReturnValue.setUndefined();
} }
return returnValue;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -837,7 +837,8 @@ public:
protected: protected:
nsIDOMWindow* GetOpenerWindow(mozilla::ErrorResult& aError); nsIDOMWindow* GetOpenerWindow(mozilla::ErrorResult& aError);
public: public:
JS::Value GetOpener(JSContext* aCx, mozilla::ErrorResult& aError); void GetOpener(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
void SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener, void SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener,
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
using nsIDOMWindow::GetParent; using nsIDOMWindow::GetParent;
@ -867,7 +868,11 @@ public:
void Prompt(const nsAString& aMessage, const nsAString& aInitial, void Prompt(const nsAString& aMessage, const nsAString& aInitial,
nsAString& aReturn, mozilla::ErrorResult& aError); nsAString& aReturn, mozilla::ErrorResult& aError);
void Print(mozilla::ErrorResult& aError); void Print(mozilla::ErrorResult& aError);
JS::Value ShowModalDialog(JSContext* aCx, const nsAString& aUrl, JS::Handle<JS::Value> aArgument, const nsAString& aOptions, mozilla::ErrorResult& aError); void ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
JS::Handle<JS::Value> aArgument,
const nsAString& aOptions,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage, void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const nsAString& aTargetOrigin, const nsAString& aTargetOrigin,
const mozilla::dom::Optional<mozilla::dom::Sequence<JS::Value > >& aTransfer, const mozilla::dom::Optional<mozilla::dom::Sequence<JS::Value > >& aTransfer,
@ -1017,13 +1022,16 @@ public:
mozilla::dom::Element* aPanel, mozilla::dom::Element* aPanel,
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
JS::Value GetDialogArguments(JSContext* aCx, mozilla::ErrorResult& aError); void GetDialogArguments(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
JS::Value GetReturnValue(JSContext* aCx, mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
void GetReturnValue(JSContext* aCx, JS::MutableHandle<JS::Value> aReturnValue,
mozilla::ErrorResult& aError);
void SetReturnValue(JSContext* aCx, JS::Handle<JS::Value> aReturnValue, void SetReturnValue(JSContext* aCx, JS::Handle<JS::Value> aReturnValue,
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
JS::Value GetInterface(JSContext* aCx, nsIJSID* aIID, void GetInterface(JSContext* aCx, nsIJSID* aIID,
mozilla::ErrorResult& aError); JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
protected: protected:
// Array of idle observers that are notified of idle events. // Array of idle observers that are notified of idle events.

Просмотреть файл

@ -96,50 +96,46 @@ nsHistory::GetLength(ErrorResult& aRv) const
return len >= 0 ? len : 0; return len >= 0 ? len : 0;
} }
JS::Value void
nsHistory::GetState(JSContext* aCx, ErrorResult& aRv) const nsHistory::GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv) const
{ {
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mInnerWindow)); nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mInnerWindow));
if (!win) { if (!win) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE); aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return;
return JS::UndefinedValue();
} }
if (!win->HasActiveDocument()) { if (!win->HasActiveDocument()) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
return JS::UndefinedValue();
} }
nsCOMPtr<nsIDocument> doc = nsCOMPtr<nsIDocument> doc =
do_QueryInterface(win->GetExtantDoc()); do_QueryInterface(win->GetExtantDoc());
if (!doc) { if (!doc) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE); aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return;
return JS::UndefinedValue();
} }
nsCOMPtr<nsIVariant> variant; nsCOMPtr<nsIVariant> variant;
doc->GetStateObject(getter_AddRefs(variant)); doc->GetStateObject(getter_AddRefs(variant));
if (variant) { if (variant) {
JS::Rooted<JS::Value> jsData(aCx); aRv = variant->GetAsJSVal(aResult);
aRv = variant->GetAsJSVal(&jsData);
if (aRv.Failed()) { if (aRv.Failed()) {
return JS::UndefinedValue(); return;
} }
if (!JS_WrapValue(aCx, &jsData)) { if (!JS_WrapValue(aCx, aResult)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY); aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return JS::UndefinedValue();
} }
return jsData; return;
} }
return JS::NullValue(); aResult.setNull();
} }
void void

Просмотреть файл

@ -37,7 +37,8 @@ public:
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
uint32_t GetLength(mozilla::ErrorResult& aRv) const; uint32_t GetLength(mozilla::ErrorResult& aRv) const;
JS::Value GetState(JSContext* aCx, mozilla::ErrorResult& aRv) const; void GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
mozilla::ErrorResult& aRv) const;
void Go(int32_t aDelta, mozilla::ErrorResult& aRv); void Go(int32_t aDelta, mozilla::ErrorResult& aRv);
void Back(mozilla::ErrorResult& aRv); void Back(mozilla::ErrorResult& aRv);
void Forward(mozilla::ErrorResult& aRv); void Forward(mozilla::ErrorResult& aRv);

Просмотреть файл

@ -884,25 +884,22 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
return true; return true;
} }
JS::Value void
GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor, GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor,
nsWrapperCache* aCache, nsIJSID* aIID, ErrorResult& aError) nsWrapperCache* aCache, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aError)
{ {
const nsID* iid = aIID->GetID(); const nsID* iid = aIID->GetID();
nsRefPtr<nsISupports> result; nsRefPtr<nsISupports> result;
aError = aRequestor->GetInterface(*iid, getter_AddRefs(result)); aError = aRequestor->GetInterface(*iid, getter_AddRefs(result));
if (aError.Failed()) { if (aError.Failed()) {
return JS::NullValue(); return;
} }
JS::Rooted<JS::Value> v(aCx, JSVAL_NULL); if (!WrapObject(aCx, result, iid, aRetval)) {
if (!WrapObject(aCx, result, iid, &v)) {
aError.Throw(NS_ERROR_FAILURE); aError.Throw(NS_ERROR_FAILURE);
return JS::NullValue();
} }
return v;
} }
bool bool

Просмотреть файл

@ -1649,15 +1649,17 @@ WantsQueryInterface
} }
}; };
JS::Value void
GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor, GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor,
nsWrapperCache* aCache, nsIJSID* aIID, ErrorResult& aError); nsWrapperCache* aCache, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aError);
template<class T> template<class T>
JS::Value void
GetInterface(JSContext* aCx, T* aThis, nsIJSID* aIID, ErrorResult& aError) GetInterface(JSContext* aCx, T* aThis, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aError)
{ {
return GetInterfaceImpl(aCx, aThis, aThis, aIID, aError); GetInterfaceImpl(aCx, aThis, aThis, aIID, aRetval, aError);
} }
bool bool

Просмотреть файл

@ -5638,7 +5638,9 @@ def getRetvalDeclarationForType(returnType, descriptorProvider,
name = returnType.unroll().identifier.name name = returnType.unroll().identifier.name
return CGGeneric("nsRefPtr<%s>" % name), None, None, None return CGGeneric("nsRefPtr<%s>" % name), None, None, None
if returnType.isAny(): if returnType.isAny():
return CGGeneric("JS::Value"), None, None, None if isMember:
return CGGeneric("JS::Value"), None, None, None
return CGGeneric("JS::Rooted<JS::Value>"), "ptr", None, "cx"
if returnType.isObject() or returnType.isSpiderMonkeyInterface(): if returnType.isObject() or returnType.isSpiderMonkeyInterface():
return CGGeneric("JSObject*"), None, None, None return CGGeneric("JSObject*"), None, None, None
if returnType.isSequence(): if returnType.isSequence():
@ -11579,7 +11581,12 @@ class CGNativeMember(ClassMethod):
return ("already_AddRefed<%s>" % type.unroll().identifier.name, return ("already_AddRefed<%s>" % type.unroll().identifier.name,
"nullptr", "return ${declName}.forget();\n") "nullptr", "return ${declName}.forget();\n")
if type.isAny(): if type.isAny():
return "JS::Value", "JS::UndefinedValue()", "return ${declName};\n" if isMember:
# No need for a third element in the isMember case
return "JS::Value", None, None
# Outparam
return "void", "", "aRetVal.set(${declName});\n"
if type.isObject(): if type.isObject():
return "JSObject*", "nullptr", "return ${declName};\n" return "JSObject*", "nullptr", "return ${declName};\n"
if type.isSpiderMonkeyInterface(): if type.isSpiderMonkeyInterface():
@ -11677,6 +11684,9 @@ class CGNativeMember(ClassMethod):
args.append(Argument("%s&" % args.append(Argument("%s&" %
CGUnionStruct.unionTypeDecl(returnType, True), CGUnionStruct.unionTypeDecl(returnType, True),
"aRetVal")) "aRetVal"))
elif returnType.isAny():
args.append(Argument("JS::MutableHandle<JS::Value>", "aRetVal"))
# And the ErrorResult # And the ErrorResult
if 'infallible' not in self.extendedAttrs: if 'infallible' not in self.extendedAttrs:
# Use aRv so it won't conflict with local vars named "rv" # Use aRv so it won't conflict with local vars named "rv"
@ -13563,7 +13573,8 @@ class CGEventGetter(CGNativeMember):
return fill( return fill(
""" """
JS::ExposeValueToActiveJS(${memberName}); JS::ExposeValueToActiveJS(${memberName});
return ${memberName}; aRetVal.set(${memberName});
return;
""", """,
memberName=memberName) memberName=memberName)
if type.isUnion(): if type.isUnion():

Просмотреть файл

@ -523,7 +523,7 @@ public:
void PassOptionalNullableMozMapOfNullableMozMapOfAny(JSContext*, const Optional<Nullable<MozMap<Nullable<MozMap<JS::Value>>>>>&); void PassOptionalNullableMozMapOfNullableMozMapOfAny(JSContext*, const Optional<Nullable<MozMap<Nullable<MozMap<JS::Value>>>>>&);
void PassOptionalNullableMozMapOfNullableSequenceOfAny(JSContext*, const Optional<Nullable<MozMap<Nullable<Sequence<JS::Value>>>>>&); void PassOptionalNullableMozMapOfNullableSequenceOfAny(JSContext*, const Optional<Nullable<MozMap<Nullable<Sequence<JS::Value>>>>>&);
void PassOptionalNullableSequenceOfNullableMozMapOfAny(JSContext*, const Optional<Nullable<Sequence<Nullable<MozMap<JS::Value>>>>>&); void PassOptionalNullableSequenceOfNullableMozMapOfAny(JSContext*, const Optional<Nullable<Sequence<Nullable<MozMap<JS::Value>>>>>&);
JS::Value ReceiveAny(JSContext*); void ReceiveAny(JSContext*, JS::MutableHandle<JS::Value>);
// object types // object types
void PassObject(JSContext*, JS::Handle<JSObject*>); void PassObject(JSContext*, JS::Handle<JSObject*>);
@ -767,7 +767,7 @@ public:
TestInterface* PutForwardsAttr(); TestInterface* PutForwardsAttr();
TestInterface* PutForwardsAttr2(); TestInterface* PutForwardsAttr2();
TestInterface* PutForwardsAttr3(); TestInterface* PutForwardsAttr3();
JS::Value JsonifierShouldSkipThis(JSContext*); void GetJsonifierShouldSkipThis(JSContext*, JS::MutableHandle<JS::Value>);
void SetJsonifierShouldSkipThis(JSContext*, JS::Rooted<JS::Value>&); void SetJsonifierShouldSkipThis(JSContext*, JS::Rooted<JS::Value>&);
TestParentInterface* JsonifierShouldSkipThis2(); TestParentInterface* JsonifierShouldSkipThis2();
void SetJsonifierShouldSkipThis2(TestParentInterface&); void SetJsonifierShouldSkipThis2(TestParentInterface&);

Просмотреть файл

@ -429,30 +429,34 @@ BluetoothAdapter::StopDiscovery(ErrorResult& aRv)
return StartStopDiscovery(false, aRv); return StartStopDiscovery(false, aRv);
} }
JS::Value void
BluetoothAdapter::GetDevices(JSContext* aContext, ErrorResult& aRv) BluetoothAdapter::GetDevices(JSContext* aContext,
JS::MutableHandle<JS::Value> aDevices,
ErrorResult& aRv)
{ {
if (!mJsDeviceAddresses) { if (!mJsDeviceAddresses) {
BT_WARNING("Devices not yet set!\n"); BT_WARNING("Devices not yet set!\n");
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::NullValue(); return;
} }
JS::ExposeObjectToActiveJS(mJsDeviceAddresses); JS::ExposeObjectToActiveJS(mJsDeviceAddresses);
return JS::ObjectValue(*mJsDeviceAddresses); aDevices.setObject(*mJsDeviceAddresses);
} }
JS::Value void
BluetoothAdapter::GetUuids(JSContext* aContext, ErrorResult& aRv) BluetoothAdapter::GetUuids(JSContext* aContext,
JS::MutableHandle<JS::Value> aUuids,
ErrorResult& aRv)
{ {
if (!mJsUuids) { if (!mJsUuids) {
BT_WARNING("UUIDs not yet set!\n"); BT_WARNING("UUIDs not yet set!\n");
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::NullValue(); return;
} }
JS::ExposeObjectToActiveJS(mJsUuids); JS::ExposeObjectToActiveJS(mJsUuids);
return JS::ObjectValue(*mJsUuids); aUuids.setObject(*mJsUuids);
} }
already_AddRefed<DOMRequest> already_AddRefed<DOMRequest>

Просмотреть файл

@ -83,8 +83,10 @@ public:
return mDiscoverableTimeout; return mDiscoverableTimeout;
} }
JS::Value GetDevices(JSContext* aContext, ErrorResult& aRv); void GetDevices(JSContext* aContext, JS::MutableHandle<JS::Value> aDevices,
JS::Value GetUuids(JSContext* aContext, ErrorResult& aRv); ErrorResult& aRv);
void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids,
ErrorResult& aRv);
already_AddRefed<mozilla::dom::DOMRequest> already_AddRefed<mozilla::dom::DOMRequest>
SetName(const nsAString& aName, ErrorResult& aRv); SetName(const nsAString& aName, ErrorResult& aRv);

Просмотреть файл

@ -206,30 +206,34 @@ BluetoothDevice::Notify(const BluetoothSignal& aData)
} }
} }
JS::Value void
BluetoothDevice::GetUuids(JSContext* aCx, ErrorResult& aRv) BluetoothDevice::GetUuids(JSContext* aContext,
JS::MutableHandle<JS::Value> aUuids,
ErrorResult& aRv)
{ {
if (!mJsUuids) { if (!mJsUuids) {
BT_WARNING("UUIDs not yet set!"); BT_WARNING("UUIDs not yet set!");
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::NullValue(); return;
} }
JS::ExposeObjectToActiveJS(mJsUuids); JS::ExposeObjectToActiveJS(mJsUuids);
return JS::ObjectValue(*mJsUuids); aUuids.setObject(*mJsUuids);
} }
JS::Value void
BluetoothDevice::GetServices(JSContext* aCx, ErrorResult& aRv) BluetoothDevice::GetServices(JSContext* aCx,
JS::MutableHandle<JS::Value> aServices,
ErrorResult& aRv)
{ {
if (!mJsServices) { if (!mJsServices) {
BT_WARNING("Services not yet set!"); BT_WARNING("Services not yet set!");
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::Value(JSVAL_NULL); return;
} }
JS::ExposeObjectToActiveJS(mJsServices); JS::ExposeObjectToActiveJS(mJsServices);
return JS::ObjectValue(*mJsServices); aServices.setObject(*mJsServices);
} }
JSObject* JSObject*

Просмотреть файл

@ -66,8 +66,10 @@ public:
return mConnected; return mConnected;
} }
JS::Value GetUuids(JSContext* aContext, ErrorResult& aRv); void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids,
JS::Value GetServices(JSContext* aContext, ErrorResult& aRv); ErrorResult& aRv);
void GetServices(JSContext* aContext, JS::MutableHandle<JS::Value> aServices,
ErrorResult& aRv);
nsISupports* nsISupports*
ToISupports() ToISupports()

Просмотреть файл

@ -457,30 +457,34 @@ BluetoothAdapter::StopDiscovery(ErrorResult& aRv)
return StartStopDiscovery(false, aRv); return StartStopDiscovery(false, aRv);
} }
JS::Value void
BluetoothAdapter::GetDevices(JSContext* aContext, ErrorResult& aRv) BluetoothAdapter::GetDevices(JSContext* aContext,
JS::MutableHandle<JS::Value> aDevices,
ErrorResult& aRv)
{ {
if (!mJsDeviceAddresses) { if (!mJsDeviceAddresses) {
BT_WARNING("Devices not yet set!\n"); BT_WARNING("Devices not yet set!\n");
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::NullValue(); return;
} }
JS::ExposeObjectToActiveJS(mJsDeviceAddresses); JS::ExposeObjectToActiveJS(mJsDeviceAddresses);
return JS::ObjectValue(*mJsDeviceAddresses); aDevices.setObject(*mJsDeviceAddresses);
} }
JS::Value void
BluetoothAdapter::GetUuids(JSContext* aContext, ErrorResult& aRv) BluetoothAdapter::GetUuids(JSContext* aContext,
JS::MutableHandle<JS::Value> aUuids,
ErrorResult& aRv)
{ {
if (!mJsUuids) { if (!mJsUuids) {
BT_WARNING("UUIDs not yet set!\n"); BT_WARNING("UUIDs not yet set!\n");
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::NullValue(); return;
} }
JS::ExposeObjectToActiveJS(mJsUuids); JS::ExposeObjectToActiveJS(mJsUuids);
return JS::ObjectValue(*mJsUuids); aUuids.setObject(*mJsUuids);
} }
already_AddRefed<DOMRequest> already_AddRefed<DOMRequest>

Просмотреть файл

@ -90,8 +90,10 @@ public:
return mDiscoverableTimeout; return mDiscoverableTimeout;
} }
JS::Value GetDevices(JSContext* aContext, ErrorResult& aRv); void GetDevices(JSContext* aContext, JS::MutableHandle<JS::Value> aDevices,
JS::Value GetUuids(JSContext* aContext, ErrorResult& aRv); ErrorResult& aRv);
void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids,
ErrorResult& aRv);
already_AddRefed<mozilla::dom::DOMRequest> already_AddRefed<mozilla::dom::DOMRequest>
SetName(const nsAString& aName, ErrorResult& aRv); SetName(const nsAString& aName, ErrorResult& aRv);

Просмотреть файл

@ -206,30 +206,34 @@ BluetoothDevice::Notify(const BluetoothSignal& aData)
} }
} }
JS::Value void
BluetoothDevice::GetUuids(JSContext* aCx, ErrorResult& aRv) BluetoothDevice::GetUuids(JSContext* aContext,
JS::MutableHandle<JS::Value> aUuids,
ErrorResult& aRv)
{ {
if (!mJsUuids) { if (!mJsUuids) {
BT_WARNING("UUIDs not yet set!"); BT_WARNING("UUIDs not yet set!");
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::NullValue(); return;
} }
JS::ExposeObjectToActiveJS(mJsUuids); JS::ExposeObjectToActiveJS(mJsUuids);
return JS::ObjectValue(*mJsUuids); aUuids.setObject(*mJsUuids);
} }
JS::Value void
BluetoothDevice::GetServices(JSContext* aCx, ErrorResult& aRv) BluetoothDevice::GetServices(JSContext* aCx,
JS::MutableHandle<JS::Value> aServices,
ErrorResult& aRv)
{ {
if (!mJsServices) { if (!mJsServices) {
BT_WARNING("Services not yet set!"); BT_WARNING("Services not yet set!");
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JS::Value(JSVAL_NULL); return;
} }
JS::ExposeObjectToActiveJS(mJsServices); JS::ExposeObjectToActiveJS(mJsServices);
return JS::ObjectValue(*mJsServices); aServices.setObject(*mJsServices);
} }
JSObject* JSObject*

Просмотреть файл

@ -66,8 +66,10 @@ public:
return mConnected; return mConnected;
} }
JS::Value GetUuids(JSContext* aContext, ErrorResult& aRv); void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids,
JS::Value GetServices(JSContext* aContext, ErrorResult& aRv); ErrorResult& aRv);
void GetServices(JSContext* aContext, JS::MutableHandle<JS::Value> aServices,
ErrorResult& aRv);
nsISupports* nsISupports*
ToISupports() ToISupports()

Просмотреть файл

@ -293,10 +293,12 @@ CameraCapabilities::ExposureCompensationStep() const
return mExposureCompensationStep; return mExposureCompensationStep;
} }
JS::Value void
CameraCapabilities::RecorderProfiles(JSContext* aCx) const CameraCapabilities::GetRecorderProfiles(JSContext* aCx,
JS::MutableHandle<JS::Value> aRetval) const
{ {
return mRecorderProfiles; JS::ExposeValueToActiveJS(mRecorderProfiles);
aRetval.set(mRecorderProfiles);
} }
void void

Просмотреть файл

@ -71,7 +71,7 @@ public:
double MinExposureCompensation() const; double MinExposureCompensation() const;
double MaxExposureCompensation() const; double MaxExposureCompensation() const;
double ExposureCompensationStep() const; double ExposureCompensationStep() const;
JS::Value RecorderProfiles(JSContext* cx) const; void GetRecorderProfiles(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval) const;
void GetIsoModes(nsTArray<nsString>& aRetVal) const; void GetIsoModes(nsTArray<nsString>& aRetVal) const;
protected: protected:

Просмотреть файл

@ -129,7 +129,8 @@ DataStoreDB::UpgradeSchema()
AutoSafeJSContext cx; AutoSafeJSContext cx;
ErrorResult error; ErrorResult error;
JS::Rooted<JS::Value> result(cx, mRequest->GetResult(error)); JS::Rooted<JS::Value> result(cx);
mRequest->GetResult(&result, error);
if (NS_WARN_IF(error.Failed())) { if (NS_WARN_IF(error.Failed())) {
return error.ErrorCode(); return error.ErrorCode();
} }
@ -190,7 +191,8 @@ DataStoreDB::DatabaseOpened()
AutoSafeJSContext cx; AutoSafeJSContext cx;
ErrorResult error; ErrorResult error;
JS::Rooted<JS::Value> result(cx, mRequest->GetResult(error)); JS::Rooted<JS::Value> result(cx);
mRequest->GetResult(&result, error);
if (NS_WARN_IF(error.Failed())) { if (NS_WARN_IF(error.Failed())) {
return error.ErrorCode(); return error.ErrorCode();
} }

Просмотреть файл

@ -587,7 +587,8 @@ public:
AutoSafeJSContext cx; AutoSafeJSContext cx;
ErrorResult error; ErrorResult error;
JS::Rooted<JS::Value> result(cx, mRequest->GetResult(error)); JS::Rooted<JS::Value> result(cx);
mRequest->GetResult(cx, &result, error);
if (NS_WARN_IF(error.Failed())) { if (NS_WARN_IF(error.Failed())) {
return error.ErrorCode(); return error.ErrorCode();
} }

Просмотреть файл

@ -640,27 +640,27 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
return NS_OK; return NS_OK;
} }
JS::Value void
DataTransfer::MozGetDataAt(JSContext* aCx, const nsAString& aFormat, DataTransfer::MozGetDataAt(JSContext* aCx, const nsAString& aFormat,
uint32_t aIndex, mozilla::ErrorResult& aRv) uint32_t aIndex,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aRv)
{ {
nsCOMPtr<nsIVariant> data; nsCOMPtr<nsIVariant> data;
aRv = MozGetDataAt(aFormat, aIndex, getter_AddRefs(data)); aRv = MozGetDataAt(aFormat, aIndex, getter_AddRefs(data));
if (aRv.Failed()) { if (aRv.Failed()) {
return JS::UndefinedValue(); return;
} }
if (!data) { if (!data) {
return JS::NullValue(); return;
} }
JS::Rooted<JS::Value> result(aCx); JS::Rooted<JS::Value> result(aCx);
if (!VariantToJsval(aCx, data, &result)) { if (!VariantToJsval(aCx, data, aRetval)) {
aRv = NS_ERROR_FAILURE; aRv = NS_ERROR_FAILURE;
return JS::UndefinedValue(); return;
} }
return result;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -164,8 +164,9 @@ public:
void MozSetDataAt(JSContext* aCx, const nsAString& aFormat, void MozSetDataAt(JSContext* aCx, const nsAString& aFormat,
JS::Handle<JS::Value> aData, uint32_t aIndex, JS::Handle<JS::Value> aData, uint32_t aIndex,
mozilla::ErrorResult& aRv); mozilla::ErrorResult& aRv);
JS::Value MozGetDataAt(JSContext* aCx, const nsAString& aFormat, void MozGetDataAt(JSContext* aCx, const nsAString& aFormat,
uint32_t aIndex, mozilla::ErrorResult& aRv); uint32_t aIndex, JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aRv);
bool MozUserCancelled() bool MozUserCancelled()
{ {
return mUserCancelled; return mUserCancelled;

Просмотреть файл

@ -18,6 +18,7 @@
#include "nsDOMJSUtils.h" #include "nsDOMJSUtils.h"
#include "WorkerPrivate.h" #include "WorkerPrivate.h"
#include "mozilla/ContentEvents.h" #include "mozilla/ContentEvents.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/HoldDropJSObjects.h" #include "mozilla/HoldDropJSObjects.h"
#include "mozilla/JSEventHandler.h" #include "mozilla/JSEventHandler.h"
#include "mozilla/Likely.h" #include "mozilla/Likely.h"
@ -155,7 +156,7 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent)
ThreadsafeAutoJSContext cx; ThreadsafeAutoJSContext cx;
error.Construct(cx); error.Construct(cx);
error.Value() = scriptEvent->Error(cx); scriptEvent->GetError(cx, &error.Value());
} else { } else {
msgOrEvent.SetAsEvent() = aEvent->InternalDOMEvent(); msgOrEvent.SetAsEvent() = aEvent->InternalDOMEvent();
} }
@ -210,8 +211,8 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent)
MOZ_ASSERT(mTypedHandler.Type() == TypedEventHandler::eNormal); MOZ_ASSERT(mTypedHandler.Type() == TypedEventHandler::eNormal);
ErrorResult rv; ErrorResult rv;
nsRefPtr<EventHandlerNonNull> handler = mTypedHandler.NormalEventHandler(); nsRefPtr<EventHandlerNonNull> handler = mTypedHandler.NormalEventHandler();
JS::Value retval = JS::Rooted<JS::Value> retval(CycleCollectedJSRuntime::Get()->Runtime());
handler->Call(mTarget, *(aEvent->InternalDOMEvent()), rv); handler->Call(mTarget, *(aEvent->InternalDOMEvent()), &retval, rv);
if (rv.Failed()) { if (rv.Failed()) {
return rv.ErrorCode(); return rv.ErrorCode();
} }

Просмотреть файл

@ -66,18 +66,19 @@ NS_IMETHODIMP
MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData) MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
{ {
ErrorResult rv; ErrorResult rv;
aData.set(GetData(aCx, rv)); GetData(aCx, aData, rv);
return rv.ErrorCode(); return rv.ErrorCode();
} }
JS::Value void
MessageEvent::GetData(JSContext* aCx, ErrorResult& aRv) MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
ErrorResult& aRv)
{ {
JS::Rooted<JS::Value> data(aCx, mData); JS::ExposeValueToActiveJS(mData);
if (!JS_WrapValue(aCx, &data)) { aData.set(mData);
if (!JS_WrapValue(aCx, aData)) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
} }
return data;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -46,7 +46,8 @@ public:
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
JS::Value GetData(JSContext* aCx, ErrorResult& aRv); void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
ErrorResult& aRv);
void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const; void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;

Просмотреть файл

@ -610,14 +610,16 @@ IDBCursor::GetSource(OwningIDBObjectStoreOrIDBIndex& aSource) const
} }
} }
JS::Value void
IDBCursor::GetKey(JSContext* aCx, ErrorResult& aRv) IDBCursor::GetKey(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mKey.IsUnset() || !mHaveValue); MOZ_ASSERT(!mKey.IsUnset() || !mHaveValue);
if (!mHaveValue) { if (!mHaveValue) {
return JSVAL_VOID; aResult.setUndefined();
return;
} }
if (!mHaveCachedKey) { if (!mHaveCachedKey) {
@ -627,21 +629,26 @@ IDBCursor::GetKey(JSContext* aCx, ErrorResult& aRv)
} }
aRv = mKey.ToJSVal(aCx, mCachedKey); aRv = mKey.ToJSVal(aCx, mCachedKey);
ENSURE_SUCCESS(aRv, JSVAL_VOID); if (NS_WARN_IF(aRv.Failed())) {
return;
}
mHaveCachedKey = true; mHaveCachedKey = true;
} }
return mCachedKey; JS::ExposeValueToActiveJS(mCachedKey);
aResult.set(mCachedKey);
} }
JS::Value void
IDBCursor::GetPrimaryKey(JSContext* aCx, ErrorResult& aRv) IDBCursor::GetPrimaryKey(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (!mHaveValue) { if (!mHaveValue) {
return JSVAL_VOID; aResult.setUndefined();
return;
} }
if (!mHaveCachedPrimaryKey) { if (!mHaveCachedPrimaryKey) {
@ -655,22 +662,27 @@ IDBCursor::GetPrimaryKey(JSContext* aCx, ErrorResult& aRv)
MOZ_ASSERT(!key.IsUnset()); MOZ_ASSERT(!key.IsUnset());
aRv = key.ToJSVal(aCx, mCachedPrimaryKey); aRv = key.ToJSVal(aCx, mCachedPrimaryKey);
ENSURE_SUCCESS(aRv, JSVAL_VOID); if (NS_WARN_IF(aRv.Failed())) {
return;
}
mHaveCachedPrimaryKey = true; mHaveCachedPrimaryKey = true;
} }
return mCachedPrimaryKey; JS::ExposeValueToActiveJS(mCachedPrimaryKey);
aResult.set(mCachedPrimaryKey);
} }
JS::Value void
IDBCursor::GetValue(JSContext* aCx, ErrorResult& aRv) IDBCursor::GetValue(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mType == OBJECTSTORE || mType == INDEXOBJECT); MOZ_ASSERT(mType == OBJECTSTORE || mType == INDEXOBJECT);
if (!mHaveValue) { if (!mHaveValue) {
return JSVAL_VOID; aResult.setUndefined();
return;
} }
if (!mHaveCachedValue) { if (!mHaveCachedValue) {
@ -682,7 +694,7 @@ IDBCursor::GetValue(JSContext* aCx, ErrorResult& aRv)
JS::Rooted<JS::Value> val(aCx); JS::Rooted<JS::Value> val(aCx);
if (!IDBObjectStore::DeserializeValue(aCx, mCloneReadInfo, &val)) { if (!IDBObjectStore::DeserializeValue(aCx, mCloneReadInfo, &val)) {
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
return JSVAL_VOID; return;
} }
mCloneReadInfo.mCloneBuffer.clear(); mCloneReadInfo.mCloneBuffer.clear();
@ -691,7 +703,8 @@ IDBCursor::GetValue(JSContext* aCx, ErrorResult& aRv)
mHaveCachedValue = true; mHaveCachedValue = true;
} }
return mCachedValue; JS::ExposeValueToActiveJS(mCachedValue);
aResult.set(mCachedValue);
} }
void void

Просмотреть файл

@ -184,11 +184,13 @@ public:
IDBCursorDirection IDBCursorDirection
GetDirection() const; GetDirection() const;
JS::Value void
GetKey(JSContext* aCx, ErrorResult& aRv); GetKey(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
JS::Value void
GetPrimaryKey(JSContext* aCx, ErrorResult& aRv); GetPrimaryKey(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
already_AddRefed<IDBRequest> already_AddRefed<IDBRequest>
Update(JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv); Update(JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv);
@ -202,8 +204,9 @@ public:
already_AddRefed<IDBRequest> already_AddRefed<IDBRequest>
Delete(JSContext* aCx, ErrorResult& aRv); Delete(JSContext* aCx, ErrorResult& aRv);
JS::Value void
GetValue(JSContext* aCx, ErrorResult& aRv); GetValue(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
protected: protected:
IDBCursor(); IDBCursor();

Просмотреть файл

@ -826,24 +826,30 @@ IDBIndex::WrapObject(JSContext* aCx)
return IDBIndexBinding::Wrap(aCx, this); return IDBIndexBinding::Wrap(aCx, this);
} }
JS::Value void
IDBIndex::GetKeyPath(JSContext* aCx, ErrorResult& aRv) IDBIndex::GetKeyPath(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv)
{ {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mCachedKeyPath.isUndefined()) { if (!mCachedKeyPath.isUndefined()) {
return mCachedKeyPath; JS::ExposeValueToActiveJS(mCachedKeyPath);
aResult.set(mCachedKeyPath);
return;
} }
aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath); aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
ENSURE_SUCCESS(aRv, JSVAL_VOID); if (NS_WARN_IF(aRv.Failed())) {
return;
}
if (mCachedKeyPath.isGCThing()) { if (mCachedKeyPath.isGCThing()) {
mozilla::HoldJSObjects(this); mozilla::HoldJSObjects(this);
mRooted = true; mRooted = true;
} }
return mCachedKeyPath; JS::ExposeValueToActiveJS(mCachedKeyPath);
aResult.set(mCachedKeyPath);
} }
already_AddRefed<IDBRequest> already_AddRefed<IDBRequest>

Просмотреть файл

@ -176,8 +176,9 @@ public:
return mObjectStore; return mObjectStore;
} }
JS::Value void
GetKeyPath(JSContext* aCx, ErrorResult& aRv); GetKeyPath(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
bool bool
MultiEntry() const MultiEntry() const

Просмотреть файл

@ -164,8 +164,9 @@ IDBKeyRange::WrapObject(JSContext* aCx)
return IDBKeyRangeBinding::Wrap(aCx, this); return IDBKeyRangeBinding::Wrap(aCx, this);
} }
JS::Value void
IDBKeyRange::GetLower(JSContext* aCx, ErrorResult& aRv) IDBKeyRange::GetLower(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv)
{ {
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
@ -177,17 +178,19 @@ IDBKeyRange::GetLower(JSContext* aCx, ErrorResult& aRv)
aRv = Lower().ToJSVal(aCx, mCachedLowerVal); aRv = Lower().ToJSVal(aCx, mCachedLowerVal);
if (aRv.Failed()) { if (aRv.Failed()) {
return JS::UndefinedValue(); return;
} }
mHaveCachedLowerVal = true; mHaveCachedLowerVal = true;
} }
return mCachedLowerVal; JS::ExposeValueToActiveJS(mCachedLowerVal);
aResult.set(mCachedLowerVal);
} }
JS::Value void
IDBKeyRange::GetUpper(JSContext* aCx, ErrorResult& aRv) IDBKeyRange::GetUpper(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv)
{ {
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
@ -199,13 +202,14 @@ IDBKeyRange::GetUpper(JSContext* aCx, ErrorResult& aRv)
aRv = Upper().ToJSVal(aCx, mCachedUpperVal); aRv = Upper().ToJSVal(aCx, mCachedUpperVal);
if (aRv.Failed()) { if (aRv.Failed()) {
return JS::UndefinedValue(); return;
} }
mHaveCachedUpperVal = true; mHaveCachedUpperVal = true;
} }
return mCachedUpperVal; JS::ExposeValueToActiveJS(mCachedUpperVal);
aResult.set(mCachedUpperVal);
} }
// static // static

Просмотреть файл

@ -156,11 +156,13 @@ public:
return mGlobal; return mGlobal;
} }
JS::Value void
GetLower(JSContext* aCx, ErrorResult& aRv); GetLower(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
JS::Value void
GetUpper(JSContext* aCx, ErrorResult& aRv); GetUpper(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
bool bool
LowerOpen() const LowerOpen() const

Просмотреть файл

@ -2622,24 +2622,30 @@ IDBObjectStore::WrapObject(JSContext* aCx)
return IDBObjectStoreBinding::Wrap(aCx, this); return IDBObjectStoreBinding::Wrap(aCx, this);
} }
JS::Value void
IDBObjectStore::GetKeyPath(JSContext* aCx, ErrorResult& aRv) IDBObjectStore::GetKeyPath(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv)
{ {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mCachedKeyPath.isUndefined()) { if (!mCachedKeyPath.isUndefined()) {
return mCachedKeyPath; JS::ExposeValueToActiveJS(mCachedKeyPath);
aResult.set(mCachedKeyPath);
return;
} }
aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath); aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
ENSURE_SUCCESS(aRv, JSVAL_VOID); if (NS_WARN_IF(aRv.Failed())) {
return;
}
if (mCachedKeyPath.isGCThing()) { if (mCachedKeyPath.isGCThing()) {
mozilla::HoldJSObjects(this); mozilla::HoldJSObjects(this);
mRooted = true; mRooted = true;
} }
return mCachedKeyPath; JS::ExposeValueToActiveJS(mCachedKeyPath);
aResult.set(mCachedKeyPath);
} }
already_AddRefed<DOMStringList> already_AddRefed<DOMStringList>

Просмотреть файл

@ -282,8 +282,9 @@ public:
aName.Assign(mName); aName.Assign(mName);
} }
JS::Value void
GetKeyPath(JSContext* aCx, ErrorResult& aRv); GetKeyPath(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
already_AddRefed<DOMStringList> already_AddRefed<DOMStringList>
GetIndexNames(ErrorResult& aRv); GetIndexNames(ErrorResult& aRv);

Просмотреть файл

@ -326,8 +326,9 @@ IDBRequest::WrapObject(JSContext* aCx)
return IDBRequestBinding::Wrap(aCx, this); return IDBRequestBinding::Wrap(aCx, this);
} }
JS::Value void
IDBRequest::GetResult(mozilla::ErrorResult& aRv) const IDBRequest::GetResult(JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv) const
{ {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -336,7 +337,8 @@ IDBRequest::GetResult(mozilla::ErrorResult& aRv) const
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
} }
return mResultVal; JS::ExposeValueToActiveJS(mResultVal);
aResult.set(mResultVal);
} }
mozilla::dom::DOMError* mozilla::dom::DOMError*

Просмотреть файл

@ -131,13 +131,14 @@ public:
return GetOwner(); return GetOwner();
} }
JS::Value void
GetResult(ErrorResult& aRv) const; GetResult(JS::MutableHandle<JS::Value> aResult, ErrorResult& aRv) const;
JS::Value void
GetResult(JSContext* aCx, ErrorResult& aRv) const GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv) const
{ {
return GetResult(aRv); GetResult(aResult, aRv);
} }
IDBTransaction* IDBTransaction*

Просмотреть файл

@ -408,7 +408,8 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
AutoSafeJSContext cx; AutoSafeJSContext cx;
ErrorResult error; ErrorResult error;
JS::Rooted<JS::Value> result(cx, mOpenRequest->GetResult(cx, error)); JS::Rooted<JS::Value> result(cx);
mOpenRequest->GetResult(cx, &result, error);
ENSURE_SUCCESS(error, error.ErrorCode()); ENSURE_SUCCESS(error, error.ErrorCode());
MOZ_ASSERT(!result.isPrimitive()); MOZ_ASSERT(!result.isPrimitive());

Просмотреть файл

@ -219,8 +219,8 @@ WrapperPromiseCallback::Call(JSContext* aCx,
// If invoking callback threw an exception, run resolver's reject with the // If invoking callback threw an exception, run resolver's reject with the
// thrown exception as argument and the synchronous flag set. // thrown exception as argument and the synchronous flag set.
JS::Rooted<JS::Value> retValue(aCx, JS::Rooted<JS::Value> retValue(aCx);
mCallback->Call(value, rv, CallbackObject::eRethrowExceptions)); mCallback->Call(value, &retValue, rv, CallbackObject::eRethrowExceptions);
rv.WouldReportJSException(); rv.WouldReportJSException();

Просмотреть файл

@ -2317,8 +2317,10 @@ XMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aResponseType,
mResponseType = ConvertStringToResponseType(acceptedResponseTypeString); mResponseType = ConvertStringToResponseType(acceptedResponseTypeString);
} }
jsval void
XMLHttpRequest::GetResponse(JSContext* /* unused */, ErrorResult& aRv) XMLHttpRequest::GetResponse(JSContext* /* unused */,
JS::MutableHandle<JS::Value> aResponse,
ErrorResult& aRv)
{ {
if (NS_SUCCEEDED(mStateData.mResponseTextResult) && if (NS_SUCCEEDED(mStateData.mResponseTextResult) &&
mStateData.mResponse.isUndefined()) { mStateData.mResponse.isUndefined()) {
@ -2331,14 +2333,15 @@ XMLHttpRequest::GetResponse(JSContext* /* unused */, ErrorResult& aRv)
mStateData.mResponseText.Length()); mStateData.mResponseText.Length());
if (!str) { if (!str) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY); aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return JSVAL_VOID; return;
} }
mStateData.mResponse = STRING_TO_JSVAL(str); mStateData.mResponse = STRING_TO_JSVAL(str);
} }
JS::ExposeValueToActiveJS(mStateData.mResponse);
aRv = mStateData.mResponseResult; aRv = mStateData.mResponseResult;
return mStateData.mResponse; aResponse.set(mStateData.mResponse);
} }
void void

Просмотреть файл

@ -213,8 +213,9 @@ public:
void void
SetResponseType(XMLHttpRequestResponseType aResponseType, ErrorResult& aRv); SetResponseType(XMLHttpRequestResponseType aResponseType, ErrorResult& aRv);
jsval void
GetResponse(JSContext* /* unused */, ErrorResult& aRv); GetResponse(JSContext* /* unused */, JS::MutableHandle<JS::Value> aResponse,
ErrorResult& aRv);
void void
GetResponseText(nsAString& aResponseText, ErrorResult& aRv); GetResponseText(nsAString& aResponseText, ErrorResult& aRv);
@ -231,11 +232,11 @@ public:
return nullptr; return nullptr;
} }
JS::Value void
GetInterface(JSContext* cx, JS::Handle<JSObject*> aIID, ErrorResult& aRv) GetInterface(JSContext* cx, JS::Handle<JSObject*> aIID,
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv)
{ {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return JSVAL_NULL;
} }
XMLHttpRequestUpload* XMLHttpRequestUpload*

Просмотреть файл

@ -183,7 +183,7 @@ def print_class_declaration(eventname, iface, fd, conf):
if a.realtype.nativeType('in').count("nsAString"): if a.realtype.nativeType('in').count("nsAString"):
continue continue
elif a.realtype.nativeType('in').count("nsIVariant"): elif a.realtype.nativeType('in').count("nsIVariant"):
fd.write(" JS::Value Get%s(JSContext* aCx, ErrorResult& aRv);\n\n" % firstCapName); fd.write(" void Get%s(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv);\n\n" % firstCapName);
elif a.realtype.nativeType('in').endswith('*'): elif a.realtype.nativeType('in').endswith('*'):
fd.write(" already_AddRefed<%s> Get%s()\n" % (xpidl_to_native(cleanNativeType, conf), firstCapName)) fd.write(" already_AddRefed<%s> Get%s()\n" % (xpidl_to_native(cleanNativeType, conf), firstCapName))
fd.write(" {\n"); fd.write(" {\n");
@ -305,15 +305,15 @@ def writeAttributeGetter(fd, classname, a):
fd.write(" return NS_OK;\n"); fd.write(" return NS_OK;\n");
fd.write("}\n\n"); fd.write("}\n\n");
if a.realtype.nativeType('in').count("nsIVariant"): if a.realtype.nativeType('in').count("nsIVariant"):
fd.write("JS::Value\n") fd.write("void\n")
fd.write("%s::Get%s(JSContext* aCx, ErrorResult& aRv)\n" % (classname, firstCap(a.name))) fd.write("%s::Get%s(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv)\n" % (classname, firstCap(a.name)))
fd.write("{\n") fd.write("{\n")
fd.write(" JS::Rooted<JS::Value> retVal(aCx, JS::NullValue());\n");
fd.write(" nsresult rv = NS_ERROR_UNEXPECTED;\n") fd.write(" nsresult rv = NS_ERROR_UNEXPECTED;\n")
fd.write(" if (m%s && !XPCVariant::VariantDataToJS(m%s, &rv, &retVal)) {\n" % (firstCap(a.name), firstCap(a.name))) fd.write(" if (!m%s) {\n" % firstCap(a.name))
fd.write(" aRetval.setNull();\n")
fd.write(" } else if (!XPCVariant::VariantDataToJS(m%s, &rv, aRetval)) {\n" % (firstCap(a.name)))
fd.write(" aRv.Throw(NS_ERROR_FAILURE);\n") fd.write(" aRv.Throw(NS_ERROR_FAILURE);\n")
fd.write(" }\n") fd.write(" }\n")
fd.write(" return retVal;\n");
fd.write("}\n\n") fd.write("}\n\n")
def writeAttributeParams(fd, a): def writeAttributeParams(fd, a):