summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibWeb/Forward.h1
-rw-r--r--Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h15
-rw-r--r--Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp20
-rw-r--r--Userland/Libraries/LibWeb/HTML/CanvasGradient.h21
-rw-r--r--Userland/Libraries/LibWeb/idl_files.cmake2
5 files changed, 32 insertions, 27 deletions
diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h
index dff2c3eea8..6243b521c2 100644
--- a/Userland/Libraries/LibWeb/Forward.h
+++ b/Userland/Libraries/LibWeb/Forward.h
@@ -449,7 +449,6 @@ class URLSearchParamsIterator;
namespace Web::Bindings {
class BlobWrapper;
-class CanvasGradientWrapper;
class CryptoWrapper;
class DOMExceptionWrapper;
class DOMPointWrapper;
diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h
index d65da16932..9e9b3e6eba 100644
--- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h
+++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h
@@ -42,19 +42,22 @@ public:
return my_drawing_state().stroke_style.to_string();
}
- NonnullRefPtr<CanvasGradient> create_radial_gradient(double x0, double y0, double r0, double x1, double y1, double r1)
+ JS::NonnullGCPtr<CanvasGradient> create_radial_gradient(double x0, double y0, double r0, double x1, double y1, double r1)
{
- return CanvasGradient::create_radial(x0, y0, r0, x1, y1, r1);
+ auto& window = static_cast<IncludingClass&>(*this).global_object();
+ return CanvasGradient::create_radial(window, x0, y0, r0, x1, y1, r1);
}
- NonnullRefPtr<CanvasGradient> create_linear_gradient(double x0, double y0, double x1, double y1)
+ JS::NonnullGCPtr<CanvasGradient> create_linear_gradient(double x0, double y0, double x1, double y1)
{
- return CanvasGradient::create_linear(x0, y0, x1, y1);
+ auto& window = static_cast<IncludingClass&>(*this).global_object();
+ return CanvasGradient::create_linear(window, x0, y0, x1, y1);
}
- NonnullRefPtr<CanvasGradient> create_conic_gradient(double start_angle, double x, double y)
+ JS::NonnullGCPtr<CanvasGradient> create_conic_gradient(double start_angle, double x, double y)
{
- return CanvasGradient::create_conic(start_angle, x, y);
+ auto& window = static_cast<IncludingClass&>(*this).global_object();
+ return CanvasGradient::create_conic(window, start_angle, x, y);
}
protected:
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp
index ff9824ab17..ffe65f2924 100644
--- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp
+++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp
@@ -5,12 +5,14 @@
*/
#include <AK/QuickSort.h>
+#include <LibWeb/Bindings/CanvasGradientPrototype.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/CanvasGradient.h>
+#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
-NonnullRefPtr<CanvasGradient> CanvasGradient::create_radial(double x0, double y0, double r0, double x1, double y1, double r1)
+JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_radial(HTML::Window& window, double x0, double y0, double r0, double x1, double y1, double r1)
{
(void)x0;
(void)y0;
@@ -18,29 +20,31 @@ NonnullRefPtr<CanvasGradient> CanvasGradient::create_radial(double x0, double y0
(void)x1;
(void)y1;
(void)r1;
- return adopt_ref(*new CanvasGradient(Type::Radial));
+ return *window.heap().allocate<CanvasGradient>(window.realm(), window, Type::Radial);
}
-NonnullRefPtr<CanvasGradient> CanvasGradient::create_linear(double x0, double y0, double x1, double y1)
+JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_linear(HTML::Window& window, double x0, double y0, double x1, double y1)
{
(void)x0;
(void)y0;
(void)x1;
(void)y1;
- return adopt_ref(*new CanvasGradient(Type::Linear));
+ return *window.heap().allocate<CanvasGradient>(window.realm(), window, Type::Linear);
}
-NonnullRefPtr<CanvasGradient> CanvasGradient::create_conic(double start_angle, double x, double y)
+JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_conic(HTML::Window& window, double start_angle, double x, double y)
{
(void)start_angle;
(void)x;
(void)y;
- return adopt_ref(*new CanvasGradient(Type::Conic));
+ return *window.heap().allocate<CanvasGradient>(window.realm(), window, Type::Conic);
}
-CanvasGradient::CanvasGradient(Type type)
- : m_type(type)
+CanvasGradient::CanvasGradient(HTML::Window& window, Type type)
+ : PlatformObject(window.realm())
+ , m_type(type)
{
+ set_prototype(&window.ensure_web_prototype<Bindings::CanvasGradientPrototype>("CanvasGradient"));
}
CanvasGradient::~CanvasGradient() = default;
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h
index 5aa89d10cb..a9efb1ff33 100644
--- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h
+++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h
@@ -6,15 +6,14 @@
#pragma once
-#include <AK/RefCounted.h>
#include <LibGfx/Color.h>
-#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/Bindings/PlatformObject.h>
namespace Web::HTML {
-class CanvasGradient final
- : public RefCounted<CanvasGradient>
- , public Bindings::Wrappable {
+class CanvasGradient final : public Bindings::PlatformObject {
+ WEB_PLATFORM_OBJECT(CanvasGradient, Bindings::PlatformObject);
+
public:
enum class Type {
Linear,
@@ -22,18 +21,16 @@ public:
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);
+ static JS::NonnullGCPtr<CanvasGradient> create_radial(HTML::Window&, double x0, double y0, double r0, double x1, double y1, double r1);
+ static JS::NonnullGCPtr<CanvasGradient> create_linear(HTML::Window&, double x0, double y0, double x1, double y1);
+ static JS::NonnullGCPtr<CanvasGradient> create_conic(HTML::Window&, double start_angle, double x, double y);
DOM::ExceptionOr<void> add_color_stop(double offset, String const& color);
~CanvasGradient();
private:
- explicit CanvasGradient(Type);
+ CanvasGradient(HTML::Window&, Type);
Type m_type {};
@@ -46,3 +43,5 @@ private:
};
}
+
+WRAPPER_HACK(CanvasGradient, Web::HTML)
diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake
index 17643b5fba..02af86c302 100644
--- a/Userland/Libraries/LibWeb/idl_files.cmake
+++ b/Userland/Libraries/LibWeb/idl_files.cmake
@@ -61,7 +61,7 @@ libweb_js_wrapper(Geometry/DOMPointReadOnly)
libweb_js_wrapper(Geometry/DOMRect)
libweb_js_wrapper(Geometry/DOMRectList)
libweb_js_wrapper(Geometry/DOMRectReadOnly)
-libweb_js_wrapper(HTML/CanvasGradient)
+libweb_js_wrapper(HTML/CanvasGradient NO_INSTANCE)
libweb_js_wrapper(HTML/CanvasRenderingContext2D NO_INSTANCE)
libweb_js_wrapper(HTML/CloseEvent NO_INSTANCE)
libweb_js_wrapper(HTML/DOMParser NO_INSTANCE)