LibWeb: Apply composite operator to keyframe effects

This commit is contained in:
Tim Ledbetter 2025-09-16 14:42:48 +01:00 committed by Sam Atkins
commit 9b15517052
Notes: github-actions[bot] 2025-09-18 15:50:50 +00:00
60 changed files with 2849 additions and 201 deletions

View file

@ -1072,6 +1072,22 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
};
HashMap<PropertyID, RefPtr<StyleValue const>> computed_start_values = compute_keyframe_values(keyframe_values);
HashMap<PropertyID, RefPtr<StyleValue const>> computed_end_values = compute_keyframe_values(keyframe_end_values);
auto to_composite_operation = [&](Bindings::CompositeOperationOrAuto composite_operation_or_auto) {
switch (composite_operation_or_auto) {
case Bindings::CompositeOperationOrAuto::Accumulate:
return Bindings::CompositeOperation::Accumulate;
case Bindings::CompositeOperationOrAuto::Add:
return Bindings::CompositeOperation::Add;
case Bindings::CompositeOperationOrAuto::Replace:
return Bindings::CompositeOperation::Replace;
case Bindings::CompositeOperationOrAuto::Auto:
return effect->composite();
}
VERIFY_NOT_REACHED();
};
auto start_composite_operation = to_composite_operation(keyframe_values.composite);
auto end_composite_operation = to_composite_operation(keyframe_end_values.composite);
for (auto const& it : computed_start_values) {
auto resolved_start_property = it.value;
@ -1098,6 +1114,13 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
continue;
}
auto const& underlying_value = computed_properties.property(it.key);
if (auto composited_start_value = composite_value(underlying_value, start, start_composite_operation))
start = *composited_start_value;
if (auto composited_end_value = composite_value(underlying_value, end, end_composite_operation))
end = *composited_end_value;
if (auto next_value = interpolate_property(*effect->target(), it.key, *start, *end, progress_in_keyframe, AllowDiscrete::Yes)) {
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));
computed_properties.set_animated_property(it.key, *next_value);