mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
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. :^)
This commit is contained in:
parent
8cc2a55cff
commit
e3bfe0b509
1 changed files with 3 additions and 3 deletions
|
@ -116,9 +116,6 @@ Gfx::FloatRect LineBoxFragment::selection_rect(const Gfx::Font& font) const
|
||||||
const auto end_index = m_start + m_length;
|
const auto end_index = m_start + m_length;
|
||||||
auto text = this->text();
|
auto text = this->text();
|
||||||
|
|
||||||
if (selection.start().index_in_node == selection.end().index_in_node)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
if (layout_node().selection_state() == LayoutNode::SelectionState::StartAndEnd) {
|
if (layout_node().selection_state() == LayoutNode::SelectionState::StartAndEnd) {
|
||||||
// we are in the start/end node (both the same)
|
// we are in the start/end node (both the same)
|
||||||
if (start_index > selection.end().index_in_node)
|
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)
|
if (end_index < selection.start().index_in_node)
|
||||||
return {};
|
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_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 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));
|
auto pixel_distance_to_first_selected_character = font.width(text.substring_view(0, selection_start_in_this_fragment));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue