1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:47:45 +00:00

LibWeb: Implement DOMRect(ReadOnly)#fromRect

This will also be used by IntersectionObserver.
This commit is contained in:
Luke Wilde 2023-07-06 23:21:20 +01:00 committed by Andreas Kling
parent 1d426df262
commit 6f8afd8cd9
6 changed files with 35 additions and 0 deletions

View file

@ -20,6 +20,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> DOMRect::create(JS::Realm& realm,
return construct_impl(realm, rect.x(), rect.y(), rect.width(), rect.height());
}
// https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> DOMRect::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other)
{
auto& realm = *vm.current_realm();
return MUST_OR_THROW_OOM(realm.heap().allocate<DOMRect>(realm, realm, other.x, other.y, other.width, other.height));
}
DOMRect::DOMRect(JS::Realm& realm, double x, double y, double width, double height)
: DOMRectReadOnly(realm, x, y, width, height)
{