diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-02-15 08:46:39 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-18 00:52:47 +0100 |
commit | 250666699119ddc67e2a2757998843bcb847f074 (patch) | |
tree | 8e98c489d753826a3a181d09cc643b11bddde072 /Userland/Libraries | |
parent | 63b69f3672f44a9bae411a6a5ba924564d24c98d (diff) | |
download | serenity-250666699119ddc67e2a2757998843bcb847f074.zip |
LibWeb: Make factory methods of HTML::CanvasGradient fallible
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/CanvasGradient.h | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h index ae0492b5f8..f086c3752d 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h @@ -65,13 +65,13 @@ public: JS::NonnullGCPtr<CanvasGradient> create_linear_gradient(double x0, double y0, double x1, double y1) { auto& realm = static_cast<IncludingClass&>(*this).realm(); - return CanvasGradient::create_linear(realm, x0, y0, x1, y1); + return CanvasGradient::create_linear(realm, x0, y0, x1, y1).release_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr<CanvasGradient> create_conic_gradient(double start_angle, double x, double y) { auto& realm = static_cast<IncludingClass&>(*this).realm(); - return CanvasGradient::create_conic(realm, start_angle, x, y); + return CanvasGradient::create_conic(realm, start_angle, x, y).release_value_but_fixme_should_propagate_errors(); } WebIDL::ExceptionOr<JS::GCPtr<CanvasPattern>> create_pattern(CanvasImageSource const& image, StringView repetition) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp index 8b65697dea..b471f8f328 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -26,17 +26,17 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_rad } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient -JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1) +WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1) { auto linear_gradient = Gfx::CanvasLinearGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, Gfx::FloatPoint { x1, y1 }); - return realm.heap().allocate<CanvasGradient>(realm, realm, *linear_gradient).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate<CanvasGradient>(realm, realm, *linear_gradient)); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createconicgradient -JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y) +WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y) { auto conic_gradient = Gfx::CanvasConicGradientPaintStyle::create(Gfx::FloatPoint { x, y }, start_angle); - return realm.heap().allocate<CanvasGradient>(realm, realm, *conic_gradient).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate<CanvasGradient>(realm, realm, *conic_gradient)); } CanvasGradient::CanvasGradient(JS::Realm& realm, Gfx::GradientPaintStyle& gradient) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h index e9f23636ac..a9dc732a93 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h @@ -17,8 +17,8 @@ class CanvasGradient final : public Bindings::PlatformObject { public: static WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> create_radial(JS::Realm&, double x0, double y0, double r0, double x1, double y1, double r1); - static JS::NonnullGCPtr<CanvasGradient> create_linear(JS::Realm&, double x0, double y0, double x1, double y1); - static JS::NonnullGCPtr<CanvasGradient> create_conic(JS::Realm&, double start_angle, double x, double y); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> create_linear(JS::Realm&, double x0, double y0, double x1, double y1); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> create_conic(JS::Realm&, double start_angle, double x, double y); WebIDL::ExceptionOr<void> add_color_stop(double offset, DeprecatedString const& color); |