@@ -950,7 +950,7 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
950950 auto const & specified_value_with_css_wide_keywords_applied = [&]() -> StyleValue const & {
951951 if (longhand_value.is_inherit () || (longhand_value.is_unset () && is_inherited_property (longhand_id))) {
952952 if (auto inherited_animated_value = get_animated_inherit_value (longhand_id, abstract_element); inherited_animated_value.has_value ())
953- return inherited_animated_value. value () ;
953+ return inherited_animated_value-> value ;
954954
955955 return get_non_animated_inherit_value (longhand_id, abstract_element);
956956 }
@@ -1070,6 +1070,8 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
10701070 VERIFY_NOT_REACHED ();
10711071 };
10721072
1073+ auto is_result_of_transition = animation->is_css_transition () ? AnimatedPropertyResultOfTransition::Yes : AnimatedPropertyResultOfTransition::No;
1074+
10731075 auto start_composite_operation = to_composite_operation (keyframe_values.composite );
10741076 auto end_composite_operation = to_composite_operation (keyframe_end_values.composite );
10751077
@@ -1079,7 +1081,7 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
10791081
10801082 if (!resolved_end_property) {
10811083 if (resolved_start_property) {
1082- computed_properties.set_animated_property (it.key , *resolved_start_property);
1084+ computed_properties.set_animated_property (it.key , *resolved_start_property, is_result_of_transition );
10831085 dbgln_if (LIBWEB_CSS_ANIMATION_DEBUG, " No end property for property {}, using {}" , string_from_property_id (it.key ), resolved_start_property->to_string (SerializationMode::Normal));
10841086 }
10851087 continue ;
@@ -1094,7 +1096,9 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
10941096 auto start = resolved_start_property.release_nonnull ();
10951097 auto end = resolved_end_property.release_nonnull ();
10961098
1097- if (computed_properties.is_property_important (it.key )) {
1099+ // OPTIMIZATION: Values resulting from animations other than CSS transitions are overriden by important
1100+ // properties so there's no need to calculate them
1101+ if (!animation->is_css_transition () && computed_properties.is_property_important (it.key )) {
10981102 continue ;
10991103 }
11001104
@@ -1107,11 +1111,11 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
11071111
11081112 if (auto next_value = interpolate_property (*effect->target (), it.key , *start, *end, progress_in_keyframe, AllowDiscrete::Yes)) {
11091113 dbgln_if (LIBWEB_CSS_ANIMATION_DEBUG, " Interpolated value for property {} at {}: {} -> {} = {}" , string_from_property_id (it.key ), progress_in_keyframe, start->to_string (SerializationMode::Normal), end->to_string (SerializationMode::Normal), next_value->to_string (SerializationMode::Normal));
1110- computed_properties.set_animated_property (it.key , *next_value);
1114+ computed_properties.set_animated_property (it.key , *next_value, is_result_of_transition );
11111115 } else {
11121116 // If interpolate_property() fails, the element should not be rendered
11131117 dbgln_if (LIBWEB_CSS_ANIMATION_DEBUG, " Interpolated value for property {} at {}: {} -> {} is invalid" , string_from_property_id (it.key ), progress_in_keyframe, start->to_string (SerializationMode::Normal), end->to_string (SerializationMode::Normal));
1114- computed_properties.set_animated_property (PropertyID::Visibility, KeywordStyleValue::create (Keyword::Hidden));
1118+ computed_properties.set_animated_property (PropertyID::Visibility, KeywordStyleValue::create (Keyword::Hidden), is_result_of_transition );
11151119 }
11161120 }
11171121}
@@ -1606,15 +1610,20 @@ NonnullRefPtr<StyleValue const> StyleComputer::get_non_animated_inherit_value(Pr
16061610 return parent_element->computed_properties ()->property (property_id, ComputedProperties::WithAnimationsApplied::No);
16071611}
16081612
1609- Optional<NonnullRefPtr<StyleValue const > > StyleComputer::get_animated_inherit_value (PropertyID property_id, DOM::AbstractElement abstract_element)
1613+ Optional<StyleComputer::AnimatedInheritValue > StyleComputer::get_animated_inherit_value (PropertyID property_id, DOM::AbstractElement abstract_element)
16101614{
16111615 auto parent_element = abstract_element.element_to_inherit_style_from ();
16121616
16131617 if (!parent_element.has_value () || !parent_element->computed_properties ())
16141618 return {};
16151619
16161620 if (auto animated_value = parent_element->computed_properties ()->animated_property_values ().get (property_id); animated_value.has_value ())
1617- return *animated_value.value ();
1621+ return AnimatedInheritValue {
1622+ .value = *animated_value.value (),
1623+ .is_result_of_transition = parent_element->computed_properties ()->is_animated_property_result_of_transition (property_id)
1624+ ? AnimatedPropertyResultOfTransition::Yes
1625+ : AnimatedPropertyResultOfTransition::No
1626+ };
16181627
16191628 return {};
16201629}
@@ -2523,7 +2532,6 @@ GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::AbstractEleme
25232532 auto property_id = static_cast <CSS::PropertyID>(i);
25242533 auto value = cascaded_properties.property (property_id);
25252534 auto inherited = ComputedProperties::Inherited::No;
2526- Optional<NonnullRefPtr<StyleValue const >> animated_value;
25272535
25282536 // NOTE: We've already handled font-size above.
25292537 if (property_id == PropertyID::FontSize && !value && new_font_size)
@@ -2545,17 +2553,17 @@ GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::AbstractEleme
25452553
25462554 // FIXME: Logical properties should inherit from their parent's equivalent unmapped logical property.
25472555 if (should_inherit) {
2548- value = get_non_animated_inherit_value (property_id, abstract_element);
2549- animated_value = get_animated_inherit_value (property_id, abstract_element);
25502556 inherited = ComputedProperties::Inherited::Yes;
2557+ value = get_non_animated_inherit_value (property_id, abstract_element);
2558+
2559+ if (auto animated_value = get_animated_inherit_value (property_id, abstract_element); animated_value.has_value ())
2560+ computed_style->set_animated_property (property_id, animated_value->value , animated_value->is_result_of_transition , ComputedProperties::Inherited::Yes);
25512561 }
25522562
25532563 if (!value || value->is_initial () || value->is_unset ())
25542564 value = property_initial_value (property_id);
25552565
25562566 computed_style->set_property (property_id, value.release_nonnull (), inherited, cascaded_properties.is_property_important (property_id) ? Important::Yes : Important::No);
2557- if (animated_value.has_value ())
2558- computed_style->set_animated_property (property_id, animated_value.value (), inherited);
25592567 }
25602568
25612569 // Compute the value of custom properties
0 commit comments