diff --git a/Tests/LibWeb/Text/expected/HTML/StructuredClone-serializable-objects.txt b/Tests/LibWeb/Text/expected/HTML/StructuredClone-serializable-objects.txt index 00c29cc79ea..69492c908a9 100644 --- a/Tests/LibWeb/Text/expected/HTML/StructuredClone-serializable-objects.txt +++ b/Tests/LibWeb/Text/expected/HTML/StructuredClone-serializable-objects.txt @@ -14,3 +14,5 @@ DOMMatrix: {"a":10,"b":20,"c":30,"d":40,"e":50,"f":60,"m11":10,"m12":20,"m13":0, DOMMatrix: {"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} instanceOf DOMPointReadOnly: true DOMPointReadOnly: {"x":10,"y":20,"z":30,"w":40} +instanceOf DOMPoint: true +DOMPoint: {"x":10,"y":20,"z":30,"w":40} diff --git a/Tests/LibWeb/Text/input/HTML/StructuredClone-serializable-objects.html b/Tests/LibWeb/Text/input/HTML/StructuredClone-serializable-objects.html index 1e626668a2a..439ac8e5ea6 100644 --- a/Tests/LibWeb/Text/input/HTML/StructuredClone-serializable-objects.html +++ b/Tests/LibWeb/Text/input/HTML/StructuredClone-serializable-objects.html @@ -31,6 +31,10 @@ println(`instanceOf DOMPointReadOnly: ${domPointReadOnly instanceof DOMPointReadOnly}`); println(`DOMPointReadOnly: ${JSON.stringify(domPointReadOnly)}`); + let domPoint = structuredClone(new DOMPoint(10, 20, 30, 40)); + println(`instanceOf DOMPoint: ${domPoint instanceof DOMPoint}`); + println(`DOMPoint: ${JSON.stringify(domPoint)}`); + done(); }); diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp index c77c2eaf906..655d523cb61 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -17,11 +17,21 @@ JS::NonnullGCPtr DOMPoint::construct_impl(JS::Realm& realm, double x, return realm.heap().allocate(realm, realm, x, y, z, w); } +JS::NonnullGCPtr DOMPoint::create(JS::Realm& realm) +{ + return realm.heap().allocate(realm, realm); +} + DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w) : DOMPointReadOnly(realm, x, y, z, w) { } +DOMPoint::DOMPoint(JS::Realm& realm) + : DOMPointReadOnly(realm) +{ +} + // https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint JS::NonnullGCPtr DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other) { diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h index 57db6e154f5..2c238e66e74 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h @@ -18,6 +18,7 @@ class DOMPoint final : public DOMPointReadOnly { public: static JS::NonnullGCPtr construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1); + static JS::NonnullGCPtr create(JS::Realm&); static JS::NonnullGCPtr from_point(JS::VM&, DOMPointInit const&); @@ -33,8 +34,11 @@ public: void set_z(double z) { m_z = z; } void set_w(double w) { m_w = w; } + virtual StringView interface_name() const override { return "DOMPoint"sv; } + private: DOMPoint(JS::Realm&, double x, double y, double z, double w); + DOMPoint(JS::Realm&); virtual void initialize(JS::Realm&) override; }; diff --git a/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp index 523bb581015..ecb4341af79 100644 --- a/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp +++ b/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -972,6 +973,8 @@ private: return Geometry::DOMMatrix::create(realm); if (interface_name == "DOMPointReadOnly"sv) return Geometry::DOMPointReadOnly::create(realm); + if (interface_name == "DOMPoint"sv) + return Geometry::DOMPoint::create(realm); VERIFY_NOT_REACHED(); }