mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 00:49:46 +00:00
LibWeb: Select the entire input when double clicking password fields
This matches the behavior of other browsers, and hides any indication of word boundaries in the password.
This commit is contained in:
parent
ded337cfec
commit
57b5df21c7
Notes:
github-actions[bot]
2025-08-10 09:06:42 +00:00
Author: https://github.com/trflynn89
Commit: 57b5df21c7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5801
3 changed files with 21 additions and 4 deletions
|
|
@ -974,11 +974,18 @@ EventResult EventHandler::handle_doubleclick(CSSPixelPoint viewport_position, CS
|
|||
|
||||
auto& hit_paintable = static_cast<Painting::TextPaintable const&>(*result->paintable);
|
||||
auto& hit_dom_node = const_cast<DOM::Text&>(as<DOM::Text>(*hit_paintable.dom_node()));
|
||||
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 target = document.active_input_events_target();
|
||||
if (target) {
|
||||
size_t previous_boundary = 0;
|
||||
size_t next_boundary = 0;
|
||||
|
||||
if (hit_dom_node.is_password_input()) {
|
||||
next_boundary = hit_dom_node.length_in_utf16_code_units();
|
||||
} else {
|
||||
previous_boundary = hit_dom_node.word_segmenter().previous_boundary(result->index_in_node, Unicode::Segmenter::Inclusive::Yes).value_or(0);
|
||||
next_boundary = hit_dom_node.word_segmenter().next_boundary(result->index_in_node).value_or(hit_dom_node.length());
|
||||
}
|
||||
|
||||
if (auto* target = document.active_input_events_target()) {
|
||||
target->set_selection_anchor(hit_dom_node, previous_boundary);
|
||||
target->set_selection_focus(hit_dom_node, next_boundary);
|
||||
} else if (auto selection = node->document().get_selection()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue