Skip to content

Truly independent web browser

LibWeb: Replace animations only by those of the same effect target

Andreas Klinga9eb9d11d9c9
diff --git a/Libraries/LibWeb/Rust/src/animations/procedures.rs b/Libraries/LibWeb/Rust/src/animations/procedures.rs
index 00efa547844..96d362b089d 100644
--- a/Libraries/LibWeb/Rust/src/animations/procedures.rs
+++ b/Libraries/LibWeb/Rust/src/animations/procedures.rs
@@ -2076,11 +2076,19 @@ pub(crate) fn remove_replaced_animations<'a>(
let mut properties_with_a_higher_animation = HashSet::new();
for animation in replaceable_animations.iter().rev() {
let mut has_any_highest_priority_property = false;
- if let Some(keyframes) = animation
- .borrow()
- .effect()
- .and_then(|effect| effect.borrow().keyframes().cloned())
+ let effect = animation.borrow().effect().cloned();
+ if let Some(effect) = effect
+ && let Some(keyframes) = effect.borrow().keyframes().cloned()
{
+ // NB: An animation is replaced by those whose effects animate the same target properties of the same
+ // effect target, as only those come above it in its effect stack.
+ let effect_target = {
+ let effect = effect.borrow();
+ (
+ effect.target_element(),
+ effect.pseudo_element().map(|pseudo_element| pseudo_element.kind),
+ )
+ };
let properties = keyframes
.target_properties()
.iter()
@@ -2092,7 +2100,8 @@ pub(crate) fn remove_replaced_animations<'a>(
.map(|name| TargetProperty::Custom(name.raw())),
);
for property in properties {
- has_any_highest_priority_property |= properties_with_a_higher_animation.insert(property);
+ has_any_highest_priority_property |=
+ properties_with_a_higher_animation.insert((effect_target, property));
}
}
diff --git a/Tests/LibWeb/Text/expected/WebAnimations/remove-replaced-animations-of-other-targets.txt b/Tests/LibWeb/Text/expected/WebAnimations/remove-replaced-animations-of-other-targets.txt
index 2e184a62540..c10b44ab473 100644
--- a/Tests/LibWeb/Text/expected/WebAnimations/remove-replaced-animations-of-other-targets.txt
+++ b/Tests/LibWeb/Text/expected/WebAnimations/remove-replaced-animations-of-other-targets.txt
@@ -1,4 +1,4 @@
-first: removed, remove event: true, opacity: 0.5
-second: removed, remove event: true, opacity: 0.25
+first: active, remove event: false, opacity: 0.5
+second: active, remove event: false, opacity: 0.25
earlier of both: removed, remove event: true, opacity: 0.25
later of both: active, remove event: false, opacity: 0.25
diff --git a/Tests/LibWeb/Text/expected/wpt-import/web-animations/interfaces/Animatable/animate.txt b/Tests/LibWeb/Text/expected/wpt-import/web-animations/interfaces/Animatable/animate.txt
index db0b0a94d05..0f089405816 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/web-animations/interfaces/Animatable/animate.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/web-animations/interfaces/Animatable/animate.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 153 tests
-151 Pass
-2 Fail
+152 Pass
+1 Fail
Pass Element.animate() creates an Animation object
Pass Element.animate() creates an Animation object in the relevant realm of the target element
Pass Element.animate() creates an Animation object with a KeyframeEffect
@@ -156,4 +156,4 @@ Pass animate() with a non-null invalid pseudoElement 'before' throws a SyntaxErr
Pass animate() with a non-null invalid pseudoElement ':abc' throws a SyntaxError
Pass animate() with a non-null invalid pseudoElement '::abc' throws a SyntaxError
Pass animate() with pseudoElement ::placeholder does not throw
-Fail Finished fill animation doesn't replace animation on a different pseudoElement
\ No newline at end of file
+Pass Finished fill animation doesn't replace animation on a different pseudoElement
\ No newline at end of file