1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 22:27:44 +00:00

LibWeb: Make DOMRect, DOMRectReadOnly and DOMRectList GC-allocated

This commit is contained in:
Andreas Kling 2022-09-04 01:59:58 +02:00
parent 44415af428
commit 57db2529cf
11 changed files with 125 additions and 79 deletions

View file

@ -6,42 +6,33 @@
#pragma once
#include <AK/Noncopyable.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/RefCounted.h>
#include <AK/Vector.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Bindings/LegacyPlatformObject.h>
#include <LibWeb/Geometry/DOMRect.h>
namespace Web::Geometry {
// https://drafts.fxtf.org/geometry-1/#DOMRectList
class DOMRectList final
: public RefCounted<DOMRectList>
, public Bindings::Wrappable {
AK_MAKE_NONCOPYABLE(DOMRectList);
AK_MAKE_NONMOVABLE(DOMRectList);
class DOMRectList final : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(DOMRectList, Bindings::LegacyPlatformObject);
public:
using WrapperType = Bindings::DOMRectListWrapper;
static JS::NonnullGCPtr<DOMRectList> create(HTML::Window&, Vector<JS::Handle<DOMRect>>);
static NonnullRefPtr<DOMRectList> create(NonnullRefPtrVector<DOMRect>&& rects)
{
return adopt_ref(*new DOMRectList(move(rects)));
}
~DOMRectList() = default;
virtual ~DOMRectList() override;
u32 length() const;
DOMRect const* item(u32 index) const;
bool is_supported_property_index(u32) const;
virtual bool is_supported_property_index(u32) const override;
virtual JS::Value item_value(size_t index) const override;
private:
DOMRectList(NonnullRefPtrVector<DOMRect>&& rects);
DOMRectList(HTML::Window&, Vector<JS::NonnullGCPtr<DOMRect>>);
NonnullRefPtrVector<DOMRect> m_rects;
Vector<JS::NonnullGCPtr<DOMRect>> m_rects;
};
}
WRAPPER_HACK(DOMRectList, Web::Geometry)