2014-04-09 08:52:10 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "DOMCameraDetectedFace.h"
|
2014-04-09 08:53:34 -07:00
|
|
|
#include "Navigator.h"
|
2014-04-09 08:52:10 -07:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2014-04-29 01:57:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMCameraDetectedFace, mParent,
|
|
|
|
mBounds, mLeftEye, mRightEye, mMouth)
|
2014-04-09 08:52:10 -07:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraDetectedFace)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraDetectedFace)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-09 08:53:34 -07:00
|
|
|
/* static */
|
|
|
|
bool
|
|
|
|
DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal)
|
|
|
|
{
|
|
|
|
return Navigator::HasCameraSupport(aCx, aGlobal);
|
|
|
|
}
|
|
|
|
|
2014-04-09 08:52:10 -07:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
DOMCameraDetectedFace::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2014-04-09 08:52:10 -07:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
return CameraDetectedFaceBinding::Wrap(aCx, this, aGivenProto);
|
2014-04-09 08:52:10 -07:00
|
|
|
}
|
|
|
|
|
2015-03-01 10:48:37 -08:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<DOMCameraDetectedFace>
|
|
|
|
DOMCameraDetectedFace::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const dom::CameraDetectedFaceInit& aFace,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2015-03-03 09:37:30 -08:00
|
|
|
nsRefPtr<DOMCameraDetectedFace> face =
|
|
|
|
new DOMCameraDetectedFace(aGlobal.GetAsSupports(), aFace);
|
2015-03-01 10:48:37 -08:00
|
|
|
return face.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent,
|
|
|
|
const dom::CameraDetectedFaceInit& aFace)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mId(aFace.mId)
|
|
|
|
, mScore(aFace.mScore)
|
|
|
|
, mBounds(new DOMRect(this))
|
|
|
|
{
|
|
|
|
mBounds->SetRect(aFace.mBounds.mLeft,
|
|
|
|
aFace.mBounds.mTop,
|
|
|
|
aFace.mBounds.mRight - aFace.mBounds.mLeft,
|
|
|
|
aFace.mBounds.mBottom - aFace.mBounds.mTop);
|
|
|
|
|
|
|
|
if (aFace.mHasLeftEye) {
|
|
|
|
mLeftEye = new DOMPoint(this, aFace.mLeftEye.mX, aFace.mLeftEye.mY);
|
|
|
|
}
|
|
|
|
if (aFace.mHasRightEye) {
|
|
|
|
mRightEye = new DOMPoint(this, aFace.mRightEye.mX, aFace.mRightEye.mY);
|
|
|
|
}
|
|
|
|
if (aFace.mHasMouth) {
|
|
|
|
mMouth = new DOMPoint(this, aFace.mMouth.mX, aFace.mMouth.mY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-09 08:52:10 -07:00
|
|
|
DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent,
|
|
|
|
const ICameraControl::Face& aFace)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mId(aFace.id)
|
|
|
|
, mScore(aFace.score)
|
2015-01-06 21:39:46 -08:00
|
|
|
, mBounds(new DOMRect(this))
|
2014-04-09 08:52:10 -07:00
|
|
|
{
|
|
|
|
mBounds->SetRect(aFace.bound.left,
|
|
|
|
aFace.bound.top,
|
|
|
|
aFace.bound.right - aFace.bound.left,
|
|
|
|
aFace.bound.bottom - aFace.bound.top);
|
|
|
|
|
|
|
|
if (aFace.hasLeftEye) {
|
2014-05-01 12:09:00 -07:00
|
|
|
mLeftEye = new DOMPoint(this, aFace.leftEye.x, aFace.leftEye.y);
|
2014-04-09 08:52:10 -07:00
|
|
|
}
|
|
|
|
if (aFace.hasRightEye) {
|
2014-05-01 12:09:00 -07:00
|
|
|
mRightEye = new DOMPoint(this, aFace.rightEye.x, aFace.rightEye.y);
|
2014-04-09 08:52:10 -07:00
|
|
|
}
|
|
|
|
if (aFace.hasMouth) {
|
2014-05-01 12:09:00 -07:00
|
|
|
mMouth = new DOMPoint(this, aFace.mouth.x, aFace.mouth.y);
|
2014-04-09 08:52:10 -07:00
|
|
|
}
|
|
|
|
}
|