Truly independent web browser
LibWeb: Sample animations of elements below display: none
Andreas Kling7d42495434ee
diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cppindex 1d32c43cdb6..9736b16177d 100644--- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp+++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp@@ -1310,8 +1310,11 @@ void KeyframeEffect::update_computed_properties(AnimationUpdateContext& context)// the update being skipped is the one that applies or removes that override, so it must always run.// NB: A descendant's retained style can still describe a display-none subtree while ancestor visibility// reactions are propagating, so inspect the current target and ancestor styles before skipping its update.+ // NB: Only a pseudo-element can skip it. What an element animates reaches the SVG paint servers below it, which+ // keep their style under display: none.DOM::AbstractElement abstract_element { *target, pseudo_element_type() };- if (!target_properties().contains(CSS::PropertyNameAndID::from_id(CSS::PropertyID::Display))+ if (abstract_element.pseudo_element().has_value()+ && !target_properties().contains(CSS::PropertyNameAndID::from_id(CSS::PropertyID::Display))&& is_in_display_none_subtree_ignoring_animations(abstract_element))return;diff --git a/Tests/LibWeb/Ref/expected/css/style-engine/gradient-stop-inherits-animated-color-below-display-none-ref.html b/Tests/LibWeb/Ref/expected/css/style-engine/gradient-stop-inherits-animated-color-below-display-none-ref.htmlnew file mode 100644index 00000000000..624c656e44e--- /dev/null+++ b/Tests/LibWeb/Ref/expected/css/style-engine/gradient-stop-inherits-animated-color-below-display-none-ref.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<style>+ svg { display: inline-block; width: 40px; height: 40px; }+</style>+<svg><rect width="40" height="40" fill="green" /></svg>+<svg><rect width="40" height="40" fill="green" /></svg>diff --git a/Tests/LibWeb/Ref/input/css/style-engine/gradient-stop-inherits-animated-color-below-display-none.html b/Tests/LibWeb/Ref/input/css/style-engine/gradient-stop-inherits-animated-color-below-display-none.htmlnew file mode 100644index 00000000000..689da16b523--- /dev/null+++ b/Tests/LibWeb/Ref/input/css/style-engine/gradient-stop-inherits-animated-color-below-display-none.html@@ -0,0 +1,33 @@+<!DOCTYPE html>+<html class="reftest-wait">+<link rel="match" href="../../../expected/css/style-engine/gradient-stop-inherits-animated-color-below-display-none-ref.html">+<style>+ .hidden { color: red; display: none; }+ stop { stop-color: currentColor; }+ svg.swatch { display: inline-block; width: 40px; height: 40px; }+</style>+<div id="running" class="hidden">+ <svg><linearGradient id="running-gradient"><stop /></linearGradient></svg>+</div>+<div id="paused" class="hidden">+ <svg><linearGradient id="paused-gradient"><stop /></linearGradient></svg>+</div>+<svg class="swatch"><rect width="40" height="40" fill="url(#running-gradient)" /></svg>+<svg class="swatch"><rect width="40" height="40" fill="url(#paused-gradient)" /></svg>+<script>+ const nextFrames = async () => {+ await new Promise(resolve => requestAnimationFrame(resolve));+ await new Promise(resolve => requestAnimationFrame(resolve));+ };+ (async () => {+ await nextFrames();+ const keyframes = { color: ["green", "green"] };+ const options = { duration: 1000000 };+ document.getElementById("running").animate(keyframes, options);+ document.getElementById("paused").animate(keyframes, options).pause();+ await nextFrames();+ await nextFrames();+ document.documentElement.classList.remove("reftest-wait");+ })();+</script>+</html>