1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:07:43 +00:00

LibWeb: Implement CanvasGradient.addColorStop() according to spec

The object is still not usable for anything, but at least now it behaves
correctly with regards to throwing exceptions.
This commit is contained in:
Andreas Kling 2022-02-05 15:16:35 +01:00
parent 7e1bf4d300
commit e6f279dada
2 changed files with 33 additions and 3 deletions

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/RefCounted.h>
#include <LibGfx/Color.h>
#include <LibWeb/Bindings/Wrappable.h>
namespace Web::HTML {
@ -27,7 +28,7 @@ public:
static NonnullRefPtr<CanvasGradient> create_linear(double x0, double y0, double x1, double y1);
static NonnullRefPtr<CanvasGradient> create_conic(double start_angle, double x, double y);
void add_color_stop(double offset, String const& color);
DOM::ExceptionOr<void> add_color_stop(double offset, String const& color);
~CanvasGradient();
@ -35,6 +36,13 @@ private:
explicit CanvasGradient(Type);
Type m_type {};
struct ColorStop {
double offset { 0 };
Gfx::Color color;
};
Vector<ColorStop> m_color_stops;
};
}