mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-05 22:52:10 +02:00
LibWeb: Propagate input/textarea selection update to document selection
Calling `.setSelectionRange()` or `.select()` now updates the document selection as well, visualizing the text selection. (cherry picked from commit 732e3fa82f216a6f4114eb0e6bb89e167e95ab42)
This commit is contained in:
committed by
Nico Weber
parent
e140e94f25
commit
33562cc25e
@@ -22,6 +22,7 @@
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Selection/Selection.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
@@ -442,4 +443,13 @@ void HTMLTextAreaElement::queue_firing_input_event()
|
||||
});
|
||||
}
|
||||
|
||||
void HTMLTextAreaElement::selection_was_changed()
|
||||
{
|
||||
auto selection = document().get_selection();
|
||||
if (!selection || selection->range_count() == 0)
|
||||
return;
|
||||
|
||||
MUST(selection->set_base_and_extent(*m_text_node, selection_start().value(), *m_text_node, selection_end().value()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user