浏览代码

LibWeb: Make factory method of Selection::Selection fallible

Kenneth Myhra 2 年之前
父节点
当前提交
dcbe927b48

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

@@ -378,7 +378,7 @@ JS::GCPtr<Selection::Selection> Document::get_selection()
     }
     }
 
 
     if (!m_selection) {
     if (!m_selection) {
-        m_selection = Selection::Selection::create(realm(), *this);
+        m_selection = Selection::Selection::create(realm(), *this).release_value_but_fixme_should_propagate_errors();
     }
     }
     return m_selection;
     return m_selection;
 }
 }

+ 2 - 2
Userland/Libraries/LibWeb/Selection/Selection.cpp

@@ -11,9 +11,9 @@
 
 
 namespace Web::Selection {
 namespace Web::Selection {
 
 
-JS::NonnullGCPtr<Selection> Selection::create(JS::NonnullGCPtr<JS::Realm> realm, JS::NonnullGCPtr<DOM::Document> document)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<Selection>> Selection::create(JS::NonnullGCPtr<JS::Realm> realm, JS::NonnullGCPtr<DOM::Document> document)
 {
 {
-    return realm->heap().allocate<Selection>(realm, realm, document).release_allocated_value_but_fixme_should_propagate_errors();
+    return MUST_OR_THROW_OOM(realm->heap().allocate<Selection>(realm, realm, document));
 }
 }
 
 
 Selection::Selection(JS::NonnullGCPtr<JS::Realm> realm, JS::NonnullGCPtr<DOM::Document> document)
 Selection::Selection(JS::NonnullGCPtr<JS::Realm> realm, JS::NonnullGCPtr<DOM::Document> document)

+ 1 - 1
Userland/Libraries/LibWeb/Selection/Selection.h

@@ -15,7 +15,7 @@ class Selection final : public Bindings::PlatformObject {
     WEB_PLATFORM_OBJECT(Selection, Bindings::PlatformObject);
     WEB_PLATFORM_OBJECT(Selection, Bindings::PlatformObject);
 
 
 public:
 public:
-    static JS::NonnullGCPtr<Selection> create(JS::NonnullGCPtr<JS::Realm>, JS::NonnullGCPtr<DOM::Document>);
+    static WebIDL::ExceptionOr<JS::NonnullGCPtr<Selection>> create(JS::NonnullGCPtr<JS::Realm>, JS::NonnullGCPtr<DOM::Document>);
 
 
     virtual ~Selection() override;
     virtual ~Selection() override;