summaryrefslogtreecommitdiff
path: root/dom/base/DOMQuad.cpp
diff options
context:
space:
mode:
authorJob Bautista <jobbautista9@aol.com>2023-05-12 16:07:16 +0800
committerJob Bautista <jobbautista9@aol.com>2023-05-12 16:26:06 +0800
commitecf05312e6e9b13bbf11781acd8e52788a77a943 (patch)
treeeefe95265658a44e86de9557133662fb3ec4743a /dom/base/DOMQuad.cpp
parentc7ca649bd14ddb24ad161c130c372f5979bc7e3c (diff)
downloaduxp-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.cpp26
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,