|
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 #include "DOMCameraDetectedFace.h" |
|
6 #include "Navigator.h" |
|
7 |
|
8 using namespace mozilla; |
|
9 using namespace mozilla::dom; |
|
10 |
|
11 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMCameraPoint, mParent) |
|
12 |
|
13 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraPoint) |
|
14 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraPoint) |
|
15 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraPoint) |
|
16 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
|
17 NS_INTERFACE_MAP_ENTRY(nsISupports) |
|
18 NS_INTERFACE_MAP_END |
|
19 |
|
20 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_5(DOMCameraDetectedFace, mParent, |
|
21 mBounds, mLeftEye, mRightEye, mMouth) |
|
22 |
|
23 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraDetectedFace) |
|
24 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraDetectedFace) |
|
25 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace) |
|
26 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
|
27 NS_INTERFACE_MAP_ENTRY(nsISupports) |
|
28 NS_INTERFACE_MAP_END |
|
29 |
|
30 /* static */ |
|
31 bool |
|
32 DOMCameraPoint::HasSupport(JSContext* aCx, JSObject* aGlobal) |
|
33 { |
|
34 return Navigator::HasCameraSupport(aCx, aGlobal); |
|
35 } |
|
36 |
|
37 /* static */ |
|
38 bool |
|
39 DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal) |
|
40 { |
|
41 return Navigator::HasCameraSupport(aCx, aGlobal); |
|
42 } |
|
43 |
|
44 JSObject* |
|
45 DOMCameraPoint::WrapObject(JSContext* aCx) |
|
46 { |
|
47 return CameraPointBinding::Wrap(aCx, this); |
|
48 } |
|
49 |
|
50 JSObject* |
|
51 DOMCameraDetectedFace::WrapObject(JSContext* aCx) |
|
52 { |
|
53 return CameraDetectedFaceBinding::Wrap(aCx, this); |
|
54 } |
|
55 |
|
56 DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent, |
|
57 const ICameraControl::Face& aFace) |
|
58 : mParent(aParent) |
|
59 , mId(aFace.id) |
|
60 , mScore(aFace.score) |
|
61 , mBounds(new DOMRect(MOZ_THIS_IN_INITIALIZER_LIST())) |
|
62 { |
|
63 mBounds->SetRect(aFace.bound.left, |
|
64 aFace.bound.top, |
|
65 aFace.bound.right - aFace.bound.left, |
|
66 aFace.bound.bottom - aFace.bound.top); |
|
67 |
|
68 if (aFace.hasLeftEye) { |
|
69 mLeftEye = new DOMCameraPoint(this, aFace.leftEye); |
|
70 } |
|
71 if (aFace.hasRightEye) { |
|
72 mRightEye = new DOMCameraPoint(this, aFace.rightEye); |
|
73 } |
|
74 if (aFace.hasMouth) { |
|
75 mMouth = new DOMCameraPoint(this, aFace.mouth); |
|
76 } |
|
77 |
|
78 SetIsDOMBinding(); |
|
79 } |