Skip to content

Commit c65d696

Browse files
AtkinsSJawesomekling
authored andcommitted
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.
1 parent 642ad80 commit c65d696

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0 calc(5px - 10px) 0 calc(2px + 3px) => #000000ff 0px calc(5px + (0 - 10px)) 0px calc(2px + 3px)
1+
0 calc(5px - 10px) 0 calc(2px + 3px) => #000000ff 0px -5px 0px 5px

Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,10 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
467467
if (!m_element->is_connected())
468468
return {};
469469

470-
if (property_affects_layout(property_id)) {
470+
// FIXME: Be smarter about updating layout if there's no layout node.
471+
// We may legitimately have no layout node if we're not visible, but this protects against situations
472+
// where we're requesting the computed style before layout has happened.
473+
if (!m_element->layout_node() || property_affects_layout(property_id)) {
471474
const_cast<DOM::Document&>(m_element->document()).update_layout();
472475
} else {
473476
// FIXME: If we had a way to update style for a single element, this would be a good place to use it.

0 commit comments

Comments
 (0)