From 3cabd17f9b6164d39ad95865b2920eaea8e0b2f9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 11 Jan 2023 19:45:03 +0100 Subject: [PATCH] LibWeb: Add convenient Selection::range() accessor This is a lot smoother than calling the throwsy get_range_at() API, especially since we know there at most 1 range in the selection. --- Userland/Libraries/LibWeb/Selection/Selection.cpp | 5 +++++ Userland/Libraries/LibWeb/Selection/Selection.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index f3ba361965..6305d5fec2 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -429,4 +429,9 @@ DeprecatedString Selection::to_deprecated_string() const return m_range->to_deprecated_string(); } +JS::GCPtr Selection::range() const +{ + return m_range; +} + } diff --git a/Userland/Libraries/LibWeb/Selection/Selection.h b/Userland/Libraries/LibWeb/Selection/Selection.h index 81fb7dd16f..a96a6e4fc1 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.h +++ b/Userland/Libraries/LibWeb/Selection/Selection.h @@ -50,6 +50,9 @@ public: DeprecatedString to_deprecated_string() const; + // Non-standard convenience accessor for the selection's range. + JS::GCPtr range() const; + private: Selection(JS::NonnullGCPtr, JS::NonnullGCPtr);