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

LibWeb: Use Layout::Box::paint_box() accessor in more places

This commit is contained in:
Andreas Kling 2022-03-10 15:50:16 +01:00
parent 02b316fd5c
commit 9461e44afa
22 changed files with 60 additions and 61 deletions

View file

@ -429,15 +429,14 @@ bool Element::serializes_as_void() const
NonnullRefPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
{
// FIXME: Support inline layout nodes as well.
if (!layout_node() || !layout_node()->is_box())
auto* paint_box = this->paint_box();
if (!paint_box)
return Geometry::DOMRect::create(0, 0, 0, 0);
VERIFY(document().browsing_context());
auto viewport_offset = document().browsing_context()->viewport_scroll_offset();
auto& box = static_cast<Layout::Box const&>(*layout_node());
return Geometry::DOMRect::create(box.m_paint_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()));
return Geometry::DOMRect::create(paint_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()));
}
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects