mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:57:45 +00:00
LibWeb: Make DOM::Event and all its subclasses GC-allocated
This commit is contained in:
parent
a4ddb0ef87
commit
7c3db526b0
76 changed files with 892 additions and 565 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -16,41 +17,34 @@ struct CustomEventInit : public EventInit {
|
|||
|
||||
// https://dom.spec.whatwg.org/#customevent
|
||||
class CustomEvent : public Event {
|
||||
JS_OBJECT(CustomEvent, Event);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::CustomEventWrapper;
|
||||
static CustomEvent* create(Bindings::WindowObject&, FlyString const& event_name, CustomEventInit const& event_init = {});
|
||||
static CustomEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, CustomEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<CustomEvent> create(FlyString const& event_name, CustomEventInit const& event_init = {})
|
||||
{
|
||||
return adopt_ref(*new CustomEvent(event_name, event_init));
|
||||
}
|
||||
static NonnullRefPtr<CustomEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, CustomEventInit const& event_init)
|
||||
{
|
||||
return CustomEvent::create(event_name, event_init);
|
||||
}
|
||||
CustomEvent(Bindings::WindowObject&, FlyString const& event_name);
|
||||
CustomEvent(Bindings::WindowObject&, FlyString const& event_name, CustomEventInit const& event_init);
|
||||
|
||||
virtual ~CustomEvent() override = default;
|
||||
virtual ~CustomEvent() override;
|
||||
|
||||
CustomEvent& impl() { return *this; }
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-customevent-detail
|
||||
JS::Value detail() const { return m_detail; }
|
||||
|
||||
void visit_edges(JS::Cell::Visitor&);
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
void init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail);
|
||||
|
||||
private:
|
||||
explicit CustomEvent(FlyString const& event_name)
|
||||
: Event(event_name)
|
||||
{
|
||||
}
|
||||
|
||||
CustomEvent(FlyString const& event_name, CustomEventInit const& event_init)
|
||||
: Event(event_name, event_init)
|
||||
, m_detail(event_init.detail)
|
||||
{
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent-type-bubbles-cancelable-detail-detail
|
||||
JS::Value m_detail { JS::js_null() };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::DOM::CustomEvent& object) { return &object; }
|
||||
using CustomEventWrapper = Web::DOM::CustomEvent;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue