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,11 +1617,13 @@ public:
// HasAttributes is defined inline in Element.h.
bool HasAttributes() const;
nsDOMAttributeMap* GetAttributes();
JS::Value SetUserData(JSContext* aCx, const nsAString& aKey,
void SetUserData(JSContext* aCx, const nsAString& aKey,
JS::Handle<JS::Value> aData,
nsIDOMUserDataHandler* aHandler,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
JS::Value GetUserData(JSContext* aCx, const nsAString& aKey,
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

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

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

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

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

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

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

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

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

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

@ -214,8 +214,9 @@ class nsObjectLoadingContent : public nsImageLoadingContent
{
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,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aRv);
protected:

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

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

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

@ -494,7 +494,8 @@ public:
return XMLHttpRequestResponseType(mResponseType);
}
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);
nsIDocument* GetResponseXML(ErrorResult& aRv);
@ -510,7 +511,8 @@ public:
}
// 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
// doesn't bubble.

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

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

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

@ -400,7 +400,8 @@ public:
mozilla::ErrorResult& error);
void GetFillRule(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,
mozilla::ErrorResult& error);

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

@ -151,18 +151,20 @@ JSValToDashArray(JSContext* cx, const JS::Value& patternArray,
}
template<typename T>
JS::Value
void
DashArrayToJSVal(FallibleTArray<T>& dashes,
JSContext* cx, mozilla::ErrorResult& rv)
JSContext* cx,
JS::MutableHandle<JS::Value> retval,
mozilla::ErrorResult& rv)
{
if (dashes.IsEmpty()) {
return JS::NullValue();
retval.setNull();
return;
}
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);
}
return val;
}
}

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

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

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

@ -454,11 +454,14 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
return JS::NullValue();
}
JS::Value
WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
void
WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index,
JS::MutableHandle<JS::Value> retval)
{
if (IsContextLost())
return JS::NullValue();
if (IsContextLost()) {
retval.setNull();
return;
}
MakeContextCurrent();
@ -467,9 +470,11 @@ WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
{
if (index >= mGLMaxTransformFeedbackSeparateAttribs) {
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:
@ -477,7 +482,7 @@ WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
}
ErrorInvalidEnumInfo("getParameterIndexed: parameter", pname);
return JS::NullValue();
retval.setNull();
}
bool

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

@ -426,7 +426,8 @@ PropertyNodeList::GetValues(JSContext* aCx, nsTArray<JS::Value >& aResult,
JSAutoCompartment ac(aCx, wrapper);
uint32_t length = mElements.Length();
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()) {
return;
}

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

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

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

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

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

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

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

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

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

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

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

@ -837,7 +837,8 @@ public:
protected:
nsIDOMWindow* GetOpenerWindow(mozilla::ErrorResult& aError);
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,
mozilla::ErrorResult& aError);
using nsIDOMWindow::GetParent;
@ -867,7 +868,11 @@ public:
void Prompt(const nsAString& aMessage, const nsAString& aInitial,
nsAString& aReturn, 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,
const nsAString& aTargetOrigin,
const mozilla::dom::Optional<mozilla::dom::Sequence<JS::Value > >& aTransfer,
@ -1017,12 +1022,15 @@ public:
mozilla::dom::Element* aPanel,
mozilla::ErrorResult& aError);
JS::Value GetDialogArguments(JSContext* aCx, mozilla::ErrorResult& aError);
JS::Value GetReturnValue(JSContext* aCx, mozilla::ErrorResult& aError);
void GetDialogArguments(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
void GetReturnValue(JSContext* aCx, JS::MutableHandle<JS::Value> aReturnValue,
mozilla::ErrorResult& aError);
void SetReturnValue(JSContext* aCx, JS::Handle<JS::Value> aReturnValue,
mozilla::ErrorResult& aError);
JS::Value GetInterface(JSContext* aCx, nsIJSID* aIID,
void GetInterface(JSContext* aCx, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
protected:

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

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

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

@ -37,7 +37,8 @@ public:
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
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 Back(mozilla::ErrorResult& aRv);
void Forward(mozilla::ErrorResult& aRv);

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

@ -884,25 +884,22 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
return true;
}
JS::Value
void
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();
nsRefPtr<nsISupports> result;
aError = aRequestor->GetInterface(*iid, getter_AddRefs(result));
if (aError.Failed()) {
return JS::NullValue();
return;
}
JS::Rooted<JS::Value> v(aCx, JSVAL_NULL);
if (!WrapObject(aCx, result, iid, &v)) {
if (!WrapObject(aCx, result, iid, aRetval)) {
aError.Throw(NS_ERROR_FAILURE);
return JS::NullValue();
}
return v;
}
bool

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

@ -1649,15 +1649,17 @@ WantsQueryInterface
}
};
JS::Value
void
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>
JS::Value
GetInterface(JSContext* aCx, T* aThis, nsIJSID* aIID, ErrorResult& aError)
void
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -71,7 +71,7 @@ public:
double MinExposureCompensation() const;
double MaxExposureCompensation() 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;
protected:

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

@ -129,7 +129,8 @@ DataStoreDB::UpgradeSchema()
AutoSafeJSContext cx;
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())) {
return error.ErrorCode();
}
@ -190,7 +191,8 @@ DataStoreDB::DatabaseOpened()
AutoSafeJSContext cx;
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())) {
return error.ErrorCode();
}

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

@ -587,7 +587,8 @@ public:
AutoSafeJSContext cx;
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())) {
return error.ErrorCode();
}

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

@ -640,27 +640,27 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
return NS_OK;
}
JS::Value
void
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;
aRv = MozGetDataAt(aFormat, aIndex, getter_AddRefs(data));
if (aRv.Failed()) {
return JS::UndefinedValue();
return;
}
if (!data) {
return JS::NullValue();
return;
}
JS::Rooted<JS::Value> result(aCx);
if (!VariantToJsval(aCx, data, &result)) {
if (!VariantToJsval(aCx, data, aRetval)) {
aRv = NS_ERROR_FAILURE;
return JS::UndefinedValue();
return;
}
return result;
}
NS_IMETHODIMP

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

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

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

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

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

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

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

@ -46,7 +46,8 @@ public:
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;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -326,8 +326,9 @@ IDBRequest::WrapObject(JSContext* aCx)
return IDBRequestBinding::Wrap(aCx, this);
}
JS::Value
IDBRequest::GetResult(mozilla::ErrorResult& aRv) const
void
IDBRequest::GetResult(JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv) const
{
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);
}
return mResultVal;
JS::ExposeValueToActiveJS(mResultVal);
aResult.set(mResultVal);
}
mozilla::dom::DOMError*

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

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

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

@ -408,7 +408,8 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
AutoSafeJSContext cx;
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());
MOZ_ASSERT(!result.isPrimitive());

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

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

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

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

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

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

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

@ -183,7 +183,7 @@ def print_class_declaration(eventname, iface, fd, conf):
if a.realtype.nativeType('in').count("nsAString"):
continue
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('*'):
fd.write(" already_AddRefed<%s> Get%s()\n" % (xpidl_to_native(cleanNativeType, conf), firstCapName))
fd.write(" {\n");
@ -305,15 +305,15 @@ def writeAttributeGetter(fd, classname, a):
fd.write(" return NS_OK;\n");
fd.write("}\n\n");
if a.realtype.nativeType('in').count("nsIVariant"):
fd.write("JS::Value\n")
fd.write("%s::Get%s(JSContext* aCx, ErrorResult& aRv)\n" % (classname, firstCap(a.name)))
fd.write("void\n")
fd.write("%s::Get%s(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv)\n" % (classname, firstCap(a.name)))
fd.write("{\n")
fd.write(" JS::Rooted<JS::Value> retVal(aCx, JS::NullValue());\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(" }\n")
fd.write(" return retVal;\n");
fd.write("}\n\n")
def writeAttributeParams(fd, a):