Przeglądaj źródła

LibWeb: Return a MarkedVector from Document::elements_from_point

A plain vector is not protected from GC.
Timothy Flynn 9 miesięcy temu
rodzic
commit
0286eb4e3e

+ 2 - 2
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -4838,10 +4838,10 @@ Element const* Document::element_from_point(double x, double y)
 }
 
 // https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint
-Vector<JS::NonnullGCPtr<Element>> Document::elements_from_point(double x, double y)
+JS::MarkedVector<JS::NonnullGCPtr<Element>> Document::elements_from_point(double x, double y)
 {
     // 1. Let sequence be a new empty sequence.
-    Vector<JS::NonnullGCPtr<Element>> sequence;
+    JS::MarkedVector<JS::NonnullGCPtr<Element>> sequence(heap());
 
     // 2. If either argument is negative, x is greater than the viewport width excluding the size of a rendered scroll bar (if any),
     //    or y is greater than the viewport height excluding the size of a rendered scroll bar (if any),

+ 1 - 1
Userland/Libraries/LibWeb/DOM/Document.h

@@ -656,7 +656,7 @@ public:
     WebIDL::ExceptionOr<void> set_design_mode(String const&);
 
     Element const* element_from_point(double x, double y);
-    Vector<JS::NonnullGCPtr<Element>> elements_from_point(double x, double y);
+    JS::MarkedVector<JS::NonnullGCPtr<Element>> elements_from_point(double x, double y);
     JS::GCPtr<Element const> scrolling_element() const;
 
     void set_needs_to_resolve_paint_only_properties() { m_needs_to_resolve_paint_only_properties = true; }