bug 870678 - move CameraSelector dictionary to webidl r=bz
authorTrevor Saunders <trev.saunders@gmail.com>
Wed, 15 May 2013 07:07:08 -0400
changeset 134184 831fa9c0c20b031ce73882daf3b720872d81769a
parent 134183 3565f3f92904e37ced76345fd363b93ca4f60cbc
child 134185 5f66c33dbf001c446e137953d4ed3df64ba21d3d
push id24784
push useremorley@mozilla.com
push dateThu, 06 Jun 2013 09:09:24 +0000
treeherdermozilla-central@10a6781c41e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs870678
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 870678 - move CameraSelector dictionary to webidl r=bz
dom/camera/DOMCameraManager.cpp
dom/camera/DOMCameraManager.h
dom/camera/nsIDOMCameraManager.idl
dom/webidl/CameraManager.webidl
--- a/dom/camera/DOMCameraManager.cpp
+++ b/dom/camera/DOMCameraManager.cpp
@@ -97,30 +97,23 @@ nsDOMCameraManager::CheckPermissionAndCr
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   obs->AddObserver(cameraManager, "xpcom-shutdown", true);
 
   return cameraManager.forget();
 }
 
 void
-nsDOMCameraManager::GetCamera(JSContext* aCx, const JS::Value aOptions,
+nsDOMCameraManager::GetCamera(const CameraSelector& aOptions,
                               nsICameraGetCameraCallback* onSuccess,
                               const Optional<nsICameraErrorCallback*>& onError,
                               ErrorResult& aRv)
 {
   uint32_t cameraId = 0;  // back (or forward-facing) camera by default
-  mozilla::idl::CameraSelector selector;
-
-  aRv = selector.Init(aCx, &aOptions);
-  if (aRv.Failed()) {
-    return;
-  }
-
-  if (selector.camera.EqualsLiteral("front")) {
+  if (aOptions.mCamera.EqualsLiteral("front")) {
     cameraId = 1;
   }
 
   // reuse the same camera thread to conserve resources
   if (!mCameraThread) {
     aRv = NS_NewThread(getter_AddRefs(mCameraThread));
     if (aRv.Failed()) {
       return;
--- a/dom/camera/DOMCameraManager.h
+++ b/dom/camera/DOMCameraManager.h
@@ -21,16 +21,19 @@
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 
 class nsPIDOMWindow;
 
 namespace mozilla {
   class ErrorResult;
 class nsDOMCameraControl;
+namespace dom {
+class CameraSelector;
+}
 }
 
 typedef nsTArray<nsRefPtr<mozilla::nsDOMCameraControl> > CameraControls;
 typedef nsClassHashtable<nsUint64HashKey, CameraControls> WindowTable;
 
 class nsDOMCameraManager MOZ_FINAL
   : public nsIObserver
   , public nsSupportsWeakReference
@@ -48,17 +51,17 @@ public:
 
   void Register(mozilla::nsDOMCameraControl* aDOMCameraControl);
   void OnNavigation(uint64_t aWindowId);
 
   nsresult GetNumberOfCameras(int32_t& aDeviceCount);
   nsresult GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName);
 
   // WebIDL
-  void GetCamera(JSContext* aCx, const JS::Value aOptions,
+  void GetCamera(const mozilla::dom::CameraSelector& aOptions,
                  nsICameraGetCameraCallback* aCallback,
                  const mozilla::dom::Optional<nsICameraErrorCallback*>& ErrorCallback,
                  mozilla::ErrorResult& aRv);
   void GetListOfCameras(nsTArray<nsString>& aList, mozilla::ErrorResult& aRv);
 
   nsPIDOMWindow* GetParentObject() const { return mWindow; }
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
     MOZ_OVERRIDE;
--- a/dom/camera/nsIDOMCameraManager.idl
+++ b/dom/camera/nsIDOMCameraManager.idl
@@ -31,21 +31,16 @@ dictionary CameraRegion {
    'NaN' indicates the information is not available. */
 dictionary CameraPosition {
     double latitude;
     double longitude;
     double altitude;
     double timestamp;
 };
 
-/* Select a camera to use. */
-dictionary CameraSelector {
-    DOMString camera = "back";
-};
-
 [scriptable, uuid(177472c9-f83d-48b5-8782-03b43b27f25d)]
 interface nsICameraCapabilities : nsISupports
 {
     /* an array of objects with 'height' and 'width' properties
        supported for the preview stream */
     [implicit_jscontext]
     readonly attribute jsval        previewSizes;
 
--- a/dom/webidl/CameraManager.webidl
+++ b/dom/webidl/CameraManager.webidl
@@ -46,25 +46,30 @@ dictionary CameraPictureOptions {
   long long dateTime = 0;
 };
 
 // If we start using CameraPictureOptions here, remove it from DummyBinding.
 
 interface GetCameraCallback;
 interface CameraErrorCallback;
 
+/* Select a camera to use. */
+dictionary CameraSelector {
+    DOMString camera = "back";
+};
+
 interface CameraManager {
     /* get a camera instance; options will be used to specify which
        camera to get from the list returned by getListOfCameras(), e.g.:
         {
             camera: "front"
         }
     */
   [Throws]
-  void getCamera(any options, GetCameraCallback callback,
+  void getCamera(CameraSelector options, GetCameraCallback callback,
                  optional CameraErrorCallback errorCallback);
 
   /* return an array of camera   identifiers, e.g.
      [ "front", "back" ]
    */
   [Throws]
   sequence<DOMString> getListOfCameras();
 };