Skip to content

Truly independent web browser

LibWeb: Allow CSS animations on UA shadow pseudo-elements

Andreas Klinge0338696d77b
diff --git a/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs b/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
index bf27182e504..2a984364204 100644
--- a/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
@@ -1018,7 +1018,10 @@ impl RetainedState {
}
let state = self.with_cascade_interning_counters(|groups| groups.intern_sorted(&winners, None));
for property in self.winner_groups.semantic_delta_properties(None, state) {
- if self.first_record_winner_needs_cpp(property) {
+ if self.first_record_winner_needs_cpp(property)
+ && !(super::property_declares_css_animations(property)
+ && self.may_plan_css_animations(node, state, scratch))
+ {
self.counters.bump(Counter::EngineComputedRecordBailProperty);
return Err(Unanswered::Refused);
}
@@ -1168,6 +1171,11 @@ impl RetainedState {
scratch.noted_substitution = Some(substituted);
let reads_sibling_position = store.uses_tree_counting_function(self);
self.note_sibling_position_reads(node, u8::MAX, reads_sibling_position);
+ // NB: The record is bound to the state it was cascaded from, so that installing it can find where the winning
+ // `animation-name` was declared and start the animations it names.
+ let generation = self.winner_groups.generation();
+ self.computed_group_sets
+ .bind_cascade_state(computed::ComputedStyleTarget::new(node, u8::MAX), (generation, state));
let old_record = old_record.unwrap_or(computed::FinalStyleRecordID::NONE);
let owes_a_transition_step = owes_a_transition_step && old_record != record;
if owes_a_transition_step || detached_composition.is_some() {
diff --git a/Tests/LibWeb/Text/expected/css/placeholder-css-animation.txt b/Tests/LibWeb/Text/expected/css/placeholder-css-animation.txt
new file mode 100644
index 00000000000..89021477e06
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/placeholder-css-animation.txt
@@ -0,0 +1,4 @@
+ [s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
+ [s2] transform=[1,0,0,1,50,0] origin=(92.84375,18) (BlockContainer<DIV>)
+ [s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
+ [s2] transform=[1,0,0,1,50,0] origin=(92.84375,18) (BlockContainer<DIV>)
diff --git a/Tests/LibWeb/Text/input/css/placeholder-css-animation.html b/Tests/LibWeb/Text/input/css/placeholder-css-animation.html
new file mode 100644
index 00000000000..21ed525495b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/placeholder-css-animation.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ @keyframes slide {
+ from {
+ transform: translateX(0);
+ }
+ to {
+ transform: translateX(100px);
+ }
+ }
+ input::placeholder {
+ display: inline-block;
+ animation: slide 1s linear -0.5s paused;
+ }
+</style>
+<input placeholder="hello">
+<script>
+ test(() => {
+ const dumpTransforms = () =>
+ println(internals.dumpDisplayList().split("\n").filter(line => line.includes("transform=")).join("\n"));
+ dumpTransforms();
+
+ // Restyling the placeholder again keeps the animation where it was.
+ const input = document.querySelector("input");
+ for (const name of ["first", "second"]) {
+ input.className = name;
+ getComputedStyle(input, "::placeholder").transform;
+ }
+ dumpTransforms();
+ });
+</script>