1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

LibWeb: Make factory methods of HTML::CanvasGradient fallible

This commit is contained in:
Kenneth Myhra 2023-02-15 08:46:39 +01:00 committed by Linus Groh
parent 63b69f3672
commit 2506666991
3 changed files with 8 additions and 8 deletions

View file

@ -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)