mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +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
33
Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp
Normal file
33
Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/MediaQueryListEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/MediaQueryListEvent.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
MediaQueryListEvent* MediaQueryListEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return window_object.heap().allocate<MediaQueryListEvent>(window_object.realm(), window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
MediaQueryListEvent* MediaQueryListEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
MediaQueryListEvent::MediaQueryListEvent(Bindings::WindowObject& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
: DOM::Event(window_object, event_name, event_init)
|
||||
, m_media(event_init.media)
|
||||
, m_matches(event_init.matches)
|
||||
{
|
||||
set_prototype(&window_object.ensure_web_prototype<Bindings::MediaQueryListEventPrototype>("MediaQueryListEvent"));
|
||||
}
|
||||
|
||||
MediaQueryListEvent::~MediaQueryListEvent() = default;
|
||||
|
||||
}
|
|
@ -15,33 +15,28 @@ struct MediaQueryListEventInit : public DOM::EventInit {
|
|||
bool matches { false };
|
||||
};
|
||||
|
||||
class MediaQueryListEvent : public DOM::Event {
|
||||
class MediaQueryListEvent final : public DOM::Event {
|
||||
JS_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::MediaQueryListEventWrapper;
|
||||
static MediaQueryListEvent* create(Bindings::WindowObject&, FlyString const& event_name, MediaQueryListEventInit const& event_init = {});
|
||||
static MediaQueryListEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<MediaQueryListEvent> create(FlyString const& event_name, MediaQueryListEventInit const& event_init = {})
|
||||
{
|
||||
return adopt_ref(*new MediaQueryListEvent(event_name, event_init));
|
||||
}
|
||||
static NonnullRefPtr<MediaQueryListEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return MediaQueryListEvent::create(event_name, event_init);
|
||||
}
|
||||
MediaQueryListEvent(Bindings::WindowObject&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
virtual ~MediaQueryListEvent() override;
|
||||
|
||||
virtual ~MediaQueryListEvent() override = default;
|
||||
MediaQueryListEvent& impl() { return *this; }
|
||||
|
||||
String const& media() const { return m_media; }
|
||||
bool matches() const { return m_matches; }
|
||||
|
||||
protected:
|
||||
MediaQueryListEvent(FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
: DOM::Event(event_name, event_init)
|
||||
, m_media(event_init.media)
|
||||
, m_matches(event_init.matches)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
String m_media;
|
||||
bool m_matches;
|
||||
};
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::MediaQueryListEvent& object) { return &object; }
|
||||
using MediaQueryListEventWrapper = Web::CSS::MediaQueryListEvent;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
[NoInstanceWrapper]
|
||||
interface MediaQueryListEvent : Event {
|
||||
constructor(CSSOMString type, optional MediaQueryListEventInit eventInitDict = {});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue