mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 13:37:10 +09: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.
This commit is contained in:
parent
badcdcacf5
commit
732e3fa82f
Notes:
github-actions[bot]
2024-08-27 11:12:49 +00:00
Author: https://github.com/gmta
Commit: 732e3fa82f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1193
Reviewed-by: https://github.com/trflynn89 ✅
6 changed files with 42 additions and 7 deletions
|
@ -45,6 +45,7 @@
|
|||
#include <LibWeb/MimeSniff/Resource.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Selection/Selection.h>
|
||||
#include <LibWeb/UIEvents/EventNames.h>
|
||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
|
@ -2353,4 +2354,13 @@ HTMLInputElement::ValueAttributeMode HTMLInputElement::value_attribute_mode() co
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void HTMLInputElement::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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue