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() };
|
|
|
|
String origin { "" };
|
|
|
|
String last_event_id { "" };
|
|
|
|
};
|
|
|
|
|
2021-04-24 13:54:24 +02:00
|
|
|
class MessageEvent : public DOM::Event {
|
2022-08-08 22:29:40 +02:00
|
|
|
JS_OBJECT(MessageEvent, DOM::Event);
|
|
|
|
|
2021-04-24 13:54:24 +02:00
|
|
|
public:
|
2022-08-08 22:29:40 +02:00
|
|
|
static MessageEvent* create(Bindings::WindowObject&, FlyString const& event_name, MessageEventInit const& event_init = {});
|
|
|
|
static MessageEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, MessageEventInit const& event_init);
|
2021-04-24 13:54:24 +02:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
MessageEvent(Bindings::WindowObject&, FlyString const& event_name, MessageEventInit const& event_init);
|
|
|
|
virtual ~MessageEvent() override;
|
2021-04-24 13:54:24 +02:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
MessageEvent& impl() { return *this; }
|
2021-04-24 13:54:24 +02:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
JS::Value data() const { return m_data; }
|
2021-10-01 18:21:38 +03:00
|
|
|
String const& origin() const { return m_origin; }
|
2021-10-01 18:30:30 +03:00
|
|
|
String 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:
|
|
|
|
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;
|
2021-04-24 13:54:24 +02:00
|
|
|
String m_origin;
|
2021-10-01 18:30:30 +03:00
|
|
|
String m_last_event_id;
|
2021-04-24 13:54:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2022-08-08 22:29:40 +02:00
|
|
|
|
|
|
|
namespace Web::Bindings {
|
|
|
|
inline JS::Object* wrap(JS::Realm&, Web::HTML::MessageEvent& object) { return &object; }
|
|
|
|
using MessageEventWrapper = Web::HTML::MessageEvent;
|
|
|
|
}
|