From 6ddc582551977ad4f70c794b7f11c453af35e4ca Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 15 Jul 2025 19:01:26 +0200 Subject: [PATCH] LibWeb: Delete unreachable code in `Node::invalidate_style()` `if (invalidation_set.needs_invalidate_whole_subtree())` branch in the end of the function was always false. --- Libraries/LibWeb/DOM/Node.cpp | 52 +++++++++++------------------------ 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index 186060e21ea..8184a96bfc1 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -508,53 +508,33 @@ void Node::invalidate_style(StyleInvalidationReason reason, Vector(node); - bool needs_style_recalculation = false; - if (invalidation_set.needs_invalidate_whole_subtree()) { - VERIFY_NOT_REACHED(); - } - - if (element.includes_properties_from_invalidation_set(invalidation_set)) { - needs_style_recalculation = true; - } else if (options.invalidate_elements_that_use_css_custom_properties && element.style_uses_css_custom_properties()) { - needs_style_recalculation = true; - } - if (needs_style_recalculation) - element.set_needs_style_update(true); + for_each_shadow_including_inclusive_descendant([&](Node& node) { + if (!node.is_element()) return TraversalDecision::Continue; - }); - }; - - invalidate_entire_subtree(*this); - - if (invalidation_set.needs_invalidate_whole_subtree()) { - for (auto* sibling = next_sibling(); sibling; sibling = sibling->next_sibling()) { - if (sibling->is_element()) - invalidate_entire_subtree(*sibling); + auto& element = static_cast(node); + bool needs_style_recalculation = false; + if (element.includes_properties_from_invalidation_set(invalidation_set)) { + needs_style_recalculation = true; + } else if (options.invalidate_elements_that_use_css_custom_properties && element.style_uses_css_custom_properties()) { + needs_style_recalculation = true; } - } + if (needs_style_recalculation) + element.set_needs_style_update(true); + return TraversalDecision::Continue; + }); } String Node::child_text_content() const