From ad25a415ae9a8a14263e0f54e55d48481a8ed519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Oppeb=C3=B8en?= Date: Tue, 29 Nov 2022 09:32:36 +0100 Subject: [PATCH] LibWeb: Return the position at end-of-line in TextCursor hit-test When starting to drag the cursor below the text, we would start the selection from the closest point in the line above in the last fragment. This is not the behavior seen in other browsers, and it causes weird behavior when the cursor is to the left of the last fragment, for instances when trying to select with the text `before middle after`. By starting the selection from the _end_ of the last fragment, including the line end character, selection behavior is similar to that of other browsers. --- Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index b6f0804f78..73b87f496d 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -700,7 +700,7 @@ Optional PaintableWithLines::hit_test(Gfx::FloatPoint const& posi return HitTestResult { *fragment.layout_node().paintable(), fragment.text_index_at(position.x()) }; } if (fragment_absolute_rect.top() <= position.y()) - last_good_candidate = HitTestResult { *fragment.layout_node().paintable(), fragment.text_index_at(position.x()) }; + last_good_candidate = HitTestResult { *fragment.layout_node().paintable(), fragment.length() + 1 }; } }