1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:27:35 +00:00

LibWeb: Make DOM::Event and all its subclasses GC-allocated

This commit is contained in:
Andreas Kling 2022-08-08 22:29:40 +02:00
parent a4ddb0ef87
commit 7c3db526b0
76 changed files with 892 additions and 565 deletions

View file

@ -21,20 +21,17 @@ struct ErrorEventInit : public DOM::EventInit {
// https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
class ErrorEvent final : public DOM::Event {
JS_OBJECT(ErrorEvent, DOM::Event);
public:
using WrapperType = Bindings::ErrorEventWrapper;
static ErrorEvent* create(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init = {});
static ErrorEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init);
static NonnullRefPtr<ErrorEvent> create(FlyString const& event_name, ErrorEventInit const& event_init = {})
{
return adopt_ref(*new ErrorEvent(event_name, event_init));
}
ErrorEvent(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init);
static NonnullRefPtr<ErrorEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init)
{
return ErrorEvent::create(event_name, event_init);
}
virtual ~ErrorEvent() override;
virtual ~ErrorEvent() override = default;
ErrorEvent& impl() { return *this; }
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-message
String const& message() const { return m_message; }
@ -49,24 +46,21 @@ public:
u32 colno() const { return m_colno; }
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-error
JS::Value error() const { return m_error.value(); }
JS::Value error() const { return m_error; }
private:
ErrorEvent(FlyString const& event_name, ErrorEventInit const& event_init)
: DOM::Event(event_name)
, m_message(event_init.message)
, m_filename(event_init.filename)
, m_lineno(event_init.lineno)
, m_colno(event_init.colno)
, m_error(JS::make_handle(event_init.error))
{
}
virtual void visit_edges(Cell::Visitor&) override;
String m_message { "" };
String m_filename { "" }; // FIXME: This should be a USVString.
u32 m_lineno { 0 };
u32 m_colno { 0 };
JS::Handle<JS::Value> m_error;
JS::Value m_error;
};
}
namespace Web::Bindings {
inline JS::Object* wrap(JS::Realm&, Web::HTML::ErrorEvent& object) { return &object; }
using ErrorEventWrapper = Web::HTML::ErrorEvent;
}