mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
LibWeb: Delete EditableTextNodeOwner
It's no longer needed after FormAssociatedTextControlElement became responsible for managing input events for text controls.
This commit is contained in:
parent
34c0303ae1
commit
2a29e348c9
Notes:
github-actions[bot]
2024-11-06 17:06:03 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/2a29e348c96 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2199
8 changed files with 8 additions and 33 deletions
|
@ -48,15 +48,6 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> Text::construct_impl(JS::Realm& real
|
|||
return realm.heap().allocate<Text>(realm, window.associated_document(), data);
|
||||
}
|
||||
|
||||
EditableTextNodeOwner* Text::editable_text_node_owner()
|
||||
{
|
||||
if (!m_owner)
|
||||
return nullptr;
|
||||
EditableTextNodeOwner* owner = dynamic_cast<EditableTextNodeOwner*>(m_owner.ptr());
|
||||
VERIFY(owner);
|
||||
return owner;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-text-splittext
|
||||
// https://dom.spec.whatwg.org/#concept-text-split
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> Text::split_text(size_t offset)
|
||||
|
|
|
@ -13,12 +13,6 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
class EditableTextNodeOwner {
|
||||
public:
|
||||
virtual ~EditableTextNodeOwner() = default;
|
||||
virtual void did_edit_text_node() = 0;
|
||||
};
|
||||
|
||||
class Text
|
||||
: public CharacterData
|
||||
, public SlottableMixin {
|
||||
|
@ -39,10 +33,6 @@ public:
|
|||
Optional<size_t> max_length() const { return m_max_length; }
|
||||
void set_max_length(Optional<size_t> max_length) { m_max_length = move(max_length); }
|
||||
|
||||
template<DerivedFrom<EditableTextNodeOwner> T>
|
||||
void set_editable_text_node_owner(Badge<T>, Element& owner_element) { m_owner = &owner_element; }
|
||||
EditableTextNodeOwner* editable_text_node_owner();
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> split_text(size_t offset);
|
||||
String whole_text();
|
||||
|
||||
|
|
|
@ -607,7 +607,7 @@ void FormAssociatedTextControlElement::handle_insert(String const& data)
|
|||
MUST(set_range_text(data_for_insertion, selection_start.value(), selection_end.value(), Bindings::SelectionMode::End));
|
||||
|
||||
text_node->invalidate_style(DOM::StyleInvalidationReason::EditingInsertion);
|
||||
text_node->editable_text_node_owner()->did_edit_text_node();
|
||||
did_edit_text_node();
|
||||
}
|
||||
|
||||
void FormAssociatedTextControlElement::handle_delete(DeleteDirection direction)
|
||||
|
|
|
@ -170,6 +170,8 @@ public:
|
|||
bool has_scheduled_selectionchange_event() const { return m_has_scheduled_selectionchange_event; }
|
||||
void set_scheduled_selectionchange_event(bool value) { m_has_scheduled_selectionchange_event = value; }
|
||||
|
||||
virtual void did_edit_text_node() = 0;
|
||||
|
||||
virtual JS::GCPtr<DOM::Text> form_associated_element_to_text_node() = 0;
|
||||
virtual JS::GCPtr<DOM::Text const> form_associated_element_to_text_node() const { return const_cast<FormAssociatedTextControlElement&>(*this).form_associated_element_to_text_node(); }
|
||||
|
||||
|
|
|
@ -850,7 +850,6 @@ void HTMLInputElement::create_text_input_shadow_tree()
|
|||
|
||||
m_placeholder_text_node = heap().allocate<DOM::Text>(realm(), document(), String {});
|
||||
m_placeholder_text_node->set_data(placeholder());
|
||||
m_placeholder_text_node->set_editable_text_node_owner(Badge<HTMLInputElement> {}, *this);
|
||||
MUST(m_placeholder_element->append_child(*m_placeholder_text_node));
|
||||
|
||||
// https://www.w3.org/TR/css-ui-4/#input-rules
|
||||
|
@ -871,7 +870,6 @@ void HTMLInputElement::create_text_input_shadow_tree()
|
|||
} else {
|
||||
handle_readonly_attribute(attribute(HTML::AttributeNames::readonly));
|
||||
}
|
||||
m_text_node->set_editable_text_node_owner(Badge<HTMLInputElement> {}, *this);
|
||||
if (type_state() == TypeAttributeState::Password)
|
||||
m_text_node->set_is_password_input({}, true);
|
||||
handle_maxlength_attribute();
|
||||
|
|
|
@ -50,7 +50,6 @@ namespace Web::HTML {
|
|||
class HTMLInputElement final
|
||||
: public HTMLElement
|
||||
, public FormAssociatedTextControlElement
|
||||
, public DOM::EditableTextNodeOwner
|
||||
, public Layout::ImageProvider {
|
||||
WEB_PLATFORM_OBJECT(HTMLInputElement, HTMLElement);
|
||||
JS_DECLARE_ALLOCATOR(HTMLInputElement);
|
||||
|
@ -150,9 +149,6 @@ public:
|
|||
|
||||
WebIDL::ExceptionOr<void> show_picker();
|
||||
|
||||
// ^DOM::EditableTextNodeOwner
|
||||
virtual void did_edit_text_node() override;
|
||||
|
||||
// ^EventTarget
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-input-element
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
|
||||
|
@ -218,6 +214,8 @@ public:
|
|||
|
||||
Optional<String> selection_direction_binding() { return selection_direction(); }
|
||||
|
||||
// ^FormAssociatedTextControlElement
|
||||
virtual void did_edit_text_node() override;
|
||||
virtual JS::GCPtr<DOM::Text> form_associated_element_to_text_node() override { return m_text_node; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -370,7 +370,6 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed()
|
|||
|
||||
m_placeholder_text_node = heap().allocate<DOM::Text>(realm(), document(), String {});
|
||||
m_placeholder_text_node->set_data(get_attribute_value(HTML::AttributeNames::placeholder));
|
||||
m_placeholder_text_node->set_editable_text_node_owner(Badge<HTMLTextAreaElement> {}, *this);
|
||||
MUST(m_placeholder_element->append_child(*m_placeholder_text_node));
|
||||
|
||||
m_inner_text_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML));
|
||||
|
@ -378,7 +377,6 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed()
|
|||
|
||||
m_text_node = heap().allocate<DOM::Text>(realm(), document(), String {});
|
||||
handle_readonly_attribute(attribute(HTML::AttributeNames::readonly));
|
||||
m_text_node->set_editable_text_node_owner(Badge<HTMLTextAreaElement> {}, *this);
|
||||
// NOTE: If `children_changed()` was called before now, `m_raw_value` will hold the text content.
|
||||
// Otherwise, it will get filled in whenever that does get called.
|
||||
m_text_node->set_text_content(m_raw_value);
|
||||
|
|
|
@ -20,8 +20,7 @@ namespace Web::HTML {
|
|||
|
||||
class HTMLTextAreaElement final
|
||||
: public HTMLElement
|
||||
, public FormAssociatedTextControlElement
|
||||
, public DOM::EditableTextNodeOwner {
|
||||
, public FormAssociatedTextControlElement {
|
||||
WEB_PLATFORM_OBJECT(HTMLTextAreaElement, HTMLElement);
|
||||
JS_DECLARE_ALLOCATOR(HTMLTextAreaElement);
|
||||
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLTextAreaElement)
|
||||
|
@ -37,9 +36,6 @@ public:
|
|||
return textarea;
|
||||
}
|
||||
|
||||
// ^DOM::EditableTextNodeOwner
|
||||
virtual void did_edit_text_node() override;
|
||||
|
||||
// ^EventTarget
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-textarea-element
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
|
||||
|
@ -126,6 +122,8 @@ public:
|
|||
|
||||
void set_dirty_value_flag(Badge<FormAssociatedElement>, bool flag) { m_dirty_value = flag; }
|
||||
|
||||
// ^FormAssociatedTextControlElement
|
||||
virtual void did_edit_text_node() override;
|
||||
virtual JS::GCPtr<DOM::Text> form_associated_element_to_text_node() override { return m_text_node; }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue