summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetsui Ohkubo <peryaudo@gmail.com>2021-08-11 22:30:38 +0900
committerAndreas Kling <kling@serenityos.org>2021-08-15 15:14:37 +0200
commit2edf4b7f616571884191379a2950dc8790950a55 (patch)
tree822838e9f2001c77688ce199abedf181d249e796
parentc27abaabc449e20e8cffac245d1e2686f94e2ba6 (diff)
downloadserenity-2edf4b7f616571884191379a2950dc8790950a55.zip
LibWeb: Return correct selection_rect when the node is at the end
When the selection state of the node is SelectionState::End, the end position of the selection within the fragment is not properly calculated, because it forgets to subtract m_start from index_in_node, unlike SelectionState::StartAndEnd. This resulted in a wrong selection shadow being painted when the node is at the end of the selection. This change resolves #5880.
-rw-r--r--Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp
index 325529e12e..adbe6711a0 100644
--- a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp
+++ b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp
@@ -137,7 +137,7 @@ Gfx::FloatRect LineBoxFragment::selection_rect(const Gfx::Font& font) const
return {};
auto selection_start_in_this_fragment = 0;
- auto selection_end_in_this_fragment = min(selection.end().index_in_node, m_length);
+ auto selection_end_in_this_fragment = min(selection.end().index_in_node - m_start, m_length);
auto pixel_distance_to_first_selected_character = font.width(text.substring_view(0, selection_start_in_this_fragment));
auto pixel_width_of_selection = font.width(text.substring_view(selection_start_in_this_fragment, selection_end_in_this_fragment - selection_start_in_this_fragment)) + 1;