LibWeb: Allow non-HTMLInputElements to have did_edit_text_node() called

HTMLTextAreaElement also needs to be told when its contained text node
has been edited, so let's make this functionality work for anyone who
extends the new EditableTextNodeOwner interface class.
This commit is contained in:
Sam Atkins 2023-08-30 14:38:58 +01:00 committed by Andreas Kling
parent ce556c9566
commit 4897643ffb
Notes: sideshowbarker 2024-07-17 05:18:58 +09:00
5 changed files with 22 additions and 18 deletions

View file

@ -13,7 +13,6 @@
#include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/HTMLDivElement.h>
@ -504,7 +503,7 @@ void HTMLInputElement::create_shadow_tree_if_needed()
m_placeholder_text_node = heap().allocate<DOM::Text>(realm(), document(), MUST(String::from_deprecated_string(initial_value)));
m_placeholder_text_node->set_data(deprecated_attribute(HTML::AttributeNames::placeholder));
m_placeholder_text_node->set_owner_input_element({}, *this);
m_placeholder_text_node->set_editable_text_node_owner(Badge<HTMLInputElement> {}, *this);
MUST(m_placeholder_element->append_child(*m_placeholder_text_node));
MUST(element->append_child(*m_placeholder_element));
@ -519,7 +518,7 @@ void HTMLInputElement::create_shadow_tree_if_needed()
handle_readonly_attribute(deprecated_attribute(HTML::AttributeNames::readonly));
}
m_text_node->set_owner_input_element({}, *this);
m_text_node->set_editable_text_node_owner(Badge<HTMLInputElement> {}, *this);
if (m_type == TypeAttributeState::Password)
m_text_node->set_is_password_input({}, true);