|
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/. */ |
|
4 |
|
5 #ifndef DOM_CAMERA_DOMCAMERADETECTEDFACE_H |
|
6 #define DOM_CAMERA_DOMCAMERADETECTEDFACE_H |
|
7 |
|
8 #include "mozilla/dom/CameraControlBinding.h" |
|
9 #include "nsCycleCollectionParticipant.h" |
|
10 #include "nsWrapperCache.h" |
|
11 #include "mozilla/dom/DOMRect.h" |
|
12 #include "ICameraControl.h" |
|
13 |
|
14 namespace mozilla { |
|
15 |
|
16 namespace dom { |
|
17 |
|
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) |
|
24 |
|
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); |
|
31 |
|
32 DOMCameraPoint(nsISupports* aParent, const ICameraControl::Point& aPoint) |
|
33 : mParent(aParent) |
|
34 , mX(aPoint.x) |
|
35 , mY(aPoint.y) |
|
36 { |
|
37 SetIsDOMBinding(); |
|
38 } |
|
39 |
|
40 void |
|
41 SetPoint(int32_t aX, int32_t aY) |
|
42 { |
|
43 mX = aX; |
|
44 mY = aY; |
|
45 } |
|
46 |
|
47 int32_t X() { return mX; } |
|
48 int32_t Y() { return mY; } |
|
49 |
|
50 void SetX(int32_t aX) { mX = aX; } |
|
51 void SetY(int32_t aY) { mY = aY; } |
|
52 |
|
53 nsISupports* |
|
54 GetParentObject() const |
|
55 { |
|
56 MOZ_ASSERT(mParent); |
|
57 return mParent; |
|
58 } |
|
59 |
|
60 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
61 |
|
62 protected: |
|
63 virtual ~DOMCameraPoint() { } |
|
64 |
|
65 nsCOMPtr<nsISupports> mParent; |
|
66 int32_t mX; |
|
67 int32_t mY; |
|
68 }; |
|
69 |
|
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) |
|
76 |
|
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); |
|
83 |
|
84 DOMCameraDetectedFace(nsISupports* aParent, const ICameraControl::Face& aFace); |
|
85 |
|
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; } |
|
91 |
|
92 dom::DOMRect* Bounds() { return mBounds; } |
|
93 |
|
94 DOMCameraPoint* GetLeftEye() { return mLeftEye; } |
|
95 DOMCameraPoint* GetRightEye() { return mRightEye; } |
|
96 DOMCameraPoint* GetMouth() { return mMouth; } |
|
97 |
|
98 nsISupports* |
|
99 GetParentObject() const |
|
100 { |
|
101 MOZ_ASSERT(mParent); |
|
102 return mParent; |
|
103 } |
|
104 |
|
105 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
106 |
|
107 protected: |
|
108 virtual ~DOMCameraDetectedFace() { } |
|
109 |
|
110 nsCOMPtr<nsISupports> mParent; |
|
111 |
|
112 uint32_t mId; |
|
113 uint32_t mScore; |
|
114 |
|
115 nsRefPtr<dom::DOMRect> mBounds; |
|
116 |
|
117 nsRefPtr<DOMCameraPoint> mLeftEye; |
|
118 nsRefPtr<DOMCameraPoint> mRightEye; |
|
119 nsRefPtr<DOMCameraPoint> mMouth; |
|
120 }; |
|
121 |
|
122 } // namespace dom |
|
123 |
|
124 } // namespace mozilla |
|
125 |
|
126 #endif // DOM_CAMERA_DOMCAMERADETECTEDFACE_H |