From 43f774459de3d0bfa0e07f9b0e7260ec72c9d273 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 17 May 2013 21:48:25 -0400 Subject: [PATCH] Bug 868312 finale: finish rooting dom/ code. r=smaug --- content/base/src/nsDocument.cpp | 3 +- dom/base/DOMCursor.cpp | 2 +- dom/base/DOMRequest.cpp | 7 +- dom/base/DOMRequest.h | 2 +- dom/bindings/BindingUtils.h | 55 ++++----- dom/bindings/CallbackFunction.h | 2 +- dom/bindings/Codegen.py | 107 ++++++++++-------- dom/camera/DOMCameraControl.cpp | 18 +-- dom/camera/nsIDOMCameraManager.idl | 41 ------- .../DeviceStorageRequestChild.cpp | 19 +++- dom/devicestorage/nsDeviceStorage.cpp | 45 +++++--- .../test/test_enumerateOptions.html | 4 +- dom/indexedDB/IDBDatabase.cpp | 41 +++---- dom/indexedDB/nsIIDBDatabase.idl | 6 - .../devicestorage/nsIDOMDeviceStorage.idl | 5 - .../interfaces/nsIDOMMobileMessageManager.idl | 8 -- .../interfaces/nsIDOMMozMmsMessage.idl | 1 + .../src/MobileMessageCallback.cpp | 13 ++- dom/mobilemessage/src/MobileMessageCallback.h | 2 +- dom/mobilemessage/src/ipc/SmsIPCService.cpp | 69 +++-------- dom/webidl/CameraManager.webidl | 48 ++++++++ dom/webidl/DeviceStorage.webidl | 12 ++ dom/webidl/DummyBinding.webidl | 5 + dom/webidl/IDBDatabase.webidl | 14 +++ dom/webidl/MobileMessageManager.webidl | 14 +++ dom/webidl/MozMmsMessage.webidl | 14 +++ dom/webidl/WebIDL.mk | 5 + dom/workers/EventListenerManager.cpp | 4 +- dom/workers/EventListenerManager.h | 20 ++-- dom/workers/EventTarget.cpp | 16 +-- dom/workers/EventTarget.h | 6 +- dom/workers/WorkerScope.cpp | 8 +- dom/workers/XMLHttpRequest.cpp | 2 + dom/workers/XMLHttpRequest.h | 3 +- dom/workers/XMLHttpRequestEventTarget.h | 3 +- js/xpconnect/src/dictionary_helper_gen.conf | 6 +- 36 files changed, 338 insertions(+), 292 deletions(-) create mode 100644 dom/webidl/CameraManager.webidl create mode 100644 dom/webidl/DeviceStorage.webidl create mode 100644 dom/webidl/IDBDatabase.webidl create mode 100644 dom/webidl/MobileMessageManager.webidl create mode 100644 dom/webidl/MozMmsMessage.webidl diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 9e55a8c3524d..0c27d8733881 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -5076,8 +5076,7 @@ nsDocument::Register(const nsAString& aName, const JS::Value& aOptions, JSContext* aCx, uint8_t aOptionalArgc, jsval* aConstructor /* out param */) { - ElementRegistrationOptions options; - DictionaryRooter optionsRooter(aCx, &options); + RootedDictionary options(aCx); if (aOptionalArgc > 0) { JSAutoCompartment ac(aCx, GetWrapper()); JS::Rooted opts(aCx, aOptions); diff --git a/dom/base/DOMCursor.cpp b/dom/base/DOMCursor.cpp index ee4ba744a6e8..3af725c4a958 100644 --- a/dom/base/DOMCursor.cpp +++ b/dom/base/DOMCursor.cpp @@ -55,7 +55,7 @@ DOMCursor::FireDone() { Reset(); mFinished = true; - FireSuccess(JSVAL_VOID); + FireSuccess(JS::UndefinedHandleValue); } NS_IMETHODIMP diff --git a/dom/base/DOMRequest.cpp b/dom/base/DOMRequest.cpp index 7251b375f8a7..f38ad4077497 100644 --- a/dom/base/DOMRequest.cpp +++ b/dom/base/DOMRequest.cpp @@ -115,7 +115,7 @@ DOMRequest::GetError(nsIDOMDOMError** aError) } void -DOMRequest::FireSuccess(JS::Value aResult) +DOMRequest::FireSuccess(JS::Handle aResult) { NS_ASSERTION(!mDone, "mDone shouldn't have been set to true already!"); NS_ASSERTION(!mError, "mError shouldn't have been set!"); @@ -222,7 +222,8 @@ DOMRequestService::FireSuccess(nsIDOMDOMRequest* aRequest, const JS::Value& aResult) { NS_ENSURE_STATE(aRequest); - static_cast(aRequest)->FireSuccess(aResult); + static_cast(aRequest)-> + FireSuccess(JS::Handle::fromMarkedLocation(&aResult)); return NS_OK; } @@ -289,7 +290,7 @@ public: NS_IMETHODIMP Run() { - mReq->FireSuccess(mResult); + mReq->FireSuccess(JS::Handle::fromMarkedLocation(&mResult)); return NS_OK; } diff --git a/dom/base/DOMRequest.h b/dom/base/DOMRequest.h index 97e96875f500..a4758c2cdbc5 100644 --- a/dom/base/DOMRequest.h +++ b/dom/base/DOMRequest.h @@ -69,7 +69,7 @@ public: IMPL_EVENT_HANDLER(error) - void FireSuccess(JS::Value aResult); + void FireSuccess(JS::Handle aResult); void FireError(const nsAString& aError); void FireError(nsresult aError); diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index 2a3178ce5f74..57ee39643859 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -1759,48 +1759,39 @@ public: }; template -class MOZ_STACK_CLASS DictionaryRooter : JS::CustomAutoRooter +class MOZ_STACK_CLASS RootedDictionary : public T, + private JS::CustomAutoRooter { public: - DictionaryRooter(JSContext *aCx, T* aDictionary - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT), - mDictionary(aDictionary), - mDictionaryType(eDictionary) + RootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : + T(), + JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) { } - DictionaryRooter(JSContext *aCx, Nullable* aDictionary - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT), - mNullableDictionary(aDictionary), - mDictionaryType(eNullableDictionary) + virtual void trace(JSTracer *trc) MOZ_OVERRIDE + { + this->TraceDictionary(trc); + } +}; + +template +class MOZ_STACK_CLASS NullableRootedDictionary : public Nullable, + private JS::CustomAutoRooter +{ +public: + NullableRootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : + Nullable(), + JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) { } -private: - enum DictionaryType { - eDictionary, - eNullableDictionary - }; - - virtual void trace(JSTracer *trc) MOZ_OVERRIDE { - if (mDictionaryType == eDictionary) { - mDictionary->TraceDictionary(trc); - } else { - MOZ_ASSERT(mDictionaryType == eNullableDictionary); - if (!mNullableDictionary->IsNull()) { - mNullableDictionary->Value().TraceDictionary(trc); - } + virtual void trace(JSTracer *trc) MOZ_OVERRIDE + { + if (!this->IsNull()) { + this->Value().TraceDictionary(trc); } } - - union { - T* mDictionary; - Nullable* mNullableDictionary; - }; - - DictionaryType mDictionaryType; }; inline bool diff --git a/dom/bindings/CallbackFunction.h b/dom/bindings/CallbackFunction.h index 3437d700137f..0ad0892bcc58 100644 --- a/dom/bindings/CallbackFunction.h +++ b/dom/bindings/CallbackFunction.h @@ -28,7 +28,7 @@ public: explicit CallbackFunction(JSObject* aCallable) : CallbackObject(aCallable) { - MOZ_ASSERT(JS_ObjectIsCallable(nullptr, aCallable)); + MOZ_ASSERT(JS_ObjectIsCallable(nullptr, mCallback)); } JS::Handle Callable() const diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index bf1525ea3a31..4fd1fdc331c2 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -2964,6 +2964,11 @@ for (uint32_t i = 0; i < length; ++i) { descriptor = descriptorProvider.getDescriptor( type.unroll().inner.identifier.name) + if descriptor.nativeType == 'JSObject': + # XXXbz Workers code does this sometimes + assert descriptor.workers + return handleJSObjectType(type, isMember, failureCode) + if (descriptor.interface.isCallback() and descriptor.interface.identifier.name != "EventListener"): if descriptor.workers: @@ -3288,11 +3293,9 @@ for (uint32_t i = 0; i < length; ++i) { raise NoSuchDescriptorError("Can't handle member callbacks in " "workers; need to sort out rooting" "issues") - if type.nullable(): - declType = CGGeneric("JSObject*") - else: - declType = CGGeneric("NonNull") - conversion = " ${declName} = &${val}.toObject();\n" + declType = CGGeneric("JS::Rooted") + conversion = " ${declName} = &${valHandle}.toObject();\n" + declArgs = "cx" else: name = type.unroll().identifier.name if type.nullable(): @@ -3301,6 +3304,7 @@ for (uint32_t i = 0; i < length; ++i) { declType = CGGeneric("OwningNonNull<%s>" % name) conversion = ( " ${declName} = new %s(&${val}.toObject());\n" % name) + declArgs = None if allowTreatNonCallableAsNull and type.treatNonCallableAsNull(): haveCallable = "JS_ObjectIsCallable(cx, &${val}.toObject())" @@ -3326,7 +3330,8 @@ for (uint32_t i = 0; i < length; ++i) { "${declName} = nullptr", failureCode) return JSToNativeConversionInfo(template, declType=declType, - dealWithOptional=isOptional) + dealWithOptional=isOptional, + declArgs=declArgs) if type.isAny(): assert not isEnforceRange and not isClamp @@ -3405,15 +3410,13 @@ for (uint32_t i = 0; i < length; ++i) { # Dictionary arguments that might contain traceable things need to get # traced if not isMember and typeNeedsCx(type, descriptorProvider): - holderType = CGTemplatedType("DictionaryRooter", declType); - holderArgs = "cx, &${declName}" + declType = CGTemplatedType("RootedDictionary", declType); + declArgs = "cx" else: - holderType = None - holderArgs = None + declArgs = None return JSToNativeConversionInfo(template, declType=declType, - holderType=holderType, - holderArgs=holderArgs) + declArgs=declArgs) if type.isVoid(): assert not isOptional @@ -4113,7 +4116,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider, resultAlreadyAddRefed, isMember=False): """ - Returns a tuple containing three things: + Returns a tuple containing four things: 1) A CGThing for the type of the return value, or None if there is no need for a return value. @@ -4123,24 +4126,27 @@ def getRetvalDeclarationForType(returnType, descriptorProvider, 3) A CGThing for a tracer for the return value, or None if no tracing is needed. + + 4) An argument string to pass to the retval declaration + constructor or None if there are no arguments. """ if returnType is None or returnType.isVoid(): # Nothing to declare - return None, False, None + return None, False, None, None if returnType.isPrimitive() and returnType.tag() in builtinNames: result = CGGeneric(builtinNames[returnType.tag()]) if returnType.nullable(): result = CGTemplatedType("Nullable", result) - return result, False, None + return result, False, None, None if returnType.isString(): if isMember: - return CGGeneric("nsString"), True, None - return CGGeneric("DOMString"), True, None + return CGGeneric("nsString"), True, None, None + return CGGeneric("DOMString"), True, None, None if returnType.isEnum(): result = CGGeneric(returnType.unroll().inner.identifier.name) if returnType.nullable(): result = CGTemplatedType("Nullable", result) - return result, False, None + return result, False, None, None if returnType.isGeckoInterface(): result = CGGeneric(descriptorProvider.getDescriptor( returnType.unroll().inner.identifier.name).nativeType) @@ -4151,26 +4157,26 @@ def getRetvalDeclarationForType(returnType, descriptorProvider, result = CGTemplatedType("nsAutoPtr", result) else: result = CGWrapper(result, post="*") - return result, False, None + return result, False, None, None if returnType.isCallback(): name = returnType.unroll().identifier.name if descriptorProvider.workers: - return CGGeneric("JSObject*"), False, None - return CGGeneric("nsRefPtr<%s>" % name), False, None + return CGGeneric("JSObject*"), False, None, None + return CGGeneric("nsRefPtr<%s>" % name), False, None, None if returnType.isAny(): - return CGGeneric("JS::Value"), False, None + return CGGeneric("JS::Value"), False, None, None if returnType.isObject() or returnType.isSpiderMonkeyInterface(): - return CGGeneric("JSObject*"), False, None + return CGGeneric("JSObject*"), False, None, None if returnType.isSequence(): nullable = returnType.nullable() if nullable: returnType = returnType.inner # If our result is already addrefed, use the right type in the # sequence argument here. - (result, _, _) = getRetvalDeclarationForType(returnType.inner, - descriptorProvider, - resultAlreadyAddRefed, - isMember="Sequence") + (result, _, _, _) = getRetvalDeclarationForType(returnType.inner, + descriptorProvider, + resultAlreadyAddRefed, + isMember="Sequence") # While we have our inner type, set up our rooter, if needed if not isMember and typeNeedsCx(returnType, descriptorProvider): rooter = CGGeneric("SequenceRooter<%s > resultRooter(cx, &result);" % @@ -4180,7 +4186,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider, result = CGTemplatedType("nsTArray", result) if nullable: result = CGTemplatedType("Nullable", result) - return result, True, rooter + return result, True, rooter, None if returnType.isDictionary(): nullable = returnType.nullable() dictName = (CGDictionary.makeDictionaryName(returnType.unroll().inner, @@ -4188,20 +4194,22 @@ def getRetvalDeclarationForType(returnType, descriptorProvider, "Initializer") result = CGGeneric(dictName) if not isMember and typeNeedsCx(returnType, descriptorProvider): - rooter = CGGeneric("DictionaryRooter<%s> resultRooter(cx, &result);\n" % - dictName) - else: - rooter = None - if nullable: + if nullable: + result = CGTemplatedType("NullableRootedDictionary", result) + else: + result = CGTemplatedType("RootedDictionary", result) + resultArgs = "cx" + elif nullable: result = CGTemplatedType("Nullable", result) - return result, True, rooter + resultArgs = None + return result, True, None, resultArgs if returnType.isUnion(): raise TypeError("Need to sort out ownership model for union retvals"); if returnType.isDate(): result = CGGeneric("Date") if returnType.nullable(): result = CGTemplatedType("Nullable", result) - return result, False, None + return result, False, None, None raise TypeError("Don't know how to declare return value for %s" % returnType) @@ -4235,7 +4243,8 @@ class CGCallGenerator(CGThing): resultAlreadyAddRefed = isResultAlreadyAddRefed(descriptorProvider, extendedAttributes) - (result, resultOutParam, resultRooter) = getRetvalDeclarationForType( + (result, resultOutParam, + resultRooter, resultArgs) = getRetvalDeclarationForType( returnType, descriptorProvider, resultAlreadyAddRefed) args = CGList([CGGeneric(arg) for arg in argsPre], ", ") @@ -4284,7 +4293,11 @@ class CGCallGenerator(CGThing): if result is not None: if resultRooter is not None: self.cgRoot.prepend(resultRooter) - result = CGWrapper(result, post=" result;") + if resultArgs is not None: + resultArgs = "(%s)" % resultArgs + else: + resultArgs = "" + result = CGWrapper(result, post=(" result%s;" % resultArgs)) self.cgRoot.prepend(result) if not resultOutParam: call = CGWrapper(call, pre="result = ") @@ -5206,9 +5219,9 @@ class CGSpecializedGetter(CGAbstractStaticMethod): name = attr.identifier.name nativeName = MakeNativeName(descriptor.binaryNames.get(name, name)) # resultOutParam does not depend on whether resultAlreadyAddRefed is set - (_, resultOutParam, _) = getRetvalDeclarationForType(attr.type, - descriptor, - False) + (_, resultOutParam, _, _) = getRetvalDeclarationForType(attr.type, + descriptor, + False) infallible = ('infallible' in descriptor.getExtendedAttributes(attr, getter=True)) if resultOutParam or attr.type.nullable() or not infallible: @@ -7996,7 +8009,7 @@ class CGForwardDeclarations(CGWrapper): Code generate the forward declarations for a header file. """ def __init__(self, config, descriptors, mainCallbacks, workerCallbacks, - callbackInterfaces): + mainDictionaries, workerDictionaries, callbackInterfaces): builder = ForwardDeclarationBuilder() def forwardDeclareForType(t, workerness='both'): @@ -8047,10 +8060,13 @@ class CGForwardDeclarations(CGWrapper): for t in getTypesFromDescriptor(d): forwardDeclareForType(t) - # Dictionaries add a header for each type they contain, so no - # need for forward declarations. However, they may refer to - # declarations made later in this file, which is why we - # forward declare everything that is declared in this file. + for d in mainDictionaries: + for t in getTypesFromDictionary(d): + forwardDeclareForType(t, workerness='mainthreadonly') + + for d in workerDictionaries: + for t in getTypesFromDictionary(d): + forwardDeclareForType(t, workerness='workeronly') CGWrapper.__init__(self, builder.build()) @@ -8162,6 +8178,7 @@ class CGBindingRoot(CGThing): curr = CGList([CGForwardDeclarations(config, descriptors, mainCallbacks, workerCallbacks, + mainDictionaries, workerDictionaries, callbackDescriptors + jsImplemented), CGWrapper(CGGeneric("using namespace mozilla::dom;"), defineOnly=True), diff --git a/dom/camera/DOMCameraControl.cpp b/dom/camera/DOMCameraControl.cpp index 8c1efd867247..fb423979bbcb 100644 --- a/dom/camera/DOMCameraControl.cpp +++ b/dom/camera/DOMCameraControl.cpp @@ -17,9 +17,11 @@ #include "DOMCameraCapabilities.h" #include "DOMCameraControl.h" #include "CameraCommon.h" +#include "mozilla/dom/CameraManagerBinding.h" +#include "mozilla/dom/BindingUtils.h" using namespace mozilla; -using namespace dom; +using namespace mozilla::dom; DOMCI_DATA(CameraControl, nsICameraControl) @@ -350,14 +352,16 @@ nsDOMCameraControl::TakePicture(const JS::Value& aOptions, nsICameraTakePictureC { NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG); - mozilla::idl::CameraPictureOptions options; + RootedDictionary options(cx); mozilla::idl::CameraSize size; mozilla::idl::CameraPosition pos; - nsresult rv = options.Init(cx, &aOptions); - NS_ENSURE_SUCCESS(rv, rv); + JS::Rooted optionVal(cx, aOptions); + if (!options.Init(cx, optionVal)) { + return NS_ERROR_FAILURE; + } - rv = size.Init(cx, &options.pictureSize); + nsresult rv = size.Init(cx, &options.mPictureSize); NS_ENSURE_SUCCESS(rv, rv); /** @@ -368,10 +372,10 @@ nsDOMCameraControl::TakePicture(const JS::Value& aOptions, nsICameraTakePictureC pos.longitude = NAN; pos.altitude = NAN; pos.timestamp = NAN; - rv = pos.Init(cx, &options.position); + rv = pos.Init(cx, &options.mPosition); NS_ENSURE_SUCCESS(rv, rv); - return mCameraControl->TakePicture(size, options.rotation, options.fileFormat, pos, options.dateTime, onSuccess, onError); + return mCameraControl->TakePicture(size, options.mRotation, options.mFileFormat, pos, options.mDateTime, onSuccess, onError); } /* [implicit_jscontext] void GetPreviewStreamVideoMode (in jsval aOptions, in nsICameraPreviewStreamCallback onSuccess, [optional] in nsICameraErrorCallback onError); */ diff --git a/dom/camera/nsIDOMCameraManager.idl b/dom/camera/nsIDOMCameraManager.idl index cb5d4ef5adb1..6425639929c2 100644 --- a/dom/camera/nsIDOMCameraManager.idl +++ b/dom/camera/nsIDOMCameraManager.idl @@ -115,47 +115,6 @@ interface nsICameraCapabilities : nsISupports readonly attribute jsval recorderProfiles; }; -/* These properties only affect the captured image; - invalid property settings are ignored. */ -dictionary CameraPictureOptions -{ - /* an object with a combination of 'height' and 'width' properties - chosen from nsICameraCapabilities.pictureSizes */ - jsval pictureSize; - - /* one of the file formats chosen from - nsICameraCapabilities.fileFormats */ - DOMString fileFormat; - - /* the rotation of the image in degrees, from 0 to 270 in - steps of 90; this doesn't affect the image, only the - rotation recorded in the image header.*/ - long rotation; - - /* an object containing any or all of 'latitude', 'longitude', - 'altitude', and 'timestamp', used to record when and where - the image was taken. e.g. - { - latitude: 43.647118, - longitude: -79.3943, - altitude: 500 - // timestamp not specified, in this case, and - // won't be included in the image header - } - - can be null in the case where position information isn't - available/desired. - - 'altitude' is in metres; 'timestamp' is UTC, in seconds from - January 1, 1970. - */ - jsval position; - - /* the number of seconds from January 1, 1970 UTC. This can be - different from the positional timestamp (above). */ - long long dateTime; -}; - /* These properties affect the video recording preview, e.g. { profile: "1080p", diff --git a/dom/devicestorage/DeviceStorageRequestChild.cpp b/dom/devicestorage/DeviceStorageRequestChild.cpp index 41e03457a151..0f36dad8bf23 100644 --- a/dom/devicestorage/DeviceStorageRequestChild.cpp +++ b/dom/devicestorage/DeviceStorageRequestChild.cpp @@ -53,7 +53,9 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal { nsString compositePath; mFile->GetCompositePath(compositePath); - JS::Value result = StringToJsval(mRequest->GetOwner(), compositePath); + AutoJSContext cx; + JS::Rooted result(cx, + StringToJsval(mRequest->GetOwner(), compositePath)); mRequest->FireSuccess(result); break; } @@ -65,8 +67,9 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal nsCOMPtr blob = actor->GetBlob(); nsCOMPtr file = do_QueryInterface(blob); - JS::Value result = InterfaceToJsval(mRequest->GetOwner(), file, - &NS_GET_IID(nsIDOMFile)); + AutoJSContext cx; + JS::Rooted result(cx, + InterfaceToJsval(mRequest->GetOwner(), file, &NS_GET_IID(nsIDOMFile))); mRequest->FireSuccess(result); break; } @@ -74,7 +77,8 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal case DeviceStorageResponseValue::TFreeSpaceStorageResponse: { FreeSpaceStorageResponse r = aValue; - JS::Value result = JS_NumberValue(double(r.freeBytes())); + AutoJSContext cx; + JS::Rooted result(cx, JS_NumberValue(double(r.freeBytes()))); mRequest->FireSuccess(result); break; } @@ -82,7 +86,8 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal case DeviceStorageResponseValue::TUsedSpaceStorageResponse: { UsedSpaceStorageResponse r = aValue; - JS::Value result = JS_NumberValue(double(r.usedBytes())); + AutoJSContext cx; + JS::Rooted result(cx, JS_NumberValue(double(r.usedBytes()))); mRequest->FireSuccess(result); break; } @@ -90,7 +95,9 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal case DeviceStorageResponseValue::TAvailableStorageResponse: { AvailableStorageResponse r = aValue; - JS::Value result = StringToJsval(mRequest->GetOwner(), r.mountState()); + AutoJSContext cx; + JS::Rooted result( + cx, StringToJsval(mRequest->GetOwner(), r.mountState())); mRequest->FireSuccess(result); break; } diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index ab089a690007..b80a087ddadb 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -47,6 +47,8 @@ #include "nsIStringBundle.h" #include +#include "mozilla/dom/DeviceStorageBinding.h" + // Microsoft's API Name hackery sucks #undef CreateEvent @@ -1586,7 +1588,9 @@ ContinueCursorEvent::Run() nsRefPtr file = GetNextFile(); nsDOMDeviceStorageCursor* cursor = static_cast(mRequest.get()); - JS::Value val = nsIFileToJsval(cursor->GetOwner(), file); + + AutoJSContext cx; + JS::Rooted val(cx, nsIFileToJsval(cursor->GetOwner(), file)); if (file) { cursor->mOkToCallContinue = true; @@ -1803,7 +1807,8 @@ public: mFile->GetStatus(state); } - JS::Value result = StringToJsval(mRequest->GetOwner(), state); + AutoJSContext cx; + JS::Rooted result(cx, StringToJsval(mRequest->GetOwner(), state)); mRequest->FireSuccess(result); mRequest = nullptr; return NS_OK; @@ -1841,7 +1846,8 @@ public: { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - JS::Value result = JSVAL_NULL; + AutoJSContext cx; + JS::Rooted result(cx, JSVAL_NULL); nsPIDOMWindow* window = mRequest->GetOwner(); if (mFile) { @@ -3040,21 +3046,20 @@ nsDOMDeviceStorage::EnumerateEditable(const JS::Value & aName, } -static PRTime -ExtractDateFromOptions(JSContext* aCx, const JS::Value& aOptions) +static bool +ExtractDateFromOptions(JSContext* aCx, const JS::Value& aOptions, PRTime* aTime) { - PRTime result = 0; - mozilla::idl::DeviceStorageEnumerationParameters params; - if (!JSVAL_IS_VOID(aOptions) && !aOptions.isNull()) { - nsresult rv = params.Init(aCx, &aOptions); - if (NS_SUCCEEDED(rv) && !JSVAL_IS_VOID(params.since) && !params.since.isNull() && params.since.isObject()) { - JS::Rooted obj(aCx, JSVAL_TO_OBJECT(params.since)); - if (JS_ObjectIsDate(aCx, obj) && js_DateIsValid(obj)) { - result = js_DateGetMsecSinceEpoch(obj); - } - } + JS::Rooted options(aCx, aOptions); + RootedDictionary params(aCx); + if (!params.Init(aCx, options)) { + return false; } - return result; + if (params.mSince.WasPassed() && !params.mSince.Value().IsUndefined()) { + *aTime = params.mSince.Value().TimeStamp(); + } else { + *aTime = 0; + } + return true; } nsresult @@ -3082,7 +3087,9 @@ nsDOMDeviceStorage::EnumerateInternal(const JS::Value & aName, path.Assign(jspath); } else if (!JSVAL_IS_PRIMITIVE(aName)) { // it also might be an options object - since = ExtractDateFromOptions(aCx, aName); + if (!ExtractDateFromOptions(aCx, aName, &since)) { + return NS_ERROR_FAILURE; + } } else { return NS_ERROR_FAILURE; } @@ -3090,7 +3097,9 @@ nsDOMDeviceStorage::EnumerateInternal(const JS::Value & aName, if (aArgc == 2 && (JSVAL_IS_VOID(aOptions) || aOptions.isNull() || !aOptions.isObject())) { return NS_ERROR_FAILURE; } - since = ExtractDateFromOptions(aCx, aOptions); + if (!ExtractDateFromOptions(aCx, aOptions, &since)) { + return NS_ERROR_FAILURE; + } } nsRefPtr dsf = new DeviceStorageFile(mStorageType, diff --git a/dom/devicestorage/test/test_enumerateOptions.html b/dom/devicestorage/test/test_enumerateOptions.html index ad32a4450560..48af8f81cdde 100644 --- a/dom/devicestorage/test/test_enumerateOptions.html +++ b/dom/devicestorage/test/test_enumerateOptions.html @@ -48,7 +48,7 @@ ok(throws, "enumerate two string parameter"); throws = false; try { -var cursor = storage.enumerate("string", {"since": 1}); +var cursor = storage.enumerate("string", {"since": new Date(1)}); } catch(e) {throws = true} ok(!throws, "enumerate a string and object parameter"); @@ -66,7 +66,7 @@ ok(throws, "enumerate object then a string"); throws = false; try { -var cursor = storage.enumerate({"path": "a", "since": 0}); +var cursor = storage.enumerate({"path": "a", "since": new Date(0) }); } catch(e) {throws = true} ok(!throws, "enumerate object parameter with path"); diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index 64a1eefb63ff..3dba4c1dd6b9 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -36,10 +36,13 @@ #include "ipc/IndexedDBChild.h" #include "ipc/IndexedDBParent.h" +#include "mozilla/dom/IDBDatabaseBinding.h" + USING_INDEXEDDB_NAMESPACE using mozilla::dom::ContentParent; using mozilla::dom::quota::Client; using mozilla::dom::quota::QuotaManager; +using namespace mozilla::dom; namespace { @@ -528,36 +531,22 @@ IDBDatabase::CreateObjectStore(const nsAString& aName, DatabaseInfo* databaseInfo = transaction->DBInfo(); - mozilla::idl::IDBObjectStoreParameters params; + RootedDictionary params(aCx); + JS::Rooted options(aCx, aOptions); + if (!params.Init(aCx, options)) { + return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + } + KeyPath keyPath(0); - - nsresult rv; - - if (!JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) { - rv = params.Init(aCx, &aOptions); - if (NS_FAILED(rv)) { - return rv; - } - - // We need a default value here, which the XPIDL dictionary stuff doesn't - // support. WebIDL shall save us all! - JSBool hasProp = false; - JSObject* obj = JSVAL_TO_OBJECT(aOptions); - if (!JS_HasProperty(aCx, obj, "keyPath", &hasProp)) { - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; - } - - if (NS_FAILED(KeyPath::Parse(aCx, hasProp ? params.keyPath : JSVAL_NULL, - &keyPath))) { - return NS_ERROR_DOM_SYNTAX_ERR; - } + if (NS_FAILED(KeyPath::Parse(aCx, params.mKeyPath, &keyPath))) { + return NS_ERROR_DOM_SYNTAX_ERR; } if (databaseInfo->ContainsStoreName(aName)) { return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; } - if (!keyPath.IsAllowedForObjectStore(params.autoIncrement)) { + if (!keyPath.IsAllowedForObjectStore(params.mAutoIncrement)) { return NS_ERROR_DOM_INVALID_ACCESS_ERR; } @@ -566,11 +555,11 @@ IDBDatabase::CreateObjectStore(const nsAString& aName, guts.name = aName; guts.id = databaseInfo->nextObjectStoreId++; guts.keyPath = keyPath; - guts.autoIncrement = params.autoIncrement; + guts.autoIncrement = params.mAutoIncrement; nsRefPtr objectStore; - rv = CreateObjectStoreInternal(transaction, guts, - getter_AddRefs(objectStore)); + nsresult rv = CreateObjectStoreInternal(transaction, guts, + getter_AddRefs(objectStore)); NS_ENSURE_SUCCESS(rv, rv); objectStore.forget(_retval); diff --git a/dom/indexedDB/nsIIDBDatabase.idl b/dom/indexedDB/nsIIDBDatabase.idl index ffc1f9c729af..c58e03c3e90f 100644 --- a/dom/indexedDB/nsIIDBDatabase.idl +++ b/dom/indexedDB/nsIIDBDatabase.idl @@ -12,12 +12,6 @@ interface nsIIDBTransaction; interface nsIDOMDOMStringList; interface nsIDOMEventListener; -dictionary IDBObjectStoreParameters -{ - jsval keyPath; - boolean autoIncrement; -}; - /** * IDBDatabase interface. See * http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBDatabase diff --git a/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl b/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl index 6080b20fdb67..b08672bebf80 100644 --- a/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl +++ b/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl @@ -11,11 +11,6 @@ interface nsIDOMDeviceStorageChangeEvent; interface nsIDOMEventListener; interface nsIFile; -dictionary DeviceStorageEnumerationParameters -{ - jsval since; -}; - [scriptable, uuid(be690a9b-f0b4-4cde-a505-0b442abe2109), builtinclass] interface nsIDOMDeviceStorage : nsIDOMEventTarget { diff --git a/dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl b/dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl index aab8ac0b1afa..8166d76e8af2 100644 --- a/dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl +++ b/dom/mobilemessage/interfaces/nsIDOMMobileMessageManager.idl @@ -11,14 +11,6 @@ interface nsIDOMDOMCursor; interface nsIDOMDOMRequest; interface nsIDOMBlob; -dictionary MmsParameters -{ - jsval receivers; // DOMString[] - DOMString? subject; - DOMString? smil; - jsval attachments; // MmsAttachment[] -}; - [scriptable, builtinclass, uuid(a7984cb3-27c8-4e3d-82a4-01553e93c078)] interface nsIDOMMozMobileMessageManager : nsIDOMEventTarget { diff --git a/dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl b/dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl index e907d59b6115..0b921be210c3 100644 --- a/dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl +++ b/dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl @@ -6,6 +6,7 @@ interface nsIDOMBlob; +// If this is changed, change the WebIDL dictionary as well. dictionary MmsAttachment { DOMString? id; diff --git a/dom/mobilemessage/src/MobileMessageCallback.cpp b/dom/mobilemessage/src/MobileMessageCallback.cpp index ad3ca7c7ab6d..8bfa83b976a6 100644 --- a/dom/mobilemessage/src/MobileMessageCallback.cpp +++ b/dom/mobilemessage/src/MobileMessageCallback.cpp @@ -38,7 +38,7 @@ MobileMessageCallback::~MobileMessageCallback() nsresult -MobileMessageCallback::NotifySuccess(const JS::Value& aResult) +MobileMessageCallback::NotifySuccess(JS::Handle aResult) { mDOMRequest->FireSuccess(aResult); return NS_OK; @@ -121,7 +121,9 @@ NS_IMETHODIMP MobileMessageCallback::NotifyMessageDeleted(bool *aDeleted, uint32_t aSize) { if (aSize == 1) { - return NotifySuccess(aDeleted[0] ? JSVAL_TRUE : JSVAL_FALSE); + AutoJSContext cx; + JS::Rooted val(cx, aDeleted[0] ? JSVAL_TRUE : JSVAL_FALSE); + return NotifySuccess(val); } nsresult rv; @@ -140,7 +142,8 @@ MobileMessageCallback::NotifyMessageDeleted(bool *aDeleted, uint32_t aSize) aDeleted[i] ? &jsValTrue : &jsValFalse); } - return NotifySuccess(OBJECT_TO_JSVAL(deleteArrayObj)); + JS::Rooted deleteArrayVal(cx, JS::ObjectValue(*deleteArrayObj)); + return NotifySuccess(deleteArrayVal); } NS_IMETHODIMP @@ -152,7 +155,9 @@ MobileMessageCallback::NotifyDeleteMessageFailed(int32_t aError) NS_IMETHODIMP MobileMessageCallback::NotifyMessageMarkedRead(bool aRead) { - return NotifySuccess(aRead ? JSVAL_TRUE : JSVAL_FALSE); + AutoJSContext cx; + JS::Rooted val(cx, aRead ? JSVAL_TRUE : JSVAL_FALSE); + return NotifySuccess(val); } NS_IMETHODIMP diff --git a/dom/mobilemessage/src/MobileMessageCallback.h b/dom/mobilemessage/src/MobileMessageCallback.h index c6f879cae19d..bce94af5a26b 100644 --- a/dom/mobilemessage/src/MobileMessageCallback.h +++ b/dom/mobilemessage/src/MobileMessageCallback.h @@ -29,7 +29,7 @@ private: nsRefPtr mDOMRequest; - nsresult NotifySuccess(const JS::Value& aResult); + nsresult NotifySuccess(JS::Handle aResult); nsresult NotifySuccess(nsISupports *aMessage); nsresult NotifyError(int32_t aError); }; diff --git a/dom/mobilemessage/src/ipc/SmsIPCService.cpp b/dom/mobilemessage/src/ipc/SmsIPCService.cpp index 89d7df1c890c..b887241c5693 100644 --- a/dom/mobilemessage/src/ipc/SmsIPCService.cpp +++ b/dom/mobilemessage/src/ipc/SmsIPCService.cpp @@ -14,6 +14,9 @@ #include "DictionaryHelpers.h" #include "nsJSUtils.h" #include "nsContentUtils.h" +#include "mozilla/dom/MobileMessageManagerBinding.h" +#include "mozilla/dom/MozMmsMessageBinding.h" +#include "mozilla/dom/BindingUtils.h" using namespace mozilla::dom; using namespace mozilla::dom::mobilemessage; @@ -174,75 +177,39 @@ GetSendMmsMessageRequestFromParams(const JS::Value& aParam, } mozilla::AutoJSContext cx; - mozilla::idl::MmsParameters params; - nsresult rv = params.Init(cx, &aParam); - NS_ENSURE_SUCCESS(rv, false); - - uint32_t len; + JS::Rooted param(cx, aParam); + RootedDictionary params(cx); + if (!params.Init(cx, param)) { + return false; + } // SendMobileMessageRequest.receivers - if (!params.receivers.isObject()) { + if (!params.mReceivers.WasPassed()) { return false; } - JS::Rooted receiversObj(cx, ¶ms.receivers.toObject()); - if (!JS_GetArrayLength(cx, receiversObj, &len)) { - return false; - } - - request.receivers().SetCapacity(len); - - for (uint32_t i = 0; i < len; i++) { - JS::Rooted val(cx); - if (!JS_GetElement(cx, receiversObj, i, val.address())) { - return false; - } - - if (!val.isString()) { - return false; - } - - nsDependentJSString str; - if (!str.init(cx, val.toString())) { - return false; - } - - request.receivers().AppendElement(str); - } + request.receivers().AppendElements(params.mReceivers.Value()); // SendMobileMessageRequest.attachments mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton(); - if (!params.attachments.isObject()) { + if (!params.mAttachments.WasPassed()) { return false; } - JS::Rooted attachmentsObj(cx, ¶ms.attachments.toObject()); - if (!JS_GetArrayLength(cx, attachmentsObj, &len)) { - return false; - } - request.attachments().SetCapacity(len); - - for (uint32_t i = 0; i < len; i++) { - JS::Rooted val(cx); - if (!JS_GetElement(cx, attachmentsObj, i, val.address())) { - return false; - } - - mozilla::idl::MmsAttachment attachment; - rv = attachment.Init(cx, val.address()); - NS_ENSURE_SUCCESS(rv, false); + for (uint32_t i = 0; i < params.mAttachments.Value().Length(); i++) { + MmsAttachment& attachment = params.mAttachments.Value()[i]; MmsAttachmentData mmsAttachment; - mmsAttachment.id().Assign(attachment.id); - mmsAttachment.location().Assign(attachment.location); - mmsAttachment.contentChild() = cc->GetOrCreateActorForBlob(attachment.content); + mmsAttachment.id().Assign(attachment.mId); + mmsAttachment.location().Assign(attachment.mLocation); + mmsAttachment.contentChild() = cc->GetOrCreateActorForBlob(attachment.mContent); if (!mmsAttachment.contentChild()) { return false; } request.attachments().AppendElement(mmsAttachment); } - request.smil() = params.smil; - request.subject() = params.subject; + request.smil() = params.mSmil; + request.subject() = params.mSubject; return true; } diff --git a/dom/webidl/CameraManager.webidl b/dom/webidl/CameraManager.webidl new file mode 100644 index 000000000000..2955a2395c98 --- /dev/null +++ b/dom/webidl/CameraManager.webidl @@ -0,0 +1,48 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +dictionary CameraPictureOptions { + + /* an object with a combination of 'height' and 'width' properties + chosen from nsICameraCapabilities.pictureSizes */ + // XXXbz this should be a CameraSize dictionary, but we don't have that yet. + any pictureSize = null; + + /* one of the file formats chosen from + nsICameraCapabilities.fileFormats */ + DOMString fileFormat = ""; + + /* the rotation of the image in degrees, from 0 to 270 in + steps of 90; this doesn't affect the image, only the + rotation recorded in the image header.*/ + long rotation = 0; + + /* an object containing any or all of 'latitude', 'longitude', + 'altitude', and 'timestamp', used to record when and where + the image was taken. e.g. + { + latitude: 43.647118, + longitude: -79.3943, + altitude: 500 + // timestamp not specified, in this case, and + // won't be included in the image header + } + + can be null in the case where position information isn't + available/desired. + + 'altitude' is in metres; 'timestamp' is UTC, in seconds from + January 1, 1970. + */ + any position = null; + + /* the number of seconds from January 1, 1970 UTC. This can be + different from the positional timestamp (above). */ + // XXXbz this should really accept a date too, no? + long long dateTime = 0; +}; + +// If we start using CameraPictureOptions here, remove it from DummyBinding. diff --git a/dom/webidl/DeviceStorage.webidl b/dom/webidl/DeviceStorage.webidl new file mode 100644 index 000000000000..7f9e2cd26e37 --- /dev/null +++ b/dom/webidl/DeviceStorage.webidl @@ -0,0 +1,12 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +dictionary DeviceStorageEnumerationParameters { + Date since; +}; + +// If we start using DeviceStorageEnumerationParameters here, remove +// it from DummyBinding. diff --git a/dom/webidl/DummyBinding.webidl b/dom/webidl/DummyBinding.webidl index 945ec6d6d1a2..5f522c7fed78 100644 --- a/dom/webidl/DummyBinding.webidl +++ b/dom/webidl/DummyBinding.webidl @@ -19,6 +19,11 @@ interface DummyInterface { void funcWebSocketDict(optional WebSocketDict arg); void funcDNSCacheDict(optional DNSCacheDict arg); void frameRequestCallback(FrameRequestCallback arg); + void idbObjectStoreParams(optional IDBObjectStoreParameters arg); + void DeviceStorageEnumerationParameters(optional DeviceStorageEnumerationParameters arg); + void CameraPictureOptions(optional CameraPictureOptions arg); + void MmsParameters(optional MmsParameters arg); + void MmsAttachment(optional MmsAttachment arg); }; interface DummyInterfaceWorkers { diff --git a/dom/webidl/IDBDatabase.webidl b/dom/webidl/IDBDatabase.webidl new file mode 100644 index 000000000000..00b7a1a47844 --- /dev/null +++ b/dom/webidl/IDBDatabase.webidl @@ -0,0 +1,14 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +dictionary IDBObjectStoreParameters { + // XXXbz this should be "(DOMString or sequence)?", but + // we don't support unions in dictionaries yet. See bug 767926. + any keyPath = null; + boolean autoIncrement = false; +}; + +// If we start using IDBObjectStoreParameters here, remove it from DummyBinding. diff --git a/dom/webidl/MobileMessageManager.webidl b/dom/webidl/MobileMessageManager.webidl new file mode 100644 index 000000000000..2cebb4d0c312 --- /dev/null +++ b/dom/webidl/MobileMessageManager.webidl @@ -0,0 +1,14 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +dictionary MmsParameters { + sequence receivers; + DOMString? subject = null; + DOMString? smil = null; + sequence attachments; +}; + +// If we start using MmsParameters here, remove it from DummyBinding. diff --git a/dom/webidl/MozMmsMessage.webidl b/dom/webidl/MozMmsMessage.webidl new file mode 100644 index 000000000000..778c85ce4490 --- /dev/null +++ b/dom/webidl/MozMmsMessage.webidl @@ -0,0 +1,14 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +// If this is changed, change the XPIDL dictionary as well. +dictionary MmsAttachment { + DOMString? id = null; + DOMString? location = null; + Blob? content = null; +}; + +// If we start using MmsParameters here, remove it from DummyBinding. diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index c7af5e305e56..590d15dff859 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -38,6 +38,7 @@ webidl_files = \ ClientRect.webidl \ ClientRectList.webidl \ ClipboardEvent.webidl \ + CameraManager.webidl \ CommandEvent.webidl \ Comment.webidl \ CompositionEvent.webidl \ @@ -52,6 +53,7 @@ webidl_files = \ DelayNode.webidl \ DesktopNotification.webidl \ DeviceMotionEvent.webidl \ + DeviceStorage.webidl \ Document.webidl \ DocumentFragment.webidl \ DocumentType.webidl \ @@ -151,6 +153,7 @@ webidl_files = \ HTMLTitleElement.webidl \ HTMLUListElement.webidl \ HTMLVideoElement.webidl \ + IDBDatabase.webidl \ IDBFactory.webidl \ IDBVersionChangeEvent.webidl \ ImageData.webidl \ @@ -165,9 +168,11 @@ webidl_files = \ MediaStreamEvent.webidl \ MediaStreamTrack.webidl \ MessageEvent.webidl \ + MobileMessageManager.webidl \ MouseEvent.webidl \ MouseScrollEvent.webidl \ MozActivity.webidl \ + MozMmsMessage.webidl \ MozNamedAttrMap.webidl \ MutationEvent.webidl \ MutationObserver.webidl \ diff --git a/dom/workers/EventListenerManager.cpp b/dom/workers/EventListenerManager.cpp index 54951aac55cf..a471b3a01a9e 100644 --- a/dom/workers/EventListenerManager.cpp +++ b/dom/workers/EventListenerManager.cpp @@ -209,7 +209,7 @@ EventListenerManager::FinalizeInternal(JSFreeOp* aFop) void EventListenerManager::Add(JSContext* aCx, const jsid& aType, - JSObject* aListener, Phase aPhase, + JS::Handle aListener, Phase aPhase, bool aWantsUntrusted, ErrorResult& aRv) { MOZ_ASSERT(aListener); @@ -244,7 +244,7 @@ EventListenerManager::Add(JSContext* aCx, const jsid& aType, void EventListenerManager::Remove(JSContext* aCx, const jsid& aType, - JSObject* aListener, Phase aPhase, + JS::Handle aListener, Phase aPhase, bool aClearEmpty) { MOZ_ASSERT(aListener); diff --git a/dom/workers/EventListenerManager.h b/dom/workers/EventListenerManager.h index 834e527515b2..11edda14e9c5 100644 --- a/dom/workers/EventListenerManager.h +++ b/dom/workers/EventListenerManager.h @@ -60,7 +60,8 @@ public: }; void - AddEventListener(JSContext* aCx, const jsid& aType, JSObject* aListener, + AddEventListener(JSContext* aCx, const jsid& aType, + JS::Handle aListener, bool aCapturing, bool aWantsUntrusted, ErrorResult& aRv) { Add(aCx, aType, aListener, aCapturing ? Capturing : Bubbling, @@ -68,8 +69,8 @@ public: } void - RemoveEventListener(JSContext* aCx, const jsid& aType, JSObject* aListener, - bool aCapturing) + RemoveEventListener(JSContext* aCx, const jsid& aType, + JS::Handle aListener, bool aCapturing) { if (mCollections.isEmpty()) { return; @@ -85,10 +86,11 @@ public: GetEventListener(const jsid& aType) const; void - SetEventListener(JSContext* aCx, const jsid& aType, JSObject* aListener, + SetEventListener(JSContext* aCx, const jsid& aType, + JS::Handle aListener, ErrorResult& aRv) { - JSObject* existing = GetEventListener(aType); + JS::Rooted existing(aCx, GetEventListener(aType)); if (existing) { Remove(aCx, aType, existing, Onfoo, false); } @@ -118,12 +120,12 @@ private: FinalizeInternal(JSFreeOp* aFop); void - Add(JSContext* aCx, const jsid& aType, JSObject* aListener, Phase aPhase, - bool aWantsUntrusted, ErrorResult& aRv); + Add(JSContext* aCx, const jsid& aType, JS::Handle aListener, + Phase aPhase, bool aWantsUntrusted, ErrorResult& aRv); void - Remove(JSContext* aCx, const jsid& aType, JSObject* aListener, Phase aPhase, - bool aClearEmpty); + Remove(JSContext* aCx, const jsid& aType, JS::Handle aListener, + Phase aPhase, bool aClearEmpty); bool HasListenersForTypeInternal(JSContext* aCx, const jsid& aType) const; diff --git a/dom/workers/EventTarget.cpp b/dom/workers/EventTarget.cpp index 58db698c6798..14bcbcc7183b 100644 --- a/dom/workers/EventTarget.cpp +++ b/dom/workers/EventTarget.cpp @@ -39,11 +39,11 @@ EventTarget::GetEventListener(const nsAString& aType, ErrorResult& aRv) const } void -EventTarget::SetEventListener(const nsAString& aType, JSObject* aListener_, +EventTarget::SetEventListener(const nsAString& aType, + JS::Handle aListener, ErrorResult& aRv) { JSContext* cx = GetJSContext(); - JS::Rooted aListener(cx, aListener_); JSString* type = JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length()); @@ -57,16 +57,16 @@ EventTarget::SetEventListener(const nsAString& aType, JSObject* aListener_, } void -EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener_, +EventTarget::AddEventListener(const nsAString& aType, + JS::Handle aListener, bool aCapturing, Nullable aWantsUntrusted, ErrorResult& aRv) { - if (!aListener_) { + if (!aListener) { return; } JSContext* cx = GetJSContext(); - JS::Rooted aListener(cx, aListener_); JSString* type = JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length()); @@ -82,15 +82,15 @@ EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener_, } void -EventTarget::RemoveEventListener(const nsAString& aType, JSObject* aListener_, +EventTarget::RemoveEventListener(const nsAString& aType, + JS::Handle aListener, bool aCapturing, ErrorResult& aRv) { - if (!aListener_) { + if (!aListener) { return; } JSContext* cx = GetJSContext(); - JS::Rooted aListener(cx, aListener_); JSString* type = JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length()); diff --git a/dom/workers/EventTarget.h b/dom/workers/EventTarget.h index 7ce2ff5778e9..0c672c7927ce 100644 --- a/dom/workers/EventTarget.h +++ b/dom/workers/EventTarget.h @@ -37,12 +37,12 @@ public: _finalize(JSFreeOp* aFop) MOZ_OVERRIDE; void - AddEventListener(const nsAString& aType, JSObject* aListener, + AddEventListener(const nsAString& aType, JS::Handle aListener, bool aCapture, Nullable aWantsUntrusted, ErrorResult& aRv); void - RemoveEventListener(const nsAString& aType, JSObject* aListener, + RemoveEventListener(const nsAString& aType, JS::Handle aListener, bool aCapture, ErrorResult& aRv); bool @@ -55,7 +55,7 @@ public: GetEventListener(const nsAString& aType, ErrorResult& aRv) const; void - SetEventListener(const nsAString& aType, JSObject* aListener, + SetEventListener(const nsAString& aType, JS::Handle aListener, ErrorResult& aRv); bool diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index dc8360fb1c06..50e097fba6b9 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -186,8 +186,9 @@ private: } ErrorResult rv; + JS::Rooted listenerObj(aCx, JSVAL_TO_OBJECT(aVp)); scope->SetEventListener(NS_ConvertASCIItoUTF16(name + 2), - JSVAL_TO_OBJECT(aVp), rv); + listenerObj, rv); if (rv.Failed()) { JS_ReportError(aCx, "Failed to set event listener!"); return false; @@ -360,7 +361,7 @@ private: return false; } - JSObject* listener = JS_GetFunctionObject(adaptor); + JS::Rooted listener(aCx, JS_GetFunctionObject(adaptor)); if (!listener) { return false; } @@ -776,8 +777,9 @@ private: ErrorResult rv; + JS::Rooted listenerObj(aCx, JSVAL_TO_OBJECT(aVp)); scope->SetEventListener(NS_ConvertASCIItoUTF16(name + 2), - JSVAL_TO_OBJECT(aVp), rv); + listenerObj, rv); if (rv.Failed()) { JS_ReportError(aCx, "Failed to set event listener!"); diff --git a/dom/workers/XMLHttpRequest.cpp b/dom/workers/XMLHttpRequest.cpp index 2625acdd31ac..dc595ae1641b 100644 --- a/dom/workers/XMLHttpRequest.cpp +++ b/dom/workers/XMLHttpRequest.cpp @@ -665,6 +665,8 @@ public: } XMLHttpRequest::StateData state; + // XXXbz there is no AutoValueRooter anymore? + JS::AutoArrayRooter rooter(aCx, 1, &state.mResponse); state.mResponseTextResult = mResponseTextResult; state.mResponseText = mResponseText; diff --git a/dom/workers/XMLHttpRequest.h b/dom/workers/XMLHttpRequest.h index 6fdc3dd34212..b5b575aab767 100644 --- a/dom/workers/XMLHttpRequest.h +++ b/dom/workers/XMLHttpRequest.h @@ -105,7 +105,8 @@ public: } \ \ void \ - SetOn##_type(JSContext* /* unused */, JSObject* aListener, ErrorResult& aRv) \ + SetOn##_type(JSContext* /* unused */, JS::Handle aListener, \ + ErrorResult& aRv) \ { \ SetEventListener(NS_LITERAL_STRING(#_type), aListener, aRv); \ } diff --git a/dom/workers/XMLHttpRequestEventTarget.h b/dom/workers/XMLHttpRequestEventTarget.h index 97121db2e978..777746e1cd9a 100644 --- a/dom/workers/XMLHttpRequestEventTarget.h +++ b/dom/workers/XMLHttpRequestEventTarget.h @@ -35,7 +35,8 @@ public: } \ \ void \ - SetOn##_type(JSContext* /* unused */, JSObject* aListener, ErrorResult& aRv) \ + SetOn##_type(JSContext* /* unused */, JS::Handle aListener, \ + ErrorResult& aRv) \ { \ SetEventListener(NS_LITERAL_STRING(#_type), aListener, aRv); \ } diff --git a/js/xpconnect/src/dictionary_helper_gen.conf b/js/xpconnect/src/dictionary_helper_gen.conf index bd771a344b9a..d5d8a4aa9a0f 100644 --- a/js/xpconnect/src/dictionary_helper_gen.conf +++ b/js/xpconnect/src/dictionary_helper_gen.conf @@ -9,20 +9,16 @@ dictionaries = [ [ 'MouseEventInit', 'nsIDOMMouseEvent.idl' ], [ 'ClipboardEventInit', 'nsIDOMClipboardEvent.idl' ], [ 'WheelEventInit', 'nsIDOMWheelEvent.idl' ], - [ 'IDBObjectStoreParameters', 'nsIIDBDatabase.idl' ], [ 'IDBIndexParameters', 'nsIIDBObjectStore.idl' ], [ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl' ], [ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ], - [ 'DeviceStorageEnumerationParameters', 'nsIDOMDeviceStorage.idl' ], [ 'CameraSize', 'nsIDOMCameraManager.idl' ], [ 'CameraRegion', 'nsIDOMCameraManager.idl' ], [ 'CameraPosition', 'nsIDOMCameraManager.idl' ], [ 'CameraSelector', 'nsIDOMCameraManager.idl' ], - [ 'CameraPictureOptions', 'nsIDOMCameraManager.idl' ], [ 'CameraRecordingOptions', 'nsIDOMCameraManager.idl' ], [ 'SmsThreadListItem', 'nsIMobileMessageCallback.idl' ], - [ 'MmsAttachment', 'nsIDOMMozMmsMessage.idl' ], - [ 'MmsParameters', 'nsIDOMMobileMessageManager.idl' ] + [ 'MmsAttachment', 'nsIDOMMozMmsMessage.idl' ] ] # include file names