2022-09-03 16:32:14 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-10-06 11:25:08 -03:00
|
|
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
2022-09-03 16:32:14 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2026-04-18 05:54:06 -03:00
|
|
|
#include <LibWeb/Bindings/DOMPoint.h>
|
2026-05-01 14:01:23 -03:00
|
|
|
#include <LibWeb/Bindings/DOMPointReadOnly.h>
|
2022-09-25 21:03:02 -03:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2022-09-03 16:32:14 -03:00
|
|
|
#include <LibWeb/Geometry/DOMPoint.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Geometry {
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(DOMPoint);
|
2023-11-19 15:47:52 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
|
2022-09-25 21:03:02 -03:00
|
|
|
{
|
2024-11-13 13:50:17 -03:00
|
|
|
return realm.create<DOMPoint>(realm, x, y, z, w);
|
2022-09-25 21:03:02 -03:00
|
|
|
}
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<DOMPoint> DOMPoint::create(JS::Realm& realm)
|
2024-03-09 19:10:11 -03:00
|
|
|
{
|
2024-11-13 13:50:17 -03:00
|
|
|
return realm.create<DOMPoint>(realm);
|
2024-03-09 19:10:11 -03:00
|
|
|
}
|
|
|
|
|
|
2022-09-25 21:03:02 -03:00
|
|
|
DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w)
|
|
|
|
|
: DOMPointReadOnly(realm, x, y, z, w)
|
2022-09-03 16:32:14 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-09 19:10:11 -03:00
|
|
|
DOMPoint::DOMPoint(JS::Realm& realm)
|
|
|
|
|
: DOMPointReadOnly(realm)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 11:25:08 -03:00
|
|
|
// https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
|
2026-05-01 14:01:23 -03:00
|
|
|
GC::Ref<DOMPoint> DOMPoint::from_point(JS::VM& vm, Bindings::DOMPointInit const& other)
|
2022-10-06 11:25:08 -03:00
|
|
|
{
|
|
|
|
|
// The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other.
|
2023-08-15 08:16:09 -03:00
|
|
|
return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
|
2022-10-06 11:25:08 -03:00
|
|
|
}
|
|
|
|
|
|
2022-09-03 16:32:14 -03:00
|
|
|
DOMPoint::~DOMPoint() = default;
|
|
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
void DOMPoint::initialize(JS::Realm& realm)
|
2023-01-10 08:28:20 -03:00
|
|
|
{
|
2024-03-16 09:13:08 -03:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(DOMPoint);
|
2025-04-20 11:22:57 -03:00
|
|
|
Base::initialize(realm);
|
2023-01-10 08:28:20 -03:00
|
|
|
}
|
|
|
|
|
|
2022-09-03 16:32:14 -03:00
|
|
|
}
|