mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 999464 - Standardize on DOMPoint and thus eliminate need for CameraPoint. r=bz, r=mikeh
This commit is contained in:
parent
5a4d32915c
commit
9349cde661
@ -195,11 +195,6 @@ DOMInterfaces = {
|
||||
'headerFile': 'DOMCameraManager.h'
|
||||
},
|
||||
|
||||
'CameraPoint': {
|
||||
'nativeType': 'mozilla::dom::DOMCameraPoint',
|
||||
'headerFile': 'DOMCameraDetectedFace.h'
|
||||
},
|
||||
|
||||
'CanvasRenderingContext2D': {
|
||||
'implicitJSContext': [
|
||||
'createImageData', 'getImageData'
|
||||
|
@ -8,15 +8,6 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMCameraPoint, mParent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraPoint)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraPoint)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraPoint)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMCameraDetectedFace, mParent,
|
||||
mBounds, mLeftEye, mRightEye, mMouth)
|
||||
|
||||
@ -27,13 +18,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
/* static */
|
||||
bool
|
||||
DOMCameraPoint::HasSupport(JSContext* aCx, JSObject* aGlobal)
|
||||
{
|
||||
return Navigator::HasCameraSupport(aCx, aGlobal);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal)
|
||||
@ -41,12 +25,6 @@ DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal)
|
||||
return Navigator::HasCameraSupport(aCx, aGlobal);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMCameraPoint::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return CameraPointBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMCameraDetectedFace::WrapObject(JSContext* aCx)
|
||||
{
|
||||
@ -66,13 +44,13 @@ DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent,
|
||||
aFace.bound.bottom - aFace.bound.top);
|
||||
|
||||
if (aFace.hasLeftEye) {
|
||||
mLeftEye = new DOMCameraPoint(this, aFace.leftEye);
|
||||
mLeftEye = new DOMPoint(this, aFace.leftEye.x, aFace.leftEye.y);
|
||||
}
|
||||
if (aFace.hasRightEye) {
|
||||
mRightEye = new DOMCameraPoint(this, aFace.rightEye);
|
||||
mRightEye = new DOMPoint(this, aFace.rightEye.x, aFace.rightEye.y);
|
||||
}
|
||||
if (aFace.hasMouth) {
|
||||
mMouth = new DOMCameraPoint(this, aFace.mouth);
|
||||
mMouth = new DOMPoint(this, aFace.mouth.x, aFace.mouth.y);
|
||||
}
|
||||
|
||||
SetIsDOMBinding();
|
||||
|
@ -9,64 +9,13 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "mozilla/dom/DOMPoint.h"
|
||||
#include "ICameraControl.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
|
||||
class DOMCameraPoint MOZ_FINAL : public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCameraPoint)
|
||||
|
||||
// Because this header's filename doesn't match its C++ or DOM-facing
|
||||
// classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
|
||||
// include the right header for us; instead we must explicitly include a
|
||||
// HasSupport() method in each header. We can get rid of these with the
|
||||
// Great Renaming proposed in bug 983177.
|
||||
static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
DOMCameraPoint(nsISupports* aParent, const ICameraControl::Point& aPoint)
|
||||
: mParent(aParent)
|
||||
, mX(aPoint.x)
|
||||
, mY(aPoint.y)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
void
|
||||
SetPoint(int32_t aX, int32_t aY)
|
||||
{
|
||||
mX = aX;
|
||||
mY = aY;
|
||||
}
|
||||
|
||||
int32_t X() { return mX; }
|
||||
int32_t Y() { return mY; }
|
||||
|
||||
void SetX(int32_t aX) { mX = aX; }
|
||||
void SetY(int32_t aY) { mY = aY; }
|
||||
|
||||
nsISupports*
|
||||
GetParentObject() const
|
||||
{
|
||||
MOZ_ASSERT(mParent);
|
||||
return mParent;
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual ~DOMCameraPoint() { }
|
||||
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
int32_t mX;
|
||||
int32_t mY;
|
||||
};
|
||||
|
||||
class DOMCameraDetectedFace MOZ_FINAL : public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
@ -91,9 +40,9 @@ public:
|
||||
|
||||
dom::DOMRect* Bounds() { return mBounds; }
|
||||
|
||||
DOMCameraPoint* GetLeftEye() { return mLeftEye; }
|
||||
DOMCameraPoint* GetRightEye() { return mRightEye; }
|
||||
DOMCameraPoint* GetMouth() { return mMouth; }
|
||||
dom::DOMPoint* GetLeftEye() { return mLeftEye; }
|
||||
dom::DOMPoint* GetRightEye() { return mRightEye; }
|
||||
dom::DOMPoint* GetMouth() { return mMouth; }
|
||||
|
||||
nsISupports*
|
||||
GetParentObject() const
|
||||
@ -114,9 +63,9 @@ protected:
|
||||
|
||||
nsRefPtr<dom::DOMRect> mBounds;
|
||||
|
||||
nsRefPtr<DOMCameraPoint> mLeftEye;
|
||||
nsRefPtr<DOMCameraPoint> mRightEye;
|
||||
nsRefPtr<DOMCameraPoint> mMouth;
|
||||
nsRefPtr<dom::DOMPoint> mLeftEye;
|
||||
nsRefPtr<dom::DOMPoint> mRightEye;
|
||||
nsRefPtr<dom::DOMPoint> mMouth;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -175,8 +175,6 @@ var interfaceNamesInGlobalScope =
|
||||
{name: "CameraDetectedFace", b2g: true, pref: "camera.control.face_detection.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "CameraManager", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "CameraPoint", b2g: true, pref: "camera.control.face_detection.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"CanvasGradient",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
@ -366,19 +366,6 @@ interface CameraControl : MediaStream
|
||||
void resumeContinuousFocus();
|
||||
};
|
||||
|
||||
/* The coordinates of a point, relative to the camera sensor, of the center of
|
||||
detected facial features. As with CameraRegions:
|
||||
{ x: -1000, y: -1000 } is the top-left corner
|
||||
{ x: 1000, y: 1000 } is the bottom-right corner
|
||||
x and y can range from -1000 to 1000.
|
||||
*/
|
||||
[Pref="camera.control.face_detection.enabled", Func="DOMCameraPoint::HasSupport"]
|
||||
interface CameraPoint
|
||||
{
|
||||
attribute long x;
|
||||
attribute long y;
|
||||
};
|
||||
|
||||
/* The information of the each face detected by a camera device, e.g.
|
||||
{
|
||||
id: 1,
|
||||
@ -408,13 +395,16 @@ interface CameraPoint
|
||||
'leftEye' is the coordinates of the centre of the left eye. The coordinates
|
||||
are in the same space as the ones for 'bounds'. This is an optional field
|
||||
and may not be supported on all devices. If it is not supported or detected,
|
||||
the value will be set to null.
|
||||
the value will be set to null. The x and y coordinates are bounded by the
|
||||
range (-1000, 1000) where:
|
||||
{ x: -1000, y: -1000 } is the top-left corner
|
||||
{ x: 1000, y: 1000 } is the bottom-right corner
|
||||
|
||||
'rightEye' is the coordinates of the detected right eye; null if not
|
||||
supported or detected.
|
||||
supported or detected. Same boundary conditions as 'leftEye'.
|
||||
|
||||
'mouth' is the coordinates of the detected mouth; null if not supported or
|
||||
detected.
|
||||
detected. Same boundary conditions as 'leftEye'.
|
||||
*/
|
||||
[Pref="camera.control.face_detection.enabled", Func="DOMCameraDetectedFace::HasSupport"]
|
||||
interface CameraDetectedFace
|
||||
@ -426,13 +416,13 @@ interface CameraDetectedFace
|
||||
readonly attribute DOMRect bounds;
|
||||
|
||||
readonly attribute boolean hasLeftEye;
|
||||
readonly attribute CameraPoint? leftEye;
|
||||
readonly attribute DOMPoint? leftEye;
|
||||
|
||||
readonly attribute boolean hasRightEye;
|
||||
readonly attribute CameraPoint? rightEye;
|
||||
readonly attribute DOMPoint? rightEye;
|
||||
|
||||
readonly attribute boolean hasMouth;
|
||||
readonly attribute CameraPoint? mouth;
|
||||
readonly attribute DOMPoint? mouth;
|
||||
};
|
||||
|
||||
callback CameraFaceDetectionCallback = void (sequence<CameraDetectedFace> faces);
|
||||
|
Loading…
x
Reference in New Issue
Block a user