소스 검색

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.
Andreas Kling 2 년 전
부모
커밋
3cabd17f9b
2개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      Userland/Libraries/LibWeb/Selection/Selection.cpp
  2. 3 0
      Userland/Libraries/LibWeb/Selection/Selection.h

+ 5 - 0
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;
+}
+
 }

+ 3 - 0
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>);