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