Truly independent web browser
LibWeb: Retain substituted discrete custom property keyframe values
Callum Lawb3a2c87699d7
diff --git a/Libraries/LibWeb/Rust/src/css/animation.rs b/Libraries/LibWeb/Rust/src/css/animation.rsindex 7ed2a64aa6e..8d4bfd85ab4 100644--- a/Libraries/LibWeb/Rust/src/css/animation.rs+++ b/Libraries/LibWeb/Rust/src/css/animation.rs@@ -9,10 +9,12 @@// Animation values use the same thread-confined shared graph as the rest of the style core.#![allow(clippy::arc_with_non_send_sync)]+use std::collections::BTreeMap;use std::sync::Arc;use crate::css::easing::{Easing, FfiEasingDescriptor, FfiLinearEasingPoint, evaluate_easing_descriptor};use crate::css::property_metadata::{property_animation_type, property_numeric_ranges};+use crate::css::style::effect_descriptions::{PublishedEffect, PublishedValue};use crate::css::style_value::{BasicShapeData, ColorBase, CssString, CssStringList, FILTER_KIND_BLUR, FILTER_KIND_COLOR, FILTER_KIND_DROP_SHADOW,FILTER_KIND_HUE_ROTATE, GridTrackEntryKind, OwnedBasicShapeData, RetainedGridTrackEntry,@@ -748,7 +750,7 @@ struct AnimationKeyframePlan {}#[repr(u8)]-#[derive(Clone, Copy)]+#[derive(Clone, Copy, PartialEq, Eq)]#[expect(dead_code, reason = "C++ constructs the variants")]pub enum FfiCompositeOperation {Replace,@@ -6928,6 +6930,66 @@ pub unsafe extern "C" fn rust_substitute_compositor_keyframe_value(})}+#[derive(Clone, Copy)]+struct CustomPropertyKeyframeLookup {+ keyframe_index: usize,+ declaration_index: usize,+}++/// Build a sequence of lookups for each custom property, in keyframe order.+fn build_custom_property_keyframe_lookups(+ effect: &PublishedEffect,+ custom_properties: &mut AnimatedCustomProperties,+) -> BTreeMap<u32, Vec<CustomPropertyKeyframeLookup>> {+ let mut property_lookups = BTreeMap::<_, Vec<_>>::new();+ let mut declaration_index = 0;+ for (keyframe_index, keyframe) in effect.keyframes.iter().enumerate() {+ for declaration in effect.custom_declarations_of(keyframe) {+ let name_id = custom_properties.mint(&declaration.name);++ property_lookups+ .entry(name_id)+ .or_default()+ .push(CustomPropertyKeyframeLookup {+ keyframe_index,+ declaration_index,+ });++ declaration_index += 1;+ }+ }+ property_lookups+}++fn select_custom_property_interval_span(+ effect: &PublishedEffect,+ keyframe_lookups: &[CustomPropertyKeyframeLookup],+ current_key: f64,+) -> [CustomPropertyKeyframeLookup; 2] {+ let first_lookup = keyframe_lookups[0];+ let first_composite = effect.keyframes[first_lookup.keyframe_index].composite;+ let first_value = &effect.custom_declaration_at(first_lookup.declaration_index).value;++ let can_use_constant_interpolation = !matches!(first_value, PublishedValue::ElementValue)+ && keyframe_lookups.iter().all(|lookup| {+ let composite = effect.keyframes[lookup.keyframe_index].composite;+ let value = &effect.custom_declaration_at(lookup.declaration_index).value;+ composite == first_composite && value == first_value+ });++ // When declared values and composite operations are equal, use the same endpoints+ // across all intervals so discrete properties reuse their retained values.+ let (start, end) = if can_use_constant_interpolation {+ (0, keyframe_lookups.len() - 1)+ } else {+ keyframe_interval(keyframe_lookups.len(), current_key, |index| {+ effect.keyframes[keyframe_lookups[index].keyframe_index].key+ })+ };++ [keyframe_lookups[start], keyframe_lookups[end]]+}+/// Resolve the declarations of the effects an element samples from their descriptions: each/// keyframe's easing and each value written as a token stream substituted against the element, a/// keyframe holding the element's own value given it, and every custom property minted into a@@ -7046,31 +7108,43 @@ pub(crate) fn resolve_published_animation_declarations(is_transition,});}- for declaration in effect.custom_declarations_of(keyframe) {- let name_id = custom_properties.mint(&declaration.name);- let (value, use_initial) = match &declaration.value {- PublishedValue::ElementValue => (custom_properties.underlying_value(registry, name_id), true),- // A custom property's value is a token stream; only the substitution functions- // in it resolve against the element.- PublishedValue::Declared(value) if holds_arbitrary_substitution(value.data()) => (- substitute(- crate::css::property_metadata::property_id::CUSTOM,- custom_properties.units(name_id),- value,- ),- false,- ),- PublishedValue::Declared(value) => (value.clone_retained(), false),- };+ }+ for (name_id, keyframe_lookups) in build_custom_property_keyframe_lookups(effect, &mut custom_properties) {+ let important = custom_properties.is_important(name_id);+ if keyframe_lookups.len() < 2 || important && !is_transition {+ continue;+ }+ let name = custom_properties.units(name_id);+ let interval_span = select_custom_property_interval_span(effect, &keyframe_lookups, selection.current_key);+ let interval_values = effect.resolve_custom_property_interval_values(+ interval_span.map(|lookup| lookup.declaration_index),+ registry.name_has_interpolable_syntax(name),+ || {+ interval_span.map(|lookup| {+ let declaration = effect.custom_declaration_at(lookup.declaration_index);+ match &declaration.value {+ PublishedValue::ElementValue => custom_properties.underlying_value(registry, name_id),+ // A custom property's value is a token stream; only the substitution functions+ // in it resolve against the element.+ PublishedValue::Declared(value) if holds_arbitrary_substitution(value.data()) => {+ substitute(crate::css::property_metadata::property_id::CUSTOM, name, value)+ }+ PublishedValue::Declared(value) => value.clone_retained(),+ }+ })+ },+ );+ for (lookup, value) in interval_span.into_iter().zip(interval_values) {+ let declaration = effect.custom_declaration_at(lookup.declaration_index);declarations.push(AnimationDeclaration {- keyframe_index,+ keyframe_index: first_keyframe_index + lookup.keyframe_index,property_id: crate::css::property_metadata::property_id::CUSTOM,custom_name_id: name_id,- custom_is_inherited: registry.name_inherits(custom_properties.units(name_id)),- custom_is_important: custom_properties.is_important(name_id),+ custom_is_inherited: registry.name_inherits(name),+ custom_is_important: important,value,style_sheet_resource_context,- use_initial,+ use_initial: matches!(declaration.value, PublishedValue::ElementValue),is_transition,});}diff --git a/Libraries/LibWeb/Rust/src/css/custom_properties.rs b/Libraries/LibWeb/Rust/src/css/custom_properties.rsindex 0b93ca93265..f7e9b1e7217 100644--- a/Libraries/LibWeb/Rust/src/css/custom_properties.rs+++ b/Libraries/LibWeb/Rust/src/css/custom_properties.rs@@ -132,6 +132,7 @@ type RegisteredValueParse = (RetainedStyleValueData, Option<RetainedStyleValueDa/// How many parses the registry keeps before it starts over.const MAX_REGISTERED_VALUE_PARSES: usize = 4096;+#[derive(PartialEq)]struct RegisteredCustomProperty {syntax: SyntaxNode,inherits: bool,@@ -263,6 +264,11 @@ impl CustomPropertyRegistry {self.registrations.contains_key(name)}+ /// Whether a name has the same effective registration in two document registries.+ pub(crate) fn registration_matches(&self, other: &Self, name: &[u16]) -> bool {+ self.registrations.get(name) == other.registrations.get(name)+ }+/// Whether a custom property of this name inherits: only a registration can say it does not.pub(crate) fn name_inherits(&self, name: &[u16]) -> bool {self.registrations@@ -278,6 +284,25 @@ impl CustomPropertyRegistry {.is_some_and(|registration| !matches!(registration.syntax, SyntaxNode::Universal))}+ /// Whether a registration's syntax permits smooth interpolation.+ pub(crate) fn name_has_interpolable_syntax(&self, name: &[u16]) -> bool {+ fn is_interpolable(syntax: &SyntaxNode) -> bool {+ match syntax {+ SyntaxNode::Universal+ | SyntaxNode::Ident { .. }+ | SyntaxNode::Type(+ SyntaxType::CustomIdent | SyntaxType::Image | SyntaxType::String | SyntaxType::Url,+ ) => false,+ SyntaxNode::Type(_) => true,+ SyntaxNode::Multiplier { child, .. } => is_interpolable(child),+ SyntaxNode::Alternatives(alternatives) => alternatives.iter().any(is_interpolable),+ }+ }+ self.registrations+ .get(name)+ .is_some_and(|registration| is_interpolable(®istration.syntax))+ }+/// A custom property's initial value: what its registration's initial value computes to, and/// the guaranteed-invalid value for an unregistered name or a registration without one.pub(crate) fn initial_value(&self, name: &[u16]) -> RetainedStyleValueData {diff --git a/Libraries/LibWeb/Rust/src/css/style/bridge.rs b/Libraries/LibWeb/Rust/src/css/style/bridge.rsindex 0b41a5795f3..59e722b97d6 100644--- a/Libraries/LibWeb/Rust/src/css/style/bridge.rs+++ b/Libraries/LibWeb/Rust/src/css/style/bridge.rs@@ -3013,6 +3013,13 @@ pub(crate) unsafe fn take_style_transaction(!= computation_inputs.custom_property_registration_generation;if engine.custom_property_registrations_changed {engine.custom_property_environments.registrations_changed();+ let previous_registry = engine.custom_property_registry.clone();+ engine.animation_effect_descriptions.registrations_changed(+ previous_registry+ .as_deref()+ .unwrap_or_else(|| CustomPropertyRegistry::shared_empty()),+ computation_inputs.custom_property_registry(),+ );}if engine.document_style_computation_inputs != computation_inputs {// Persistent records are derived from every document computation input, not only thediff --git a/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs b/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rsindex 658e72bc364..690c842165d 100644--- a/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs+++ b/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs@@ -20,6 +20,7 @@ use super::bridge::{};use super::tree::StyleNodeID;use crate::css::animation::FfiCompositeOperation;+use crate::css::custom_properties::CustomPropertyRegistry;use crate::css::easing::{Easing, FfiEasingDescriptor, FfiEasingKind, FfiLinearEasingPoint};use crate::css::retained_fly_string::RetainedUtf16FlyString;use crate::css::style_compute::FfiEffectTiming;@@ -27,10 +28,10 @@ use crate::css::style_value::{RetainedStyleValueData, StyleValueData};use std::collections::HashMap;use std::ffi::c_void;use std::ops::Range;-use std::sync::Arc;+use std::sync::{Arc, Mutex};/// What a published keyframe declares for a property.-#[derive(Clone)]+#[derive(Clone, PartialEq)]pub(crate) enum PublishedValue {/// The element's own value, held by a keyframe the host synthesized, and not known until the/// element is sampled.@@ -171,6 +172,9 @@ pub(crate) struct PublishedResourceContext {pub(crate) origin_clean: bool,}+/// Maps an interval's declaration indices to its substituted values.+type CustomPropertyIntervalValues = HashMap<[usize; 2], [RetainedStyleValueData; 2]>;+/// One of an element's animation effects, described for the style engine.#[derive(Clone)]pub(crate) struct PublishedEffect {@@ -183,6 +187,8 @@ pub(crate) struct PublishedEffect {pub(crate) keyframes: Box<[PublishedKeyframe]>,declarations: Box<[PublishedDeclaration]>,custom_declarations: Box<[PublishedCustomDeclaration]>,+ /// Substituted interval values retained for this effect version.+ custom_property_interval_values: Arc<Mutex<CustomPropertyIntervalValues>>,/// The timing the host last sampled the effect with, which moves without the description.pub(crate) timing: Option<EffectTiming>,/// What a transition reverses to, and how much shorter a reversing transition runs, where the effect is one.@@ -245,6 +251,7 @@ impl PublishedEffect {value: PublishedValue::Declared(value),})),custom_declarations: Box::new([]),+ custom_property_interval_values: Default::default(),timing,reversing: None,}@@ -259,6 +266,37 @@ impl PublishedEffect {pub(crate) fn custom_declarations_of(&self, keyframe: &PublishedKeyframe) -> &[PublishedCustomDeclaration] {&self.custom_declarations[keyframe.custom_declarations.clone()]}++ #[must_use]+ pub(crate) fn custom_declaration_at(&self, index: usize) -> &PublishedCustomDeclaration {+ &self.custom_declarations[index]+ }++ /// Resolve interval values afresh for interpolable syntaxes or neutral keyframes; retain them otherwise.+ pub(crate) fn resolve_custom_property_interval_values(+ &self,+ declaration_indices: [usize; 2],+ has_interpolable_syntax: bool,+ resolve_values: impl FnOnce() -> [RetainedStyleValueData; 2],+ ) -> [RetainedStyleValueData; 2] {+ let has_neutral_endpoint = declaration_indices+ .iter()+ .any(|&index| matches!(self.custom_declarations[index].value, PublishedValue::ElementValue));++ if has_interpolable_syntax || has_neutral_endpoint {+ return resolve_values();+ }++ // AD-HOC: Match Chromium's retention of substituted interval values for discrete interpolations+ // without checking substitution dependencies. Chromium also does this for some standard+ // properties via CSSDefaultInterpolationType; we currently limit it to custom properties.+ self.custom_property_interval_values+ .lock()+ .unwrap()+ .entry(declaration_indices)+ .or_insert_with(resolve_values)+ .clone()+ }}/// The flat buffers one animation list's descriptions travel in.@@ -334,6 +372,7 @@ impl PublishedEffectBuffers<'_> {keyframes,declarations: declarations.into(),custom_declarations: custom_declarations.into(),+ custom_property_interval_values: Default::default(),timing: None,reversing: (!effect.reversing_adjusted_start_value.is_null()).then(|| TransitionReversing {adjusted_start_value: unsafe { retained(effect.reversing_adjusted_start_value) },@@ -382,10 +421,39 @@ pub(crate) struct AnimationEffectDescriptions {}impl AnimationEffectDescriptions {+ pub(super) fn registrations_changed(+ &mut self,+ previous: &CustomPropertyRegistry,+ registry: &CustomPropertyRegistry,+ ) {+ for (_, effects) in self.rows.values_mut().flatten() {+ for effect in effects {+ let mut retained_values = effect.custom_property_interval_values.lock().unwrap().clone();+ retained_values.retain(|declaration_indices, _| {+ let name = &effect.custom_declarations[declaration_indices[0]].name;+ registry.registration_matches(previous, &name.to_utf16())+ });+ // Leave values held by older style snapshots intact.+ effect.custom_property_interval_values = Arc::new(Mutex::new(retained_values));+ }+ }+ }+/// Replace one list. An empty list drops it.- pub(crate) fn set(&mut self, node: StyleNodeID, slot: AnimationSlot, effects: Box<[PublishedEffect]>) {+ pub(crate) fn set(&mut self, node: StyleNodeID, slot: AnimationSlot, mut effects: Box<[PublishedEffect]>) {let lists = self.rows.entry(node).or_default();let existing = lists.iter().position(|(list_slot, _)| *list_slot == slot);+ if let Some(index) = existing {+ let previous_effects = &lists[index].1;+ for effect in &mut effects {+ if let Some(previous_effect) = previous_effects+ .iter()+ .find(|previous| previous.identity == effect.identity && previous.generation == effect.generation)+ {+ effect.custom_property_interval_values = previous_effect.custom_property_interval_values.clone();+ }+ }+ }match (existing, effects.is_empty()) {(Some(index), true) => {lists.swap_remove(index);diff --git a/Tests/LibWeb/Text/expected/css/custom-property-keyframe-intervals.txt b/Tests/LibWeb/Text/expected/css/custom-property-keyframe-intervals.txtnew file mode 100644index 00000000000..8fd6a734ad1--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/custom-property-keyframe-intervals.txt@@ -0,0 +1,8 @@+start: 1, start, 1, 1, 1+input changed: 1, start, 1, 1, 2+first interval: middle, 1, 1, 1, 2+second interval: middle, 2, 1, end, underlying+last endpoint: 2, end, 1, end, underlying+return to first interval: 1, start, 1, 1, 2+return to second interval: middle, 2, 1, end, underlying+last endpoint retained: 2, end, 1, end, underlyingdiff --git a/Tests/LibWeb/Text/expected/css/custom-property-keyframe-registration-changes.txt b/Tests/LibWeb/Text/expected/css/custom-property-keyframe-registration-changes.txtnew file mode 100644index 00000000000..31520af3b2d--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/custom-property-keyframe-registration-changes.txt@@ -0,0 +1,11 @@+start: 1, 1, 1+input changed: 1, 1, 1+other effect changed: 1, 1, 1+other effect removed: 1, 1, 1+unrelated registration: 1, 1, 1+registered: 2, 1, 1+registered input changed: 3, 1, 1+unregistered: 3, 1, 1+unregistered input changed: 3, 1, 1+keyframes replaced: 4, 4, 4+replacement retained: 4, 4, 4diff --git a/Tests/LibWeb/Text/expected/css/discrete-registered-custom-property-keyframes.txt b/Tests/LibWeb/Text/expected/css/discrete-registered-custom-property-keyframes.txtnew file mode 100644index 00000000000..789ce3b4042--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/discrete-registered-custom-property-keyframes.txt@@ -0,0 +1,25 @@+Retained values after: input change, seek, return, keyframe replacement+ident intervals: true, false, true, false+ident constant: true, true, true, false+literal intervals: true, false, true, false+literal constant: true, true, true, false+string intervals: true, false, true, false+string constant: true, true, true, false+url intervals: true, false, true, false+url constant: true, true, true, false+image intervals: true, false, true, false+image constant: true, true, true, false+ident-list intervals: true, false, true, false+ident-list constant: true, true, true, false+string-list intervals: true, false, true, false+string-list constant: true, true, true, false+url-list intervals: true, false, true, false+url-list constant: true, true, true, false+alternatives intervals: true, false, true, false+alternatives constant: true, true, true, false+number-list intervals: false, false, false, false+number-list constant: false, false, false, false+mixed-number intervals: false, false, false, false+mixed-number constant: false, false, false, false+mixed-ident intervals: false, false, false, false+mixed-ident constant: false, false, false, falsediff --git a/Tests/LibWeb/Text/expected/css/paused-custom-property-keyframes.txt b/Tests/LibWeb/Text/expected/css/paused-custom-property-keyframes.txtnew file mode 100644index 00000000000..6f43afaa493--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/paused-custom-property-keyframes.txt@@ -0,0 +1,4 @@+start: 1, 1+input changed: 1, 2+seek: 1, 2+running: 2, 2diff --git a/Tests/LibWeb/Text/input/css/custom-property-keyframe-intervals.html b/Tests/LibWeb/Text/input/css/custom-property-keyframe-intervals.htmlnew file mode 100644index 00000000000..8db54595eb8--- /dev/null+++ b/Tests/LibWeb/Text/input/css/custom-property-keyframe-intervals.html@@ -0,0 +1,59 @@+<!doctype html>+<style>+ @keyframes sample {+ 0% {+ --sample: var(--input);+ --shared: start;+ --constant: var(--input);+ --sparse: var(--input);+ --neutral: var(--input);+ }++ 25% {+ opacity: 0.5;+ }++ 50% {+ --sample: middle;+ --shared: var(--input);+ --constant: var(--input);+ }++ 100% {+ --sample: var(--input);+ --shared: end;+ --constant: var(--input);+ --sparse: end;+ }+ }+ #target {+ --input: 1;+ --neutral: underlying;+ animation: sample 1s linear both paused;+ }+</style>+<div id="target"></div>+<script src="../include.js"></script>+<script>+ test(() => {+ const animation = target.getAnimations()[0];+ function sample(label, time) {+ if (time !== undefined) animation.currentTime = time;+ const style = getComputedStyle(target);+ const values = ["--sample", "--shared", "--constant", "--sparse", "--neutral"].map(name =>+ style.getPropertyValue(name).trim()+ );+ println(`${label}: ${values.join(", ")}`);+ }+ sample("start");+ target.style.setProperty("--input", "2");+ sample("input changed");+ sample("first interval", 400);+ sample("second interval", 600);+ sample("last endpoint", 900);+ sample("return to first interval", 100);+ target.style.setProperty("--input", "3");+ sample("return to second interval", 600);+ sample("last endpoint retained", 900);+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/custom-property-keyframe-registration-changes.html b/Tests/LibWeb/Text/input/css/custom-property-keyframe-registration-changes.htmlnew file mode 100644index 00000000000..58e03a2afca--- /dev/null+++ b/Tests/LibWeb/Text/input/css/custom-property-keyframe-registration-changes.html@@ -0,0 +1,45 @@+<!doctype html>+<style id="registration"></style>+<div id="target" style="--input: 1"></div>+<script src="../include.js"></script>+<script>+ test(() => {+ CSS.registerProperty({ name: "--universal", syntax: "*", inherits: true });+ const prefix = { "--prefix": "var(--input)" };+ const earlier = target.animate([prefix, prefix], 1000);+ earlier.pause();+ earlier.currentTime = 0;+ const keyframe = { "--sample": "var(--input)", "--kept": "var(--input)", "--universal": "var(--input)" };+ const keyframes = [keyframe, keyframe];+ const animation = target.animate(keyframes, { duration: 1000, fill: "both" });+ animation.pause();+ animation.currentTime = 0;+ function dump(label) {+ const style = getComputedStyle(target);+ const values = ["--sample", "--kept", "--universal"].map(name => style.getPropertyValue(name).trim());+ println(`${label}: ${values.join(", ")}`);+ }+ dump("start");+ target.style.setProperty("--input", "2");+ dump("input changed");+ const expanded = { ...prefix, "--extra": "var(--input)" };+ earlier.effect.setKeyframes([expanded, expanded]);+ dump("other effect changed");+ earlier.cancel();+ dump("other effect removed");+ CSS.registerProperty({ name: "--unrelated", syntax: "<integer>", inherits: false, initialValue: "0" });+ dump("unrelated registration");+ registration.textContent = "@property --sample { syntax: '<integer>'; inherits: false; initial-value: 0; }";+ dump("registered");+ target.style.setProperty("--input", "3");+ dump("registered input changed");+ registration.textContent = "";+ dump("unregistered");+ target.style.setProperty("--input", "4");+ dump("unregistered input changed");+ animation.effect.setKeyframes(keyframes);+ dump("keyframes replaced");+ target.style.setProperty("--input", "5");+ dump("replacement retained");+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/discrete-registered-custom-property-keyframes.html b/Tests/LibWeb/Text/input/css/discrete-registered-custom-property-keyframes.htmlnew file mode 100644index 00000000000..e9d2bbee269--- /dev/null+++ b/Tests/LibWeb/Text/input/css/discrete-registered-custom-property-keyframes.html@@ -0,0 +1,47 @@+<!doctype html>+<script src="../include.js"></script>+<script>+ test(() => {+ const cases = [+ ["ident", "<custom-ident>", "alpha", "beta"],+ ["literal", "alpha | beta", "alpha", "beta"],+ ["string", "<string>", '"alpha"', '"beta"'],+ ["url", "<url>", 'url("data:,alpha")', 'url("data:,beta")'],+ ["image", "<image>", 'url("data:,alpha")', 'url("data:,beta")'],+ ["ident-list", "<custom-ident>+", "alpha beta", "gamma delta"],+ ["string-list", "<string>#", '"alpha", "beta"', '"gamma", "delta"'],+ ["url-list", "<url>+", 'url("data:,alpha") url("data:,beta")', 'url("data:,gamma") url("data:,delta")'],+ ["alternatives", "<custom-ident> | <string>", "alpha", '"beta"'],+ ["number-list", "<number>+", "1 2", "3 4"],+ ["mixed-number", "<number> | <custom-ident>", "1", "2"],+ ["mixed-ident", "<number> | <custom-ident>", "alpha", "beta"],+ ];+ println("Retained values after: input change, seek, return, keyframe replacement");+ for (const [label, syntax, first, second] of cases) {+ const name = `--${label}`;+ CSS.registerProperty({ name, syntax, inherits: false, initialValue: first });+ for (const constant of [false, true]) {+ const target = document.body.appendChild(document.createElement("div"));+ target.style.setProperty("--input", first);+ const written = { [name]: "var(--input)" };+ const keyframes = constant ? [written, written] : [written, { [name]: first }, written];+ const animation = target.animate(keyframes, { duration: 1000, fill: "both" });+ animation.pause();+ animation.currentTime = 0;+ const sample = () => getComputedStyle(target).getPropertyValue(name).trim();+ const initial = sample();+ if (initial === "") throw new Error(`${label}: missing initial value`);+ target.style.setProperty("--input", second);+ const retained = [sample() === initial];+ animation.currentTime = 900;+ retained.push(sample() === initial);+ animation.currentTime = 0;+ retained.push(sample() === initial);+ animation.effect.setKeyframes(keyframes);+ retained.push(sample() === initial);+ println(`${label} ${constant ? "constant" : "intervals"}: ${retained.join(", ")}`);+ target.remove();+ }+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/paused-custom-property-keyframes.html b/Tests/LibWeb/Text/input/css/paused-custom-property-keyframes.htmlnew file mode 100644index 00000000000..78871a7d900--- /dev/null+++ b/Tests/LibWeb/Text/input/css/paused-custom-property-keyframes.html@@ -0,0 +1,36 @@+<!doctype html>+<style>+ @property --registered {+ syntax: "<integer>";+ inherits: true;+ initial-value: 0;+ }+ @keyframes sample {+ from,+ to {+ --sample: var(--input);+ --registered: var(--input);+ }+ }+ #target {+ --input: 1;+ animation: sample 1s paused;+ }+</style>+<div id="target"></div>+<script src="../include.js"></script>+<script>+ test(() => {+ function dump(label) {+ const style = getComputedStyle(target);+ println(`${label}: ${style.getPropertyValue("--sample")}, ${style.getPropertyValue("--registered")}`);+ }+ dump("start");+ target.style.setProperty("--input", "2");+ dump("input changed");+ target.getAnimations()[0].currentTime = 750;+ dump("seek");+ target.style.animationPlayState = "running";+ dump("running");+ });+</script>