LibWeb: Optimize style invalidation for presentational hint attributes

Use invalidation sets for presentational hint attribute invalidation
instead of falling back to full descendants and siblings invalidation.
The only difference for presentational hint attributes is that we always
have to invalidate the style of element itself.
This commit is contained in:
Aliaksandr Kalenik 2025-01-21 16:40:57 +01:00 committed by Andreas Kling
parent f3f1db7725
commit 3c41bdbf92
Notes: github-actions[bot] 2025-01-21 20:08:52 +00:00

View file

@ -1970,13 +1970,12 @@ ErrorOr<void> Element::scroll_into_view(Optional<Variant<bool, ScrollIntoViewOpt
void Element::invalidate_style_after_attribute_change(FlyString const& attribute_name, Optional<String> const& old_value, Optional<String> const& new_value) void Element::invalidate_style_after_attribute_change(FlyString const& attribute_name, Optional<String> const& old_value, Optional<String> const& new_value)
{ {
Vector<CSS::InvalidationSet::Property, 1> changed_properties;
ForceSelfStyleInvalidation force_self_invalidation = ForceSelfStyleInvalidation::No;
if (is_presentational_hint(attribute_name)) { if (is_presentational_hint(attribute_name)) {
invalidate_style(StyleInvalidationReason::ElementAttributeChange); force_self_invalidation = ForceSelfStyleInvalidation::Yes;
return;
} }
Vector<CSS::InvalidationSet::Property> changed_properties;
ForceSelfStyleInvalidation force_self_invalidation = ForceSelfStyleInvalidation::No;
if (attribute_name == HTML::AttributeNames::style) { if (attribute_name == HTML::AttributeNames::style) {
force_self_invalidation = ForceSelfStyleInvalidation::Yes; force_self_invalidation = ForceSelfStyleInvalidation::Yes;
changed_properties.append({ .type = CSS::InvalidationSet::Property::Type::Attribute, .value = HTML::AttributeNames::style }); changed_properties.append({ .type = CSS::InvalidationSet::Property::Type::Attribute, .value = HTML::AttributeNames::style });