From da26941b505ea3a2aab1dae99c3a6d648f4222a9 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 30 Oct 2024 17:16:12 +0100 Subject: [PATCH] LibWeb: Use cached word segmenter for word selection in EventHandler --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 4583464d73c..440d3076cf5 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -693,15 +693,9 @@ EventResult EventHandler::handle_doubleclick(CSSPixelPoint viewport_position, CS return EventResult::Accepted; auto& hit_paintable = static_cast(*result->paintable); - auto& hit_dom_node = const_cast(verify_cast(*hit_paintable.dom_node())); - auto const& text_for_rendering = hit_paintable.text_for_rendering(); - - auto& segmenter = word_segmenter(); - segmenter.set_segmented_text(text_for_rendering); - - auto previous_boundary = segmenter.previous_boundary(result->index_in_node, Unicode::Segmenter::Inclusive::Yes).value_or(0); - auto next_boundary = segmenter.next_boundary(result->index_in_node).value_or(text_for_rendering.byte_count()); + auto previous_boundary = hit_dom_node.word_segmenter().previous_boundary(result->index_in_node, Unicode::Segmenter::Inclusive::Yes).value_or(0); + auto next_boundary = hit_dom_node.word_segmenter().next_boundary(result->index_in_node).value_or(hit_dom_node.length()); auto& realm = node->document().realm(); document.set_cursor_position(DOM::Position::create(realm, hit_dom_node, next_boundary));