diff options
author | Andreas Kling <kling@serenityos.org> | 2023-01-11 19:45:03 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-12 19:55:10 +0100 |
commit | 3cabd17f9b6164d39ad95865b2920eaea8e0b2f9 (patch) | |
tree | 267ddc9582f1013f6d04f7f876b3d9e2441bb917 /Userland | |
parent | 36866730cea7d3868fb49de88ce2d2844beb885a (diff) | |
download | serenity-3cabd17f9b6164d39ad95865b2920eaea8e0b2f9.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Selection/Selection.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Selection/Selection.h | 3 |
2 files changed, 8 insertions, 0 deletions
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<DOM::Range> 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<DOM::Range> range() const; + private: Selection(JS::NonnullGCPtr<JS::Realm>, JS::NonnullGCPtr<DOM::Document>); |