瀏覽代碼

LibWeb: Stub Range.getBoundingClientRect

This seems to be used by Discord around the chat message box, but
didn't explore very far.
Luke Wilde 2 年之前
父節點
當前提交
34c130b336

+ 8 - 0
Userland/Libraries/LibWeb/DOM/Range.cpp

@@ -15,6 +15,7 @@
 #include <LibWeb/DOM/ProcessingInstruction.h>
 #include <LibWeb/DOM/Range.h>
 #include <LibWeb/DOM/Text.h>
+#include <LibWeb/Geometry/DOMRect.h>
 #include <LibWeb/HTML/Window.h>
 
 namespace Web::DOM {
@@ -1102,4 +1103,11 @@ WebIDL::ExceptionOr<void> Range::delete_contents()
     return {};
 }
 
+// https://w3c.github.io/csswg-drafts/cssom-view/#dom-range-getboundingclientrect
+JS::NonnullGCPtr<Geometry::DOMRect> Range::get_bounding_client_rect() const
+{
+    dbgln("(STUBBED) Range::get_bounding_client_rect()");
+    return Geometry::DOMRect::construct_impl(realm(), 0, 0, 0, 0);
+}
+
 }

+ 2 - 0
Userland/Libraries/LibWeb/DOM/Range.h

@@ -82,6 +82,8 @@ public:
 
     static HashTable<Range*>& live_ranges();
 
+    JS::NonnullGCPtr<Geometry::DOMRect> get_bounding_client_rect() const;
+
 private:
     explicit Range(Document&);
     Range(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);

+ 3 - 0
Userland/Libraries/LibWeb/DOM/Range.idl

@@ -1,5 +1,6 @@
 #import <DOM/Node.idl>
 #import <DOM/AbstractRange.idl>
+#import <Geometry/DOMRect.idl>
 
 [Exposed=Window]
 interface Range : AbstractRange {
@@ -38,6 +39,8 @@ interface Range : AbstractRange {
 
     boolean intersectsNode(Node node);
 
+    DOMRect getBoundingClientRect();
+
     stringifier;
 
 };