Truly independent web browser
LibWeb: Preserve neutral keyframes in cyclic registered intervals
Callum Lawb813c78fb1da
diff --git a/Libraries/LibWeb/Rust/src/css/animation.rs b/Libraries/LibWeb/Rust/src/css/animation.rsindex 180d422f417..5259864a0c6 100644--- a/Libraries/LibWeb/Rust/src/css/animation.rs+++ b/Libraries/LibWeb/Rust/src/css/animation.rs@@ -9244,6 +9244,7 @@ impl PreparedAnimationBatch {&mut self,intervals: &[CustomPropertyInterval],registry: &Registry,+ inherited: Option<&crate::css::custom_properties::CustomPropertyStore>,cyclic_declarations: &mut Vec<crate::css::retained_fly_string::RetainedUtf16FlyString>,) -> bool {let mut has_cyclic_interval = false;@@ -9253,15 +9254,12 @@ impl PreparedAnimationBatch {}// SAFETY: The interval retains the name while it is borrowed for the lookup.let name = unsafe { ak::Utf16FlyString::from_raw_borrowed(interval.name.raw()) };- let has_neutral_endpoint = interval- .declared_values- .iter()- .any(|value| value.optional_data().is_none());let registered = registry.is_registered(&name);- if !registered || has_neutral_endpoint {+ if !registered {cyclic_declarations.push(interval.name.clone());continue;}+ let fallback = registry.invalid_at_computed_value_time(&interval.name, inherited);for (plan, keyframes) in self.resolved.value_plans.iter().zip(&mut self.keyframes_by_value) {if plan.custom_name_id != interval.custom_name_id || plan.effect_index != interval.effect_index {continue;@@ -9271,7 +9269,11 @@ impl PreparedAnimationBatch {// AD-HOC: Compose a registered custom property's selected interval as unset if it has a cyclic endpoint// and two explicit keyframe values, matching Chromium. Keep unset as a marker until all effects// are composed so later additive effects do not add the inherited or initial value.- let fallback = RetainedStyleValueData::shared_keyword(crate::css::css_enums::keyword::UNSET);+ let fallback = if keyframes.iter().all(|keyframe| !keyframe.is_implicit) {+ RetainedStyleValueData::shared_keyword(crate::css::css_enums::keyword::UNSET)+ } else {+ &fallback+ };for keyframe in keyframes {keyframe.value = fallback.clone();}diff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rsindex 2048c45a1af..86d935e9105 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs@@ -7332,6 +7332,7 @@ fn finish_animation_sample(if preparation.replace_cyclic_custom_property_endpoints(&custom_properties.intervals,registry,+ inherited,&mut cyclic_declarations,) {retained = anim::evaluate_prepared_animations(preparation, &mut batch)diff --git a/Tests/LibWeb/Text/expected/css/registered-custom-property-animation-cycle-composition.txt b/Tests/LibWeb/Text/expected/css/registered-custom-property-animation-cycle-composition.txtindex 7729367658f..df48b85ce74 100644--- a/Tests/LibWeb/Text/expected/css/registered-custom-property-animation-cycle-composition.txt+++ b/Tests/LibWeb/Text/expected/css/registered-custom-property-animation-cycle-composition.txt@@ -1,3 +1,4 @@replace preserves a later additive animation over a cyclic registered interval: trueadd preserves a later additive animation over a cyclic registered interval: trueaccumulate preserves a later additive animation over a cyclic registered interval: true+a neutral keyframe contributes its underlying value in a cyclic registered interval: truediff --git a/Tests/LibWeb/Text/input/css/registered-custom-property-animation-cycle-composition.html b/Tests/LibWeb/Text/input/css/registered-custom-property-animation-cycle-composition.htmlindex d1153da08e2..2fb9914c297 100644--- a/Tests/LibWeb/Text/input/css/registered-custom-property-animation-cycle-composition.html+++ b/Tests/LibWeb/Text/input/css/registered-custom-property-animation-cycle-composition.html@@ -37,5 +37,12 @@);later.cancel();}+ animation.cancel();+ const neutral = target.animate([{ offset: 1, "--number": "var(--reader)" }], 1000);+ neutral.pause();+ neutral.currentTime = 500;+ println(+ `a neutral keyframe contributes its underlying value in a cyclic registered interval: ${getComputedStyle(target).getPropertyValue("--number") === "8.5"}`+ );});</script>