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

LibWeb: Make Path2D GC-allocated

This commit is contained in:
Andreas Kling 2022-09-02 23:35:06 +02:00
parent 0d2fee351a
commit 2704bcdaaa
5 changed files with 28 additions and 17 deletions

View file

@ -8,29 +8,27 @@
#include <AK/RefCounted.h>
#include <LibGfx/Path.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/HTML/Canvas/CanvasPath.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/canvas.html#path2d
class Path2D
: public RefCounted<Path2D>
, public Bindings::Wrappable
class Path2D final
: public Bindings::PlatformObject
, public CanvasPath {
AK_MAKE_NONCOPYABLE(Path2D);
AK_MAKE_NONMOVABLE(Path2D);
WEB_PLATFORM_OBJECT(Path2D, Bindings::PlatformObject);
public:
using WrapperType = Bindings::Path2DWrapper;
static JS::NonnullGCPtr<Path2D> create_with_global_object(HTML::Window&, Optional<Variant<JS::Handle<Path2D>, String>> const& path);
static NonnullRefPtr<Path2D> create_with_global_object(HTML::Window&, Optional<Variant<NonnullRefPtr<Path2D>, String>> const& path) { return adopt_ref(*new Path2D(path)); }
static NonnullRefPtr<Path2D> create(Optional<Variant<NonnullRefPtr<Path2D>, String>> const& path) { return adopt_ref(*new Path2D(path)); }
~Path2D() = default;
virtual ~Path2D() override;
private:
Path2D(Optional<Variant<NonnullRefPtr<Path2D>, String>> const&);
Path2D(HTML::Window&, Optional<Variant<JS::Handle<Path2D>, String>> const&);
};
}
WRAPPER_HACK(Path2D, Web::HTML)