1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/camera/DOMCameraDetectedFace.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,79 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "DOMCameraDetectedFace.h" 1.9 +#include "Navigator.h" 1.10 + 1.11 +using namespace mozilla; 1.12 +using namespace mozilla::dom; 1.13 + 1.14 +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMCameraPoint, mParent) 1.15 + 1.16 +NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraPoint) 1.17 +NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraPoint) 1.18 +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraPoint) 1.19 + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY 1.20 + NS_INTERFACE_MAP_ENTRY(nsISupports) 1.21 +NS_INTERFACE_MAP_END 1.22 + 1.23 +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_5(DOMCameraDetectedFace, mParent, 1.24 + mBounds, mLeftEye, mRightEye, mMouth) 1.25 + 1.26 +NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraDetectedFace) 1.27 +NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraDetectedFace) 1.28 +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace) 1.29 + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY 1.30 + NS_INTERFACE_MAP_ENTRY(nsISupports) 1.31 +NS_INTERFACE_MAP_END 1.32 + 1.33 +/* static */ 1.34 +bool 1.35 +DOMCameraPoint::HasSupport(JSContext* aCx, JSObject* aGlobal) 1.36 +{ 1.37 + return Navigator::HasCameraSupport(aCx, aGlobal); 1.38 +} 1.39 + 1.40 +/* static */ 1.41 +bool 1.42 +DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal) 1.43 +{ 1.44 + return Navigator::HasCameraSupport(aCx, aGlobal); 1.45 +} 1.46 + 1.47 +JSObject* 1.48 +DOMCameraPoint::WrapObject(JSContext* aCx) 1.49 +{ 1.50 + return CameraPointBinding::Wrap(aCx, this); 1.51 +} 1.52 + 1.53 +JSObject* 1.54 +DOMCameraDetectedFace::WrapObject(JSContext* aCx) 1.55 +{ 1.56 + return CameraDetectedFaceBinding::Wrap(aCx, this); 1.57 +} 1.58 + 1.59 +DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent, 1.60 + const ICameraControl::Face& aFace) 1.61 + : mParent(aParent) 1.62 + , mId(aFace.id) 1.63 + , mScore(aFace.score) 1.64 + , mBounds(new DOMRect(MOZ_THIS_IN_INITIALIZER_LIST())) 1.65 +{ 1.66 + mBounds->SetRect(aFace.bound.left, 1.67 + aFace.bound.top, 1.68 + aFace.bound.right - aFace.bound.left, 1.69 + aFace.bound.bottom - aFace.bound.top); 1.70 + 1.71 + if (aFace.hasLeftEye) { 1.72 + mLeftEye = new DOMCameraPoint(this, aFace.leftEye); 1.73 + } 1.74 + if (aFace.hasRightEye) { 1.75 + mRightEye = new DOMCameraPoint(this, aFace.rightEye); 1.76 + } 1.77 + if (aFace.hasMouth) { 1.78 + mMouth = new DOMCameraPoint(this, aFace.mouth); 1.79 + } 1.80 + 1.81 + SetIsDOMBinding(); 1.82 +}