From e068ff5a5d99635552f61a941443c9f3f99a6885 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 12 Apr 2025 22:45:25 +0200 Subject: [PATCH] LibWeb: Always store ComputedProperties, even if no invalidations Before this change, we'd skip storing the new ComputedProperties in Element::recompute_style() if there was no invalidation needed. This caused us to lose the information about which properties are inherited and/or important (which is also carried by ComputedProperties, but doesn't affect invalidation). Consequently, we'd then fail to recompute inherited styles, since that mechanism depends on this data. The fix is simply to always store the new ComputedProperties. --- Libraries/LibWeb/DOM/Element.cpp | 3 +- .../wpt-import/css/css-box/inheritance.txt | 30 ++++++++++++++++ .../wpt-import/css/css-box/inheritance.html | 35 +++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-box/inheritance.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-box/inheritance.html diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 0f238ed60d4..3db8cdf39e8 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -539,8 +539,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() auto old_display_is_none = m_computed_properties ? m_computed_properties->display().is_none() : true; auto new_display_is_none = new_computed_properties->display().is_none(); - if (!invalidation.is_none()) - set_computed_properties(move(new_computed_properties)); + set_computed_properties(move(new_computed_properties)); if (old_display_is_none != new_display_is_none) { play_or_cancel_animations_after_display_property_change(); diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-box/inheritance.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-box/inheritance.txt new file mode 100644 index 00000000000..a1a76604dba --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-box/inheritance.txt @@ -0,0 +1,30 @@ +Harness status: OK + +Found 24 tests + +22 Pass +2 Fail +Pass Property clear has initial value none +Pass Property clear does not inherit +Pass Property float has initial value none +Pass Property float does not inherit +Pass Property margin-bottom has initial value 0px +Pass Property margin-bottom does not inherit +Pass Property margin-left has initial value 0px +Pass Property margin-left does not inherit +Pass Property margin-right has initial value 0px +Pass Property margin-right does not inherit +Pass Property margin-top has initial value 0px +Pass Property margin-top does not inherit +Fail Property margin-trim has initial value none +Fail Property margin-trim does not inherit +Pass Property padding-bottom has initial value 0px +Pass Property padding-bottom does not inherit +Pass Property padding-left has initial value 0px +Pass Property padding-left does not inherit +Pass Property padding-right has initial value 0px +Pass Property padding-right does not inherit +Pass Property padding-top has initial value 0px +Pass Property padding-top does not inherit +Pass Property visibility has initial value visible +Pass Property visibility inherits \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-box/inheritance.html b/Tests/LibWeb/Text/input/wpt-import/css/css-box/inheritance.html new file mode 100644 index 00000000000..bfa0997845e --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-box/inheritance.html @@ -0,0 +1,35 @@ + + + + +Inheritance of CSS Box Model properties + + + + + + + + + +
+
+
+ + +