From dcbe927b4850610b1f07bbb9d9eb1972278f35db Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Sun, 19 Feb 2023 18:39:04 +0100 Subject: [PATCH] LibWeb: Make factory method of Selection::Selection fallible --- Userland/Libraries/LibWeb/DOM/Document.cpp | 2 +- Userland/Libraries/LibWeb/Selection/Selection.cpp | 4 ++-- Userland/Libraries/LibWeb/Selection/Selection.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 81026d449cd..1ac10ea2639 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -378,7 +378,7 @@ JS::GCPtr Document::get_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; } diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index 77c050a2462..524c892faa1 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -11,9 +11,9 @@ namespace Web::Selection { -JS::NonnullGCPtr Selection::create(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) +WebIDL::ExceptionOr> Selection::create(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) { - return realm->heap().allocate(realm, realm, document).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm->heap().allocate(realm, realm, document)); } Selection::Selection(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) diff --git a/Userland/Libraries/LibWeb/Selection/Selection.h b/Userland/Libraries/LibWeb/Selection/Selection.h index e1dc3833432..dbf249a624d 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.h +++ b/Userland/Libraries/LibWeb/Selection/Selection.h @@ -15,7 +15,7 @@ class Selection final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(Selection, Bindings::PlatformObject); public: - static JS::NonnullGCPtr create(JS::NonnullGCPtr, JS::NonnullGCPtr); + static WebIDL::ExceptionOr> create(JS::NonnullGCPtr, JS::NonnullGCPtr); virtual ~Selection() override;