summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/CustomEvent.h
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/CustomEvent.h')
-rw-r--r--Userland/Libraries/LibWeb/DOM/CustomEvent.h38
1 files changed, 16 insertions, 22 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.h b/Userland/Libraries/LibWeb/DOM/CustomEvent.h
index 6ecbd83950..5111b346be 100644
--- a/Userland/Libraries/LibWeb/DOM/CustomEvent.h
+++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.h
@@ -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);
+
+ CustomEvent(Bindings::WindowObject&, FlyString const& event_name);
+ CustomEvent(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);
- }
+ virtual ~CustomEvent() override;
- virtual ~CustomEvent() override = default;
+ 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;
+}