2022-09-04 01:59:58 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2022-09-25 18:03:02 -06:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2022-09-04 01:59:58 +02:00
|
|
|
#include <LibWeb/Geometry/DOMRectReadOnly.h>
|
2023-02-19 18:31:05 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2022-09-04 01:59:58 +02:00
|
|
|
|
|
|
|
namespace Web::Geometry {
|
|
|
|
|
2023-02-19 18:31:05 +01:00
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRectReadOnly>> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
|
2022-09-04 01:59:58 +02:00
|
|
|
{
|
2023-08-13 13:05:26 +02:00
|
|
|
return realm.heap().allocate<DOMRectReadOnly>(realm, realm, x, y, width, height);
|
2022-09-04 01:59:58 +02:00
|
|
|
}
|
|
|
|
|
2023-07-06 23:21:20 +01:00
|
|
|
// https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary
|
2023-08-13 13:05:26 +02:00
|
|
|
JS::NonnullGCPtr<DOMRectReadOnly> DOMRectReadOnly::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other)
|
2023-07-06 23:21:20 +01:00
|
|
|
{
|
|
|
|
auto& realm = *vm.current_realm();
|
2023-08-13 13:05:26 +02:00
|
|
|
return realm.heap().allocate<DOMRectReadOnly>(realm, realm, other.x, other.y, other.width, other.height);
|
2023-07-06 23:21:20 +01:00
|
|
|
}
|
|
|
|
|
2022-09-25 18:03:02 -06:00
|
|
|
DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double width, double height)
|
|
|
|
: PlatformObject(realm)
|
2022-09-04 01:59:58 +02:00
|
|
|
, m_rect(x, y, width, height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMRectReadOnly::~DOMRectReadOnly() = default;
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
void DOMRectReadOnly::initialize(JS::Realm& realm)
|
2023-01-10 06:28:20 -05:00
|
|
|
{
|
2023-08-07 08:41:28 +02:00
|
|
|
Base::initialize(realm);
|
2023-01-10 06:28:20 -05:00
|
|
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMRectReadOnlyPrototype>(realm, "DOMRectReadOnly"));
|
|
|
|
}
|
|
|
|
|
2022-09-04 01:59:58 +02:00
|
|
|
}
|