From 4fec1508c5246296b6d132dd103aed311e5e70b5 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Thu, 19 Dec 2024 00:00:54 +0100 Subject: [PATCH] text: Always use default text format for empty text This behavior is observable in Flash Player, because the caret in empty input text fields uses this format to be rendered. --- core/src/html/text_format.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/html/text_format.rs b/core/src/html/text_format.rs index 4596fe65031e..f7f761739c4b 100644 --- a/core/src/html/text_format.rs +++ b/core/src/html/text_format.rs @@ -1000,6 +1000,11 @@ impl FormatSpans { pub fn set_default_format(&mut self, tf: TextFormat) { self.default_format = tf.mix_with(self.default_format.clone()); + + // Empty text always gets the default format. + if self.text.is_empty() { + self.spans = vec![TextSpan::with_length_and_format(0, &self.default_format)]; + } } pub fn hide_text(&mut self) {