1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 20:17:42 +00:00

LibWeb: Make factory method of SVG::SVGLength fallible

This commit is contained in:
Kenneth Myhra 2023-02-15 20:25:50 +01:00 committed by Linus Groh
parent bfc8cbcf3b
commit 71316614b8
7 changed files with 45 additions and 45 deletions

View file

@ -84,8 +84,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGCircleElement::cx() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -94,8 +94,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGCircleElement::cy() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -104,8 +104,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGCircleElement::r() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_radius.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_radius.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_radius.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }

View file

@ -89,8 +89,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGEllipseElement::cx() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -99,8 +99,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGEllipseElement::cy() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -109,8 +109,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGEllipseElement::rx() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -119,8 +119,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGEllipseElement::ry() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }

View file

@ -30,17 +30,17 @@ JS::ThrowCompletionOr<void> SVGForeignObjectElement::initialize(JS::Realm& realm
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGForeignObjectElementPrototype>(realm, "SVGForeignObjectElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGForeignObjectElementPrototype>(realm, "SVGForeignObjectElement"));
// FIXME: These never actually get updated! // FIXME: These never actually get updated!
m_x = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { m_x = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGAnimatedLength>> {
return SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); return SVGAnimatedLength::create(realm, TRY(SVGLength::create(realm, 0, 0)), TRY(SVGLength::create(realm, 0, 0)));
})); }));
m_y = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { m_y = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGAnimatedLength>> {
return SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); return SVGAnimatedLength::create(realm, TRY(SVGLength::create(realm, 0, 0)), TRY(SVGLength::create(realm, 0, 0)));
})); }));
m_width = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { m_width = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGAnimatedLength>> {
return SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); return SVGAnimatedLength::create(realm, TRY(SVGLength::create(realm, 0, 0)), TRY(SVGLength::create(realm, 0, 0)));
})); }));
m_height = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { m_height = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGAnimatedLength>> {
return SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); return SVGAnimatedLength::create(realm, TRY(SVGLength::create(realm, 0, 0)), TRY(SVGLength::create(realm, 0, 0)));
})); }));
return {}; return {};

View file

@ -9,9 +9,9 @@
namespace Web::SVG { namespace Web::SVG {
JS::NonnullGCPtr<SVGLength> SVGLength::create(JS::Realm& realm, u8 unit_type, float value) WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGLength>> SVGLength::create(JS::Realm& realm, u8 unit_type, float value)
{ {
return realm.heap().allocate<SVGLength>(realm, realm, unit_type, value).release_allocated_value_but_fixme_should_propagate_errors(); return MUST_OR_THROW_OOM(realm.heap().allocate<SVGLength>(realm, realm, unit_type, value));
} }
SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value) SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value)

View file

@ -16,7 +16,7 @@ class SVGLength : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(SVGLength, Bindings::PlatformObject); WEB_PLATFORM_OBJECT(SVGLength, Bindings::PlatformObject);
public: public:
static JS::NonnullGCPtr<SVGLength> create(JS::Realm&, u8 unit_type, float value); static WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGLength>> create(JS::Realm&, u8 unit_type, float value);
virtual ~SVGLength() override; virtual ~SVGLength() override;
u8 unit_type() const { return m_unit_type; } u8 unit_type() const { return m_unit_type; }

View file

@ -69,8 +69,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::x1() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_x1.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_x1.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_x1.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_x1.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -79,8 +79,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::y1() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_y1.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_y1.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_y1.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_y1.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -89,8 +89,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::x2() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_x2.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_x2.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_x2.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_x2.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -99,8 +99,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::y2() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_y2.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_y2.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_y2.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_y2.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }

View file

@ -166,8 +166,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::x() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -176,8 +176,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::y() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -186,8 +186,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::width() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_width.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_width.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_width.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_width.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -196,8 +196,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::height() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_height.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_height.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_height.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_height.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -206,8 +206,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::rx() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }
@ -216,8 +216,8 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::ry() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)).release_value_but_fixme_should_propagate_errors();
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors();
} }