mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +09:00
Issue #2241 - Part 7.2: Implement .fromRect and .fromQuad.
Backported from Mozilla bug 1558101.
This commit is contained in:
parent
0e2f687f4d
commit
4ec35fdcf2
6 changed files with 68 additions and 4 deletions
|
|
@ -43,6 +43,32 @@ DOMQuad::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||||
return DOMQuadBinding::Wrap(aCx, this, aGivenProto);
|
return DOMQuadBinding::Wrap(aCx, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
already_AddRefed<DOMQuad>
|
||||||
|
DOMQuad::FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit)
|
||||||
|
{
|
||||||
|
nsISupports* parent = aGlobal.GetAsSupports();
|
||||||
|
RefPtr<DOMQuad> obj = new DOMQuad(parent);
|
||||||
|
obj->mPoints[0] = new DOMPoint(parent, aInit.mX, aInit.mY, 0, 1);
|
||||||
|
obj->mPoints[1] =
|
||||||
|
new DOMPoint(parent, aInit.mX + aInit.mWidth, aInit.mY, 0, 1);
|
||||||
|
obj->mPoints[2] = new DOMPoint(parent, aInit.mX + aInit.mWidth,
|
||||||
|
aInit.mY + aInit.mHeight, 0, 1);
|
||||||
|
obj->mPoints[3] =
|
||||||
|
new DOMPoint(parent, aInit.mX, aInit.mY + aInit.mHeight, 0, 1);
|
||||||
|
return obj.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<DOMQuad>
|
||||||
|
DOMQuad::FromQuad(const GlobalObject& aGlobal, const DOMQuadInit& aInit)
|
||||||
|
{
|
||||||
|
RefPtr<DOMQuad> obj = new DOMQuad(aGlobal.GetAsSupports());
|
||||||
|
obj->mPoints[0] = DOMPoint::FromPoint(aGlobal, aInit.mP1);
|
||||||
|
obj->mPoints[1] = DOMPoint::FromPoint(aGlobal, aInit.mP2);
|
||||||
|
obj->mPoints[2] = DOMPoint::FromPoint(aGlobal, aInit.mP3);
|
||||||
|
obj->mPoints[3] = DOMPoint::FromPoint(aGlobal, aInit.mP4);
|
||||||
|
return obj.forget();
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<DOMQuad>
|
already_AddRefed<DOMQuad>
|
||||||
DOMQuad::Constructor(const GlobalObject& aGlobal,
|
DOMQuad::Constructor(const GlobalObject& aGlobal,
|
||||||
const DOMPointInit& aP1,
|
const DOMPointInit& aP1,
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ class DOMRectReadOnly;
|
||||||
class DOMPoint;
|
class DOMPoint;
|
||||||
struct DOMQuadJSON;
|
struct DOMQuadJSON;
|
||||||
struct DOMPointInit;
|
struct DOMPointInit;
|
||||||
|
struct DOMQuadInit;
|
||||||
|
|
||||||
class DOMQuad final : public nsWrapperCache
|
class DOMQuad final : public nsWrapperCache
|
||||||
{
|
{
|
||||||
|
|
@ -38,6 +39,12 @@ public:
|
||||||
nsISupports* GetParentObject() const { return mParent; }
|
nsISupports* GetParentObject() const { return mParent; }
|
||||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||||
|
|
||||||
|
static already_AddRefed<DOMQuad>
|
||||||
|
FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit);
|
||||||
|
|
||||||
|
static already_AddRefed<DOMQuad>
|
||||||
|
FromQuad(const GlobalObject& aGlobal, const DOMQuadInit& aInit);
|
||||||
|
|
||||||
static already_AddRefed<DOMQuad>
|
static already_AddRefed<DOMQuad>
|
||||||
Constructor(const GlobalObject& aGlobal,
|
Constructor(const GlobalObject& aGlobal,
|
||||||
const DOMPointInit& aP1,
|
const DOMPointInit& aP1,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ DOMRectReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||||
return DOMRectReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
return DOMRectReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
already_AddRefed<DOMRectReadOnly>
|
||||||
|
DOMRectReadOnly::FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit)
|
||||||
|
{
|
||||||
|
RefPtr<DOMRectReadOnly> obj = new DOMRectReadOnly(
|
||||||
|
aGlobal.GetAsSupports(), aInit.mX, aInit.mY, aInit.mWidth, aInit.mHeight);
|
||||||
|
return obj.forget();
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<DOMRectReadOnly>
|
already_AddRefed<DOMRectReadOnly>
|
||||||
DOMRectReadOnly::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
DOMRectReadOnly::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||||
double aWidth, double aHeight, ErrorResult& aRv)
|
double aWidth, double aHeight, ErrorResult& aRv)
|
||||||
|
|
@ -98,6 +106,14 @@ DOMRect::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||||
return DOMRectBinding::Wrap(aCx, this, aGivenProto);
|
return DOMRectBinding::Wrap(aCx, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
already_AddRefed<DOMRect>
|
||||||
|
DOMRect::FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit)
|
||||||
|
{
|
||||||
|
RefPtr<DOMRect> obj = new DOMRect(aGlobal.GetAsSupports(), aInit.mX, aInit.mY,
|
||||||
|
aInit.mWidth, aInit.mHeight);
|
||||||
|
return obj.forget();
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<DOMRect>
|
already_AddRefed<DOMRect>
|
||||||
DOMRect::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
DOMRect::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||||
double aWidth, double aHeight, ErrorResult& aRv)
|
double aWidth, double aHeight, ErrorResult& aRv)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ struct nsRect;
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
|
struct DOMRectInit;
|
||||||
|
|
||||||
class DOMRectReadOnly : public nsISupports
|
class DOMRectReadOnly : public nsISupports
|
||||||
, public nsWrapperCache
|
, public nsWrapperCache
|
||||||
{
|
{
|
||||||
|
|
@ -50,6 +52,9 @@ public:
|
||||||
}
|
}
|
||||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||||
|
|
||||||
|
static already_AddRefed<DOMRectReadOnly>
|
||||||
|
FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit);
|
||||||
|
|
||||||
static already_AddRefed<DOMRectReadOnly>
|
static already_AddRefed<DOMRectReadOnly>
|
||||||
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||||
double aWidth, double aHeight, ErrorResult& aRv);
|
double aWidth, double aHeight, ErrorResult& aRv);
|
||||||
|
|
@ -114,6 +119,9 @@ public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
NS_DECL_NSIDOMCLIENTRECT
|
NS_DECL_NSIDOMCLIENTRECT
|
||||||
|
|
||||||
|
static already_AddRefed<DOMRect>
|
||||||
|
FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit);
|
||||||
|
|
||||||
static already_AddRefed<DOMRect>
|
static already_AddRefed<DOMRect>
|
||||||
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||||
double aWidth, double aHeight, ErrorResult& aRv);
|
double aWidth, double aHeight, ErrorResult& aRv);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@
|
||||||
Constructor(DOMRectReadOnly rect),
|
Constructor(DOMRectReadOnly rect),
|
||||||
Exposed=(Window,Worker)]
|
Exposed=(Window,Worker)]
|
||||||
interface DOMQuad {
|
interface DOMQuad {
|
||||||
|
[NewObject] static DOMQuad fromRect(optional DOMRectInit other);
|
||||||
|
[NewObject] static DOMQuad fromQuad(optional DOMQuadInit other);
|
||||||
|
|
||||||
[SameObject] readonly attribute DOMPoint p1;
|
[SameObject] readonly attribute DOMPoint p1;
|
||||||
[SameObject] readonly attribute DOMPoint p2;
|
[SameObject] readonly attribute DOMPoint p2;
|
||||||
[SameObject] readonly attribute DOMPoint p3;
|
[SameObject] readonly attribute DOMPoint p3;
|
||||||
|
|
@ -34,8 +37,8 @@ dictionary DOMQuadJSON {
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary DOMQuadInit {
|
dictionary DOMQuadInit {
|
||||||
DOMPointInit p1;
|
DOMPointInit p1 = null;
|
||||||
DOMPointInit p2;
|
DOMPointInit p2 = null;
|
||||||
DOMPointInit p3;
|
DOMPointInit p3 = null;
|
||||||
DOMPointInit p4;
|
DOMPointInit p4 = null;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
optional unrestricted double width = 0, optional unrestricted double height = 0),
|
optional unrestricted double width = 0, optional unrestricted double height = 0),
|
||||||
Exposed=(Window,Worker)]
|
Exposed=(Window,Worker)]
|
||||||
interface DOMRect : DOMRectReadOnly {
|
interface DOMRect : DOMRectReadOnly {
|
||||||
|
[NewObject] static DOMRect fromRect(optional DOMRectInit other);
|
||||||
|
|
||||||
inherit attribute unrestricted double x;
|
inherit attribute unrestricted double x;
|
||||||
inherit attribute unrestricted double y;
|
inherit attribute unrestricted double y;
|
||||||
inherit attribute unrestricted double width;
|
inherit attribute unrestricted double width;
|
||||||
|
|
@ -24,6 +26,8 @@ interface DOMRect : DOMRectReadOnly {
|
||||||
optional unrestricted double width = 0, optional unrestricted double height = 0),
|
optional unrestricted double width = 0, optional unrestricted double height = 0),
|
||||||
Exposed=(Window,Worker)]
|
Exposed=(Window,Worker)]
|
||||||
interface DOMRectReadOnly {
|
interface DOMRectReadOnly {
|
||||||
|
[NewObject] static DOMRectReadOnly fromRect(optional DOMRectInit other);
|
||||||
|
|
||||||
readonly attribute unrestricted double x;
|
readonly attribute unrestricted double x;
|
||||||
readonly attribute unrestricted double y;
|
readonly attribute unrestricted double y;
|
||||||
readonly attribute unrestricted double width;
|
readonly attribute unrestricted double width;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue