2022-07-12 20:06:50 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-10-06 15:25:08 +01:00
|
|
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
2024-03-09 23:02:22 +01:00
|
|
|
* Copyright (c) 2024, Kenneth Myhra <kennethmyhra@serenityos.org>
|
2022-07-12 20:06:50 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibGfx/Point.h>
|
2022-09-03 21:32:14 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2024-03-09 23:02:22 +01:00
|
|
|
#include <LibWeb/Bindings/Serializable.h>
|
2022-07-12 20:06:50 +02:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
|
|
|
namespace Web::Geometry {
|
|
|
|
|
2022-10-06 15:25:08 +01:00
|
|
|
struct DOMPointInit {
|
|
|
|
double x { 0 };
|
|
|
|
double y { 0 };
|
|
|
|
double z { 0 };
|
|
|
|
double w { 1 };
|
|
|
|
};
|
|
|
|
|
2022-07-12 20:06:50 +02:00
|
|
|
// https://drafts.fxtf.org/geometry/#dompointreadonly
|
2024-03-09 23:02:22 +01:00
|
|
|
class DOMPointReadOnly
|
|
|
|
: public Bindings::PlatformObject
|
|
|
|
, public Bindings::Serializable {
|
2022-09-03 21:32:14 +02:00
|
|
|
WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(DOMPointReadOnly);
|
2022-07-12 20:06:50 +02:00
|
|
|
|
2022-09-03 21:32:14 +02:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
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&);
|
2022-07-12 20:06:50 +02:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
static GC::Ref<DOMPointReadOnly> from_point(JS::VM&, DOMPointInit const&);
|
2022-10-06 15:25:08 +01:00
|
|
|
|
2022-09-03 21:32:14 +02:00
|
|
|
virtual ~DOMPointReadOnly() override;
|
2022-07-12 20:06:50 +02:00
|
|
|
|
|
|
|
double x() const { return m_x; }
|
|
|
|
double y() const { return m_y; }
|
|
|
|
double z() const { return m_z; }
|
|
|
|
double w() const { return m_w; }
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
WebIDL::ExceptionOr<GC::Ref<DOMPoint>> matrix_transform(DOMMatrixInit&) const;
|
2023-08-15 13:16:45 +02:00
|
|
|
|
2025-07-14 17:15:09 +01:00
|
|
|
virtual HTML::SerializeType serialize_type() const override { return HTML::SerializeType::DOMPointReadOnly; }
|
2025-07-17 09:51:04 -04:00
|
|
|
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;
|
2024-03-09 23:02:22 +01:00
|
|
|
|
2022-07-12 20:06:50 +02:00
|
|
|
protected:
|
2022-09-25 18:03:02 -06:00
|
|
|
DOMPointReadOnly(JS::Realm&, double x, double y, double z, double w);
|
2024-03-09 23:02:22 +01:00
|
|
|
explicit DOMPointReadOnly(JS::Realm&);
|
2022-07-12 20:06:50 +02:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2022-07-12 20:06:50 +02:00
|
|
|
double m_x;
|
|
|
|
double m_y;
|
|
|
|
double m_z;
|
|
|
|
double m_w;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|