mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
LibWeb: Make DOMPoint and DOMPointReadOnly GC-allocated
This commit is contained in:
parent
a9cae56f8e
commit
44415af428
9 changed files with 78 additions and 43 deletions
|
@ -135,6 +135,8 @@ set(SOURCES
|
||||||
FileAPI/Blob.cpp
|
FileAPI/Blob.cpp
|
||||||
FileAPI/File.cpp
|
FileAPI/File.cpp
|
||||||
FontCache.cpp
|
FontCache.cpp
|
||||||
|
Geometry/DOMPoint.cpp
|
||||||
|
Geometry/DOMPointReadOnly.cpp
|
||||||
Geometry/DOMRectList.cpp
|
Geometry/DOMRectList.cpp
|
||||||
HTML/AttributeNames.cpp
|
HTML/AttributeNames.cpp
|
||||||
HTML/BrowsingContext.cpp
|
HTML/BrowsingContext.cpp
|
||||||
|
|
|
@ -451,8 +451,6 @@ namespace Web::Bindings {
|
||||||
class BlobWrapper;
|
class BlobWrapper;
|
||||||
class CryptoWrapper;
|
class CryptoWrapper;
|
||||||
class DOMExceptionWrapper;
|
class DOMExceptionWrapper;
|
||||||
class DOMPointWrapper;
|
|
||||||
class DOMPointReadOnlyWrapper;
|
|
||||||
class DOMRectListWrapper;
|
class DOMRectListWrapper;
|
||||||
class DOMRectReadOnlyWrapper;
|
class DOMRectReadOnlyWrapper;
|
||||||
class DOMRectWrapper;
|
class DOMRectWrapper;
|
||||||
|
|
25
Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp
Normal file
25
Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Geometry/DOMPoint.h>
|
||||||
|
#include <LibWeb/HTML/Window.h>
|
||||||
|
|
||||||
|
namespace Web::Geometry {
|
||||||
|
|
||||||
|
JS::NonnullGCPtr<DOMPoint> DOMPoint::create_with_global_object(HTML::Window& window, double x, double y, double z, double w)
|
||||||
|
{
|
||||||
|
return *window.heap().allocate<DOMPoint>(window.realm(), window, x, y, z, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMPoint::DOMPoint(HTML::Window& window, double x, double y, double z, double w)
|
||||||
|
: DOMPointReadOnly(window, x, y, z, w)
|
||||||
|
{
|
||||||
|
set_prototype(&window.cached_web_prototype("DOMPoint"));
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMPoint::~DOMPoint() = default;
|
||||||
|
|
||||||
|
}
|
|
@ -12,18 +12,12 @@ namespace Web::Geometry {
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#DOMPoint
|
// https://drafts.fxtf.org/geometry/#DOMPoint
|
||||||
class DOMPoint final : public DOMPointReadOnly {
|
class DOMPoint final : public DOMPointReadOnly {
|
||||||
|
WEB_PLATFORM_OBJECT(DOMPoint, DOMPointReadOnly);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using WrapperType = Bindings::DOMPointWrapper;
|
static JS::NonnullGCPtr<DOMPoint> create_with_global_object(HTML::Window&, double x = 0, double y = 0, double z = 0, double w = 0);
|
||||||
|
|
||||||
static NonnullRefPtr<DOMPoint> create_with_global_object(HTML::Window&, double x = 0, double y = 0, double z = 0, double w = 0)
|
virtual ~DOMPoint() override;
|
||||||
{
|
|
||||||
return DOMPoint::create(x, y, z, w);
|
|
||||||
}
|
|
||||||
|
|
||||||
static NonnullRefPtr<DOMPoint> create(double x = 0, double y = 0, double z = 0, double w = 0)
|
|
||||||
{
|
|
||||||
return adopt_ref(*new DOMPoint(x, y, z, w));
|
|
||||||
}
|
|
||||||
|
|
||||||
double x() const { return m_x; }
|
double x() const { return m_x; }
|
||||||
double y() const { return m_y; }
|
double y() const { return m_y; }
|
||||||
|
@ -36,9 +30,9 @@ public:
|
||||||
void set_w(double w) { m_w = w; }
|
void set_w(double w) { m_w = w; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DOMPoint(float x, float y, float z, float w)
|
DOMPoint(HTML::Window&, double x, double y, double z, double w);
|
||||||
: DOMPointReadOnly(x, y, z, w)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WRAPPER_HACK(DOMPoint, Web::Geometry)
|
||||||
|
|
29
Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp
Normal file
29
Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Geometry/DOMPointReadOnly.h>
|
||||||
|
#include <LibWeb/HTML/Window.h>
|
||||||
|
|
||||||
|
namespace Web::Geometry {
|
||||||
|
|
||||||
|
JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::create_with_global_object(HTML::Window& window, double x, double y, double z, double w)
|
||||||
|
{
|
||||||
|
return *window.heap().allocate<DOMPointReadOnly>(window.realm(), window, x, y, z, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMPointReadOnly::DOMPointReadOnly(HTML::Window& window, double x, double y, double z, double w)
|
||||||
|
: PlatformObject(window.realm())
|
||||||
|
, m_x(x)
|
||||||
|
, m_y(y)
|
||||||
|
, m_z(z)
|
||||||
|
, m_w(w)
|
||||||
|
{
|
||||||
|
set_prototype(&window.cached_web_prototype("DOMPointReadOnly"));
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMPointReadOnly::~DOMPointReadOnly() = default;
|
||||||
|
|
||||||
|
}
|
|
@ -6,29 +6,20 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/RefCounted.h>
|
|
||||||
#include <LibGfx/Point.h>
|
#include <LibGfx/Point.h>
|
||||||
#include <LibWeb/Bindings/Wrappable.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
|
|
||||||
namespace Web::Geometry {
|
namespace Web::Geometry {
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dompointreadonly
|
// https://drafts.fxtf.org/geometry/#dompointreadonly
|
||||||
class DOMPointReadOnly
|
class DOMPointReadOnly : public Bindings::PlatformObject {
|
||||||
: public RefCounted<DOMPointReadOnly>
|
WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
|
||||||
, public Bindings::Wrappable {
|
|
||||||
public:
|
public:
|
||||||
using WrapperType = Bindings::DOMPointReadOnlyWrapper;
|
static JS::NonnullGCPtr<DOMPointReadOnly> create_with_global_object(HTML::Window&, double x = 0, double y = 0, double z = 0, double w = 0);
|
||||||
|
|
||||||
static NonnullRefPtr<DOMPointReadOnly> create_with_global_object(HTML::Window&, double x = 0, double y = 0, double z = 0, double w = 0)
|
virtual ~DOMPointReadOnly() override;
|
||||||
{
|
|
||||||
return DOMPointReadOnly::create(x, y, z, w);
|
|
||||||
}
|
|
||||||
|
|
||||||
static NonnullRefPtr<DOMPointReadOnly> create(double x = 0, double y = 0, double z = 0, double w = 0)
|
|
||||||
{
|
|
||||||
return adopt_ref(*new DOMPointReadOnly(x, y, z, w));
|
|
||||||
}
|
|
||||||
|
|
||||||
double x() const { return m_x; }
|
double x() const { return m_x; }
|
||||||
double y() const { return m_y; }
|
double y() const { return m_y; }
|
||||||
|
@ -36,13 +27,7 @@ public:
|
||||||
double w() const { return m_w; }
|
double w() const { return m_w; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DOMPointReadOnly(double x, double y, double z, double w)
|
DOMPointReadOnly(HTML::Window&, double x, double y, double z, double w);
|
||||||
: m_x(x)
|
|
||||||
, m_y(y)
|
|
||||||
, m_z(z)
|
|
||||||
, m_w(w)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
double m_x;
|
double m_x;
|
||||||
double m_y;
|
double m_y;
|
||||||
|
@ -51,3 +36,5 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WRAPPER_HACK(DOMPointReadOnly, Web::Geometry)
|
||||||
|
|
|
@ -26,10 +26,10 @@ float SVGGeometryElement::get_total_length()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Geometry::DOMPoint> SVGGeometryElement::get_point_at_length(float distance)
|
JS::NonnullGCPtr<Geometry::DOMPoint> SVGGeometryElement::get_point_at_length(float distance)
|
||||||
{
|
{
|
||||||
(void)distance;
|
(void)distance;
|
||||||
return Geometry::DOMPoint::create(0, 0, 0, 0);
|
return Geometry::DOMPoint::create_with_global_object(window(), 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
virtual Gfx::Path& get_path() = 0;
|
virtual Gfx::Path& get_path() = 0;
|
||||||
|
|
||||||
float get_total_length();
|
float get_total_length();
|
||||||
NonnullRefPtr<Geometry::DOMPoint> get_point_at_length(float distance);
|
JS::NonnullGCPtr<Geometry::DOMPoint> get_point_at_length(float distance);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name);
|
SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name);
|
||||||
|
|
|
@ -56,8 +56,8 @@ libweb_js_wrapper(Encoding/TextEncoder)
|
||||||
libweb_js_wrapper(Fetch/Headers ITERABLE)
|
libweb_js_wrapper(Fetch/Headers ITERABLE)
|
||||||
libweb_js_wrapper(FileAPI/Blob)
|
libweb_js_wrapper(FileAPI/Blob)
|
||||||
libweb_js_wrapper(FileAPI/File)
|
libweb_js_wrapper(FileAPI/File)
|
||||||
libweb_js_wrapper(Geometry/DOMPoint)
|
libweb_js_wrapper(Geometry/DOMPoint NO_INSTANCE)
|
||||||
libweb_js_wrapper(Geometry/DOMPointReadOnly)
|
libweb_js_wrapper(Geometry/DOMPointReadOnly NO_INSTANCE)
|
||||||
libweb_js_wrapper(Geometry/DOMRect)
|
libweb_js_wrapper(Geometry/DOMRect)
|
||||||
libweb_js_wrapper(Geometry/DOMRectList)
|
libweb_js_wrapper(Geometry/DOMRectList)
|
||||||
libweb_js_wrapper(Geometry/DOMRectReadOnly)
|
libweb_js_wrapper(Geometry/DOMRectReadOnly)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue