mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Use cached word segmenter for word selection in EventHandler
This commit is contained in:
parent
33507578e0
commit
da26941b50
Notes:
github-actions[bot]
2024-10-30 18:31:10 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/da26941b505 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2024
1 changed files with 2 additions and 8 deletions
|
@ -693,15 +693,9 @@ EventResult EventHandler::handle_doubleclick(CSSPixelPoint viewport_position, CS
|
|||
return EventResult::Accepted;
|
||||
|
||||
auto& hit_paintable = static_cast<Painting::TextPaintable const&>(*result->paintable);
|
||||
|
||||
auto& hit_dom_node = const_cast<DOM::Text&>(verify_cast<DOM::Text>(*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));
|
||||
|
|
Loading…
Reference in a new issue