LibWeb: Update the <textarea> shadow DOM after reseting its form owner

This generally happens after a form is submitted. We need to update the
text node in the shadow DOM to actually display the reset value.
This commit is contained in:
Timothy Flynn 2024-03-14 10:33:15 -04:00 committed by Andreas Kling
parent c0d594568d
commit 9eb38ce79c
3 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,26 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x34 children: not-inline
BlockContainer <form#form> at (8,8) content-size 784x34 children: inline
frag 0 from BlockContainer start: 0, length: 0, rect: [11,11 185.875x28] baseline: 13.296875
TextNode <#text>
BlockContainer <textarea#textarea> at (11,11) content-size 185.875x28 inline-block [BFC] children: not-inline
BlockContainer <div> at (11,11) content-size 185.875x17 children: not-inline
BlockContainer <div> at (11,11) content-size 185.875x17 children: inline
frag 0 from TextNode start: 0, length: 14, rect: [11,11 108.453125x17] baseline: 13.296875
"Original value"
TextNode <#text>
TextNode <#text>
BlockContainer <(anonymous)> at (8,58) content-size 784x0 children: inline
TextNode <#text>
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x34] overflow: [8,8 784x50]
PaintableWithLines (BlockContainer<FORM>#form) [8,8 784x34]
PaintableWithLines (BlockContainer<TEXTAREA>#textarea) [8,8 191.875x34]
PaintableWithLines (BlockContainer<DIV>) [11,11 185.875x17]
PaintableWithLines (BlockContainer<DIV>) [11,11 185.875x17]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [8,58 784x0]

View file

@ -0,0 +1,10 @@
<form id="form">
<textarea id="textarea">Original value</textarea>
</form>
<script type="text/javascript">
let textarea = document.getElementById("textarea");
textarea.value = "Modified value";
let form = document.getElementById("form");
form.reset();
</script>

View file

@ -96,7 +96,10 @@ void HTMLTextAreaElement::reset_algorithm()
// and set the raw value of element to its child text content.
set_raw_value(child_text_content());
update_placeholder_visibility();
if (m_text_node) {
m_text_node->set_text_content(m_raw_value);
update_placeholder_visibility();
}
}
void HTMLTextAreaElement::form_associated_element_was_inserted()