/src/serenity/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> |
3 | | * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org> |
4 | | * |
5 | | * SPDX-License-Identifier: BSD-2-Clause |
6 | | */ |
7 | | |
8 | | #include <LibWeb/Bindings/DOMPointPrototype.h> |
9 | | #include <LibWeb/Bindings/Intrinsics.h> |
10 | | #include <LibWeb/Geometry/DOMPoint.h> |
11 | | |
12 | | namespace Web::Geometry { |
13 | | |
14 | | JS_DEFINE_ALLOCATOR(DOMPoint); |
15 | | |
16 | | JS::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w) |
17 | 0 | { |
18 | 0 | return realm.heap().allocate<DOMPoint>(realm, realm, x, y, z, w); |
19 | 0 | } |
20 | | |
21 | | JS::NonnullGCPtr<DOMPoint> DOMPoint::create(JS::Realm& realm) |
22 | 0 | { |
23 | 0 | return realm.heap().allocate<DOMPoint>(realm, realm); |
24 | 0 | } |
25 | | |
26 | | DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w) |
27 | 0 | : DOMPointReadOnly(realm, x, y, z, w) |
28 | 0 | { |
29 | 0 | } |
30 | | |
31 | | DOMPoint::DOMPoint(JS::Realm& realm) |
32 | 0 | : DOMPointReadOnly(realm) |
33 | 0 | { |
34 | 0 | } |
35 | | |
36 | | // https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint |
37 | | JS::NonnullGCPtr<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other) |
38 | 0 | { |
39 | | // The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other. |
40 | 0 | return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w); |
41 | 0 | } |
42 | | |
43 | 0 | DOMPoint::~DOMPoint() = default; |
44 | | |
45 | | void DOMPoint::initialize(JS::Realm& realm) |
46 | 0 | { |
47 | 0 | Base::initialize(realm); |
48 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(DOMPoint); |
49 | 0 | } |
50 | | |
51 | | } |