From 0026213799a614cf67abe471652a39e80502ec58 Mon Sep 17 00:00:00 2001
From: Jo Steven Novaryo <65610990+stevennovaryo@users.noreply.github.com>
Date: Fri, 22 Aug 2025 12:43:38 +0800
Subject: [PATCH] dom: Implement textual `` lazy initialized placeholder
(#38821)
Following #37527, every textual input is constructing the containers for
value and placeholder. However not all of textual `` element
require the initialization of such placeholder container. This is
apparent with JS UI framework that defines its own placeholder
management.
This PR add lazy initialization for placeholder which construct the
relevant HTML elements for placeholder container whenever it is
necessary.
Testing: Existing WPT coverage
Signed-off-by: Jo Steven Novaryo
---
components/script/dom/htmlinputelement.rs | 119 ++++++++++++++--------
1 file changed, 77 insertions(+), 42 deletions(-)
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index cf68b60c90c..aa5693ad47d 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -121,11 +121,34 @@ const DEFAULT_FILE_INPUT_VALUE: &str = "No file chosen";
// But, this could be slower in performance and does have some discrepancies. For example,
// they would try to vertically align text baseline with the baseline of other
// TextNode within an inline flow. Another example is the horizontal scroll.
-// FIXME(stevennovaryo): Implement lazily initiated placeholder.
-// FIXME(stevennovaryo): Refactor these logic into a TextControl wrapper that would handle all textual input.
+// FIXME(#38263): Refactor these logics into a TextControl wrapper that would decouple all textual input.
struct InputTypeTextShadowTree {
+ inner_container: Dom,
text_container: Dom,
- placeholder_container: Dom,
+ placeholder_container: DomRefCell