LibWeb: Add LayoutRange::normalized()

We use this to ensure that we're always working with a selection where
the start() is before the end() in document order. That simplifies all
the logic around this.
This commit is contained in:
Andreas Kling 2020-06-29 00:24:35 +02:00
commit 9177eea8fe
Notes: sideshowbarker 2024-07-19 05:19:58 +09:00
5 changed files with 61 additions and 1 deletions

View file

@ -97,7 +97,7 @@ int LineBoxFragment::text_index_at(float x) const
Gfx::FloatRect LineBoxFragment::selection_rect(const Gfx::Font& font) const
{
auto& selection = layout_node().root().selection();
auto selection = layout_node().root().selection().normalized();
if (!selection.is_valid())
return {};
if (!layout_node().is_text())