mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +00:00
LibWeb: Collapse selection when selecting text inside a text control
This commit is contained in:
parent
584cbcf3ef
commit
2b1725ea51
Notes:
github-actions[bot]
2024-12-16 10:44:22 +00:00
Author: https://github.com/tcl3
Commit: 2b1725ea51
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2849
1 changed files with 6 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <LibUnicode/CharacterTypes.h>
|
#include <LibUnicode/CharacterTypes.h>
|
||||||
#include <LibUnicode/Segmenter.h>
|
#include <LibUnicode/Segmenter.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
|
#include <LibWeb/DOM/EditingHostManager.h>
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
#include <LibWeb/DOM/Position.h>
|
#include <LibWeb/DOM/Position.h>
|
||||||
#include <LibWeb/DOM/SelectionchangeEventDispatching.h>
|
#include <LibWeb/DOM/SelectionchangeEventDispatching.h>
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
#include <LibWeb/HTML/HTMLTextAreaElement.h>
|
#include <LibWeb/HTML/HTMLTextAreaElement.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||||
#include <LibWeb/Painting/Paintable.h>
|
#include <LibWeb/Painting/Paintable.h>
|
||||||
|
#include <LibWeb/Selection/Selection.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
@ -691,6 +693,8 @@ void FormAssociatedTextControlElement::select_all()
|
||||||
|
|
||||||
void FormAssociatedTextControlElement::set_selection_anchor(GC::Ref<DOM::Node> anchor_node, size_t anchor_offset)
|
void FormAssociatedTextControlElement::set_selection_anchor(GC::Ref<DOM::Node> anchor_node, size_t anchor_offset)
|
||||||
{
|
{
|
||||||
|
auto editing_host_manager = form_associated_element_to_html_element().document().editing_host_manager();
|
||||||
|
editing_host_manager->set_selection_anchor(anchor_node, anchor_offset);
|
||||||
auto text_node = form_associated_element_to_text_node();
|
auto text_node = form_associated_element_to_text_node();
|
||||||
if (!text_node || anchor_node != text_node)
|
if (!text_node || anchor_node != text_node)
|
||||||
return;
|
return;
|
||||||
|
@ -700,6 +704,8 @@ void FormAssociatedTextControlElement::set_selection_anchor(GC::Ref<DOM::Node> a
|
||||||
|
|
||||||
void FormAssociatedTextControlElement::set_selection_focus(GC::Ref<DOM::Node> focus_node, size_t focus_offset)
|
void FormAssociatedTextControlElement::set_selection_focus(GC::Ref<DOM::Node> focus_node, size_t focus_offset)
|
||||||
{
|
{
|
||||||
|
auto editing_host_manager = form_associated_element_to_html_element().document().editing_host_manager();
|
||||||
|
editing_host_manager->set_selection_focus(focus_node, focus_offset);
|
||||||
auto text_node = form_associated_element_to_text_node();
|
auto text_node = form_associated_element_to_text_node();
|
||||||
if (!text_node || focus_node != text_node)
|
if (!text_node || focus_node != text_node)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue