LibWeb: Make sure layout is up to date in Element::scroll_width()

This commit is contained in:
Aliaksandr Kalenik 2024-02-16 02:27:03 +01:00 committed by Andreas Kling
commit 639e9b5012
Notes: sideshowbarker 2024-07-17 04:57:23 +09:00

View file

@ -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&>(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();