LibGC+Everywhere: Factor out a LibGC from LibJS

Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
This commit is contained in:
Shannon Booth 2024-11-15 04:01:23 +13:00 committed by Andreas Kling
commit f87041bf3a
Notes: github-actions[bot] 2024-11-15 13:50:17 +00:00
1722 changed files with 9939 additions and 9906 deletions

View file

@ -15,10 +15,10 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMMatrix);
GC_DEFINE_ALLOCATOR(DOMMatrix);
// https://drafts.fxtf.org/geometry/#dom-dommatrix-dommatrix
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::construct_impl(JS::Realm& realm, Optional<Variant<String, Vector<double>>> const& init)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::construct_impl(JS::Realm& realm, Optional<Variant<String, Vector<double>>> const& init)
{
auto& vm = realm.vm();
@ -77,7 +77,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::construct_impl(JS::R
}
// https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-2d-dictionary
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::create_from_dom_matrix_2d_init(JS::Realm& realm, DOMMatrix2DInit& init)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::create_from_dom_matrix_2d_init(JS::Realm& realm, DOMMatrix2DInit& init)
{
// 1. Validate and fixup (2D) other.
TRY(validate_and_fixup_dom_matrix_2d_init(init));
@ -96,7 +96,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::create_from_dom_matr
}
// https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-dictionary
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::create_from_dom_matrix_init(JS::Realm& realm, DOMMatrixInit& init)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::create_from_dom_matrix_init(JS::Realm& realm, DOMMatrixInit& init)
{
// 1. Validate and fixup other.
TRY(validate_and_fixup_dom_matrix_init(init));
@ -114,12 +114,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::create_from_dom_matr
init.m41.value(), init.m42.value(), init.m43, init.m44);
}
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::create_from_dom_matrix_read_only(JS::Realm& realm, DOMMatrixReadOnly const& read_only_matrix)
GC::Ref<DOMMatrix> DOMMatrix::create_from_dom_matrix_read_only(JS::Realm& realm, DOMMatrixReadOnly const& read_only_matrix)
{
return realm.create<DOMMatrix>(realm, read_only_matrix);
}
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::create(JS::Realm& realm)
GC::Ref<DOMMatrix> DOMMatrix::create(JS::Realm& realm)
{
return realm.create<DOMMatrix>(realm);
}
@ -153,13 +153,13 @@ void DOMMatrix::initialize(JS::Realm& realm)
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-frommatrix
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::from_matrix(JS::VM& vm, DOMMatrixInit other)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::from_matrix(JS::VM& vm, DOMMatrixInit other)
{
return create_from_dom_matrix_init(*vm.current_realm(), other);
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-fromfloat32array
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::from_float32_array(JS::VM& vm, JS::Handle<WebIDL::BufferSource> const& array32)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::from_float32_array(JS::VM& vm, GC::Root<WebIDL::BufferSource> const& array32)
{
if (!is<JS::Float32Array>(*array32->raw_object()))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Float32Array");
@ -184,7 +184,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::from_float32_array(J
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-fromfloat64array
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::from_float64_array(JS::VM& vm, JS::Handle<WebIDL::BufferSource> const& array64)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::from_float64_array(JS::VM& vm, GC::Root<WebIDL::BufferSource> const& array64)
{
if (!is<JS::Float64Array>(*array64->raw_object()))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Float64Array");
@ -383,7 +383,7 @@ void DOMMatrix::set_f(double value)
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-multiplyself
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::multiply_self(DOMMatrixInit other)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::multiply_self(DOMMatrixInit other)
{
// 1. Let otherObject be the result of invoking create a DOMMatrix from the dictionary other.
auto other_object = TRY(DOMMatrix::create_from_dom_matrix_init(realm(), other));
@ -396,11 +396,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::multiply_self(DOMMat
m_is_2d = false;
// 4. Return the current matrix.
return JS::NonnullGCPtr<DOMMatrix>(*this);
return GC::Ref<DOMMatrix>(*this);
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-premultiplyself
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::pre_multiply_self(DOMMatrixInit other)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::pre_multiply_self(DOMMatrixInit other)
{
// 1. Let otherObject be the result of invoking create a DOMMatrix from the dictionary other.
auto other_object = TRY(DOMMatrix::create_from_dom_matrix_init(realm(), other));
@ -413,11 +413,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::pre_multiply_self(DO
m_is_2d = false;
// 4. Return the current matrix.
return JS::NonnullGCPtr<DOMMatrix>(*this);
return GC::Ref<DOMMatrix>(*this);
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-translateself
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::translate_self(Optional<double> tx, Optional<double> ty, Optional<double> tz)
GC::Ref<DOMMatrix> DOMMatrix::translate_self(Optional<double> tx, Optional<double> ty, Optional<double> tz)
{
// 1. Post-multiply a translation transformation on the current matrix. The 3D translation matrix is described in CSS Transforms.
m_matrix = m_matrix * Gfx::translation_matrix(Vector3<double> { tx.value_or(0), ty.value_or(0), tz.value_or(0) });
@ -431,7 +431,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::translate_self(Optional<double> tx, Optio
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-scaleself
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::scale_self(Optional<double> scale_x, Optional<double> scale_y, Optional<double> scale_z, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z)
GC::Ref<DOMMatrix> DOMMatrix::scale_self(Optional<double> scale_x, Optional<double> scale_y, Optional<double> scale_z, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z)
{
// 1. Perform a translateSelf() transformation on the current matrix with the arguments originX, originY, originZ.
translate_self(origin_x, origin_y, origin_z);
@ -456,7 +456,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::scale_self(Optional<double> scale_x, Opti
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-scale3dself
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::scale3d_self(Optional<double> scale, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z)
GC::Ref<DOMMatrix> DOMMatrix::scale3d_self(Optional<double> scale, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z)
{
// 1. Apply a translateSelf() transformation to the current matrix with the arguments originX, originY, originZ.
translate_self(origin_x, origin_y, origin_z);
@ -476,7 +476,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::scale3d_self(Optional<double> scale, Opti
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-rotateself
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::rotate_self(Optional<double> rot_x, Optional<double> rot_y, Optional<double> rot_z)
GC::Ref<DOMMatrix> DOMMatrix::rotate_self(Optional<double> rot_x, Optional<double> rot_y, Optional<double> rot_z)
{
// 1. If rotY and rotZ are both missing, set rotZ to the value of rotX and set rotX and rotY to 0.
if (!rot_y.has_value() && !rot_z.has_value()) {
@ -510,7 +510,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::rotate_self(Optional<double> rot_x, Optio
return *this;
}
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::rotate_from_vector_self(Optional<double> x, Optional<double> y)
GC::Ref<DOMMatrix> DOMMatrix::rotate_from_vector_self(Optional<double> x, Optional<double> y)
{
// 1. Post-multiply a rotation transformation on the current matrix.
// The rotation angle is determined by the angle between the vector (1,0)T and (x,y)T in the clockwise direction. If x and y should both be 0 or -0, the angle is specified as 0.
@ -523,7 +523,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::rotate_from_vector_self(Optional<double>
return *this;
}
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::rotate_axis_angle_self(Optional<double> x, Optional<double> y, Optional<double> z, Optional<double> angle)
GC::Ref<DOMMatrix> DOMMatrix::rotate_axis_angle_self(Optional<double> x, Optional<double> y, Optional<double> z, Optional<double> angle)
{
// 1. Post-multiply a rotation transformation on the current matrix around the specified vector x, y, z by the specified rotation angle in degrees. The 3D rotation matrix is described in CSS Transforms with alpha = angle in degrees. [CSS3-TRANSFORMS]
m_matrix = m_matrix * Gfx::rotation_matrix<double>(Vector3<double> { x.value_or(0), y.value_or(0), z.value_or(0) }.normalized(), AK::to_radians(angle.value()));
@ -537,7 +537,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::rotate_axis_angle_self(Optional<double> x
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-skewxself
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::skew_x_self(double sx)
GC::Ref<DOMMatrix> DOMMatrix::skew_x_self(double sx)
{
// 1. Post-multiply a skewX transformation on the current matrix by the specified angle sx in degrees. The 2D skewX matrix is described in CSS Transforms with alpha = sx in degrees. [CSS3-TRANSFORMS]
Gfx::DoubleMatrix4x4 skew_matrix = {
@ -553,7 +553,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::skew_x_self(double sx)
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-skewyself
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::skew_y_self(double sy)
GC::Ref<DOMMatrix> DOMMatrix::skew_y_self(double sy)
{
// 1. Post-multiply a skewX transformation on the current matrix by the specified angle sy in degrees. The 2D skewY matrix is described in CSS Transforms with beta = sy in degrees. [CSS3-TRANSFORMS]
Gfx::DoubleMatrix4x4 skew_matrix = {
@ -569,7 +569,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::skew_y_self(double sy)
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-invertself
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::invert_self()
GC::Ref<DOMMatrix> DOMMatrix::invert_self()
{
bool is_invertible = m_matrix.is_invertible();
@ -591,7 +591,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrix::invert_self()
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-setmatrixvalue
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::set_matrix_value(String const& transform_list)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrix::set_matrix_value(String const& transform_list)
{
// 1. Parse transformList into an abstract matrix, and let matrix and 2dTransform be the result. If the result is failure, then throw a "SyntaxError" DOMException.
auto result = TRY(parse_dom_matrix_init_string(realm(), transform_list));
@ -603,7 +603,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::set_matrix_value(Str
m_matrix = result.matrix;
// 4. Return the current matrix.
return JS::NonnullGCPtr<DOMMatrix>(*this);
return GC::Ref<DOMMatrix>(*this);
}
}

View file

@ -16,20 +16,20 @@ namespace Web::Geometry {
// https://drafts.fxtf.org/geometry/#dommatrix
class DOMMatrix : public DOMMatrixReadOnly {
WEB_PLATFORM_OBJECT(DOMMatrix, DOMMatrixReadOnly);
JS_DECLARE_ALLOCATOR(DOMMatrix);
GC_DECLARE_ALLOCATOR(DOMMatrix);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> construct_impl(JS::Realm&, Optional<Variant<String, Vector<double>>> const& init);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> create_from_dom_matrix_2d_init(JS::Realm&, DOMMatrix2DInit& init);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> create_from_dom_matrix_init(JS::Realm&, DOMMatrixInit& init);
static JS::NonnullGCPtr<DOMMatrix> create_from_dom_matrix_read_only(JS::Realm&, DOMMatrixReadOnly const& read_only_matrix);
static JS::NonnullGCPtr<DOMMatrix> create(JS::Realm&);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> construct_impl(JS::Realm&, Optional<Variant<String, Vector<double>>> const& init);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> create_from_dom_matrix_2d_init(JS::Realm&, DOMMatrix2DInit& init);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> create_from_dom_matrix_init(JS::Realm&, DOMMatrixInit& init);
static GC::Ref<DOMMatrix> create_from_dom_matrix_read_only(JS::Realm&, DOMMatrixReadOnly const& read_only_matrix);
static GC::Ref<DOMMatrix> create(JS::Realm&);
virtual ~DOMMatrix() override;
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> from_matrix(JS::VM&, DOMMatrixInit other = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> from_float32_array(JS::VM&, JS::Handle<WebIDL::BufferSource> const& array32);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> from_float64_array(JS::VM&, JS::Handle<WebIDL::BufferSource> const& array64);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> from_matrix(JS::VM&, DOMMatrixInit other = {});
static WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> from_float32_array(JS::VM&, GC::Root<WebIDL::BufferSource> const& array32);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> from_float64_array(JS::VM&, GC::Root<WebIDL::BufferSource> const& array64);
void set_m11(double value);
void set_m12(double value);
@ -55,19 +55,19 @@ public:
void set_e(double value);
void set_f(double value);
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> multiply_self(DOMMatrixInit other = {});
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> pre_multiply_self(DOMMatrixInit other = {});
JS::NonnullGCPtr<DOMMatrix> translate_self(Optional<double> tx, Optional<double> ty, Optional<double> tz);
JS::NonnullGCPtr<DOMMatrix> scale_self(Optional<double> scale_x, Optional<double> scale_y, Optional<double> scale_z, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z);
JS::NonnullGCPtr<DOMMatrix> scale3d_self(Optional<double> scale, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z);
JS::NonnullGCPtr<DOMMatrix> rotate_self(Optional<double> rot_x, Optional<double> rot_y, Optional<double> rot_z);
JS::NonnullGCPtr<DOMMatrix> rotate_from_vector_self(Optional<double> x, Optional<double> y);
JS::NonnullGCPtr<DOMMatrix> rotate_axis_angle_self(Optional<double> x, Optional<double> y, Optional<double> z, Optional<double> angle);
JS::NonnullGCPtr<DOMMatrix> skew_x_self(double sx = 0);
JS::NonnullGCPtr<DOMMatrix> skew_y_self(double sy = 0);
JS::NonnullGCPtr<DOMMatrix> invert_self();
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> multiply_self(DOMMatrixInit other = {});
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> pre_multiply_self(DOMMatrixInit other = {});
GC::Ref<DOMMatrix> translate_self(Optional<double> tx, Optional<double> ty, Optional<double> tz);
GC::Ref<DOMMatrix> scale_self(Optional<double> scale_x, Optional<double> scale_y, Optional<double> scale_z, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z);
GC::Ref<DOMMatrix> scale3d_self(Optional<double> scale, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z);
GC::Ref<DOMMatrix> rotate_self(Optional<double> rot_x, Optional<double> rot_y, Optional<double> rot_z);
GC::Ref<DOMMatrix> rotate_from_vector_self(Optional<double> x, Optional<double> y);
GC::Ref<DOMMatrix> rotate_axis_angle_self(Optional<double> x, Optional<double> y, Optional<double> z, Optional<double> angle);
GC::Ref<DOMMatrix> skew_x_self(double sx = 0);
GC::Ref<DOMMatrix> skew_y_self(double sy = 0);
GC::Ref<DOMMatrix> invert_self();
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> set_matrix_value(String const& transform_list);
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> set_matrix_value(String const& transform_list);
virtual StringView interface_name() const override { return "DOMMatrix"sv; }

View file

@ -21,10 +21,10 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMMatrixReadOnly);
GC_DEFINE_ALLOCATOR(DOMMatrixReadOnly);
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-dommatrixreadonly
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::construct_impl(JS::Realm& realm, Optional<Variant<String, Vector<double>>> const& init)
WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> DOMMatrixReadOnly::construct_impl(JS::Realm& realm, Optional<Variant<String, Vector<double>>> const& init)
{
auto& vm = realm.vm();
@ -83,7 +83,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::cons
}
// https://drafts.fxtf.org/geometry/#create-a-dommatrixreadonly-from-the-2d-dictionary
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::create_from_dom_matrix_2d_init(JS::Realm& realm, DOMMatrix2DInit& init)
WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> DOMMatrixReadOnly::create_from_dom_matrix_2d_init(JS::Realm& realm, DOMMatrix2DInit& init)
{
// 1. Validate and fixup (2D) other.
TRY(validate_and_fixup_dom_matrix_2d_init(init));
@ -102,7 +102,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::crea
}
// https://drafts.fxtf.org/geometry/#create-a-dommatrixreadonly-from-the-dictionary
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::create_from_dom_matrix_init(JS::Realm& realm, DOMMatrixInit& init)
WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> DOMMatrixReadOnly::create_from_dom_matrix_init(JS::Realm& realm, DOMMatrixInit& init)
{
// 1. Validate and fixup other.
TRY(validate_and_fixup_dom_matrix_init(init));
@ -120,7 +120,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::crea
init.m41.value(), init.m42.value(), init.m43, init.m44);
}
JS::NonnullGCPtr<DOMMatrixReadOnly> DOMMatrixReadOnly::create(JS::Realm& realm)
GC::Ref<DOMMatrixReadOnly> DOMMatrixReadOnly::create(JS::Realm& realm)
{
return realm.create<DOMMatrixReadOnly>(realm);
}
@ -224,13 +224,13 @@ void DOMMatrixReadOnly::initialize_from_create_3d_matrix(double m11, double m12,
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-frommatrix
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::from_matrix(JS::VM& vm, DOMMatrixInit& other)
WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> DOMMatrixReadOnly::from_matrix(JS::VM& vm, DOMMatrixInit& other)
{
return create_from_dom_matrix_init(*vm.current_realm(), other);
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-fromfloat32array
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::from_float32_array(JS::VM& vm, JS::Handle<WebIDL::BufferSource> const& array32)
WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> DOMMatrixReadOnly::from_float32_array(JS::VM& vm, GC::Root<WebIDL::BufferSource> const& array32)
{
if (!is<JS::Float32Array>(*array32))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Float32Array");
@ -255,7 +255,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::from
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-fromfloat64array
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> DOMMatrixReadOnly::from_float64_array(JS::VM& vm, JS::Handle<WebIDL::BufferSource> const& array64)
WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> DOMMatrixReadOnly::from_float64_array(JS::VM& vm, GC::Root<WebIDL::BufferSource> const& array64)
{
if (!is<JS::Float64Array>(*array64))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Float64Array");
@ -333,7 +333,7 @@ bool DOMMatrixReadOnly::is_identity() const
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-translate
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::translate(Optional<double> const& tx, Optional<double> const& ty, Optional<double> const& tz) const
GC::Ref<DOMMatrix> DOMMatrixReadOnly::translate(Optional<double> const& tx, Optional<double> const& ty, Optional<double> const& tz) const
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -344,7 +344,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::translate(Optional<double> const&
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-scale
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::scale(Optional<double> scale_x, Optional<double> scale_y, Optional<double> scale_z, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z)
GC::Ref<DOMMatrix> DOMMatrixReadOnly::scale(Optional<double> scale_x, Optional<double> scale_y, Optional<double> scale_z, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z)
{
// 1. If scaleY is missing, set scaleY to the value of scaleX.
if (!scale_y.has_value())
@ -359,7 +359,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::scale(Optional<double> scale_x, O
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-scalenonuniform
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::scale_non_uniform(Optional<double> scale_x, Optional<double> scale_y)
GC::Ref<DOMMatrix> DOMMatrixReadOnly::scale_non_uniform(Optional<double> scale_x, Optional<double> scale_y)
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -370,7 +370,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::scale_non_uniform(Optional<double
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-scale3d
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::scale3d(Optional<double> scale, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z)
GC::Ref<DOMMatrix> DOMMatrixReadOnly::scale3d(Optional<double> scale, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z)
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -380,7 +380,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::scale3d(Optional<double> scale, O
return result->scale3d_self(scale, origin_x, origin_y, origin_z);
}
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::rotate(Optional<double> rot_x, Optional<double> rot_y, Optional<double> rot_z)
GC::Ref<DOMMatrix> DOMMatrixReadOnly::rotate(Optional<double> rot_x, Optional<double> rot_y, Optional<double> rot_z)
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -390,7 +390,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::rotate(Optional<double> rot_x, Op
return result->rotate_self(rot_x, rot_y, rot_z);
}
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::rotate_from_vector(Optional<double> x, Optional<double> y)
GC::Ref<DOMMatrix> DOMMatrixReadOnly::rotate_from_vector(Optional<double> x, Optional<double> y)
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -400,7 +400,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::rotate_from_vector(Optional<doubl
return result->rotate_from_vector_self(x, y);
}
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::rotate_axis_angle(Optional<double> x, Optional<double> y, Optional<double> z, Optional<double> angle)
GC::Ref<DOMMatrix> DOMMatrixReadOnly::rotate_axis_angle(Optional<double> x, Optional<double> y, Optional<double> z, Optional<double> angle)
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -411,7 +411,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::rotate_axis_angle(Optional<double
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-skewx
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::skew_x(double sx) const
GC::Ref<DOMMatrix> DOMMatrixReadOnly::skew_x(double sx) const
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -422,7 +422,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::skew_x(double sx) const
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-skewy
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::skew_y(double sy) const
GC::Ref<DOMMatrix> DOMMatrixReadOnly::skew_y(double sy) const
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -433,7 +433,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::skew_y(double sy) const
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-multiply
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrixReadOnly::multiply(DOMMatrixInit other)
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> DOMMatrixReadOnly::multiply(DOMMatrixInit other)
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -444,7 +444,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrixReadOnly::multiply(DOM
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-flipx
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::flip_x()
GC::Ref<DOMMatrix> DOMMatrixReadOnly::flip_x()
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -463,7 +463,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::flip_x()
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-flipy
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::flip_y()
GC::Ref<DOMMatrix> DOMMatrixReadOnly::flip_y()
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -482,7 +482,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::flip_y()
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-inverse
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::inverse() const
GC::Ref<DOMMatrix> DOMMatrixReadOnly::inverse() const
{
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
@ -494,7 +494,7 @@ JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::inverse() const
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-transformpoint
JS::NonnullGCPtr<DOMPoint> DOMMatrixReadOnly::transform_point(DOMPointInit const& point) const
GC::Ref<DOMPoint> DOMMatrixReadOnly::transform_point(DOMPointInit const& point) const
{
// Let pointObject be the result of invoking create a DOMPoint from the dictionary point.
auto point_object = DOMPoint::from_point(realm().vm(), point);
@ -504,7 +504,7 @@ JS::NonnullGCPtr<DOMPoint> DOMMatrixReadOnly::transform_point(DOMPointInit const
}
// https://drafts.fxtf.org/geometry/#transform-a-point-with-a-matrix
JS::NonnullGCPtr<DOMPoint> DOMMatrixReadOnly::transform_point(DOMPointReadOnly const& point) const
GC::Ref<DOMPoint> DOMMatrixReadOnly::transform_point(DOMPointReadOnly const& point) const
{
// 1. Let x be points x coordinate.
// 2. Let y be points y coordinate.
@ -527,7 +527,7 @@ JS::NonnullGCPtr<DOMPoint> DOMMatrixReadOnly::transform_point(DOMPointReadOnly c
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-tofloat32array
JS::NonnullGCPtr<JS::Float32Array> DOMMatrixReadOnly::to_float32_array() const
GC::Ref<JS::Float32Array> DOMMatrixReadOnly::to_float32_array() const
{
// Returns the serialized 16 elements m11 to m44 of the current matrix in column-major order as Float32Array.
float elements[16] = { static_cast<float>(m11()), static_cast<float>(m12()), static_cast<float>(m13()), static_cast<float>(m14()),
@ -540,7 +540,7 @@ JS::NonnullGCPtr<JS::Float32Array> DOMMatrixReadOnly::to_float32_array() const
}
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-tofloat64array
JS::NonnullGCPtr<JS::Float64Array> DOMMatrixReadOnly::to_float64_array() const
GC::Ref<JS::Float64Array> DOMMatrixReadOnly::to_float64_array() const
{
// Returns the serialized 16 elements m11 to m44 of the current matrix in column-major order as Float64Array.
double elements[16] = { m11(), m12(), m13(), m14(),

View file

@ -52,19 +52,19 @@ class DOMMatrixReadOnly
: public Bindings::PlatformObject
, public Bindings::Serializable {
WEB_PLATFORM_OBJECT(DOMMatrixReadOnly, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMMatrixReadOnly);
GC_DECLARE_ALLOCATOR(DOMMatrixReadOnly);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> construct_impl(JS::Realm&, Optional<Variant<String, Vector<double>>> const& init);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> create_from_dom_matrix_2d_init(JS::Realm&, DOMMatrix2DInit& init);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> create_from_dom_matrix_init(JS::Realm&, DOMMatrixInit& init);
static JS::NonnullGCPtr<DOMMatrixReadOnly> create(JS::Realm&);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> construct_impl(JS::Realm&, Optional<Variant<String, Vector<double>>> const& init);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> create_from_dom_matrix_2d_init(JS::Realm&, DOMMatrix2DInit& init);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> create_from_dom_matrix_init(JS::Realm&, DOMMatrixInit& init);
static GC::Ref<DOMMatrixReadOnly> create(JS::Realm&);
virtual ~DOMMatrixReadOnly() override;
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> from_matrix(JS::VM&, DOMMatrixInit& other);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> from_float32_array(JS::VM&, JS::Handle<WebIDL::BufferSource> const& array32);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrixReadOnly>> from_float64_array(JS::VM&, JS::Handle<WebIDL::BufferSource> const& array64);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> from_matrix(JS::VM&, DOMMatrixInit& other);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> from_float32_array(JS::VM&, GC::Root<WebIDL::BufferSource> const& array32);
static WebIDL::ExceptionOr<GC::Ref<DOMMatrixReadOnly>> from_float64_array(JS::VM&, GC::Root<WebIDL::BufferSource> const& array64);
// https://drafts.fxtf.org/geometry/#dommatrix-attributes
double m11() const { return m_matrix.elements()[0][0]; }
@ -94,24 +94,24 @@ public:
bool is2d() const { return m_is_2d; }
bool is_identity() const;
JS::NonnullGCPtr<DOMMatrix> translate(Optional<double> const& tx, Optional<double> const& ty, Optional<double> const& tz) const;
JS::NonnullGCPtr<DOMMatrix> scale(Optional<double> scale_x, Optional<double> scale_y, Optional<double> scale_z, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z);
JS::NonnullGCPtr<DOMMatrix> scale_non_uniform(Optional<double> scale_x, Optional<double> scale_y);
JS::NonnullGCPtr<DOMMatrix> scale3d(Optional<double> scale, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z);
JS::NonnullGCPtr<DOMMatrix> rotate(Optional<double> rot_x, Optional<double> rot_y, Optional<double> rot_z);
JS::NonnullGCPtr<DOMMatrix> rotate_from_vector(Optional<double> x, Optional<double> y);
JS::NonnullGCPtr<DOMMatrix> rotate_axis_angle(Optional<double> x, Optional<double> y, Optional<double> z, Optional<double> angle);
JS::NonnullGCPtr<DOMMatrix> skew_x(double sx = 0) const;
JS::NonnullGCPtr<DOMMatrix> skew_y(double sy = 0) const;
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> multiply(DOMMatrixInit other = {});
JS::NonnullGCPtr<DOMMatrix> flip_x();
JS::NonnullGCPtr<DOMMatrix> flip_y();
JS::NonnullGCPtr<DOMMatrix> inverse() const;
GC::Ref<DOMMatrix> translate(Optional<double> const& tx, Optional<double> const& ty, Optional<double> const& tz) const;
GC::Ref<DOMMatrix> scale(Optional<double> scale_x, Optional<double> scale_y, Optional<double> scale_z, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z);
GC::Ref<DOMMatrix> scale_non_uniform(Optional<double> scale_x, Optional<double> scale_y);
GC::Ref<DOMMatrix> scale3d(Optional<double> scale, Optional<double> origin_x, Optional<double> origin_y, Optional<double> origin_z);
GC::Ref<DOMMatrix> rotate(Optional<double> rot_x, Optional<double> rot_y, Optional<double> rot_z);
GC::Ref<DOMMatrix> rotate_from_vector(Optional<double> x, Optional<double> y);
GC::Ref<DOMMatrix> rotate_axis_angle(Optional<double> x, Optional<double> y, Optional<double> z, Optional<double> angle);
GC::Ref<DOMMatrix> skew_x(double sx = 0) const;
GC::Ref<DOMMatrix> skew_y(double sy = 0) const;
WebIDL::ExceptionOr<GC::Ref<DOMMatrix>> multiply(DOMMatrixInit other = {});
GC::Ref<DOMMatrix> flip_x();
GC::Ref<DOMMatrix> flip_y();
GC::Ref<DOMMatrix> inverse() const;
JS::NonnullGCPtr<DOMPoint> transform_point(DOMPointInit const&) const;
JS::NonnullGCPtr<DOMPoint> transform_point(DOMPointReadOnly const&) const;
JS::NonnullGCPtr<JS::Float32Array> to_float32_array() const;
JS::NonnullGCPtr<JS::Float64Array> to_float64_array() const;
GC::Ref<DOMPoint> transform_point(DOMPointInit const&) const;
GC::Ref<DOMPoint> transform_point(DOMPointReadOnly const&) const;
GC::Ref<JS::Float32Array> to_float32_array() const;
GC::Ref<JS::Float64Array> to_float64_array() const;
WebIDL::ExceptionOr<String> to_string() const;

View file

@ -11,14 +11,14 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMPoint);
GC_DEFINE_ALLOCATOR(DOMPoint);
JS::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
GC::Ref<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
{
return realm.create<DOMPoint>(realm, x, y, z, w);
}
JS::NonnullGCPtr<DOMPoint> DOMPoint::create(JS::Realm& realm)
GC::Ref<DOMPoint> DOMPoint::create(JS::Realm& realm)
{
return realm.create<DOMPoint>(realm);
}
@ -34,7 +34,7 @@ DOMPoint::DOMPoint(JS::Realm& realm)
}
// https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
JS::NonnullGCPtr<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other)
GC::Ref<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other)
{
// The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other.
return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);

View file

@ -14,13 +14,13 @@ namespace Web::Geometry {
// https://drafts.fxtf.org/geometry/#DOMPoint
class DOMPoint final : public DOMPointReadOnly {
WEB_PLATFORM_OBJECT(DOMPoint, DOMPointReadOnly);
JS_DECLARE_ALLOCATOR(DOMPoint);
GC_DECLARE_ALLOCATOR(DOMPoint);
public:
static JS::NonnullGCPtr<DOMPoint> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
static JS::NonnullGCPtr<DOMPoint> create(JS::Realm&);
static GC::Ref<DOMPoint> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
static GC::Ref<DOMPoint> create(JS::Realm&);
static JS::NonnullGCPtr<DOMPoint> from_point(JS::VM&, DOMPointInit const&);
static GC::Ref<DOMPoint> from_point(JS::VM&, DOMPointInit const&);
virtual ~DOMPoint() override;

View file

@ -15,14 +15,14 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMPointReadOnly);
GC_DEFINE_ALLOCATOR(DOMPointReadOnly);
JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
GC::Ref<DOMPointReadOnly> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
{
return realm.create<DOMPointReadOnly>(realm, x, y, z, w);
}
JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::create(JS::Realm& realm)
GC::Ref<DOMPointReadOnly> DOMPointReadOnly::create(JS::Realm& realm)
{
return realm.create<DOMPointReadOnly>(realm);
}
@ -42,7 +42,7 @@ DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm)
}
// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint
JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::from_point(JS::VM& vm, DOMPointInit const& other)
GC::Ref<DOMPointReadOnly> DOMPointReadOnly::from_point(JS::VM& vm, DOMPointInit const& other)
{
// The fromPoint(other) static method on DOMPointReadOnly must create a DOMPointReadOnly from the dictionary other.
return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
@ -51,7 +51,7 @@ JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::from_point(JS::VM& vm, DOMP
DOMPointReadOnly::~DOMPointReadOnly() = default;
// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-matrixtransform
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPoint>> DOMPointReadOnly::matrix_transform(DOMMatrixInit& matrix) const
WebIDL::ExceptionOr<GC::Ref<DOMPoint>> DOMPointReadOnly::matrix_transform(DOMMatrixInit& matrix) const
{
// 1. Let matrixObject be the result of invoking create a DOMMatrix from the dictionary matrix.
auto matrix_object = TRY(DOMMatrix::create_from_dom_matrix_init(realm(), matrix));

View file

@ -27,13 +27,13 @@ class DOMPointReadOnly
: public Bindings::PlatformObject
, public Bindings::Serializable {
WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMPointReadOnly);
GC_DECLARE_ALLOCATOR(DOMPointReadOnly);
public:
static JS::NonnullGCPtr<DOMPointReadOnly> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
static JS::NonnullGCPtr<DOMPointReadOnly> create(JS::Realm&);
static GC::Ref<DOMPointReadOnly> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
static GC::Ref<DOMPointReadOnly> create(JS::Realm&);
static JS::NonnullGCPtr<DOMPointReadOnly> from_point(JS::VM&, DOMPointInit const&);
static GC::Ref<DOMPointReadOnly> from_point(JS::VM&, DOMPointInit const&);
virtual ~DOMPointReadOnly() override;
@ -42,7 +42,7 @@ public:
double z() const { return m_z; }
double w() const { return m_w; }
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPoint>> matrix_transform(DOMMatrixInit&) const;
WebIDL::ExceptionOr<GC::Ref<DOMPoint>> matrix_transform(DOMMatrixInit&) const;
virtual StringView interface_name() const override { return "DOMPointReadOnly"sv; }
virtual WebIDL::ExceptionOr<void> serialization_steps(HTML::SerializationRecord&, bool for_storage, HTML::SerializationMemory&) override;

View file

@ -10,14 +10,14 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMQuad);
GC_DEFINE_ALLOCATOR(DOMQuad);
JS::NonnullGCPtr<DOMQuad> DOMQuad::construct_impl(JS::Realm& realm, DOMPointInit const& p1, DOMPointInit const& p2, DOMPointInit const& p3, DOMPointInit const& p4)
GC::Ref<DOMQuad> DOMQuad::construct_impl(JS::Realm& realm, DOMPointInit const& p1, DOMPointInit const& p2, DOMPointInit const& p3, DOMPointInit const& p4)
{
return realm.create<DOMQuad>(realm, p1, p2, p3, p4);
}
JS::NonnullGCPtr<DOMQuad> DOMQuad::create(JS::Realm& realm)
GC::Ref<DOMQuad> DOMQuad::create(JS::Realm& realm)
{
return realm.create<DOMQuad>(realm);
}
@ -43,7 +43,7 @@ DOMQuad::DOMQuad(JS::Realm& realm)
DOMQuad::~DOMQuad() = default;
// https://drafts.fxtf.org/geometry/#dom-domquad-fromrect
JS::NonnullGCPtr<DOMQuad> DOMQuad::from_rect(JS::VM& vm, DOMRectInit const& other)
GC::Ref<DOMQuad> DOMQuad::from_rect(JS::VM& vm, DOMRectInit const& other)
{
// The fromRect(other) static method on DOMQuad must create a DOMQuad from the DOMRectInit dictionary other.
return construct_impl(*vm.current_realm(), { other.x, other.y },
@ -53,14 +53,14 @@ JS::NonnullGCPtr<DOMQuad> DOMQuad::from_rect(JS::VM& vm, DOMRectInit const& othe
}
// https://drafts.fxtf.org/geometry/#dom-domquad-fromquad
JS::NonnullGCPtr<DOMQuad> DOMQuad::from_quad(JS::VM& vm, DOMQuadInit const& other)
GC::Ref<DOMQuad> DOMQuad::from_quad(JS::VM& vm, DOMQuadInit const& other)
{
// The fromQuad(other) static method on DOMQuad must create a DOMQuad from the DOMQuadInit dictionary other.
return construct_impl(*vm.current_realm(), other.p1, other.p2, other.p3, other.p4);
}
// https://drafts.fxtf.org/geometry/#dom-domquad-getbounds
JS::NonnullGCPtr<DOMRect> DOMQuad::get_bounds() const
GC::Ref<DOMRect> DOMQuad::get_bounds() const
{
// The NaN-safe minimum of a non-empty list of unrestricted double values is NaN if any member of the list is NaN, or the minimum of the list otherwise.
auto nan_safe_minimum = [](double a, double b, double c, double d) -> double {

View file

@ -26,23 +26,23 @@ class DOMQuad
: public Bindings::PlatformObject
, public Bindings::Serializable {
WEB_PLATFORM_OBJECT(DOMQuad, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMQuad);
GC_DECLARE_ALLOCATOR(DOMQuad);
public:
static JS::NonnullGCPtr<DOMQuad> construct_impl(JS::Realm&, DOMPointInit const& p1, DOMPointInit const& p2, DOMPointInit const& p3, DOMPointInit const& p4);
static JS::NonnullGCPtr<DOMQuad> create(JS::Realm& realm);
static GC::Ref<DOMQuad> construct_impl(JS::Realm&, DOMPointInit const& p1, DOMPointInit const& p2, DOMPointInit const& p3, DOMPointInit const& p4);
static GC::Ref<DOMQuad> create(JS::Realm& realm);
virtual ~DOMQuad() override;
static JS::NonnullGCPtr<DOMQuad> from_rect(JS::VM&, DOMRectInit const&);
static JS::NonnullGCPtr<DOMQuad> from_quad(JS::VM&, DOMQuadInit const&);
static GC::Ref<DOMQuad> from_rect(JS::VM&, DOMRectInit const&);
static GC::Ref<DOMQuad> from_quad(JS::VM&, DOMQuadInit const&);
JS::NonnullGCPtr<DOMPoint> p1() const { return m_p1; }
JS::NonnullGCPtr<DOMPoint> p2() const { return m_p2; }
JS::NonnullGCPtr<DOMPoint> p3() const { return m_p3; }
JS::NonnullGCPtr<DOMPoint> p4() const { return m_p4; }
GC::Ref<DOMPoint> p1() const { return m_p1; }
GC::Ref<DOMPoint> p2() const { return m_p2; }
GC::Ref<DOMPoint> p3() const { return m_p3; }
GC::Ref<DOMPoint> p4() const { return m_p4; }
JS::NonnullGCPtr<DOMRect> get_bounds() const;
GC::Ref<DOMRect> get_bounds() const;
virtual StringView interface_name() const override { return "DOMQuad"sv; }
virtual WebIDL::ExceptionOr<void> serialization_steps(HTML::SerializationRecord&, bool for_storage, HTML::SerializationMemory&) override;
@ -55,10 +55,10 @@ private:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
JS::NonnullGCPtr<DOMPoint> m_p1;
JS::NonnullGCPtr<DOMPoint> m_p2;
JS::NonnullGCPtr<DOMPoint> m_p3;
JS::NonnullGCPtr<DOMPoint> m_p4;
GC::Ref<DOMPoint> m_p1;
GC::Ref<DOMPoint> m_p2;
GC::Ref<DOMPoint> m_p3;
GC::Ref<DOMPoint> m_p4;
};
}

View file

@ -11,25 +11,25 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMRect);
GC_DEFINE_ALLOCATOR(DOMRect);
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
WebIDL::ExceptionOr<GC::Ref<DOMRect>> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
{
return create(realm, Gfx::FloatRect { x, y, width, height });
}
JS::NonnullGCPtr<DOMRect> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect)
GC::Ref<DOMRect> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect)
{
return realm.create<DOMRect>(realm, rect.x(), rect.y(), rect.width(), rect.height());
}
JS::NonnullGCPtr<DOMRect> DOMRect::create(JS::Realm& realm)
GC::Ref<DOMRect> DOMRect::create(JS::Realm& realm)
{
return realm.create<DOMRect>(realm);
}
// https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary
JS::NonnullGCPtr<DOMRect> DOMRect::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other)
GC::Ref<DOMRect> DOMRect::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other)
{
auto& realm = *vm.current_realm();
return realm.create<DOMRect>(realm, other.x, other.y, other.width, other.height);

View file

@ -13,13 +13,13 @@ namespace Web::Geometry {
// https://drafts.fxtf.org/geometry/#DOMRect
class DOMRect final : public DOMRectReadOnly {
WEB_PLATFORM_OBJECT(DOMRect, DOMRectReadOnly);
JS_DECLARE_ALLOCATOR(DOMRect);
GC_DECLARE_ALLOCATOR(DOMRect);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);
[[nodiscard]] static JS::NonnullGCPtr<DOMRect> create(JS::Realm&, Gfx::FloatRect const&);
[[nodiscard]] static JS::NonnullGCPtr<DOMRect> create(JS::Realm&);
[[nodiscard]] static JS::NonnullGCPtr<DOMRect> from_rect(JS::VM&, DOMRectInit const&);
static WebIDL::ExceptionOr<GC::Ref<DOMRect>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);
[[nodiscard]] static GC::Ref<DOMRect> create(JS::Realm&, Gfx::FloatRect const&);
[[nodiscard]] static GC::Ref<DOMRect> create(JS::Realm&);
[[nodiscard]] static GC::Ref<DOMRect> from_rect(JS::VM&, DOMRectInit const&);
virtual ~DOMRect() override;

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Heap/Handle.h>
#include <LibGC/Root.h>
#include <LibWeb/Bindings/DOMRectListPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Geometry/DOMRect.h>
@ -13,17 +13,17 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMRectList);
GC_DEFINE_ALLOCATOR(DOMRectList);
JS::NonnullGCPtr<DOMRectList> DOMRectList::create(JS::Realm& realm, Vector<JS::Handle<DOMRect>> rect_handles)
GC::Ref<DOMRectList> DOMRectList::create(JS::Realm& realm, Vector<GC::Root<DOMRect>> rect_handles)
{
Vector<JS::NonnullGCPtr<DOMRect>> rects;
Vector<GC::Ref<DOMRect>> rects;
for (auto& rect : rect_handles)
rects.append(*rect);
return realm.create<DOMRectList>(realm, move(rects));
}
DOMRectList::DOMRectList(JS::Realm& realm, Vector<JS::NonnullGCPtr<DOMRect>> rects)
DOMRectList::DOMRectList(JS::Realm& realm, Vector<GC::Ref<DOMRect>> rects)
: Bindings::PlatformObject(realm)
, m_rects(move(rects))
{

View file

@ -16,10 +16,10 @@ namespace Web::Geometry {
// https://drafts.fxtf.org/geometry-1/#DOMRectList
class DOMRectList final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMRectList, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMRectList);
GC_DECLARE_ALLOCATOR(DOMRectList);
public:
[[nodiscard]] static JS::NonnullGCPtr<DOMRectList> create(JS::Realm&, Vector<JS::Handle<DOMRect>>);
[[nodiscard]] static GC::Ref<DOMRectList> create(JS::Realm&, Vector<GC::Root<DOMRect>>);
virtual ~DOMRectList() override;
@ -29,12 +29,12 @@ public:
virtual Optional<JS::Value> item_value(size_t index) const override;
private:
DOMRectList(JS::Realm&, Vector<JS::NonnullGCPtr<DOMRect>>);
DOMRectList(JS::Realm&, Vector<GC::Ref<DOMRect>>);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
Vector<JS::NonnullGCPtr<DOMRect>> m_rects;
Vector<GC::Ref<DOMRect>> m_rects;
};
}

View file

@ -13,21 +13,21 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMRectReadOnly);
GC_DEFINE_ALLOCATOR(DOMRectReadOnly);
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRectReadOnly>> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
WebIDL::ExceptionOr<GC::Ref<DOMRectReadOnly>> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
{
return realm.create<DOMRectReadOnly>(realm, x, y, width, height);
}
// https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary
JS::NonnullGCPtr<DOMRectReadOnly> DOMRectReadOnly::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other)
GC::Ref<DOMRectReadOnly> DOMRectReadOnly::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other)
{
auto& realm = *vm.current_realm();
return realm.create<DOMRectReadOnly>(realm, other.x, other.y, other.width, other.height);
}
JS::NonnullGCPtr<DOMRectReadOnly> DOMRectReadOnly::create(JS::Realm& realm)
GC::Ref<DOMRectReadOnly> DOMRectReadOnly::create(JS::Realm& realm)
{
return realm.create<DOMRectReadOnly>(realm);
}

View file

@ -27,12 +27,12 @@ class DOMRectReadOnly
: public Bindings::PlatformObject
, public Bindings::Serializable {
WEB_PLATFORM_OBJECT(DOMRectReadOnly, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMRectReadOnly);
GC_DECLARE_ALLOCATOR(DOMRectReadOnly);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRectReadOnly>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);
[[nodiscard]] static JS::NonnullGCPtr<DOMRectReadOnly> from_rect(JS::VM&, DOMRectInit const&);
static JS::NonnullGCPtr<DOMRectReadOnly> create(JS::Realm&);
static WebIDL::ExceptionOr<GC::Ref<DOMRectReadOnly>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);
[[nodiscard]] static GC::Ref<DOMRectReadOnly> from_rect(JS::VM&, DOMRectInit const&);
static GC::Ref<DOMRectReadOnly> create(JS::Realm&);
virtual ~DOMRectReadOnly() override;