From 4b4d960cbad72834c3327c155b65bd128fc7f4df Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 27 May 2025 17:09:39 +0200 Subject: [PATCH] LibWeb: Cancel previous animation if new animation-name is "none" "none" value should be interpreted as "no animation" to trigger the path that cancels previous animation if it exists. --- Libraries/LibWeb/CSS/StyleComputer.cpp | 2 + .../WebAnimations/cancel-animation.txt | 1 + .../input/WebAnimations/cancel-animation.html | 39 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/WebAnimations/cancel-animation.txt create mode 100644 Tests/LibWeb/Text/input/WebAnimations/cancel-animation.html diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index cbe7dd8e7d1..50c2a4c0005 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -2678,6 +2678,8 @@ GC::Ref StyleComputer::compute_properties(DOM::Element& elem auto const animation_name = computed_style->maybe_null_property(PropertyID::AnimationName); if (!animation_name) return OptionalNone {}; + if (animation_name->is_keyword() && animation_name->to_keyword() == Keyword::None) + return OptionalNone {}; if (animation_name->is_string()) return animation_name->as_string().string_value().to_string(); return animation_name->to_string(SerializationMode::Normal); diff --git a/Tests/LibWeb/Text/expected/WebAnimations/cancel-animation.txt b/Tests/LibWeb/Text/expected/WebAnimations/cancel-animation.txt new file mode 100644 index 00000000000..c3ab6b48279 --- /dev/null +++ b/Tests/LibWeb/Text/expected/WebAnimations/cancel-animation.txt @@ -0,0 +1 @@ +Animation cancelled diff --git a/Tests/LibWeb/Text/input/WebAnimations/cancel-animation.html b/Tests/LibWeb/Text/input/WebAnimations/cancel-animation.html new file mode 100644 index 00000000000..f2e427cacc7 --- /dev/null +++ b/Tests/LibWeb/Text/input/WebAnimations/cancel-animation.html @@ -0,0 +1,39 @@ + + + +
+ + + + +