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
|
|
|
|
|
|
|
|
#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);
|
2022-08-08 23:29:40 +03:00
|
|
|
|
2021-09-27 18:10:56 +03:00
|
|
|
public:
|
2022-08-28 14:42:07 +03:00
|
|
|
static CustomEvent* create(HTML::Window&, FlyString const& event_name, CustomEventInit const& event_init = {});
|
|
|
|
static CustomEvent* create_with_global_object(HTML::Window&, FlyString const& event_name, CustomEventInit const& event_init);
|
2022-08-08 23:29:40 +03:00
|
|
|
|
2022-08-28 14:42:07 +03:00
|
|
|
CustomEvent(HTML::Window&, FlyString const& event_name);
|
|
|
|
CustomEvent(HTML::Window&, FlyString const& event_name, CustomEventInit const& event_init);
|
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; }
|
|
|
|
|
2022-08-08 23:29:40 +03:00
|
|
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
2021-09-27 18:10:56 +03:00
|
|
|
|
|
|
|
void init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent-type-bubbles-cancelable-detail-detail
|
|
|
|
JS::Value m_detail { JS::js_null() };
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2022-08-08 23:29:40 +03:00
|
|
|
|
|
|
|
namespace Web::Bindings {
|
|
|
|
inline JS::Object* wrap(JS::Realm&, Web::DOM::CustomEvent& object) { return &object; }
|
|
|
|
using CustomEventWrapper = Web::DOM::CustomEvent;
|
|
|
|
}
|