LibWeb: Put most LibWeb GC objects in type-specific heap blocks

With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
This commit is contained in:
Andreas Kling 2023-11-19 19:47:52 +01:00
parent 536596632b
commit bfd354492e
Notes: sideshowbarker 2024-07-16 23:34:49 +09:00
599 changed files with 933 additions and 3 deletions

View file

@ -2502,6 +2502,7 @@ static void generate_named_properties_object_declarations(IDL::Interface const&
generator.append(R"~~~(
class @named_properties_class@ : public JS::Object {
JS_OBJECT(@named_properties_class@, JS::Object);
JS_DECLARE_ALLOCATOR(@named_properties_class@);
public:
explicit @named_properties_class@(JS::Realm&);
virtual void initialize(JS::Realm&) override;
@ -3298,7 +3299,7 @@ namespace Web::Bindings {
class @namespace_class@ final : public JS::Object {
JS_OBJECT(@namespace_class@, JS::Object);
JS_DECLARE_ALLOCATOR(@namespace_class@);
public:
explicit @namespace_class@(JS::Realm&);
virtual void initialize(JS::Realm&) override;
@ -3395,6 +3396,8 @@ using namespace Web::WebIDL;
namespace Web::Bindings {
JS_DEFINE_ALLOCATOR(@namespace_class@);
@namespace_class@::@namespace_class@(JS::Realm& realm)
: Object(ConstructWithoutPrototypeTag::Tag, realm)
{
@ -3467,6 +3470,7 @@ namespace Web::Bindings {
class @constructor_class@ : public JS::NativeFunction {
JS_OBJECT(@constructor_class@, JS::NativeFunction);
JS_DECLARE_ALLOCATOR(@constructor_class@);
public:
explicit @constructor_class@(JS::Realm&);
virtual void initialize(JS::Realm&) override;
@ -3619,6 +3623,8 @@ using namespace Web::WebIDL;
namespace Web::Bindings {
JS_DEFINE_ALLOCATOR(@constructor_class@);
@constructor_class@::@constructor_class@(JS::Realm& realm)
: NativeFunction("@name@"sv, realm.intrinsics().function_prototype())
{
@ -3958,6 +3964,7 @@ namespace Web::Bindings {
class @prototype_class@ : public JS::Object {
JS_OBJECT(@prototype_class@, JS::Object);
JS_DECLARE_ALLOCATOR(@prototype_class@);
public:
explicit @prototype_class@(JS::Realm&);
virtual void initialize(JS::Realm&) override;
@ -4096,6 +4103,8 @@ using namespace Web::WebIDL;
namespace Web::Bindings {
JS_DEFINE_ALLOCATOR(@prototype_class@);
@prototype_class@::@prototype_class@([[maybe_unused]] JS::Realm& realm))~~~");
if (interface.name == "DOMException") {
// https://webidl.spec.whatwg.org/#es-DOMException-specialness
@ -4168,6 +4177,7 @@ namespace Web::Bindings {
class @prototype_class@ : public JS::Object {
JS_OBJECT(@prototype_class@, JS::Object);
JS_DECLARE_ALLOCATOR(@prototype_class@);
public:
explicit @prototype_class@(JS::Realm&);
virtual void initialize(JS::Realm&) override;
@ -4241,6 +4251,8 @@ using namespace Web::WebIDL;
namespace Web::Bindings {
JS_DEFINE_ALLOCATOR(@prototype_class@);
@prototype_class@::@prototype_class@(JS::Realm& realm)
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().iterator_prototype())
{

View file

@ -17,6 +17,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(Animation);
// https://www.w3.org/TR/web-animations-1/#dom-animation-animation
JS::NonnullGCPtr<Animation> Animation::create(JS::Realm& realm, JS::GCPtr<AnimationEffect> effect, JS::GCPtr<AnimationTimeline> timeline)
{

View file

@ -15,6 +15,7 @@ namespace Web::Animations {
// https://www.w3.org/TR/web-animations-1/#the-animation-interface
class Animation : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(Animation, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(Animation);
public:
static JS::NonnullGCPtr<Animation> create(JS::Realm&, JS::GCPtr<AnimationEffect>, JS::GCPtr<AnimationTimeline>);

View file

@ -12,6 +12,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationEffect);
JS::NonnullGCPtr<AnimationEffect> AnimationEffect::create(JS::Realm& realm)
{
return realm.heap().allocate<AnimationEffect>(realm, realm);

View file

@ -58,6 +58,7 @@ enum class AnimationDirection {
// https://www.w3.org/TR/web-animations-1/#the-animationeffect-interface
class AnimationEffect : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AnimationEffect, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(AnimationEffect);
public:
static JS::NonnullGCPtr<AnimationEffect> create(JS::Realm&);

View file

@ -9,6 +9,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationPlaybackEvent);
JS::NonnullGCPtr<AnimationPlaybackEvent> AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& event_name, AnimationPlaybackEventInit const& event_init)
{
return realm.heap().allocate<AnimationPlaybackEvent>(realm, realm, event_name, event_init);

View file

@ -20,6 +20,7 @@ struct AnimationPlaybackEventInit : public DOM::EventInit {
// https://www.w3.org/TR/web-animations-1/#animationplaybackevent
class AnimationPlaybackEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(AnimationPlaybackEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(AnimationPlaybackEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<AnimationPlaybackEvent> create(JS::Realm&, FlyString const& event_name, AnimationPlaybackEventInit const& event_init = {});

View file

@ -10,6 +10,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationTimeline);
WebIDL::ExceptionOr<void> AnimationTimeline::set_current_time(Optional<double> value)
{
if (value == m_current_time)

View file

@ -13,6 +13,7 @@ namespace Web::Animations {
// https://www.w3.org/TR/web-animations-1/#animationtimeline
class AnimationTimeline : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AnimationTimeline, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(AnimationTimeline);
public:
Optional<double> current_time() const { return m_current_time; }

View file

@ -13,6 +13,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(DocumentTimeline);
JS::NonnullGCPtr<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DOM::Document& document, HighResolutionTime::DOMHighResTimeStamp origin_time)
{
return realm.heap().allocate<DocumentTimeline>(realm, realm, document, origin_time);

View file

@ -20,6 +20,7 @@ struct DocumentTimelineOptions {
// https://www.w3.org/TR/web-animations-1/#the-documenttimeline-interface
class DocumentTimeline : public AnimationTimeline {
WEB_PLATFORM_OBJECT(DocumentTimeline, AnimationTimeline);
JS_DECLARE_ALLOCATOR(DocumentTimeline);
public:
static JS::NonnullGCPtr<DocumentTimeline> create(JS::Realm&, DOM::Document&, HighResolutionTime::DOMHighResTimeStamp origin_time);

View file

@ -39,6 +39,7 @@ struct BaseKeyframe {
// https://www.w3.org/TR/web-animations-1/#the-keyframeeffect-interface
class KeyframeEffect : public AnimationEffect {
WEB_PLATFORM_OBJECT(KeyframeEffect, AnimationEffect);
JS_DECLARE_ALLOCATOR(KeyframeEffect);
public:
static JS::NonnullGCPtr<KeyframeEffect> create(JS::Realm&);

View file

@ -12,6 +12,8 @@
namespace Web::Bindings {
JS_DEFINE_ALLOCATOR(Intrinsics);
void Intrinsics::visit_edges(JS::Cell::Visitor& visitor)
{
Base::visit_edges(visitor);

View file

@ -18,6 +18,7 @@ namespace Web::Bindings {
class Intrinsics final : public JS::Cell {
JS_CELL(Intrinsics, JS::Cell);
JS_DECLARE_ALLOCATOR(Intrinsics);
public:
Intrinsics(JS::Realm& realm)

View file

@ -14,6 +14,7 @@ namespace Web::CSS {
class CSSFontFaceRule final : public CSSRule {
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
JS_DECLARE_ALLOCATOR(CSSFontFaceRule);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSFontFaceRule> create(JS::Realm&, FontFace&&);

View file

@ -19,6 +19,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSImportRule);
JS::NonnullGCPtr<CSSImportRule> CSSImportRule::create(AK::URL url, DOM::Document& document)
{
auto& realm = document.realm();

View file

@ -20,6 +20,7 @@ class CSSImportRule final
: public CSSRule
, public ResourceClient {
WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule);
JS_DECLARE_ALLOCATOR(CSSImportRule);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSImportRule> create(AK::URL, DOM::Document&);

View file

@ -11,6 +11,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSKeyframeRule);
JS::NonnullGCPtr<CSSKeyframeRule> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::CSSStyleDeclaration& declarations)
{
return realm.heap().allocate<CSSKeyframeRule>(realm, realm, key, declarations);

View file

@ -18,6 +18,7 @@ namespace Web::CSS {
// https://drafts.csswg.org/css-animations/#interface-csskeyframerule
class CSSKeyframeRule final : public CSSRule {
WEB_PLATFORM_OBJECT(CSSKeyframeRule, CSSRule);
JS_DECLARE_ALLOCATOR(CSSKeyframeRule);
public:
static JS::NonnullGCPtr<CSSKeyframeRule> create(JS::Realm&, CSS::Percentage key, CSSStyleDeclaration&);

View file

@ -10,6 +10,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSKeyframesRule);
JS::NonnullGCPtr<CSSKeyframesRule> CSSKeyframesRule::create(JS::Realm& realm, FlyString name, JS::MarkedVector<JS::NonnullGCPtr<CSSKeyframeRule>> keyframes)
{
return realm.heap().allocate<CSSKeyframesRule>(realm, realm, move(name), move(keyframes));

View file

@ -19,6 +19,7 @@ namespace Web::CSS {
// https://drafts.csswg.org/css-animations/#interface-csskeyframesrule
class CSSKeyframesRule final : public CSSRule {
WEB_PLATFORM_OBJECT(CSSKeyframesRule, CSSRule);
JS_DECLARE_ALLOCATOR(CSSKeyframesRule);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSKeyframesRule> create(JS::Realm&, FlyString name, JS::MarkedVector<JS::NonnullGCPtr<CSSKeyframeRule>>);

View file

@ -12,6 +12,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSMediaRule);
JS::NonnullGCPtr<CSSMediaRule> CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
{
return realm.heap().allocate<CSSMediaRule>(realm, realm, media_queries, rules);

View file

@ -16,6 +16,7 @@ namespace Web::CSS {
// https://www.w3.org/TR/css-conditional-3/#the-cssmediarule-interface
class CSSMediaRule final : public CSSConditionRule {
WEB_PLATFORM_OBJECT(CSSMediaRule, CSSConditionRule);
JS_DECLARE_ALLOCATOR(CSSMediaRule);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSMediaRule> create(JS::Realm&, MediaList& media_queries, CSSRuleList&);

View file

@ -14,6 +14,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSNamespaceRule);
CSSNamespaceRule::CSSNamespaceRule(JS::Realm& realm, Optional<DeprecatedString> prefix, StringView namespace_uri)
: CSSRule(realm)
, m_namespace_uri(namespace_uri)

View file

@ -12,6 +12,7 @@ namespace Web::CSS {
class CSSNamespaceRule final : public CSSRule {
WEB_PLATFORM_OBJECT(CSSNamespaceRule, CSSRule);
JS_DECLARE_ALLOCATOR(CSSNamespaceRule);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSNamespaceRule> create(JS::Realm&, Optional<DeprecatedString> prefix, StringView namespace_uri);

View file

@ -18,6 +18,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSRuleList);
JS::NonnullGCPtr<CSSRuleList> CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
{
auto rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);

View file

@ -21,6 +21,7 @@ namespace Web::CSS {
// https://www.w3.org/TR/cssom/#the-cssrulelist-interface
class CSSRuleList : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject);
JS_DECLARE_ALLOCATOR(CSSRuleList);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSRuleList> create(JS::Realm&, JS::MarkedVector<CSSRule*> const&);

View file

@ -16,6 +16,10 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSStyleDeclaration);
JS_DEFINE_ALLOCATOR(PropertyOwningCSSStyleDeclaration);
JS_DEFINE_ALLOCATOR(ElementInlineCSSStyleDeclaration);
CSSStyleDeclaration::CSSStyleDeclaration(JS::Realm& realm)
: PlatformObject(realm)
{

View file

@ -16,6 +16,7 @@ namespace Web::CSS {
class CSSStyleDeclaration : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(CSSStyleDeclaration, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(CSSStyleDeclaration);
public:
virtual ~CSSStyleDeclaration() = default;
@ -50,6 +51,8 @@ protected:
class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
WEB_PLATFORM_OBJECT(PropertyOwningCSSStyleDeclaration, CSSStyleDeclaration);
JS_DECLARE_ALLOCATOR(PropertyOwningCSSStyleDeclaration);
friend class ElementInlineCSSStyleDeclaration;
public:
@ -93,6 +96,7 @@ private:
class ElementInlineCSSStyleDeclaration final : public PropertyOwningCSSStyleDeclaration {
WEB_PLATFORM_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration);
JS_DECLARE_ALLOCATOR(ElementInlineCSSStyleDeclaration);
public:
[[nodiscard]] static JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration> create(DOM::Element&, Vector<StyleProperty>, HashMap<FlyString, StyleProperty> custom_properties);

View file

@ -12,6 +12,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSStyleRule);
JS::NonnullGCPtr<CSSStyleRule> CSSStyleRule::create(JS::Realm& realm, Vector<NonnullRefPtr<Web::CSS::Selector>>&& selectors, CSSStyleDeclaration& declaration)
{
return realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration);

View file

@ -16,6 +16,7 @@ namespace Web::CSS {
class CSSStyleRule final : public CSSRule {
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule);
JS_DECLARE_ALLOCATOR(CSSStyleRule);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleRule> create(JS::Realm&, Vector<NonnullRefPtr<Selector>>&&, CSSStyleDeclaration&);

View file

@ -15,6 +15,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSStyleSheet);
JS::NonnullGCPtr<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
{
return realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, media, move(location));

View file

@ -21,6 +21,7 @@ class CSSStyleSheet final
: public StyleSheet
, public Weakable<CSSStyleSheet> {
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
JS_DECLARE_ALLOCATOR(CSSStyleSheet);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleSheet> create(JS::Realm&, CSSRuleList&, MediaList&, Optional<AK::URL> location);

View file

@ -11,6 +11,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSSupportsRule);
JS::NonnullGCPtr<CSSSupportsRule> CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
{
return realm.heap().allocate<CSSSupportsRule>(realm, realm, move(supports), rules);

View file

@ -17,6 +17,7 @@ namespace Web::CSS {
// https://www.w3.org/TR/css-conditional-3/#the-csssupportsrule-interface
class CSSSupportsRule final : public CSSConditionRule {
WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule);
JS_DECLARE_ALLOCATOR(CSSSupportsRule);
public:
static JS::NonnullGCPtr<CSSSupportsRule> create(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);

View file

@ -13,6 +13,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(MediaList);
JS::NonnullGCPtr<MediaList> MediaList::create(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
{
return realm.heap().allocate<MediaList>(realm, realm, move(media));

View file

@ -18,6 +18,7 @@ namespace Web::CSS {
// https://www.w3.org/TR/cssom-1/#the-medialist-interface
class MediaList final : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject);
JS_DECLARE_ALLOCATOR(MediaList);
public:
[[nodiscard]] static JS::NonnullGCPtr<MediaList> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);

View file

@ -15,6 +15,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(MediaQueryList);
JS::NonnullGCPtr<MediaQueryList> MediaQueryList::create(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
{
return document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));

View file

@ -15,6 +15,7 @@ namespace Web::CSS {
// 4.2. The MediaQueryList Interface, https://drafts.csswg.org/cssom-view/#the-mediaquerylist-interface
class MediaQueryList final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(MediaQueryList);
public:
[[nodiscard]] static JS::NonnullGCPtr<MediaQueryList> create(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&);

View file

@ -10,6 +10,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(MediaQueryListEvent);
JS::NonnullGCPtr<MediaQueryListEvent> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
{
return realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init);

View file

@ -18,6 +18,7 @@ struct MediaQueryListEventInit : public DOM::EventInit {
class MediaQueryListEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(MediaQueryListEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<MediaQueryListEvent> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& = {});

View file

@ -44,6 +44,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(ResolvedCSSStyleDeclaration);
JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> ResolvedCSSStyleDeclaration::create(DOM::Element& element)
{
return element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element);

View file

@ -12,6 +12,7 @@ namespace Web::CSS {
class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
WEB_PLATFORM_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration);
JS_DECLARE_ALLOCATOR(ResolvedCSSStyleDeclaration);
public:
[[nodiscard]] static JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> create(DOM::Element&);

View file

@ -13,6 +13,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(Screen);
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
{
return window.heap().allocate<Screen>(window.realm(), window);

View file

@ -15,6 +15,7 @@ namespace Web::CSS {
class Screen final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(Screen, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(Screen);
public:
[[nodiscard]] static JS::NonnullGCPtr<Screen> create(HTML::Window&);

View file

@ -13,6 +13,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(StyleSheetList);
void StyleSheetList::add_sheet(CSSStyleSheet& sheet)
{
sheet.set_style_sheet_list({}, this);

View file

@ -12,8 +12,9 @@
namespace Web::CSS {
class StyleSheetList : public Bindings::LegacyPlatformObject {
class StyleSheetList final : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject);
JS_DECLARE_ALLOCATOR(StyleSheetList);
public:
[[nodiscard]] static JS::NonnullGCPtr<StyleSheetList> create(DOM::Document&);

View file

@ -15,6 +15,8 @@
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(VisualViewport);
JS::NonnullGCPtr<VisualViewport> VisualViewport::create(DOM::Document& document)
{
return document.heap().allocate<VisualViewport>(document.realm(), document);

View file

@ -13,6 +13,7 @@ namespace Web::CSS {
// https://drafts.csswg.org/cssom-view/#visualviewport
class VisualViewport final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(VisualViewport, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(VisualViewport);
public:
[[nodiscard]] static JS::NonnullGCPtr<VisualViewport> create(DOM::Document&);

View file

@ -19,6 +19,8 @@
namespace Web::Clipboard {
JS_DEFINE_ALLOCATOR(Clipboard);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Clipboard>> Clipboard::construct_impl(JS::Realm& realm)
{
return realm.heap().allocate<Clipboard>(realm, realm);

View file

@ -17,6 +17,7 @@ namespace Web::Clipboard {
class Clipboard final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(Clipboard, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(Clipboard);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Clipboard>> construct_impl(JS::Realm&);

View file

@ -15,6 +15,8 @@
namespace Web::Crypto {
JS_DEFINE_ALLOCATOR(Crypto);
JS::NonnullGCPtr<Crypto> Crypto::create(JS::Realm& realm)
{
return realm.heap().allocate<Crypto>(realm, realm);

View file

@ -14,6 +14,7 @@ namespace Web::Crypto {
class Crypto : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(Crypto);
public:
[[nodiscard]] static JS::NonnullGCPtr<Crypto> create(JS::Realm&);

View file

@ -14,6 +14,8 @@
namespace Web::Crypto {
JS_DEFINE_ALLOCATOR(SubtleCrypto);
JS::NonnullGCPtr<SubtleCrypto> SubtleCrypto::create(JS::Realm& realm)
{
return realm.heap().allocate<SubtleCrypto>(realm, realm);

View file

@ -13,6 +13,7 @@ namespace Web::Crypto {
class SubtleCrypto final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(SubtleCrypto, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(SubtleCrypto);
public:
[[nodiscard]] static JS::NonnullGCPtr<SubtleCrypto> create(JS::Realm&);

View file

@ -10,6 +10,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(AbortController);
WebIDL::ExceptionOr<JS::NonnullGCPtr<AbortController>> AbortController::construct_impl(JS::Realm& realm)
{
auto signal = TRY(AbortSignal::construct_impl(realm));

View file

@ -14,6 +14,7 @@ namespace Web::DOM {
// https://dom.spec.whatwg.org/#abortcontroller
class AbortController final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AbortController, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(AbortController);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<AbortController>> construct_impl(JS::Realm&);

View file

@ -12,6 +12,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(AbortSignal);
WebIDL::ExceptionOr<JS::NonnullGCPtr<AbortSignal>> AbortSignal::construct_impl(JS::Realm& realm)
{
return realm.heap().allocate<AbortSignal>(realm, realm);

View file

@ -17,6 +17,7 @@ namespace Web::DOM {
// https://dom.spec.whatwg.org/#abortsignal
class AbortSignal final : public EventTarget {
WEB_PLATFORM_OBJECT(AbortSignal, EventTarget);
JS_DECLARE_ALLOCATOR(AbortSignal);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<AbortSignal>> construct_impl(JS::Realm&);

View file

@ -13,6 +13,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(AccessibilityTreeNode);
JS::NonnullGCPtr<AccessibilityTreeNode> AccessibilityTreeNode::create(Document* document, DOM::Node const* value)
{
return document->heap().allocate<AccessibilityTreeNode>(document->realm(), value);

View file

@ -9,13 +9,16 @@
#include <AK/JsonObjectSerializer.h>
#include <AK/Vector.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/CellAllocator.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/Forward.h>
namespace Web::DOM {
class AccessibilityTreeNode final : public JS::Cell {
JS_CELL(AccessibilityTreeNode, JS::Cell)
JS_CELL(AccessibilityTreeNode, JS::Cell);
JS_DECLARE_ALLOCATOR(AccessibilityTreeNode);
public:
static JS::NonnullGCPtr<AccessibilityTreeNode> create(Document*, DOM::Node const*);
virtual ~AccessibilityTreeNode() override = default;

View file

@ -15,6 +15,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(Attr);
JS::NonnullGCPtr<Attr> Attr::create(Document& document, FlyString local_name, String value, Element* owner_element)
{
return document.heap().allocate<Attr>(document.realm(), document, QualifiedName(move(local_name), Optional<FlyString> {}, Optional<FlyString> {}), move(value), owner_element);

View file

@ -15,6 +15,7 @@ namespace Web::DOM {
// https://dom.spec.whatwg.org/#attr
class Attr final : public Node {
WEB_PLATFORM_OBJECT(Attr, Node);
JS_DECLARE_ALLOCATOR(Attr);
public:
[[nodiscard]] static JS::NonnullGCPtr<Attr> create(Document&, QualifiedName, String value = {}, Element* = nullptr);

View file

@ -9,6 +9,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(CDATASection);
CDATASection::CDATASection(Document& document, String const& data)
: Text(document, NodeType::CDATA_SECTION_NODE, data)
{

View file

@ -13,6 +13,7 @@ namespace Web::DOM {
class CDATASection final : public Text {
WEB_PLATFORM_OBJECT(CDATASection, Text);
JS_DECLARE_ALLOCATOR(CDATASection);
public:
virtual ~CDATASection() override;

View file

@ -14,6 +14,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(CharacterData);
CharacterData::CharacterData(Document& document, NodeType type, String const& data)
: Node(document, type)
, m_data(data)

View file

@ -18,6 +18,7 @@ class CharacterData
, public ChildNode<CharacterData>
, public NonDocumentTypeChildNode<CharacterData> {
WEB_PLATFORM_OBJECT(CharacterData, Node);
JS_DECLARE_ALLOCATOR(CharacterData);
public:
virtual ~CharacterData() override = default;

View file

@ -11,6 +11,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(Comment);
Comment::Comment(Document& document, String const& data)
: CharacterData(document, NodeType::COMMENT_NODE, data)
{

View file

@ -12,6 +12,7 @@ namespace Web::DOM {
class Comment final : public CharacterData {
WEB_PLATFORM_OBJECT(Comment, CharacterData);
JS_DECLARE_ALLOCATOR(Comment);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Comment>> construct_impl(JS::Realm&, String const& data);

View file

@ -11,6 +11,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(CustomEvent);
JS::NonnullGCPtr<CustomEvent> CustomEvent::create(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
{
return realm.heap().allocate<CustomEvent>(realm, realm, event_name, event_init);

View file

@ -19,6 +19,7 @@ struct CustomEventInit : public EventInit {
// https://dom.spec.whatwg.org/#customevent
class CustomEvent : public Event {
WEB_PLATFORM_OBJECT(CustomEvent, Event);
JS_DECLARE_ALLOCATOR(CustomEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<CustomEvent> create(JS::Realm&, FlyString const& event_name, CustomEventInit const& = {});

View file

@ -10,6 +10,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(DOMEventListener);
DOMEventListener::DOMEventListener() = default;
DOMEventListener::~DOMEventListener() = default;

View file

@ -17,6 +17,7 @@ namespace Web::DOM {
// NOTE: The spec calls this "event listener", and it's *importantly* not the same as "EventListener"
class DOMEventListener : public JS::Cell {
JS_CELL(DOMEventListener, JS::Cell);
JS_DECLARE_ALLOCATOR(DOMEventListener);
public:
DOMEventListener();

View file

@ -17,6 +17,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(DOMImplementation);
JS::NonnullGCPtr<DOMImplementation> DOMImplementation::create(Document& document)
{
auto& realm = document.realm();

View file

@ -15,6 +15,7 @@ namespace Web::DOM {
class DOMImplementation final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMImplementation, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMImplementation);
public:
[[nodiscard]] static JS::NonnullGCPtr<DOMImplementation> create(Document&);

View file

@ -52,6 +52,8 @@ inline void replace_in_ordered_set(Vector<String>& set, String const& item, Stri
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(DOMTokenList);
JS::NonnullGCPtr<DOMTokenList> DOMTokenList::create(Element& associated_element, FlyString associated_attribute)
{
auto& realm = associated_element.realm();

View file

@ -22,6 +22,7 @@ namespace Web::DOM {
// https://dom.spec.whatwg.org/#domtokenlist
class DOMTokenList final : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(DOMTokenList, Bindings::LegacyPlatformObject);
JS_DECLARE_ALLOCATOR(DOMTokenList);
public:
[[nodiscard]] static JS::NonnullGCPtr<DOMTokenList> create(Element& associated_element, FlyString associated_attribute);

View file

@ -106,6 +106,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(Document);
// https://html.spec.whatwg.org/multipage/origin.html#obtain-browsing-context-navigation
static JS::NonnullGCPtr<HTML::BrowsingContext> obtain_a_browsing_context_to_use_for_a_navigation_response(
HTML::BrowsingContext& browsing_context,

View file

@ -81,6 +81,7 @@ class Document
, public NonElementParentNode<Document>
, public HTML::GlobalEventHandlers {
WEB_PLATFORM_OBJECT(Document, ParentNode);
JS_DECLARE_ALLOCATOR(Document);
public:
enum class Type {

View file

@ -9,6 +9,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(DocumentFragment);
DocumentFragment::DocumentFragment(Document& document)
: ParentNode(document, NodeType::DOCUMENT_FRAGMENT_NODE)
{

View file

@ -16,6 +16,7 @@ class DocumentFragment
: public ParentNode
, public NonElementParentNode<DocumentFragment> {
WEB_PLATFORM_OBJECT(DocumentFragment, ParentNode);
JS_DECLARE_ALLOCATOR(DocumentFragment);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> construct_impl(JS::Realm& realm);

View file

@ -10,6 +10,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(DocumentObserver);
DocumentObserver::DocumentObserver(JS::Realm& realm, DOM::Document& document)
: Bindings::PlatformObject(realm)
, m_document(document)

View file

@ -16,6 +16,7 @@ namespace Web::DOM {
class DocumentObserver final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DocumentObserver, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DocumentObserver);
public:
[[nodiscard]] JS::GCPtr<JS::HeapFunction<void()>> document_became_inactive() const { return m_document_became_inactive; }

View file

@ -9,6 +9,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(DocumentType);
JS::NonnullGCPtr<DocumentType> DocumentType::create(Document& document)
{
return document.heap().allocate<DocumentType>(document.realm(), document);

View file

@ -16,6 +16,7 @@ class DocumentType final
: public Node
, public ChildNode<DocumentType> {
WEB_PLATFORM_OBJECT(DocumentType, Node);
JS_DECLARE_ALLOCATOR(DocumentType);
public:
[[nodiscard]] static JS::NonnullGCPtr<DocumentType> create(Document&);

View file

@ -14,6 +14,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(Event);
JS::NonnullGCPtr<Event> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
{
return realm.heap().allocate<Event>(realm, realm, event_name, event_init);

View file

@ -20,6 +20,7 @@ struct EventInit {
class Event : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(Event, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(Event);
public:
enum Phase : u16 {

View file

@ -13,6 +13,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(HTMLCollection);
JS::NonnullGCPtr<HTMLCollection> HTMLCollection::create(ParentNode& root, Scope scope, Function<bool(Element const&)> filter)
{
return root.heap().allocate<HTMLCollection>(root.realm(), root, scope, move(filter));

View file

@ -27,6 +27,7 @@ namespace Web::DOM {
class HTMLCollection : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(HTMLCollection, Bindings::LegacyPlatformObject);
JS_DECLARE_ALLOCATOR(HTMLCollection);
public:
enum class Scope {

View file

@ -12,6 +12,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(HTMLFormControlsCollection);
JS::NonnullGCPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(ParentNode& root, Scope scope, Function<bool(Element const&)> filter)
{
return root.heap().allocate<HTMLFormControlsCollection>(root.realm(), root, scope, move(filter));

View file

@ -13,6 +13,7 @@ namespace Web::DOM {
class HTMLFormControlsCollection : public HTMLCollection {
WEB_PLATFORM_OBJECT(HTMLFormControlsCollection, HTMLCollection);
JS_DECLARE_ALLOCATOR(HTMLFormControlsCollection);
public:
[[nodiscard]] static JS::NonnullGCPtr<HTMLFormControlsCollection> create(ParentNode& root, Scope, Function<bool(Element const&)> filter);

View file

@ -12,6 +12,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(LiveNodeList);
JS::NonnullGCPtr<NodeList> LiveNodeList::create(JS::Realm& realm, Node& root, Scope scope, Function<bool(Node const&)> filter)
{
return realm.heap().allocate<LiveNodeList>(realm, realm, root, scope, move(filter));

View file

@ -16,6 +16,7 @@ namespace Web::DOM {
class LiveNodeList : public NodeList {
WEB_PLATFORM_OBJECT(LiveNodeList, NodeList);
JS_DECLARE_ALLOCATOR(LiveNodeList);
public:
enum class Scope {

View file

@ -11,6 +11,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(MutationObserver);
WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationObserver>> MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackType> callback)
{
return realm.heap().allocate<MutationObserver>(realm, realm, callback);

View file

@ -29,6 +29,7 @@ struct MutationObserverInit {
// https://dom.spec.whatwg.org/#mutationobserver
class MutationObserver final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(MutationObserver, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(MutationObserver);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationObserver>> construct_impl(JS::Realm&, JS::GCPtr<WebIDL::CallbackType>);

View file

@ -12,6 +12,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(MutationRecord);
JS::NonnullGCPtr<MutationRecord> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional<String> const& attribute_name, Optional<String> const& attribute_namespace, Optional<String> const& old_value)
{
return realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value);

View file

@ -14,6 +14,7 @@ namespace Web::DOM {
// https://dom.spec.whatwg.org/#mutationrecord
class MutationRecord : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(MutationRecord);
public:
[[nodiscard]] static JS::NonnullGCPtr<MutationRecord> create(JS::Realm&, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional<String> const& attribute_name, Optional<String> const& attribute_namespace, Optional<String> const& old_value);

View file

@ -13,6 +13,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(NamedNodeMap);
JS::NonnullGCPtr<NamedNodeMap> NamedNodeMap::create(Element& element)
{
auto& realm = element.realm();

View file

@ -20,6 +20,7 @@ namespace Web::DOM {
// https://dom.spec.whatwg.org/#interface-namednodemap
class NamedNodeMap : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(NamedNodeMap, Bindings::LegacyPlatformObject);
JS_DECLARE_ALLOCATOR(NamedNodeMap);
public:
[[nodiscard]] static JS::NonnullGCPtr<NamedNodeMap> create(Element&);

View file

@ -10,6 +10,8 @@
namespace Web::DOM {
JS_DEFINE_ALLOCATOR(NodeFilter);
JS::NonnullGCPtr<NodeFilter> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback)
{
return realm.heap().allocate<NodeFilter>(realm, realm, callback);

Some files were not shown because too many files have changed in this diff Show more