
This is a monster patch that turns all EventTargets into GC-allocated PlatformObjects. Their C++ wrapper classes are removed, and the LibJS garbage collector is now responsible for their lifetimes. There's a fair amount of hacks and band-aids in this patch, and we'll have a lot of cleanup to do after this.
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/RefCounted.h>
|
|
#include <LibGfx/Color.h>
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
class CanvasGradient final
|
|
: public RefCounted<CanvasGradient>
|
|
, public Bindings::Wrappable {
|
|
public:
|
|
enum class Type {
|
|
Linear,
|
|
Radial,
|
|
Conic,
|
|
};
|
|
|
|
using WrapperType = Bindings::CanvasGradientWrapper;
|
|
|
|
static NonnullRefPtr<CanvasGradient> create_radial(double x0, double y0, double r0, double x1, double y1, double r1);
|
|
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);
|
|
|
|
DOM::ExceptionOr<void> add_color_stop(double offset, String const& color);
|
|
|
|
~CanvasGradient();
|
|
|
|
private:
|
|
explicit CanvasGradient(Type);
|
|
|
|
Type m_type {};
|
|
|
|
struct ColorStop {
|
|
double offset { 0 };
|
|
Gfx::Color color;
|
|
};
|
|
|
|
Vector<ColorStop> m_color_stops;
|
|
};
|
|
|
|
}
|