summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h
blob: be5819b57f87a7fc9669ae12367091623bf951ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibGfx/Point.h>
#include <LibWeb/Bindings/PlatformObject.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 {
    WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);

public:
    static JS::NonnullGCPtr<DOMPointReadOnly> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);

    static JS::NonnullGCPtr<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; }

protected:
    DOMPointReadOnly(JS::Realm&, double x, double y, double z, double w);

    virtual void initialize(JS::Realm&) override;

    double m_x;
    double m_y;
    double m_z;
    double m_w;
};

}