From 530ec85c4ab913d3c8ba87df8b13fce7e920767b Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Sun, 19 Feb 2023 18:07:00 +0100 Subject: [PATCH] LibWeb: Make factory method of Geometry::DOMPoint fallible --- Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp | 7 ++++--- Userland/Libraries/LibWeb/Geometry/DOMPoint.h | 2 +- Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp index 667ad56942..93ce969b1c 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -7,12 +7,13 @@ #include #include +#include namespace Web::Geometry { -JS::NonnullGCPtr DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w) +WebIDL::ExceptionOr> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { - return realm.heap().allocate(realm, realm, x, y, z, w).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, x, y, z, w)); } DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w) @@ -24,7 +25,7 @@ DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w) JS::NonnullGCPtr DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other) { // The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other. - return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w); + return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w).release_value_but_fixme_should_propagate_errors(); } DOMPoint::~DOMPoint() = default; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h index 57999c4402..aa4037b50d 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h @@ -16,7 +16,7 @@ class DOMPoint final : public DOMPointReadOnly { WEB_PLATFORM_OBJECT(DOMPoint, DOMPointReadOnly); public: - static JS::NonnullGCPtr construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1); static JS::NonnullGCPtr from_point(JS::VM&, DOMPointInit const&); diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index 5af78482e8..b0962ec5d4 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -36,7 +36,7 @@ float SVGGeometryElement::get_total_length() JS::NonnullGCPtr SVGGeometryElement::get_point_at_length(float distance) { (void)distance; - return Geometry::DOMPoint::construct_impl(realm(), 0, 0, 0, 0); + return Geometry::DOMPoint::construct_impl(realm(), 0, 0, 0, 0).release_value_but_fixme_should_propagate_errors(); } }