diff --git a/Libraries/LibWeb/Layout/TextNode.cpp b/Libraries/LibWeb/Layout/TextNode.cpp index 79f19daab5f..00e87718999 100644 --- a/Libraries/LibWeb/Layout/TextNode.cpp +++ b/Libraries/LibWeb/Layout/TextNode.cpp @@ -321,6 +321,11 @@ String const& TextNode::text_for_rendering() const // NOTE: This collapses whitespace into a single ASCII space if the CSS white-space property tells us to. void TextNode::compute_text_for_rendering() { + if (dom_node().is_password_input()) { + m_text_for_rendering = MUST(String::repeated('*', dom_node().data().code_points().length())); + return; + } + bool collapse = [](CSS::WhiteSpace white_space) { switch (white_space) { case CSS::WhiteSpace::Normal: @@ -345,11 +350,6 @@ void TextNode::compute_text_for_rendering() auto data_view = data.bytes_as_string_view(); - if (dom_node().is_password_input()) { - m_text_for_rendering = MUST(String::repeated('*', data_view.length())); - return; - } - if (!collapse || data.is_empty()) { m_text_for_rendering = data; return; diff --git a/Tests/LibWeb/Layout/expected/unicode-password-input.txt b/Tests/LibWeb/Layout/expected/unicode-password-input.txt new file mode 100644 index 00000000000..c3583215e42 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/unicode-password-input.txt @@ -0,0 +1,19 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x37 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x21 children: inline + frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 200x19] baseline: 14.296875 + BlockContainer at (9,9) content-size 200x19 inline-block [BFC] children: not-inline + Box
at (11,10) content-size 196x17 flex-container(row) [FFC] children: not-inline + BlockContainer
at (11,10) content-size 196x17 flex-item [BFC] children: inline + frag 0 from TextNode start: 0, length: 14, rect: [11,10 111.125x17] baseline: 13.296875 + "**************" + TextNode <#text> + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x37] + PaintableWithLines (BlockContainer) [8,8 784x21] + PaintableWithLines (BlockContainer) [8,8 202x21] + PaintableBox (Box
) [9,9 200x19] + PaintableWithLines (BlockContainer
) [11,10 196x17] + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/input/unicode-password-input.html b/Tests/LibWeb/Layout/input/unicode-password-input.html new file mode 100644 index 00000000000..2b0fbb0f378 --- /dev/null +++ b/Tests/LibWeb/Layout/input/unicode-password-input.html @@ -0,0 +1,2 @@ + +