diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-02-19 12:45:09 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-22 09:55:33 +0100 |
commit | 1f48081ee409b5b2f62e9a07192e12ac0a1d70e0 (patch) | |
tree | 08424c592896d6c3277bf7dcbbb4d32693d733a2 /Userland/Libraries/LibWeb | |
parent | 3689d58c64f660434f72846a8db5304f581db3e1 (diff) | |
download | serenity-1f48081ee409b5b2f62e9a07192e12ac0a1d70e0.zip |
LibWeb: Make factory methods of IDLEventListener and NodeFilter fallible
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/IDLEventListener.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/NodeFilter.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/NodeFilter.h | 2 |
5 files changed, 8 insertions, 7 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index cd2a6256fc..cbbb2644de 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -561,7 +561,7 @@ void EventTarget::activate_event_handler(DeprecatedFlyString const& name, HTML:: // 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback. auto listener = realm.heap().allocate_without_realm<DOMEventListener>(); listener->type = name; - listener->callback = IDLEventListener::create(realm, *callback).ptr(); + listener->callback = IDLEventListener::create(realm, *callback).release_value_but_fixme_should_propagate_errors(); // 6. Add an event listener with eventTarget and listener. add_an_event_listener(*listener); diff --git a/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp b/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp index bae25528f5..685a7fdcd4 100644 --- a/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp +++ b/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp @@ -8,9 +8,9 @@ namespace Web::DOM { -JS::NonnullGCPtr<IDLEventListener> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback) +WebIDL::ExceptionOr<JS::NonnullGCPtr<IDLEventListener>> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback) { - return realm.heap().allocate<IDLEventListener>(realm, realm, move(callback)).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate<IDLEventListener>(realm, realm, move(callback))); } IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback) diff --git a/Userland/Libraries/LibWeb/DOM/IDLEventListener.h b/Userland/Libraries/LibWeb/DOM/IDLEventListener.h index 8a22c14b4a..eadb1893dd 100644 --- a/Userland/Libraries/LibWeb/DOM/IDLEventListener.h +++ b/Userland/Libraries/LibWeb/DOM/IDLEventListener.h @@ -28,7 +28,7 @@ class IDLEventListener final : public JS::Object { JS_OBJECT(IDLEventListener, JS::Object); public: - static JS::NonnullGCPtr<IDLEventListener> create(JS::Realm&, JS::NonnullGCPtr<WebIDL::CallbackType>); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<IDLEventListener>> create(JS::Realm&, JS::NonnullGCPtr<WebIDL::CallbackType>); IDLEventListener(JS::Realm&, JS::NonnullGCPtr<WebIDL::CallbackType>); virtual ~IDLEventListener() = default; diff --git a/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp b/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp index 4b24bc9f85..a81a25e7a0 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp @@ -6,12 +6,13 @@ #include <LibJS/Runtime/VM.h> #include <LibWeb/DOM/NodeFilter.h> +#include <LibWeb/WebIDL/ExceptionOr.h> namespace Web::DOM { -JS::NonnullGCPtr<NodeFilter> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback) +WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeFilter>> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback) { - return realm.heap().allocate<NodeFilter>(realm, realm, callback).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate<NodeFilter>(realm, realm, callback)); } NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback) diff --git a/Userland/Libraries/LibWeb/DOM/NodeFilter.h b/Userland/Libraries/LibWeb/DOM/NodeFilter.h index 754b77f8b8..894919d4ca 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeFilter.h +++ b/Userland/Libraries/LibWeb/DOM/NodeFilter.h @@ -15,7 +15,7 @@ class NodeFilter final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(NodeFilter, Bindings::PlatformObject); public: - static JS::NonnullGCPtr<NodeFilter> create(JS::Realm&, WebIDL::CallbackType&); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeFilter>> create(JS::Realm&, WebIDL::CallbackType&); virtual ~NodeFilter() = default; |