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

LibWeb: Update layout in Element.client{Left,Top}

We have to flush any pending layout changes before getting metrics.
This commit is contained in:
Andreas Kling 2022-09-09 15:01:28 +02:00
parent 67b3af8025
commit b7d8fbbd70

View file

@ -603,6 +603,9 @@ JS::NonnullGCPtr<Geometry::DOMRectList> Element::get_client_rects() const
int Element::client_top() const
{
// NOTE: Ensure that layout is up-to-date before looking at metrics.
const_cast<Document&>(document()).update_layout();
// 1. If the element has no associated CSS layout box or if the CSS layout box is inline, return zero.
if (!layout_node() || !layout_node()->is_box())
return 0;
@ -616,6 +619,9 @@ int Element::client_top() const
// https://drafts.csswg.org/cssom-view/#dom-element-clientleft
int Element::client_left() const
{
// NOTE: Ensure that layout is up-to-date before looking at metrics.
const_cast<Document&>(document()).update_layout();
// 1. If the element has no associated CSS layout box or if the CSS layout box is inline, return zero.
if (!layout_node() || !layout_node()->is_box())
return 0;