Skip to content

Truly independent web browser

LibWeb: Don't crash reading below a hidden animated custom property

Andreas Kling35409f1ca1de
diff --git a/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs b/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs
index 6bbc2799e86..b476f34a760 100644
--- a/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs
@@ -147,6 +147,12 @@ impl Application<'_> {
for &record in &installation.pinned_records {
engine.unpin_layout_style_record(record);
}
+ // NB: Installing the record replays the element's animations over it, which ask to restyle what reads the
+ // custom properties they sample. The next demand of the walk reads those from here, and what the walk
+ // does not reach computes when something reads it.
+ // FIXME: A read below an element that is not displayed stays at the first sampled value of a custom property
+ // animation that moves later.
+ engine.consume_element_style_input(node);
});
true
}
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/read-below-animated-custom-property-in-hidden-subtree.txt b/Tests/LibWeb/Text/expected/css/style-engine/read-below-animated-custom-property-in-hidden-subtree.txt
new file mode 100644
index 00000000000..ad283c4f183
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/read-below-animated-custom-property-in-hidden-subtree.txt
@@ -0,0 +1,3 @@
+36.000001deg
+0deg
+36.000001deg
diff --git a/Tests/LibWeb/Text/input/css/style-engine/read-below-animated-custom-property-in-hidden-subtree.html b/Tests/LibWeb/Text/input/css/style-engine/read-below-animated-custom-property-in-hidden-subtree.html
new file mode 100644
index 00000000000..24815735427
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/read-below-animated-custom-property-in-hidden-subtree.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<style>
+ @property --spin {
+ syntax: "<angle>";
+ inherits: true;
+ initial-value: 0deg;
+ }
+ @keyframes spin {
+ to {
+ --spin: 360deg;
+ }
+ }
+ #animated {
+ animation: spin 100s linear infinite paused -10s;
+ }
+</style>
+<div id="hidden">
+ <div id="animated"><div id="reader"></div></div>
+</div>
+<script src="../../include.js"></script>
+<script>
+ test(() => {
+ println(getComputedStyle(reader).getPropertyValue("--spin"));
+ hidden.style.display = "none";
+ println(getComputedStyle(reader).getPropertyValue("--spin"));
+ hidden.style.display = "";
+ println(getComputedStyle(reader).getPropertyValue("--spin"));
+ });
+</script>