mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Add {,de}serialization steps for DOMMatrix
This commit is contained in:
parent
181424377d
commit
8d2f7cfb58
Notes:
sideshowbarker
2024-07-17 05:00:08 +09:00
Author: https://github.com/kennethmyhra
Commit: 8d2f7cfb58
Pull-request: https://github.com/SerenityOS/serenity/pull/23538
Reviewed-by: https://github.com/ADKaster
5 changed files with 27 additions and 0 deletions
|
@ -9,3 +9,6 @@ File.size: 12
|
|||
instanceOf DOMMatrixReadOnly: true
|
||||
DOMMatrixReadOnly: {"a":1.7976931348623157e+308,"b":2.2250738585072014e-308,"c":2.220446049250313e-16,"d":40,"e":50,"f":60,"m11":1.7976931348623157e+308,"m12":2.2250738585072014e-308,"m13":0,"m14":0,"m21":2.220446049250313e-16,"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}
|
||||
DOMMatrixReadOnly: {"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 DOMMatrix: true
|
||||
DOMMatrix: {"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}
|
||||
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}
|
||||
|
|
|
@ -21,6 +21,12 @@
|
|||
domMatrixReadOnly = structuredClone(new DOMMatrixReadOnly([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]));
|
||||
println(`DOMMatrixReadOnly: ${JSON.stringify(domMatrixReadOnly)}`);
|
||||
|
||||
let domMatrix = structuredClone(new DOMMatrix([10, 20, 30, 40, 50, 60]));
|
||||
println(`instanceOf DOMMatrix: ${domMatrix instanceof DOMMatrix}`);
|
||||
println(`DOMMatrix: ${JSON.stringify(domMatrix)}`);
|
||||
domMatrix = structuredClone(new DOMMatrix([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]));
|
||||
println(`DOMMatrix: ${JSON.stringify(domMatrix)}`);
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -118,6 +118,11 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::create_from_dom_matrix_read_only(JS::Real
|
|||
return realm.heap().allocate<DOMMatrix>(realm, realm, read_only_matrix);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<DOMMatrix>(realm, realm);
|
||||
}
|
||||
|
||||
DOMMatrix::DOMMatrix(JS::Realm& realm, double m11, double m12, double m21, double m22, double m41, double m42)
|
||||
: DOMMatrixReadOnly(realm, m11, m12, m21, m22, m41, m42)
|
||||
{
|
||||
|
@ -133,6 +138,11 @@ DOMMatrix::DOMMatrix(JS::Realm& realm, DOMMatrixReadOnly const& read_only_matrix
|
|||
{
|
||||
}
|
||||
|
||||
DOMMatrix::DOMMatrix(JS::Realm& realm)
|
||||
: DOMMatrixReadOnly(realm)
|
||||
{
|
||||
}
|
||||
|
||||
DOMMatrix::~DOMMatrix() = default;
|
||||
|
||||
void DOMMatrix::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/Serializable.h>
|
||||
#include <LibWeb/Geometry/DOMMatrixReadOnly.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
||||
|
@ -22,6 +23,7 @@ public:
|
|||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> create_from_dom_matrix_2d_init(JS::Realm&, DOMMatrix2DInit& init);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> create_from_dom_matrix_init(JS::Realm&, DOMMatrixInit& init);
|
||||
static JS::NonnullGCPtr<DOMMatrix> create_from_dom_matrix_read_only(JS::Realm&, DOMMatrixReadOnly const& read_only_matrix);
|
||||
static JS::NonnullGCPtr<DOMMatrix> create(JS::Realm&);
|
||||
|
||||
virtual ~DOMMatrix() override;
|
||||
|
||||
|
@ -67,10 +69,13 @@ public:
|
|||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> set_matrix_value(String const& transform_list);
|
||||
|
||||
virtual StringView interface_name() const override { return "DOMMatrix"sv; }
|
||||
|
||||
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&, DOMMatrixReadOnly const& read_only_matrix);
|
||||
explicit DOMMatrix(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <LibWeb/Bindings/Transferable.h>
|
||||
#include <LibWeb/FileAPI/Blob.h>
|
||||
#include <LibWeb/FileAPI/File.h>
|
||||
#include <LibWeb/Geometry/DOMMatrix.h>
|
||||
#include <LibWeb/Geometry/DOMMatrixReadOnly.h>
|
||||
#include <LibWeb/HTML/MessagePort.h>
|
||||
#include <LibWeb/HTML/StructuredSerialize.h>
|
||||
|
@ -966,6 +967,8 @@ private:
|
|||
return FileAPI::File::create(realm);
|
||||
if (interface_name == "DOMMatrixReadOnly"sv)
|
||||
return Geometry::DOMMatrixReadOnly::create(realm);
|
||||
if (interface_name == "DOMMatrix"sv)
|
||||
return Geometry::DOMMatrix::create(realm);
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue