From 38bc8836d6c747dadc96f4c50c6fd4e3da7c90db Mon Sep 17 00:00:00 2001 From: Bastiaan van der Plaat Date: Tue, 15 Aug 2023 13:16:09 +0200 Subject: [PATCH] LibWeb: Remove exceptions from DOMPoint because allocate is unfailable --- Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp | 5 ++--- Userland/Libraries/LibWeb/Geometry/DOMPoint.h | 2 +- Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp | 4 ++-- Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h | 4 ++-- Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp index 36bc79b80d..cd2a160629 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -7,11 +7,10 @@ #include #include -#include namespace Web::Geometry { -WebIDL::ExceptionOr> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w) +JS::NonnullGCPtr DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { return realm.heap().allocate(realm, realm, x, y, z, w); } @@ -25,7 +24,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).release_value_but_fixme_should_propagate_errors(); + return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w); } DOMPoint::~DOMPoint() = default; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h index 166fcb4cd8..8d9bdc4c9e 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 WebIDL::ExceptionOr> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1); + static JS::NonnullGCPtr 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/Geometry/DOMPointReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp index 07758bfac4..7a1fc94644 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp @@ -11,7 +11,7 @@ namespace Web::Geometry { -WebIDL::ExceptionOr> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w) +JS::NonnullGCPtr DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { return realm.heap().allocate(realm, realm, x, y, z, w); } @@ -26,7 +26,7 @@ DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double } // https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint -WebIDL::ExceptionOr> DOMPointReadOnly::from_point(JS::VM& vm, DOMPointInit const& other) +JS::NonnullGCPtr DOMPointReadOnly::from_point(JS::VM& vm, DOMPointInit const& other) { // The fromPoint(other) static method on DOMPointReadOnly must create a DOMPointReadOnly from the dictionary other. return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w); diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h index 68829f0f5f..be5819b57f 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h @@ -25,9 +25,9 @@ class DOMPointReadOnly : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1); + static JS::NonnullGCPtr construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1); - static WebIDL::ExceptionOr> from_point(JS::VM&, DOMPointInit const&); + static JS::NonnullGCPtr from_point(JS::VM&, DOMPointInit const&); virtual ~DOMPointReadOnly() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index 40b481a2db..6e3979d736 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -34,7 +34,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).release_value_but_fixme_should_propagate_errors(); + return Geometry::DOMPoint::construct_impl(realm(), 0, 0, 0, 0); } }