2021-04-24 13:54:24 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
|
2022-08-08 22:29:40 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
2021-04-24 13:54:24 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/DOM/Event.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2021-10-01 18:39:03 +03:00
|
|
|
struct MessageEventInit : public DOM::EventInit {
|
|
|
|
JS::Value data { JS::js_null() };
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString origin { "" };
|
|
|
|
DeprecatedString last_event_id { "" };
|
2021-10-01 18:39:03 +03:00
|
|
|
};
|
|
|
|
|
2021-04-24 13:54:24 +02:00
|
|
|
class MessageEvent : public DOM::Event {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(MessageEvent, DOM::Event);
|
2022-08-08 22:29:40 +02:00
|
|
|
|
2021-04-24 13:54:24 +02:00
|
|
|
public:
|
2023-01-08 19:23:00 -05:00
|
|
|
static MessageEvent* create(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init = {});
|
|
|
|
static MessageEvent* construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init);
|
2021-04-24 13:54:24 +02:00
|
|
|
|
2023-01-08 19:23:00 -05:00
|
|
|
MessageEvent(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init);
|
2022-08-08 22:29:40 +02:00
|
|
|
virtual ~MessageEvent() override;
|
2021-04-24 13:54:24 +02:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
JS::Value data() const { return m_data; }
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString const& origin() const { return m_origin; }
|
|
|
|
DeprecatedString const& last_event_id() const { return m_last_event_id; }
|
2021-04-24 13:54:24 +02:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
private:
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2022-08-08 22:29:40 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
2021-04-24 13:54:24 +02:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
JS::Value m_data;
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString m_origin;
|
|
|
|
DeprecatedString m_last_event_id;
|
2021-04-24 13:54:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|