1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

LibWeb: Remove unecessary dependence on Window from Geometry classes

These classes only needed Window to get at its realm. Pass a realm
directly to construct Geometry classes.
This commit is contained in:
Andrew Kaster 2022-09-25 18:03:02 -06:00 committed by Linus Groh
parent f0c5f77f99
commit 62a8c26b73
11 changed files with 51 additions and 44 deletions

View file

@ -587,12 +587,12 @@ JS::NonnullGCPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
// FIXME: Support inline layout nodes as well.
auto* paint_box = this->paint_box();
if (!paint_box)
return Geometry::DOMRect::create_with_global_object(window(), 0, 0, 0, 0);
return Geometry::DOMRect::construct_impl(realm(), 0, 0, 0, 0);
VERIFY(document().browsing_context());
auto viewport_offset = document().browsing_context()->viewport_scroll_offset();
return Geometry::DOMRect::create(window(), paint_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()));
return Geometry::DOMRect::create(realm(), paint_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()));
}
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
@ -602,7 +602,7 @@ JS::NonnullGCPtr<Geometry::DOMRectList> Element::get_client_rects() const
// 1. If the element on which it was invoked does not have an associated layout box return an empty DOMRectList object and stop this algorithm.
if (!layout_node() || !layout_node()->is_box())
return Geometry::DOMRectList::create(window(), move(rects));
return Geometry::DOMRectList::create(realm(), move(rects));
// FIXME: 2. If the element has an associated SVG layout box return a DOMRectList object containing a single DOMRect object that describes
// the bounding box of the element as defined by the SVG specification, applying the transforms that apply to the element and its ancestors.
@ -616,7 +616,7 @@ JS::NonnullGCPtr<Geometry::DOMRectList> Element::get_client_rects() const
auto bounding_rect = get_bounding_client_rect();
rects.append(*bounding_rect);
return Geometry::DOMRectList::create(window(), move(rects));
return Geometry::DOMRectList::create(realm(), move(rects));
}
int Element::client_top() const