From 96ad310643ff90af557b9ca71db450ebd4d37ba5 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 27 Aug 2024 10:22:35 -0400 Subject: [PATCH] LibWeb: Remove range-count filter from selection change handlers The implementation of setBaseAndExtent will create a new range. --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 7 ++----- Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 7a68d4c434e..001996a3eea 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -2366,11 +2366,8 @@ void HTMLInputElement::selection_was_changed(size_t selection_start, size_t sele { document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end)); - auto selection = document().get_selection(); - if (!selection || selection->range_count() == 0) - return; - - MUST(selection->set_base_and_extent(*m_text_node, selection_start, *m_text_node, selection_end)); + if (auto selection = document().get_selection()) + MUST(selection->set_base_and_extent(*m_text_node, selection_start, *m_text_node, selection_end)); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index c2a3b05e400..1d639455212 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -464,11 +464,8 @@ void HTMLTextAreaElement::selection_was_changed(size_t selection_start, size_t s { document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end)); - auto selection = document().get_selection(); - if (!selection || selection->range_count() == 0) - return; - - MUST(selection->set_base_and_extent(*m_text_node, selection_start, *m_text_node, selection_end)); + if (auto selection = document().get_selection()) + MUST(selection->set_base_and_extent(*m_text_node, selection_start, *m_text_node, selection_end)); } }