From 04311ca7f115a33aa9891b7146407ed8fee3b726 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 9 Mar 2022 17:51:02 +0100 Subject: [PATCH] LibWeb: Flush pending layouts when accessing element resolved style We were handing out stale values from window.getComputedStyle() objects after the first layout. Fix this by always updating layout on property access. This is not necessary for all properties, but for now let's go with the simplest approach to make it work correctly. --- Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 88b255fb65..296bc7ab6e 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -772,7 +772,8 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: Optional ResolvedCSSStyleDeclaration::property(PropertyID property_id) const { - const_cast(m_element->document()).ensure_layout(); + // FIXME: Only update layout if required to resolve the property we're accessing. + const_cast(m_element->document()).update_layout(); if (!m_element->layout_node()) { auto style = m_element->document().style_computer().compute_style(const_cast(*m_element));