mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-21 16:32:34 +00:00
Our structured serialization implementation had its own bespoke encoder and decoder to serialize JS values. It also used a u32 buffer under the hood, which made using its structures a bit awkward. We had previously worked around its data structures in transferable streams, which nested transfers of MessagePort instances. We basically had to add hooks into the MessagePort to route to the correct transfer receiving steps, and we could not invoke the correct AOs directly as the spec dictates. We now use IPC mechanics to encode and decode data. This works because, although we are encoding JS values, we are only ultimately encoding primitive and basic AK types. The resulting data structures actually enforce that we implement transferable streams exactly as the spec is worded (I had planned to do that in a separate commit, but the fallout of this patch actually required that change).
63 lines
1.9 KiB
C++
63 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
|
* Copyright (c) 2024, Kenneth Myhra <kennethmyhra@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGfx/Point.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/Bindings/Serializable.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::Geometry {
|
|
|
|
struct DOMPointInit {
|
|
double x { 0 };
|
|
double y { 0 };
|
|
double z { 0 };
|
|
double w { 1 };
|
|
};
|
|
|
|
// https://drafts.fxtf.org/geometry/#dompointreadonly
|
|
class DOMPointReadOnly
|
|
: public Bindings::PlatformObject
|
|
, public Bindings::Serializable {
|
|
WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
|
|
GC_DECLARE_ALLOCATOR(DOMPointReadOnly);
|
|
|
|
public:
|
|
static GC::Ref<DOMPointReadOnly> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
|
|
static GC::Ref<DOMPointReadOnly> create(JS::Realm&);
|
|
|
|
static GC::Ref<DOMPointReadOnly> from_point(JS::VM&, DOMPointInit const&);
|
|
|
|
virtual ~DOMPointReadOnly() override;
|
|
|
|
double x() const { return m_x; }
|
|
double y() const { return m_y; }
|
|
double z() const { return m_z; }
|
|
double w() const { return m_w; }
|
|
|
|
WebIDL::ExceptionOr<GC::Ref<DOMPoint>> matrix_transform(DOMMatrixInit&) const;
|
|
|
|
virtual HTML::SerializeType serialize_type() const override { return HTML::SerializeType::DOMPointReadOnly; }
|
|
virtual WebIDL::ExceptionOr<void> serialization_steps(HTML::TransferDataEncoder&, bool for_storage, HTML::SerializationMemory&) override;
|
|
virtual WebIDL::ExceptionOr<void> deserialization_steps(HTML::TransferDataDecoder&, HTML::DeserializationMemory&) override;
|
|
|
|
protected:
|
|
DOMPointReadOnly(JS::Realm&, double x, double y, double z, double w);
|
|
explicit DOMPointReadOnly(JS::Realm&);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
double m_x;
|
|
double m_y;
|
|
double m_z;
|
|
double m_w;
|
|
};
|
|
|
|
}
|