Bug 999464 - Standardize on DOMPoint and thus eliminate need for CameraPoint. r=bz, r=mikeh
authorAndrew Osmond <aosmond@gmail.com>
Thu, 01 May 2014 15:09:00 -0400
changeset 181348 d97263d58ac5ee88e526e8b080211e1ab96c89c2
parent 181347 8eddc5ea91ba64b346bfe15783c5c4ad58cfbfec
child 181349 cc29ea949039296121363e1b137fa5ed80e7bf6d
push id26702
push userryanvm@gmail.com
push dateFri, 02 May 2014 20:32:37 +0000
treeherdermozilla-central@c8d9cc05d899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, mikeh
bugs999464
milestone32.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 999464 - Standardize on DOMPoint and thus eliminate need for CameraPoint. r=bz, r=mikeh
dom/bindings/Bindings.conf
dom/camera/DOMCameraDetectedFace.cpp
dom/camera/DOMCameraDetectedFace.h
dom/tests/mochitest/general/test_interfaces.html
dom/webidl/CameraControl.webidl
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -190,21 +190,16 @@ DOMInterfaces = {
     'headerFile': 'DOMCameraDetectedFace.h'
 },
 
 'CameraManager': {
     'nativeType': 'nsDOMCameraManager',
     'headerFile': 'DOMCameraManager.h'
 },
 
-'CameraPoint': {
-    'nativeType': 'mozilla::dom::DOMCameraPoint',
-    'headerFile': 'DOMCameraDetectedFace.h'
-},
-
 'CanvasRenderingContext2D': {
     'implicitJSContext': [
         'createImageData', 'getImageData'
     ],
     'resultNotAddRefed': [ 'canvas', 'measureText' ],
     'binaryNames': {
         'mozImageSmoothingEnabled': 'imageSmoothingEnabled',
         'mozFillRule': 'fillRule'
--- a/dom/camera/DOMCameraDetectedFace.cpp
+++ b/dom/camera/DOMCameraDetectedFace.cpp
@@ -3,56 +3,34 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DOMCameraDetectedFace.h"
 #include "Navigator.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMCameraPoint, mParent)
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraPoint)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraPoint)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraPoint)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMCameraDetectedFace, mParent,
                                       mBounds, mLeftEye, mRightEye, mMouth)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraDetectedFace)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraDetectedFace)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 /* static */
 bool
-DOMCameraPoint::HasSupport(JSContext* aCx, JSObject* aGlobal)
-{
-  return Navigator::HasCameraSupport(aCx, aGlobal);
-}
-
-/* static */
-bool
 DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal)
 {
   return Navigator::HasCameraSupport(aCx, aGlobal);
 }
 
 JSObject*
-DOMCameraPoint::WrapObject(JSContext* aCx)
-{
-  return CameraPointBinding::Wrap(aCx, this);
-}
-
-JSObject*
 DOMCameraDetectedFace::WrapObject(JSContext* aCx)
 {
   return CameraDetectedFaceBinding::Wrap(aCx, this);
 }
 
 DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent,
                                              const ICameraControl::Face& aFace)
   : mParent(aParent)
@@ -61,19 +39,19 @@ DOMCameraDetectedFace::DOMCameraDetected
   , mBounds(new DOMRect(MOZ_THIS_IN_INITIALIZER_LIST()))
 {
   mBounds->SetRect(aFace.bound.left,
                    aFace.bound.top,
                    aFace.bound.right - aFace.bound.left,
                    aFace.bound.bottom - aFace.bound.top);
 
   if (aFace.hasLeftEye) {
-    mLeftEye = new DOMCameraPoint(this, aFace.leftEye);
+    mLeftEye = new DOMPoint(this, aFace.leftEye.x, aFace.leftEye.y);
   }
   if (aFace.hasRightEye) {
-    mRightEye = new DOMCameraPoint(this, aFace.rightEye);
+    mRightEye = new DOMPoint(this, aFace.rightEye.x, aFace.rightEye.y);
   }
   if (aFace.hasMouth) {
-    mMouth = new DOMCameraPoint(this, aFace.mouth);
+    mMouth = new DOMPoint(this, aFace.mouth.x, aFace.mouth.y);
   }
 
   SetIsDOMBinding();
 }
--- a/dom/camera/DOMCameraDetectedFace.h
+++ b/dom/camera/DOMCameraDetectedFace.h
@@ -4,74 +4,23 @@
 
 #ifndef DOM_CAMERA_DOMCAMERADETECTEDFACE_H
 #define DOM_CAMERA_DOMCAMERADETECTEDFACE_H
 
 #include "mozilla/dom/CameraControlBinding.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "mozilla/dom/DOMRect.h"
+#include "mozilla/dom/DOMPoint.h"
 #include "ICameraControl.h"
 
 namespace mozilla {
 
 namespace dom {
 
-class DOMCameraPoint MOZ_FINAL : public nsISupports
-                               , public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCameraPoint)
-
-  // Because this header's filename doesn't match its C++ or DOM-facing
-  // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
-  // include the right header for us; instead we must explicitly include a
-  // HasSupport() method in each header. We can get rid of these with the
-  // Great Renaming proposed in bug 983177.
-  static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
-
-  DOMCameraPoint(nsISupports* aParent, const ICameraControl::Point& aPoint)
-    : mParent(aParent)
-    , mX(aPoint.x)
-    , mY(aPoint.y)
-  {
-    SetIsDOMBinding();
-  }
-
-  void
-  SetPoint(int32_t aX, int32_t aY)
-  {
-    mX = aX;
-    mY = aY;
-  }
-
-  int32_t X() { return mX; }
-  int32_t Y() { return mY; }
-
-  void SetX(int32_t aX) { mX = aX; }
-  void SetY(int32_t aY) { mY = aY; }
-
-  nsISupports*
-  GetParentObject() const
-  {
-    MOZ_ASSERT(mParent);
-    return mParent;
-  }
-
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
-
-protected:
-  virtual ~DOMCameraPoint() { }
-
-  nsCOMPtr<nsISupports> mParent;
-  int32_t mX;
-  int32_t mY;
-};
-
 class DOMCameraDetectedFace MOZ_FINAL : public nsISupports
                                       , public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCameraDetectedFace)
 
   // Because this header's filename doesn't match its C++ or DOM-facing
@@ -86,19 +35,19 @@ public:
   uint32_t Id()       { return mId; }
   uint32_t Score()    { return mScore; }
   bool HasLeftEye()   { return mLeftEye; }
   bool HasRightEye()  { return mRightEye; }
   bool HasMouth()     { return mMouth; }
 
   dom::DOMRect* Bounds()        { return mBounds; }
 
-  DOMCameraPoint* GetLeftEye()  { return mLeftEye; }
-  DOMCameraPoint* GetRightEye() { return mRightEye; }
-  DOMCameraPoint* GetMouth()    { return mMouth; }
+  dom::DOMPoint* GetLeftEye()  { return mLeftEye; }
+  dom::DOMPoint* GetRightEye() { return mRightEye; }
+  dom::DOMPoint* GetMouth()    { return mMouth; }
 
   nsISupports*
   GetParentObject() const
   {
     MOZ_ASSERT(mParent);
     return mParent;
   }
 
@@ -109,18 +58,18 @@ protected:
 
   nsCOMPtr<nsISupports> mParent;
 
   uint32_t mId;
   uint32_t mScore;
 
   nsRefPtr<dom::DOMRect> mBounds;
 
-  nsRefPtr<DOMCameraPoint> mLeftEye;
-  nsRefPtr<DOMCameraPoint> mRightEye;
-  nsRefPtr<DOMCameraPoint> mMouth;
+  nsRefPtr<dom::DOMPoint> mLeftEye;
+  nsRefPtr<dom::DOMPoint> mRightEye;
+  nsRefPtr<dom::DOMPoint> mMouth;
 };
 
 } // namespace dom
 
 } // namespace mozilla
 
 #endif // DOM_CAMERA_DOMCAMERADETECTEDFACE_H
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -171,18 +171,16 @@ var interfaceNamesInGlobalScope =
     {name: "CameraCapabilities", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "CameraControl", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "CameraDetectedFace", b2g: true, pref: "camera.control.face_detection.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "CameraManager", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "CameraPoint", b2g: true, pref: "camera.control.face_detection.enabled"},
-// IMPORTANT: Do not change this list without review from a DOM peer!
     "CanvasGradient",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "CanvasPattern",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "CanvasRenderingContext2D",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "CaretPosition",
 // IMPORTANT: Do not change this list without review from a DOM peer!
--- a/dom/webidl/CameraControl.webidl
+++ b/dom/webidl/CameraControl.webidl
@@ -361,29 +361,16 @@ interface CameraControl : MediaStream
      once autoFocus() is called with a continuous autofocus mode set, the
      continuous autofocus process is stopped and focus is locked in the
      current state until this method is called.
   */
   [Throws]
   void resumeContinuousFocus();
 };
 
-/* The coordinates of a point, relative to the camera sensor, of the center of
-   detected facial features. As with CameraRegions:
-     { x: -1000, y: -1000 } is the top-left corner
-     { x:  1000, y:  1000 } is the bottom-right corner
-   x and y can range from -1000 to 1000.
-*/
-[Pref="camera.control.face_detection.enabled", Func="DOMCameraPoint::HasSupport"]
-interface CameraPoint
-{
-  attribute long x;
-  attribute long y;
-};
-
 /* The information of the each face detected by a camera device, e.g.
      {
        id: 1,
        score: 80,
        bound: { left:   -203,
                 top:    -400,
                 right:   300,
                 bottom:  250 },
@@ -403,41 +390,44 @@ interface CameraPoint
 
    'bounds' is the bounds of the face. It is guaranteed left < right and
    top < bottom. The coordinates can be smaller than -1000 or bigger than 1000.
    But at least one vertex will be within (-1000, -1000) and (1000, 1000).
 
    'leftEye' is the coordinates of the centre of the left eye. The coordinates
    are in the same space as the ones for 'bounds'. This is an optional field
    and may not be supported on all devices. If it is not supported or detected,
-   the value will be set to null.
+   the value will be set to null. The x and y coordinates are bounded by the
+   range (-1000, 1000) where:
+       { x: -1000, y: -1000 } is the top-left corner
+       { x:  1000, y:  1000 } is the bottom-right corner
 
    'rightEye' is the coordinates of the detected right eye; null if not
-   supported or detected.
+   supported or detected. Same boundary conditions as 'leftEye'.
 
    'mouth' is the coordinates of the detected mouth; null if not supported or
-   detected.
+   detected. Same boundary conditions as 'leftEye'.
 */
 [Pref="camera.control.face_detection.enabled", Func="DOMCameraDetectedFace::HasSupport"]
 interface CameraDetectedFace
 {
   readonly attribute unsigned long id;
 
   readonly attribute unsigned long score;
 
   readonly attribute DOMRect bounds;
 
   readonly attribute boolean hasLeftEye;
-  readonly attribute CameraPoint? leftEye;
+  readonly attribute DOMPoint? leftEye;
 
   readonly attribute boolean hasRightEye;
-  readonly attribute CameraPoint? rightEye;
+  readonly attribute DOMPoint? rightEye;
 
   readonly attribute boolean hasMouth;
-  readonly attribute CameraPoint? mouth;
+  readonly attribute DOMPoint? mouth;
 };
 
 callback CameraFaceDetectionCallback = void (sequence<CameraDetectedFace> faces);
 
 partial interface CameraControl
 {
   /* Starts the face detection. This should be called after the preview is
      started. The camera will periodically call 'onFacesDetected' with a