michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "DOMCameraDetectedFace.h" michael@0: #include "Navigator.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::dom; michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMCameraPoint, mParent) michael@0: michael@0: NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraPoint) michael@0: NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraPoint) michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraPoint) michael@0: NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY michael@0: NS_INTERFACE_MAP_ENTRY(nsISupports) michael@0: NS_INTERFACE_MAP_END michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_5(DOMCameraDetectedFace, mParent, michael@0: mBounds, mLeftEye, mRightEye, mMouth) michael@0: michael@0: NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraDetectedFace) michael@0: NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraDetectedFace) michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace) michael@0: NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY michael@0: NS_INTERFACE_MAP_ENTRY(nsISupports) michael@0: NS_INTERFACE_MAP_END michael@0: michael@0: /* static */ michael@0: bool michael@0: DOMCameraPoint::HasSupport(JSContext* aCx, JSObject* aGlobal) michael@0: { michael@0: return Navigator::HasCameraSupport(aCx, aGlobal); michael@0: } michael@0: michael@0: /* static */ michael@0: bool michael@0: DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal) michael@0: { michael@0: return Navigator::HasCameraSupport(aCx, aGlobal); michael@0: } michael@0: michael@0: JSObject* michael@0: DOMCameraPoint::WrapObject(JSContext* aCx) michael@0: { michael@0: return CameraPointBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: JSObject* michael@0: DOMCameraDetectedFace::WrapObject(JSContext* aCx) michael@0: { michael@0: return CameraDetectedFaceBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent, michael@0: const ICameraControl::Face& aFace) michael@0: : mParent(aParent) michael@0: , mId(aFace.id) michael@0: , mScore(aFace.score) michael@0: , mBounds(new DOMRect(MOZ_THIS_IN_INITIALIZER_LIST())) michael@0: { michael@0: mBounds->SetRect(aFace.bound.left, michael@0: aFace.bound.top, michael@0: aFace.bound.right - aFace.bound.left, michael@0: aFace.bound.bottom - aFace.bound.top); michael@0: michael@0: if (aFace.hasLeftEye) { michael@0: mLeftEye = new DOMCameraPoint(this, aFace.leftEye); michael@0: } michael@0: if (aFace.hasRightEye) { michael@0: mRightEye = new DOMCameraPoint(this, aFace.rightEye); michael@0: } michael@0: if (aFace.hasMouth) { michael@0: mMouth = new DOMCameraPoint(this, aFace.mouth); michael@0: } michael@0: michael@0: SetIsDOMBinding(); michael@0: }