1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +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

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