diff --git a/Tests/LibWeb/Layout/expected/input-password-to-text.txt b/Tests/LibWeb/Layout/expected/input-password-to-text.txt new file mode 100644 index 00000000000..b864f5ed6dd --- /dev/null +++ b/Tests/LibWeb/Layout/expected/input-password-to-text.txt @@ -0,0 +1,20 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x21 children: inline + frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 189.875x19] baseline: 13.296875 + BlockContainer at (9,9) content-size 189.875x19 inline-block [BFC] children: not-inline + Box
at (11,10) content-size 185.875x17 flex-container(row) [FFC] children: not-inline + BlockContainer
at (11,10) content-size 185.875x17 flex-item [BFC] children: inline + frag 0 from TextNode start: 0, length: 7, rect: [11,10 61.890625x17] baseline: 13.296875 + "hunter2" + TextNode <#text> + TextNode <#text> + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x600] + PaintableWithLines (BlockContainer) [8,8 784x21] + PaintableWithLines (BlockContainer) [8,8 191.875x21] + PaintableBox (Box
) [9,9 189.875x19] + PaintableWithLines (BlockContainer
) [11,10 185.875x17] + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/expected/input-text-to-password.txt b/Tests/LibWeb/Layout/expected/input-text-to-password.txt new file mode 100644 index 00000000000..0126db96b5a --- /dev/null +++ b/Tests/LibWeb/Layout/expected/input-text-to-password.txt @@ -0,0 +1,20 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x21 children: inline + frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 189.875x19] baseline: 13.296875 + BlockContainer at (9,9) content-size 189.875x19 inline-block [BFC] children: not-inline + Box
at (11,10) content-size 185.875x17 flex-container(row) [FFC] children: not-inline + BlockContainer
at (11,10) content-size 185.875x17 flex-item [BFC] children: inline + frag 0 from TextNode start: 0, length: 7, rect: [11,10 55.5625x17] baseline: 13.296875 + "*******" + TextNode <#text> + TextNode <#text> + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x600] + PaintableWithLines (BlockContainer) [8,8 784x21] + PaintableWithLines (BlockContainer) [8,8 191.875x21] + PaintableBox (Box
) [9,9 189.875x19] + PaintableWithLines (BlockContainer
) [11,10 185.875x17] + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/input/input-password-to-text.html b/Tests/LibWeb/Layout/input/input-password-to-text.html new file mode 100644 index 00000000000..fcb9f9e9122 --- /dev/null +++ b/Tests/LibWeb/Layout/input/input-password-to-text.html @@ -0,0 +1,7 @@ + + diff --git a/Tests/LibWeb/Layout/input/input-text-to-password.html b/Tests/LibWeb/Layout/input/input-text-to-password.html new file mode 100644 index 00000000000..ac489c5fb1b --- /dev/null +++ b/Tests/LibWeb/Layout/input/input-text-to-password.html @@ -0,0 +1,7 @@ + + diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index a9cff20b78e..36ff501e04e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -612,6 +612,14 @@ void HTMLInputElement::update_placeholder_visibility() } } +void HTMLInputElement::update_text_input_shadow_tree() +{ + if (m_text_node) { + m_text_node->set_data(m_value); + update_placeholder_visibility(); + } +} + // https://html.spec.whatwg.org/multipage/input.html#the-input-element:attr-input-readonly-3 static bool is_allowed_to_be_readonly(HTML::HTMLInputElement::TypeAttributeState state) { @@ -746,6 +754,7 @@ void HTMLInputElement::update_shadow_tree() update_slider_thumb_element(); break; default: + update_text_input_shadow_tree(); break; } } @@ -1073,6 +1082,9 @@ void HTMLInputElement::form_associated_element_attribute_changed(FlyString const } } else if (name == HTML::AttributeNames::type) { m_type = parse_type_attribute(value.value_or(String {})); + + set_shadow_root(nullptr); + create_shadow_tree_if_needed(); } else if (name == HTML::AttributeNames::value) { if (!m_dirty_value) { if (!value.has_value()) { @@ -1081,7 +1093,6 @@ void HTMLInputElement::form_associated_element_attribute_changed(FlyString const m_value = value_sanitization_algorithm(*value); } - update_placeholder_visibility(); update_shadow_tree(); } } else if (name == HTML::AttributeNames::placeholder) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 68188a52494..e530b18a3fc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -265,6 +265,7 @@ private: JS::GCPtr m_placeholder_element; JS::GCPtr m_placeholder_text_node; + void update_text_input_shadow_tree(); JS::GCPtr m_inner_text_element; JS::GCPtr m_text_node; bool m_checked { false };