diff --git a/Tests/LibWeb/Text/expected/geometry/dommatrix-create.txt b/Tests/LibWeb/Text/expected/geometry/dommatrix-create.txt
new file mode 100644
index 0000000000..ef3f561853
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/geometry/dommatrix-create.txt
@@ -0,0 +1,4 @@
+1. {"a":10,"b":20,"c":30,"d":40,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+2. {"a":10,"b":20,"c":30,"d":40,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+3. {"a":10,"b":20,"c":50,"d":60,"e":130,"f":140,"m11":10,"m12":20,"m13":30,"m14":40,"m21":50,"m22":60,"m23":70,"m24":80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
+4. {"a":10,"b":20,"c":50,"d":60,"e":130,"f":140,"m11":10,"m12":20,"m13":30,"m14":40,"m21":50,"m22":60,"m23":70,"m24":80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
diff --git a/Tests/LibWeb/Text/expected/geometry/dommatrix-flip.txt b/Tests/LibWeb/Text/expected/geometry/dommatrix-flip.txt
new file mode 100644
index 0000000000..05e63ae186
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/geometry/dommatrix-flip.txt
@@ -0,0 +1,4 @@
+1. {"a":-10,"b":-20,"c":30,"d":40,"e":50,"f":60,"m11":-10,"m12":-20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+2. {"a":-10,"b":-20,"c":50,"d":60,"e":130,"f":140,"m11":-10,"m12":-20,"m13":-30,"m14":-40,"m21":50,"m22":60,"m23":70,"m24":80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
+3. {"a":10,"b":20,"c":-30,"d":-40,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":-30,"m22":-40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+4. {"a":10,"b":20,"c":-50,"d":-60,"e":130,"f":140,"m11":10,"m12":20,"m13":30,"m14":40,"m21":-50,"m22":-60,"m23":-70,"m24":-80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
diff --git a/Tests/LibWeb/Text/expected/geometry/dommatrix-skew.txt b/Tests/LibWeb/Text/expected/geometry/dommatrix-skew.txt
new file mode 100644
index 0000000000..d3309b88b3
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/geometry/dommatrix-skew.txt
@@ -0,0 +1,8 @@
+1. {"a":10,"b":20,"c":31.76326980708465,"d":43.5265396141693,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":31.76326980708465,"m22":43.5265396141693,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+2. {"a":10,"b":20,"c":31.76326980708465,"d":43.5265396141693,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":31.76326980708465,"m22":43.5265396141693,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+3. {"a":10,"b":20,"c":53.63970234266203,"d":67.27940468532405,"e":130,"f":140,"m11":10,"m12":20,"m13":30,"m14":40,"m21":53.63970234266203,"m22":67.27940468532405,"m23":80.91910702798607,"m24":94.55880937064809,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
+4. {"a":10,"b":20,"c":53.63970234266203,"d":67.27940468532405,"e":130,"f":140,"m11":10,"m12":20,"m13":30,"m14":40,"m21":53.63970234266203,"m22":67.27940468532405,"m23":80.91910702798607,"m24":94.55880937064809,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
+5. {"a":15.289809421253949,"b":27.0530792283386,"c":30,"d":40,"e":50,"f":60,"m11":15.289809421253949,"m12":27.0530792283386,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+6. {"a":15.289809421253949,"b":27.0530792283386,"c":30,"d":40,"e":50,"f":60,"m11":15.289809421253949,"m12":27.0530792283386,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+7. {"a":28.19851171331012,"b":41.838214055972145,"c":50,"d":60,"e":130,"f":140,"m11":28.19851171331012,"m12":41.838214055972145,"m13":55.477916398634164,"m14":69.11761874129618,"m21":50,"m22":60,"m23":70,"m24":80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
+8. {"a":28.19851171331012,"b":41.838214055972145,"c":50,"d":60,"e":130,"f":140,"m11":28.19851171331012,"m12":41.838214055972145,"m13":55.477916398634164,"m14":69.11761874129618,"m21":50,"m22":60,"m23":70,"m24":80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
diff --git a/Tests/LibWeb/Text/expected/geometry/dommatrix-translate.txt b/Tests/LibWeb/Text/expected/geometry/dommatrix-translate.txt
new file mode 100644
index 0000000000..d3ca232346
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/geometry/dommatrix-translate.txt
@@ -0,0 +1,6 @@
+1. {"a":10,"b":20,"c":30,"d":40,"e":1050,"f":1560,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":1050,"m42":1560,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+2. {"a":10,"b":20,"c":30,"d":40,"e":1050,"f":1560,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":1050,"m42":1560,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+3. {"a":10,"b":20,"c":30,"d":40,"e":75,"f":85,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":75,"m42":85,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
+4. {"a":10,"b":20,"c":50,"d":60,"e":3130,"f":4140,"m11":10,"m12":20,"m13":30,"m14":40,"m21":50,"m22":60,"m23":70,"m24":80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":3130,"m42":4140,"m43":5150,"m44":6160,"is2D":false,"isIdentity":false}
+5. {"a":10,"b":20,"c":50,"d":60,"e":3130,"f":4140,"m11":10,"m12":20,"m13":30,"m14":40,"m21":50,"m22":60,"m23":70,"m24":80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":3130,"m42":4140,"m43":5150,"m44":6160,"is2D":false,"isIdentity":false}
+6. {"a":2010,"b":2020,"c":4050,"d":4060,"e":8130,"f":8140,"m11":2010,"m12":2020,"m13":30,"m14":40,"m21":4050,"m22":4060,"m23":70,"m24":80,"m31":6090,"m32":6100,"m33":110,"m34":120,"m41":8130,"m42":8140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
diff --git a/Tests/LibWeb/Text/expected/geometry/dommatrix.txt b/Tests/LibWeb/Text/expected/geometry/dommatrix.txt
deleted file mode 100644
index d928e142cc..0000000000
--- a/Tests/LibWeb/Text/expected/geometry/dommatrix.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-1. {"a":10,"b":20,"c":30,"d":40,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-2. {"a":10,"b":20,"c":30,"d":40,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-3. {"a":700,"b":1000,"c":1500,"d":2200,"e":2350,"f":3460,"m11":700,"m12":1000,"m13":0,"m14":0,"m21":1500,"m22":2200,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":2350,"m42":3460,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-4. {"a":1,"b":0,"c":0,"d":1,"e":25,"f":25,"m11":1,"m12":0,"m13":0,"m14":0,"m21":0,"m22":1,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":25,"m42":25,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-5. {"a":10,"b":20,"c":30,"d":40,"e":1050,"f":1560,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":1050,"m42":1560,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-6. {"a":10,"b":20,"c":30,"d":40,"e":1050,"f":1560,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":1050,"m42":1560,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-7. {"a":10,"b":20,"c":30,"d":40,"e":1050,"f":1560,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":1050,"m42":1560,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-8. {"a":10,"b":20,"c":30,"d":40,"e":75,"f":85,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":75,"m42":85,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-9. {"a":10,"b":20,"c":31.76326980708465,"d":43.5265396141693,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":31.76326980708465,"m22":43.5265396141693,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-10. {"a":10,"b":20,"c":31.76326980708465,"d":43.5265396141693,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":31.76326980708465,"m22":43.5265396141693,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-11. {"a":15.289809421253949,"b":27.0530792283386,"c":30,"d":40,"e":50,"f":60,"m11":15.289809421253949,"m12":27.0530792283386,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-12. {"a":15.289809421253949,"b":27.0530792283386,"c":30,"d":40,"e":50,"f":60,"m11":15.289809421253949,"m12":27.0530792283386,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-13. {"a":-10,"b":-20,"c":30,"d":40,"e":50,"f":60,"m11":-10,"m12":-20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
-14. {"a":10,"b":20,"c":-30,"d":-40,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":-30,"m22":-40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
diff --git a/Tests/LibWeb/Text/input/geometry/dommatrix-create.html b/Tests/LibWeb/Text/input/geometry/dommatrix-create.html
new file mode 100644
index 0000000000..1c171dbbed
--- /dev/null
+++ b/Tests/LibWeb/Text/input/geometry/dommatrix-create.html
@@ -0,0 +1,21 @@
+
+
diff --git a/Tests/LibWeb/Text/input/geometry/dommatrix-flip.html b/Tests/LibWeb/Text/input/geometry/dommatrix-flip.html
new file mode 100644
index 0000000000..93c407ca78
--- /dev/null
+++ b/Tests/LibWeb/Text/input/geometry/dommatrix-flip.html
@@ -0,0 +1,21 @@
+
+
diff --git a/Tests/LibWeb/Text/input/geometry/dommatrix-skew.html b/Tests/LibWeb/Text/input/geometry/dommatrix-skew.html
new file mode 100644
index 0000000000..dcf736da9b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/geometry/dommatrix-skew.html
@@ -0,0 +1,33 @@
+
+
diff --git a/Tests/LibWeb/Text/input/geometry/dommatrix-translate.html b/Tests/LibWeb/Text/input/geometry/dommatrix-translate.html
new file mode 100644
index 0000000000..48a6559d28
--- /dev/null
+++ b/Tests/LibWeb/Text/input/geometry/dommatrix-translate.html
@@ -0,0 +1,27 @@
+
+
diff --git a/Tests/LibWeb/Text/input/geometry/dommatrix.html b/Tests/LibWeb/Text/input/geometry/dommatrix.html
deleted file mode 100644
index 9e39d68771..0000000000
--- a/Tests/LibWeb/Text/input/geometry/dommatrix.html
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp
index 6023d77e46..ccad4fe208 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp
@@ -46,6 +46,25 @@ WebIDL::ExceptionOr> DOMMatrix::create_from_dom_matr
return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value());
}
+// https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-dictionary
+WebIDL::ExceptionOr> DOMMatrix::create_from_dom_matrix_init(JS::Realm& realm, DOMMatrixInit& init)
+{
+ // 1. Validate and fixup other.
+ TRY(validate_and_fixup_dom_matrix_init(init));
+
+ // 2. If the is2D dictionary member of other is true.
+ if (init.is2d.has_value() && init.is2d.value()) {
+ // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 6 elements m11, m12, m21, m22, m41 and m42 of other in the given order.
+ return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value());
+ }
+
+ // Otherwise, Return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 16 elements m11, m12, m13, ..., m44 of other in the given order.
+ return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m13, init.m14,
+ init.m21.value(), init.m22.value(), init.m23, init.m24,
+ init.m31, init.m32, init.m33, init.m34,
+ init.m41.value(), init.m42.value(), init.m43, init.m44);
+}
+
JS::NonnullGCPtr DOMMatrix::create_from_dom_matrix_read_only(JS::Realm& realm, DOMMatrixReadOnly const& read_only_matrix)
{
return realm.heap().allocate(realm, realm, read_only_matrix);
@@ -56,6 +75,11 @@ DOMMatrix::DOMMatrix(JS::Realm& realm, double m11, double m12, double m21, doubl
{
}
+DOMMatrix::DOMMatrix(JS::Realm& realm, double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44)
+ : DOMMatrixReadOnly(realm, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)
+{
+}
+
DOMMatrix::DOMMatrix(JS::Realm& realm, Optional>> const& init)
: DOMMatrixReadOnly(realm, init)
{
@@ -77,7 +101,7 @@ void DOMMatrix::initialize(JS::Realm& realm)
// https://drafts.fxtf.org/geometry/#dom-dommatrix-frommatrix
WebIDL::ExceptionOr> DOMMatrix::from_matrix(JS::VM& vm, DOMMatrixInit other)
{
- return create_from_dom_matrix_2d_init(*vm.current_realm(), other);
+ return create_from_dom_matrix_init(*vm.current_realm(), other);
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-m11
@@ -258,7 +282,7 @@ void DOMMatrix::set_f(double value)
WebIDL::ExceptionOr> DOMMatrix::multiply_self(DOMMatrixInit other)
{
// 1. Let otherObject be the result of invoking create a DOMMatrix from the dictionary other.
- auto other_object = TRY(DOMMatrix::create_from_dom_matrix_2d_init(realm(), other));
+ auto other_object = TRY(DOMMatrix::create_from_dom_matrix_init(realm(), other));
// 2. The otherObject matrix gets post-multiplied to the current matrix.
m_matrix = m_matrix * other_object->m_matrix;
@@ -275,7 +299,7 @@ WebIDL::ExceptionOr> DOMMatrix::multiply_self(DOMMat
WebIDL::ExceptionOr> DOMMatrix::pre_multiply_self(DOMMatrixInit other)
{
// 1. Let otherObject be the result of invoking create a DOMMatrix from the dictionary other.
- auto other_object = TRY(DOMMatrix::create_from_dom_matrix_2d_init(realm(), other));
+ auto other_object = TRY(DOMMatrix::create_from_dom_matrix_init(realm(), other));
// 2. The otherObject matrix gets pre-multiplied to the current matrix.
m_matrix = other_object->m_matrix * m_matrix;
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.h b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.h
index 6c840b7e3a..7d99a50305 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.h
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.h
@@ -18,6 +18,7 @@ class DOMMatrix : public DOMMatrixReadOnly {
public:
static WebIDL::ExceptionOr> construct_impl(JS::Realm&, Optional>> const& init);
static WebIDL::ExceptionOr> create_from_dom_matrix_2d_init(JS::Realm&, DOMMatrix2DInit& init);
+ static WebIDL::ExceptionOr> create_from_dom_matrix_init(JS::Realm&, DOMMatrixInit& init);
static JS::NonnullGCPtr create_from_dom_matrix_read_only(JS::Realm&, DOMMatrixReadOnly const& read_only_matrix);
virtual ~DOMMatrix() override;
@@ -57,6 +58,7 @@ public:
private:
DOMMatrix(JS::Realm&, double m11, double m12, double m21, double m22, double m41, double m42);
+ DOMMatrix(JS::Realm&, double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44);
DOMMatrix(JS::Realm&, Optional>> const& init);
DOMMatrix(JS::Realm&, DOMMatrixReadOnly const& read_only_matrix);
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp
index a3d1735c31..4f59e314a0 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp
@@ -48,6 +48,25 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::crea
return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value());
}
+// https://drafts.fxtf.org/geometry/#create-a-dommatrixreadonly-from-the-dictionary
+WebIDL::ExceptionOr> DOMMatrixReadOnly::create_from_dom_matrix_init(JS::Realm& realm, DOMMatrixInit& init)
+{
+ // 1. Validate and fixup other.
+ TRY(validate_and_fixup_dom_matrix_init(init));
+
+ // 2. If the is2D dictionary member of other is true.
+ if (init.is2d.has_value() && init.is2d.value()) {
+ // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 6 elements m11, m12, m21, m22, m41 and m42 of other in the given order.
+ return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value());
+ }
+
+ // Otherwise, Return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 16 elements m11, m12, m13, ..., m44 of other in the given order.
+ return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m13, init.m14,
+ init.m21.value(), init.m22.value(), init.m23, init.m24,
+ init.m31, init.m32, init.m33, init.m34,
+ init.m41.value(), init.m42.value(), init.m43, init.m44);
+}
+
DOMMatrixReadOnly::DOMMatrixReadOnly(JS::Realm& realm, double m11, double m12, double m21, double m22, double m41, double m42)
: Bindings::PlatformObject(realm)
{
@@ -184,7 +203,7 @@ void DOMMatrixReadOnly::initialize_from_create_3d_matrix(double m11, double m12,
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-frommatrix
WebIDL::ExceptionOr> DOMMatrixReadOnly::from_matrix(JS::VM& vm, DOMMatrixInit& other)
{
- return create_from_dom_matrix_2d_init(*vm.current_realm(), other);
+ return create_from_dom_matrix_init(*vm.current_realm(), other);
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-isidentity
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.h
index 41025d20d7..9bd17793ea 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.h
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.h
@@ -51,6 +51,7 @@ class DOMMatrixReadOnly : public Bindings::PlatformObject {
public:
static WebIDL::ExceptionOr> construct_impl(JS::Realm&, Optional>> const& init);
static WebIDL::ExceptionOr> create_from_dom_matrix_2d_init(JS::Realm&, DOMMatrix2DInit& init);
+ static WebIDL::ExceptionOr> create_from_dom_matrix_init(JS::Realm&, DOMMatrixInit& init);
virtual ~DOMMatrixReadOnly() override;