diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp index 9dd26537c43..123fbda9773 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp @@ -9,9 +9,9 @@ namespace Web::SVG { -JS::NonnullGCPtr SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) +WebIDL::ExceptionOr> SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) { - return realm.heap().allocate(realm, realm, move(base_val), move(anim_val)).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(base_val), move(anim_val))); } SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h index e0517f08f78..a2e8993283b 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h @@ -16,7 +16,7 @@ class SVGAnimatedLength final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(SVGAnimatedLength, Bindings::PlatformObject); public: - static JS::NonnullGCPtr create(JS::Realm&, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val); + static WebIDL::ExceptionOr> create(JS::Realm&, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val); virtual ~SVGAnimatedLength() override; JS::NonnullGCPtr base_val() const { return m_base_val; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp index 68ae712ecfd..5af992448f2 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp @@ -86,7 +86,7 @@ JS::NonnullGCPtr SVGCircleElement::cx() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#CircleElementCYAttribute @@ -96,7 +96,7 @@ JS::NonnullGCPtr SVGCircleElement::cy() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#CircleElementRAttribute @@ -106,7 +106,7 @@ JS::NonnullGCPtr SVGCircleElement::r() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_radius.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp index 4f4a93de00b..26a4f11a34d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp @@ -91,7 +91,7 @@ JS::NonnullGCPtr SVGEllipseElement::cx() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCYAttribute @@ -101,7 +101,7 @@ JS::NonnullGCPtr SVGEllipseElement::cy() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRXAttribute @@ -111,7 +111,7 @@ JS::NonnullGCPtr SVGEllipseElement::rx() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRYAttribute @@ -121,7 +121,7 @@ JS::NonnullGCPtr SVGEllipseElement::ry() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index 40f100a2213..ecd217dee72 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -23,14 +24,24 @@ SVGForeignObjectElement::~SVGForeignObjectElement() = default; JS::ThrowCompletionOr SVGForeignObjectElement::initialize(JS::Realm& realm) { + auto& vm = realm.vm(); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype(realm, "SVGForeignObjectElement")); // FIXME: These never actually get updated! - m_x = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); - m_y = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); - m_width = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); - m_height = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + m_x = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { + return SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + })); + m_y = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { + return SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + })); + m_width = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { + return SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + })); + m_height = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { + return SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + })); return {}; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp index 7fb9e7ce632..8f6d3da945f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp @@ -71,7 +71,7 @@ JS::NonnullGCPtr SVGLineElement::x1() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_x1.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_x1.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#LineElementY1Attribute @@ -81,7 +81,7 @@ JS::NonnullGCPtr SVGLineElement::y1() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_y1.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_y1.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#LineElementX2Attribute @@ -91,7 +91,7 @@ JS::NonnullGCPtr SVGLineElement::x2() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_x2.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_x2.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#LineElementY2Attribute @@ -101,7 +101,7 @@ JS::NonnullGCPtr SVGLineElement::y2() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_y2.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_y2.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp index 3cce1d95228..f2c3cf83c18 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp @@ -168,7 +168,7 @@ JS::NonnullGCPtr SVGRectElement::x() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute @@ -178,7 +178,7 @@ JS::NonnullGCPtr SVGRectElement::y() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementWidthAttribute @@ -188,7 +188,7 @@ JS::NonnullGCPtr SVGRectElement::width() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_width.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_width.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementHeightAttribute @@ -198,7 +198,7 @@ JS::NonnullGCPtr SVGRectElement::height() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_height.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_height.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute @@ -208,7 +208,7 @@ JS::NonnullGCPtr SVGRectElement::rx() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementRYAttribute @@ -218,7 +218,7 @@ JS::NonnullGCPtr SVGRectElement::ry() const // FIXME: Create a proper animated value when animations are supported. auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); } }