From 89319cd0c9608e16511bb609adb7f83cc5bbdd07 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Fri, 16 Feb 2024 02:28:00 +0100 Subject: [PATCH] LibWeb: Make sure layout is up to date in Element::scroll_height() --- 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 3ac1e1fd1b..fbbfa0e0ba 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1407,6 +1407,9 @@ int Element::scroll_height() 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 height be the height of the viewport excluding the height of the scroll bar, if any, // or zero if there is no viewport. auto viewport_height = document.viewport_rect().height().to_int();