LibWeb: Ensure registered transitions are reflective of properties

Previously we would only update these if:
a) We had a cascaded value for `transition-property`
b) The source of that cascaded value had changed since we last
   registered transitions

This meant that there were a lot of changes we didn't apply:
 - Changes exclusively to properties other than `transition-property`
   (e.g. `transition-duration`, `transition-behavior`, etc)
 - Removing the `transition-property` property
 - Updating the `transition-property` property in a way that didn't
   change it's source (e.g. setting it within inline-style)

Unfortunately this does mean that we now register transitions for all
properties on most elements since "all" is the initial value for
"transition-property" which isn't great for performance, but that can be
looked at in later commits.
This commit is contained in:
Callum Law 2025-11-18 22:15:15 +13:00 committed by Jelle Raaijmakers
parent 46abc0e8e2
commit b2b889e1da
Notes: github-actions[bot] 2025-11-23 08:44:36 +00:00
13 changed files with 98 additions and 45 deletions

View file

@ -1221,19 +1221,15 @@ static void apply_dimension_attribute(CascadedProperties& cascaded_properties, D
static void compute_transitioned_properties(ComputedProperties const& style, DOM::AbstractElement abstract_element)
{
auto const source_declaration = style.transition_property_source();
if (!source_declaration)
return;
// FIXME: For now we don't bother registering transitions on the first computation since they can't run (because
// there is nothing to transition from) but this will change once we implement @starting-style
if (!abstract_element.computed_properties())
return;
// FIXME: Add transition helpers on AbstractElement.
auto& element = abstract_element.element();
auto pseudo_element = abstract_element.pseudo_element();
if (source_declaration == element.cached_transition_property_source(pseudo_element))
return;
// Reparse this transition property
element.clear_registered_transitions(pseudo_element);
element.set_cached_transition_property_source(pseudo_element, *source_declaration);
auto coordinated_transition_list = style.assemble_coordinated_value_list(
PropertyID::TransitionProperty,
@ -2541,10 +2537,6 @@ GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::AbstractEleme
computed_style->set_property(property_id, value.release_nonnull(), inherited, cascaded_properties.is_property_important(property_id) ? Important::Yes : Important::No);
if (animated_value.has_value())
computed_style->set_animated_property(property_id, animated_value.value(), inherited);
if (property_id == PropertyID::TransitionProperty) {
computed_style->set_transition_property_source(cascaded_properties.property_source(property_id));
}
}
// Compute the value of custom properties