Truly independent web browser
LibWeb: Keep frozen SVG animations from being replaced
Jelle Raaijmakers67b454f861f7
diff --git a/Libraries/LibWeb/Animations/Animation.cpp b/Libraries/LibWeb/Animations/Animation.cppindex 9d70eed35d2..d194b0035dc 100644--- a/Libraries/LibWeb/Animations/Animation.cpp+++ b/Libraries/LibWeb/Animations/Animation.cpp@@ -600,6 +600,9 @@ bool Animation::is_replaceable() const// element, nor a CSS transition with an owning element.if ((is_css_animation() || is_css_transition()) && owning_element().has_value())return false;+ // AD-HOC: Like a CSS animation with an owning element, an SVG animation element prescribes its animation in markup.+ if (is_smil_animation())+ return false;// - The animation's play state is finished.if (play_state() != AnimationPlayState::Finished)diff --git a/Tests/LibWeb/Text/expected/SVG/set-element-frozen-not-replaced.txt b/Tests/LibWeb/Text/expected/SVG/set-element-frozen-not-replaced.txtnew file mode 100644index 00000000000..97e440f0c78--- /dev/null+++ b/Tests/LibWeb/Text/expected/SVG/set-element-frozen-not-replaced.txt@@ -0,0 +1,3 @@+frozen set: rgb(0, 128, 0)+finished script animation: rgb(0, 0, 255)+cancelled script animation: rgb(0, 128, 0)diff --git a/Tests/LibWeb/Text/input/SVG/set-element-frozen-not-replaced.html b/Tests/LibWeb/Text/input/SVG/set-element-frozen-not-replaced.htmlnew file mode 100644index 00000000000..54f085d9933--- /dev/null+++ b/Tests/LibWeb/Text/input/SVG/set-element-frozen-not-replaced.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<svg>+ <rect id="rect" width="100" height="100" fill="red">+ <set attributeName="fill" to="green" dur="1ms" fill="freeze"/>+ </rect>+</svg>+<script>+ asyncTest(async done => {+ const nextFrame = () => new Promise(requestAnimationFrame);+ await nextFrame();+ await new Promise(resolve => setTimeout(resolve, 20));+ await nextFrame();+ println(`frozen set: ${getComputedStyle(rect).fill}`);++ const animation = rect.animate({ fill: "blue" }, { duration: 1, fill: "forwards" });+ await animation.finished;+ await nextFrame();+ await nextFrame();+ println(`finished script animation: ${getComputedStyle(rect).fill}`);++ animation.cancel();+ await nextFrame();+ println(`cancelled script animation: ${getComputedStyle(rect).fill}`);+ done();+ });+</script>