From 3c41bdbf9211c2722b45495932549a153c57a284 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 21 Jan 2025 16:40:57 +0100 Subject: [PATCH] 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. --- Libraries/LibWeb/DOM/Element.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 36ca42019a2..12b8c28912e 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -1970,13 +1970,12 @@ ErrorOr Element::scroll_into_view(Optional const& old_value, Optional const& new_value) { + Vector changed_properties; + ForceSelfStyleInvalidation force_self_invalidation = ForceSelfStyleInvalidation::No; if (is_presentational_hint(attribute_name)) { - invalidate_style(StyleInvalidationReason::ElementAttributeChange); - return; + force_self_invalidation = ForceSelfStyleInvalidation::Yes; } - Vector changed_properties; - ForceSelfStyleInvalidation force_self_invalidation = ForceSelfStyleInvalidation::No; if (attribute_name == HTML::AttributeNames::style) { force_self_invalidation = ForceSelfStyleInvalidation::Yes; changed_properties.append({ .type = CSS::InvalidationSet::Property::Type::Attribute, .value = HTML::AttributeNames::style });