diff --git a/Userland/Libraries/LibGfx/PaintStyle.h b/Userland/Libraries/LibGfx/PaintStyle.h index 6d377af03f..1abe6978b9 100644 --- a/Userland/Libraries/LibGfx/PaintStyle.h +++ b/Userland/Libraries/LibGfx/PaintStyle.h @@ -61,16 +61,17 @@ private: class GradientPaintStyle : public PaintStyle { public: - void add_color_stop(float position, Color color, Optional transition_hint = {}) + ErrorOr add_color_stop(float position, Color color, Optional transition_hint = {}) { - add_color_stop(ColorStop { color, position, transition_hint }); + return add_color_stop(ColorStop { color, position, transition_hint }); } - void add_color_stop(ColorStop stop, bool sort = true) + ErrorOr add_color_stop(ColorStop stop, bool sort = true) { - m_color_stops.append(stop); + TRY(m_color_stops.try_append(stop)); if (sort) quick_sort(m_color_stops, [](auto& a, auto& b) { return a.position < b.position; }); + return {}; } void set_repeat_length(float repeat_length) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp index 0fa6e87789..013f3c7ea2 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -70,7 +70,7 @@ WebIDL::ExceptionOr CanvasGradient::add_color_stop(double offset, Deprecat return WebIDL::SyntaxError::create(realm(), "Could not parse color for CanvasGradient"); // 4. Place a new stop on the gradient, at offset offset relative to the whole gradient, and with the color parsed color. - m_gradient->add_color_stop(offset, parsed_color.value()); + TRY_OR_THROW_OOM(realm().vm(), m_gradient->add_color_stop(offset, parsed_color.value())); // FIXME: If multiple stops are added at the same offset on a gradient, then they must be placed in the order added, // with the first one closest to the start of the gradient, and each subsequent one infinitesimally further along