diff --git a/Tests/LibWeb/Text/expected/geometry/dommatrix.txt b/Tests/LibWeb/Text/expected/geometry/dommatrix.txt
new file mode 100644
index 0000000000..773fe501de
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/geometry/dommatrix.txt
@@ -0,0 +1,2 @@
+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}
diff --git a/Tests/LibWeb/Text/input/geometry/dommatrix.html b/Tests/LibWeb/Text/input/geometry/dommatrix.html
new file mode 100644
index 0000000000..920300bd74
--- /dev/null
+++ b/Tests/LibWeb/Text/input/geometry/dommatrix.html
@@ -0,0 +1,15 @@
+
+
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp
index 59ad0fd126..e20b7e1fed 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp
@@ -73,6 +73,12 @@ void DOMMatrix::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype(realm, "DOMMatrix"));
}
+// 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);
+}
+
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-m11
void DOMMatrix::set_m11(double value)
{
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.h b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.h
index c9372f2ff8..9fa47d9f90 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.h
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.h
@@ -21,6 +21,8 @@ public:
virtual ~DOMMatrix() override;
+ static WebIDL::ExceptionOr> from_matrix(JS::VM&, DOMMatrixInit other = {});
+
void set_m11(double value);
void set_m12(double value);
void set_m13(double value);
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.idl b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.idl
index cd72719f33..579d7b3d12 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.idl
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.idl
@@ -6,7 +6,7 @@
interface DOMMatrix : DOMMatrixReadOnly {
constructor(optional (DOMString or sequence) init);
- // FIXME: [NewObject] static DOMMatrix fromMatrix(optional DOMMatrixInit other = {});
+ [NewObject] static DOMMatrix fromMatrix(optional DOMMatrixInit other = {});
// FIXME: [NewObject] static DOMMatrix fromFloat32Array(Float32Array array32);
// FIXME: [NewObject] static DOMMatrix fromFloat64Array(Float64Array array64);
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp
index acc69aac2b..96fd291f6b 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp
@@ -180,6 +180,12 @@ void DOMMatrixReadOnly::initialize_from_create_3d_matrix(double m11, double m12,
// 4. Return matrix
}
+// 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);
+}
+
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-isidentity
bool DOMMatrixReadOnly::is_identity() const
{
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.h
index 5e7ed1a5b7..e045de0d49 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.h
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.h
@@ -53,6 +53,8 @@ public:
virtual ~DOMMatrixReadOnly() override;
+ static WebIDL::ExceptionOr> from_matrix(JS::VM&, DOMMatrixInit& other);
+
// https://drafts.fxtf.org/geometry/#dommatrix-attributes
double m11() const { return m_matrix.elements()[0][0]; }
double m12() const { return m_matrix.elements()[1][0]; }
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.idl b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.idl
index 0471e524ff..d757df0658 100644
--- a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.idl
+++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.idl
@@ -6,7 +6,7 @@
interface DOMMatrixReadOnly {
constructor(optional (DOMString or sequence) init);
- // FIXME: [NewObject] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other = {});
+ [NewObject] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other = {});
// FIXME: [NewObject] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32);
// FIXME: [NewObject] static DOMMatrixReadOnly fromFloat64Array(Float64Array array64);