Skip to content

Truly independent web browser

LibWeb: Restyle a `::placeholder` whose transition was cancelled

Tim Ledbetter181087330d6b
diff --git a/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs b/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
index 2a984364204..9347e5478d8 100644
--- a/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
@@ -964,9 +964,11 @@ impl RetainedState {
return Err(Unanswered::Refused);
}
// A record it already holds is replaced by a full drive. A composition laid over it is
- // the element's own effects, sampled again over the new base.
+ // the element's own effects, sampled again over the new base, or ended effects, which the
+ // new base drops.
let old_record = self.computed_group_sets.assigned_style_record(node);
- if old_record.is_some_and(|old| !animates && self.record_holds_an_animation_overlay(old)) {
+ let composes_animations = old_record.is_some_and(|old| self.record_holds_an_animation_overlay(old));
+ if composes_animations && !scratch.host_applies_animation_plans {
self.counters.bump(Counter::EngineComputedRecordBailRecordOverlay);
return Err(Unanswered::Refused);
}
@@ -1143,7 +1145,7 @@ impl RetainedState {
self.table_counter_style_environment_identity(computed::ComputedStyleTarget::new(node, u8::MAX), &table);
// The composition stays pinned for the host's step, which reads it as the before-change
// style, until the host installs the new base or the derivation is reverted.
- let detached_composition = animates
+ let detached_composition = composes_animations
.then(|| self.computed_group_sets.detach_composition(node))
.flatten();
let replaced = self.computed_group_sets.replaced_columns(node);
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/placeholder-shown-after-cancelled-transition.txt b/Tests/LibWeb/Text/expected/css/style-engine/placeholder-shown-after-cancelled-transition.txt
new file mode 100644
index 00000000000..8caf446f554
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/placeholder-shown-after-cancelled-transition.txt
@@ -0,0 +1,3 @@
+initial: block, opacity 1
+with a value: none
+without a value: block, opacity 0
diff --git a/Tests/LibWeb/Text/input/css/style-engine/placeholder-shown-after-cancelled-transition.html b/Tests/LibWeb/Text/input/css/style-engine/placeholder-shown-after-cancelled-transition.html
new file mode 100644
index 00000000000..4065229330f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/placeholder-shown-after-cancelled-transition.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<style>
+ #input::placeholder {
+ transition: opacity 100s linear;
+ }
+ #input.faded::placeholder {
+ opacity: 0;
+ }
+</style>
+<input id="input" placeholder="Placeholder">
+<script>
+ promiseTest(async () => {
+ const placeholderStyle = getComputedStyle(input, "::placeholder");
+ println(`initial: ${placeholderStyle.display}, opacity ${placeholderStyle.opacity}`);
+ input.classList.add("faded");
+ await animationFrame();
+ input.value = "Value";
+ println(`with a value: ${placeholderStyle.display}`);
+ await animationFrame();
+ input.value = "";
+ println(`without a value: ${placeholderStyle.display}, opacity ${placeholderStyle.opacity}`);
+ });
+</script>