summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2023-02-19 18:07:00 +0100
committerAndreas Kling <kling@serenityos.org>2023-02-22 09:55:33 +0100
commit530ec85c4ab913d3c8ba87df8b13fce7e920767b (patch)
tree891c3cb066b2611c9cacfa8fbca60386d7f65ce7
parent459959b297892aa88e30be66a302a6bd00810e34 (diff)
downloadserenity-530ec85c4ab913d3c8ba87df8b13fce7e920767b.zip
LibWeb: Make factory method of Geometry::DOMPoint fallible
-rw-r--r--Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp7
-rw-r--r--Userland/Libraries/LibWeb/Geometry/DOMPoint.h2
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp2
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 <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Geometry/DOMPoint.h>
+#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Geometry {
-JS::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPoint>> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
{
- return realm.heap().allocate<DOMPoint>(realm, realm, x, y, z, w).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<DOMPoint>(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> 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<DOMPoint> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPoint>> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
static JS::NonnullGCPtr<DOMPoint> 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<Geometry::DOMPoint> 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();
}
}