mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Fix selectionchange
event dispatch on text control elements
With a8077f79cc
Selection object is no
longer aware of selection state inside text controls (<textarea> and
<input>), so this change makes them responsible for dispatching
`selectionchange` if their selection state was changed.
This commit is contained in:
parent
3a6b698572
commit
e915143593
Notes:
github-actions[bot]
2024-11-01 14:07:07 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: e915143593
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2094
Reviewed-by: https://github.com/gmta ✅
7 changed files with 91 additions and 70 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/Position.h>
|
||||
#include <LibWeb/DOM/SelectionchangeEventDispatching.h>
|
||||
#include <LibWeb/HTML/FormAssociatedElement.h>
|
||||
#include <LibWeb/HTML/HTMLButtonElement.h>
|
||||
#include <LibWeb/HTML/HTMLFieldSetElement.h>
|
||||
|
@ -580,9 +581,7 @@ void FormAssociatedTextControlElement::set_the_selection_range(Optional<WebIDL::
|
|||
});
|
||||
}
|
||||
|
||||
// AD-HOC: Notify the element that the selection was changed, so it can perform
|
||||
// element-specific updates.
|
||||
selection_was_changed(m_selection_start, m_selection_end);
|
||||
selection_was_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -657,6 +656,15 @@ void FormAssociatedTextControlElement::collapse_selection_to_offset(size_t posit
|
|||
|
||||
void FormAssociatedTextControlElement::selection_was_changed()
|
||||
{
|
||||
auto& element = form_associated_element_to_html_element();
|
||||
if (is<HTML::HTMLInputElement>(element)) {
|
||||
schedule_a_selectionchange_event(static_cast<HTML::HTMLInputElement&>(element), element.document());
|
||||
} else if (is<HTML::HTMLTextAreaElement>(element)) {
|
||||
schedule_a_selectionchange_event(static_cast<HTML::HTMLTextAreaElement&>(element), element.document());
|
||||
} else {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
auto text_node = form_associated_element_to_text_node();
|
||||
if (!text_node)
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue