diff options
author | Job Bautista <jobbautista9@aol.com> | 2023-05-12 16:07:16 +0800 |
---|---|---|
committer | Job Bautista <jobbautista9@aol.com> | 2023-05-12 16:26:06 +0800 |
commit | ecf05312e6e9b13bbf11781acd8e52788a77a943 (patch) | |
tree | eefe95265658a44e86de9557133662fb3ec4743a /dom/base/DOMQuad.cpp | |
parent | c7ca649bd14ddb24ad161c130c372f5979bc7e3c (diff) | |
download | uxp-ecf05312e6e9b13bbf11781acd8e52788a77a943.tar.gz |
Issue #2241 - Part 7.2: Implement .fromRect and .fromQuad.
Backported from Mozilla bug 1558101.
Diffstat (limited to 'dom/base/DOMQuad.cpp')
-rw-r--r-- | dom/base/DOMQuad.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/dom/base/DOMQuad.cpp b/dom/base/DOMQuad.cpp index 8457d9ddaa..258bfc1bfd 100644 --- a/dom/base/DOMQuad.cpp +++ b/dom/base/DOMQuad.cpp @@ -44,6 +44,32 @@ DOMQuad::WrapObject(JSContext* aCx, JS::Handle<JSObject*> 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> DOMQuad::Constructor(const GlobalObject& aGlobal, const DOMPointInit& aP1, const DOMPointInit& aP2, |