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