Truly independent web browser
LibWeb: Keep old pseudo-element style alive until its box compares it
Tim Ledbetter3841842c3f98
diff --git a/Libraries/LibWeb/Animations/AnimationEffect.cpp b/Libraries/LibWeb/Animations/AnimationEffect.cppindex e728bcde210..21c03cce510 100644--- a/Libraries/LibWeb/Animations/AnimationEffect.cpp+++ b/Libraries/LibWeb/Animations/AnimationEffect.cpp@@ -897,7 +897,7 @@ void AnimationUpdateContext::publish()// transition baseline once the publication is compared with it, and from its originating element, whose// entry may install first and recompute its pseudo-element styles. An element holds its record until it// installs the published one, but a pseudo-element holds it nowhere, so the update pins it until its own- // entry.+ // entry ends.bool const may_record_baseline = style.animated_overlay() && !CSS::ComputedValuesFFI::rust_animated_overlay_is_empty(style.animated_overlay())&& document.is_in_style_stabilization_epoch();if (sample.element.pseudo_element().has_value())@@ -919,8 +919,10 @@ void AnimationUpdateContext::publish()bool const republished = element.style_record_identity() != data.style_record_before_update;if (!republished && may_record_baseline && (document.style_stabilization_has_style_reactions() || animated_property_invalidation.requires_base_style_recomputation))style_computer.record_transition_stabilization_baseline(element, data.style_record_before_update);- if (element.pseudo_element().has_value())- CSS::StyleEngineFFI::style_engine_unpin_style_record(style_computer.style_engine().host(), data.style_record_before_update.value());+ ScopeGuard unpin_installed_record = [&] {+ if (element.pseudo_element().has_value())+ CSS::StyleEngineFFI::style_engine_unpin_style_record(style_computer.style_engine().host(), data.style_record_before_update.value());+ };if (republished)continue;auto invalidation = CSS::decode_style_invalidation(animated_property_invalidation.invalidation);diff --git a/Tests/LibWeb/Crash/Animations/pseudo-element-animation-update-reads-released-overlay-record.html b/Tests/LibWeb/Crash/Animations/pseudo-element-animation-update-reads-released-overlay-record.htmlnew file mode 100644index 00000000000..ec331e257df--- /dev/null+++ b/Tests/LibWeb/Crash/Animations/pseudo-element-animation-update-reads-released-overlay-record.html@@ -0,0 +1,51 @@+<!DOCTYPE html>+<html class="test-wait">+<style>+@keyframes pulse {+ from { filter: blur(0px); }+ to { filter: blur(4px); }+}+@keyframes fade {+ from { opacity: 0; }+ to { opacity: 1; }+}+.pulsing::before {+ content: "x";+ animation: pulse 1s infinite;+}+.ending::after {+ content: "x";+}+.ending.run::after {+ animation: fade 60ms;+}+</style>+<body>+<script>+ for (let i = 0; i < 5; ++i) {+ const element = document.createElement("div");+ element.className = "pulsing";+ document.body.appendChild(element);+ }+ const ending = [];+ for (let i = 0; i < 200; ++i) {+ const element = document.createElement("div");+ element.className = "ending";+ document.body.appendChild(element);+ ending.push(element);+ }+ document.body.offsetHeight;+ for (const element of ending)+ element.classList.add("run");+ let remaining = ending.length;+ document.body.addEventListener("animationend", () => --remaining);+ function tick() {+ document.body.scrollHeight;+ if (remaining > 0)+ requestAnimationFrame(tick);+ else+ document.documentElement.classList.remove("test-wait");+ }+ requestAnimationFrame(tick);+</script>+</html>