diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-02-19 18:21:27 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-22 09:55:33 +0100 |
commit | ec0049441c9aa87273996edcda614726d8caf7cc (patch) | |
tree | d1e9abcaaf05a02ce8404baa4f094b44ff84ef3b /Userland/Libraries/LibWeb/Geometry | |
parent | 9b190b9509ad6d05a564bf88cbe3345cd2364afe (diff) | |
download | serenity-ec0049441c9aa87273996edcda614726d8caf7cc.zip |
LibWeb: Make factory methods of Geometry::DOMRect fallible
Diffstat (limited to 'Userland/Libraries/LibWeb/Geometry')
-rw-r--r-- | Userland/Libraries/LibWeb/Geometry/DOMRect.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Geometry/DOMRect.h | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp index a85a2beab3..db39cda450 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp @@ -6,15 +6,16 @@ #include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Geometry/DOMRect.h> +#include <LibWeb/WebIDL/ExceptionOr.h> namespace Web::Geometry { -JS::NonnullGCPtr<DOMRect> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height) +WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height) { - return realm.heap().allocate<DOMRect>(realm, realm, x, y, width, height).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate<DOMRect>(realm, realm, x, y, width, height)); } -JS::NonnullGCPtr<DOMRect> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect) +WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect) { return construct_impl(realm, rect.x(), rect.y(), rect.width(), rect.height()); } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.h b/Userland/Libraries/LibWeb/Geometry/DOMRect.h index 0eb93c1d54..407b21b940 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.h @@ -15,8 +15,8 @@ class DOMRect final : public DOMRectReadOnly { WEB_PLATFORM_OBJECT(DOMRect, DOMRectReadOnly); public: - static JS::NonnullGCPtr<DOMRect> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0); - static JS::NonnullGCPtr<DOMRect> create(JS::Realm&, Gfx::FloatRect const&); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> create(JS::Realm&, Gfx::FloatRect const&); virtual ~DOMRect() override; |