2021-09-27 16:10:56 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2021-09-27 16:10:56 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-04-06 12:54:03 +02:00
|
|
|
#include <AK/FlyString.h>
|
2021-09-27 16:10:56 +01:00
|
|
|
#include <LibWeb/DOM/Event.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2021-09-27 16:10:56 +01:00
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
2021-09-29 20:32:29 +03:00
|
|
|
struct CustomEventInit : public EventInit {
|
|
|
|
JS::Value detail { JS::js_null() };
|
|
|
|
};
|
|
|
|
|
2021-09-27 16:10:56 +01:00
|
|
|
// https://dom.spec.whatwg.org/#customevent
|
2025-07-19 19:35:33 -07:00
|
|
|
class WEB_API CustomEvent : public Event {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(CustomEvent, Event);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(CustomEvent);
|
2022-08-08 22:29:40 +02:00
|
|
|
|
2021-09-27 16:10:56 +01:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
[[nodiscard]] static GC::Ref<CustomEvent> create(JS::Realm&, FlyString const& event_name, CustomEventInit const& = {});
|
|
|
|
static WebIDL::ExceptionOr<GC::Ref<CustomEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CustomEventInit const&);
|
2021-09-27 16:10:56 +01:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
virtual ~CustomEvent() override;
|
2021-09-27 16:10:56 +01:00
|
|
|
|
|
|
|
// https://dom.spec.whatwg.org/#dom-customevent-detail
|
|
|
|
JS::Value detail() const { return m_detail; }
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-08-08 22:29:40 +02:00
|
|
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
2021-09-27 16:10:56 +01:00
|
|
|
|
2023-04-06 12:54:03 +02:00
|
|
|
void init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail);
|
2021-09-27 16:10:56 +01:00
|
|
|
|
|
|
|
private:
|
2023-04-06 12:54:03 +02:00
|
|
|
CustomEvent(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init);
|
2022-09-25 16:15:49 -06:00
|
|
|
|
2021-09-27 16:10:56 +01:00
|
|
|
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent-type-bubbles-cancelable-detail-detail
|
|
|
|
JS::Value m_detail { JS::js_null() };
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|