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.
This commit is contained in:
parent
3259b17a6a
commit
04311ca7f1
Notes:
sideshowbarker
2024-07-17 17:39:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/04311ca7f1
1 changed files with 2 additions and 1 deletions
|
@ -772,7 +772,8 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
|
|||
|
||||
Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID property_id) const
|
||||
{
|
||||
const_cast<DOM::Document&>(m_element->document()).ensure_layout();
|
||||
// FIXME: Only update layout if required to resolve the property we're accessing.
|
||||
const_cast<DOM::Document&>(m_element->document()).update_layout();
|
||||
|
||||
if (!m_element->layout_node()) {
|
||||
auto style = m_element->document().style_computer().compute_style(const_cast<DOM::Element&>(*m_element));
|
||||
|
|
Loading…
Add table
Reference in a new issue