mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15:35:07 +00:00
LibWeb: Update layout if we lack a node when getting computed style
As noted, there are two situations where an element will have no layout node here: 1. The element is invisible in a way that it generates no layout node. 2. We haven't built the layout yet. This protects against the second case, which would otherwise incorrectly send us down the path of looking directly at the computed style.
This commit is contained in:
parent
642ad80960
commit
c65d6964ea
2 changed files with 5 additions and 2 deletions
|
@ -467,7 +467,10 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
|
|||
if (!m_element->is_connected())
|
||||
return {};
|
||||
|
||||
if (property_affects_layout(property_id)) {
|
||||
// FIXME: Be smarter about updating layout if there's no layout node.
|
||||
// We may legitimately have no layout node if we're not visible, but this protects against situations
|
||||
// where we're requesting the computed style before layout has happened.
|
||||
if (!m_element->layout_node() || property_affects_layout(property_id)) {
|
||||
const_cast<DOM::Document&>(m_element->document()).update_layout();
|
||||
} else {
|
||||
// FIXME: If we had a way to update style for a single element, this would be a good place to use it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue