From 7dcbb403bb2b7d8f31698557a5b5eeaa279c1c47 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 11 Oct 2022 12:05:36 +0200 Subject: [PATCH] LibWeb: Update layout in Element.getClientRects() We always have to flush any pending layout updates before inspecting the layout tree. --- Userland/Libraries/LibWeb/DOM/Element.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 000e750013..4b72d7cb8c 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -600,6 +600,9 @@ JS::NonnullGCPtr Element::get_client_rects() const { Vector> rects; + // NOTE: Ensure that layout is up-to-date before looking at metrics. + const_cast(document()).update_layout(); + // 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(realm(), move(rects));