dom/camera/DOMCameraDetectedFace.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "DOMCameraDetectedFace.h"
michael@0 6 #include "Navigator.h"
michael@0 7
michael@0 8 using namespace mozilla;
michael@0 9 using namespace mozilla::dom;
michael@0 10
michael@0 11 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMCameraPoint, mParent)
michael@0 12
michael@0 13 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraPoint)
michael@0 14 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraPoint)
michael@0 15 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraPoint)
michael@0 16 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
michael@0 17 NS_INTERFACE_MAP_ENTRY(nsISupports)
michael@0 18 NS_INTERFACE_MAP_END
michael@0 19
michael@0 20 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_5(DOMCameraDetectedFace, mParent,
michael@0 21 mBounds, mLeftEye, mRightEye, mMouth)
michael@0 22
michael@0 23 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraDetectedFace)
michael@0 24 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraDetectedFace)
michael@0 25 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace)
michael@0 26 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
michael@0 27 NS_INTERFACE_MAP_ENTRY(nsISupports)
michael@0 28 NS_INTERFACE_MAP_END
michael@0 29
michael@0 30 /* static */
michael@0 31 bool
michael@0 32 DOMCameraPoint::HasSupport(JSContext* aCx, JSObject* aGlobal)
michael@0 33 {
michael@0 34 return Navigator::HasCameraSupport(aCx, aGlobal);
michael@0 35 }
michael@0 36
michael@0 37 /* static */
michael@0 38 bool
michael@0 39 DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal)
michael@0 40 {
michael@0 41 return Navigator::HasCameraSupport(aCx, aGlobal);
michael@0 42 }
michael@0 43
michael@0 44 JSObject*
michael@0 45 DOMCameraPoint::WrapObject(JSContext* aCx)
michael@0 46 {
michael@0 47 return CameraPointBinding::Wrap(aCx, this);
michael@0 48 }
michael@0 49
michael@0 50 JSObject*
michael@0 51 DOMCameraDetectedFace::WrapObject(JSContext* aCx)
michael@0 52 {
michael@0 53 return CameraDetectedFaceBinding::Wrap(aCx, this);
michael@0 54 }
michael@0 55
michael@0 56 DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent,
michael@0 57 const ICameraControl::Face& aFace)
michael@0 58 : mParent(aParent)
michael@0 59 , mId(aFace.id)
michael@0 60 , mScore(aFace.score)
michael@0 61 , mBounds(new DOMRect(MOZ_THIS_IN_INITIALIZER_LIST()))
michael@0 62 {
michael@0 63 mBounds->SetRect(aFace.bound.left,
michael@0 64 aFace.bound.top,
michael@0 65 aFace.bound.right - aFace.bound.left,
michael@0 66 aFace.bound.bottom - aFace.bound.top);
michael@0 67
michael@0 68 if (aFace.hasLeftEye) {
michael@0 69 mLeftEye = new DOMCameraPoint(this, aFace.leftEye);
michael@0 70 }
michael@0 71 if (aFace.hasRightEye) {
michael@0 72 mRightEye = new DOMCameraPoint(this, aFace.rightEye);
michael@0 73 }
michael@0 74 if (aFace.hasMouth) {
michael@0 75 mMouth = new DOMCameraPoint(this, aFace.mouth);
michael@0 76 }
michael@0 77
michael@0 78 SetIsDOMBinding();
michael@0 79 }

mercurial