Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef DOM_CAMERA_DOMCAMERADETECTEDFACE_H
6 #define DOM_CAMERA_DOMCAMERADETECTEDFACE_H
8 #include "mozilla/dom/CameraControlBinding.h"
9 #include "nsCycleCollectionParticipant.h"
10 #include "nsWrapperCache.h"
11 #include "mozilla/dom/DOMRect.h"
12 #include "ICameraControl.h"
14 namespace mozilla {
16 namespace dom {
18 class DOMCameraPoint MOZ_FINAL : public nsISupports
19 , public nsWrapperCache
20 {
21 public:
22 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
23 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCameraPoint)
25 // Because this header's filename doesn't match its C++ or DOM-facing
26 // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
27 // include the right header for us; instead we must explicitly include a
28 // HasSupport() method in each header. We can get rid of these with the
29 // Great Renaming proposed in bug 983177.
30 static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
32 DOMCameraPoint(nsISupports* aParent, const ICameraControl::Point& aPoint)
33 : mParent(aParent)
34 , mX(aPoint.x)
35 , mY(aPoint.y)
36 {
37 SetIsDOMBinding();
38 }
40 void
41 SetPoint(int32_t aX, int32_t aY)
42 {
43 mX = aX;
44 mY = aY;
45 }
47 int32_t X() { return mX; }
48 int32_t Y() { return mY; }
50 void SetX(int32_t aX) { mX = aX; }
51 void SetY(int32_t aY) { mY = aY; }
53 nsISupports*
54 GetParentObject() const
55 {
56 MOZ_ASSERT(mParent);
57 return mParent;
58 }
60 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
62 protected:
63 virtual ~DOMCameraPoint() { }
65 nsCOMPtr<nsISupports> mParent;
66 int32_t mX;
67 int32_t mY;
68 };
70 class DOMCameraDetectedFace MOZ_FINAL : public nsISupports
71 , public nsWrapperCache
72 {
73 public:
74 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
75 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCameraDetectedFace)
77 // Because this header's filename doesn't match its C++ or DOM-facing
78 // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
79 // include the right header for us; instead we must explicitly include a
80 // HasSupport() method in each header. We can get rid of these with the
81 // Great Renaming proposed in bug 983177.
82 static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
84 DOMCameraDetectedFace(nsISupports* aParent, const ICameraControl::Face& aFace);
86 uint32_t Id() { return mId; }
87 uint32_t Score() { return mScore; }
88 bool HasLeftEye() { return mLeftEye; }
89 bool HasRightEye() { return mRightEye; }
90 bool HasMouth() { return mMouth; }
92 dom::DOMRect* Bounds() { return mBounds; }
94 DOMCameraPoint* GetLeftEye() { return mLeftEye; }
95 DOMCameraPoint* GetRightEye() { return mRightEye; }
96 DOMCameraPoint* GetMouth() { return mMouth; }
98 nsISupports*
99 GetParentObject() const
100 {
101 MOZ_ASSERT(mParent);
102 return mParent;
103 }
105 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
107 protected:
108 virtual ~DOMCameraDetectedFace() { }
110 nsCOMPtr<nsISupports> mParent;
112 uint32_t mId;
113 uint32_t mScore;
115 nsRefPtr<dom::DOMRect> mBounds;
117 nsRefPtr<DOMCameraPoint> mLeftEye;
118 nsRefPtr<DOMCameraPoint> mRightEye;
119 nsRefPtr<DOMCameraPoint> mMouth;
120 };
122 } // namespace dom
124 } // namespace mozilla
126 #endif // DOM_CAMERA_DOMCAMERADETECTEDFACE_H