diff --git a/Libraries/LibWeb/CSS/StyleInvalidation.cpp b/Libraries/LibWeb/CSS/StyleInvalidation.cpp index a97667f4480..d8897b2d335 100644 --- a/Libraries/LibWeb/CSS/StyleInvalidation.cpp +++ b/Libraries/LibWeb/CSS/StyleInvalidation.cpp @@ -15,7 +15,7 @@ namespace Web::CSS { -static bool is_stacking_context_creating_value(CSS::PropertyID property_id, RefPtr const& value) +static bool is_stacking_context_creating_value(CSS::PropertyID property_id, StyleValue const* value) { if (!value) return false; @@ -59,12 +59,14 @@ static bool is_stacking_context_creating_value(CSS::PropertyID property_id, RefP } } -RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, ValueComparingRefPtr const& old_value, ValueComparingRefPtr const& new_value) +RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, StyleValue const* old_value, StyleValue const* new_value) { RequiredInvalidationAfterStyleChange invalidation; if (old_value == new_value) return invalidation; + if (old_value && new_value && old_value->equals(*new_value)) + return invalidation; // NOTE: If the computed CSS display, position, content, or content-visibility property changes, we have to rebuild the entire layout tree. // In the future, we should figure out ways to rebuild a smaller part of the tree. diff --git a/Libraries/LibWeb/CSS/StyleInvalidation.h b/Libraries/LibWeb/CSS/StyleInvalidation.h index 87f63e3860a..ba72d151f22 100644 --- a/Libraries/LibWeb/CSS/StyleInvalidation.h +++ b/Libraries/LibWeb/CSS/StyleInvalidation.h @@ -31,6 +31,6 @@ struct RequiredInvalidationAfterStyleChange { static RequiredInvalidationAfterStyleChange full() { return { true, true, true, true, false }; } }; -RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, ValueComparingRefPtr const& old_value, ValueComparingRefPtr const& new_value); +RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, StyleValue const* old_value, StyleValue const* new_value); } diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 0a6ad8e3ebf..5d3c32ad603 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -850,8 +850,11 @@ static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation(C for (auto i = to_underlying(CSS::first_longhand_property_id); i <= to_underlying(CSS::last_longhand_property_id); ++i) { auto property_id = static_cast(i); - - invalidation |= CSS::compute_property_invalidation(property_id, old_style.property(property_id), new_style.property(property_id)); + auto const& old_value = old_style.property(property_id); + auto const& new_value = new_style.property(property_id); + if (&old_value == &new_value) + continue; + invalidation |= CSS::compute_property_invalidation(property_id, &old_value, &new_value); } // NB: Even if the computed value hasn't changed the resolved counter style may have (e.g. if the relevant @@ -1068,7 +1071,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_inherited_style() RefPtr new_value = CSS::StyleComputer::get_non_animated_inherit_value(property_id, { *this }); computed_properties->set_property(property_id, *new_value, CSS::ComputedProperties::Inherited::Yes); - invalidation |= CSS::compute_property_invalidation(property_id, old_value, computed_properties->property(property_id)); + invalidation |= CSS::compute_property_invalidation(property_id, old_value.ptr(), &computed_properties->property(property_id)); } if (invalidation.is_none() && property_values_affected_by_inherited_style.is_empty()) @@ -1080,7 +1083,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_inherited_style() for (auto const& [property_id, old_value] : property_values_affected_by_inherited_style) { auto const& new_value = computed_properties->property(static_cast(property_id)); - invalidation |= CSS::compute_property_invalidation(static_cast(property_id), old_value, new_value); + invalidation |= CSS::compute_property_invalidation(static_cast(property_id), old_value.ptr(), &new_value); } if (invalidation.is_none())