summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-26 21:00:26 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-26 21:00:26 +0200
commite3bfe0b5095e9a0bdeb73d8f72bab3138f4494bf (patch)
tree029b3dd70239699e892b4d2433e14dfde727cfc9 /Libraries
parent8cc2a55cffa125e5332efe7e31a67ade5757d20b (diff)
downloadserenity-e3bfe0b5095e9a0bdeb73d8f72bab3138f4494bf.zip
LibWeb: Fix sometimes missing text selection highlight
There's no selection if it starts and ends at the same column, but only if both columns are in the same node. :^)
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibWeb/Layout/LineBoxFragment.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Libraries/LibWeb/Layout/LineBoxFragment.cpp b/Libraries/LibWeb/Layout/LineBoxFragment.cpp
index 118ea3bc35..05332f8007 100644
--- a/Libraries/LibWeb/Layout/LineBoxFragment.cpp
+++ b/Libraries/LibWeb/Layout/LineBoxFragment.cpp
@@ -116,9 +116,6 @@ Gfx::FloatRect LineBoxFragment::selection_rect(const Gfx::Font& font) const
const auto end_index = m_start + m_length;
auto text = this->text();
- if (selection.start().index_in_node == selection.end().index_in_node)
- return {};
-
if (layout_node().selection_state() == LayoutNode::SelectionState::StartAndEnd) {
// we are in the start/end node (both the same)
if (start_index > selection.end().index_in_node)
@@ -126,6 +123,9 @@ Gfx::FloatRect LineBoxFragment::selection_rect(const Gfx::Font& font) const
if (end_index < selection.start().index_in_node)
return {};
+ if (selection.start().index_in_node == selection.end().index_in_node)
+ return {};
+
auto selection_start_in_this_fragment = max(0, selection.start().index_in_node - m_start);
auto selection_end_in_this_fragment = min(m_length, selection.end().index_in_node - m_start);
auto pixel_distance_to_first_selected_character = font.width(text.substring_view(0, selection_start_in_this_fragment));