From 639e9b50127d6ed5913882f5dcb7f014c8aa449e Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Fri, 16 Feb 2024 02:27:03 +0100 Subject: [PATCH] LibWeb: Make sure layout is up to date in Element::scroll_width() --- 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 cb7cc71367..3ac1e1fd1b 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1371,6 +1371,9 @@ int Element::scroll_width() const if (!document.is_active()) return 0; + // NOTE: Ensure that layout is up-to-date before looking at metrics. + const_cast(document).update_layout(); + // 3. Let viewport width be the width of the viewport excluding the width of the scroll bar, if any, // or zero if there is no viewport. auto viewport_width = document.viewport_rect().width().to_int();