2020-07-28 19:38:25 +02:00
|
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
|
* Copyright (c) 2020-2022, Andreas Kling <andreas@ladybird.org>
|
2020-07-28 19:38:25 +02:00
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-28 19:38:25 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
2021-10-01 19:18:19 +03:00
|
|
|
|
#include <AK/RefPtr.h>
|
2020-07-28 19:38:25 +02:00
|
|
|
|
#include <LibWeb/DOM/Event.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
|
#include <LibWeb/Export.h>
|
2022-03-07 23:08:26 +01:00
|
|
|
|
#include <LibWeb/HTML/Window.h>
|
2020-07-28 19:38:25 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Web::UIEvents {
|
|
|
|
|
|
|
2021-10-01 19:30:50 +03:00
|
|
|
|
struct UIEventInit : public DOM::EventInit {
|
2024-11-17 21:54:03 +01:00
|
|
|
|
GC::Ptr<HTML::WindowProxy> view;
|
2021-10-01 19:30:50 +03:00
|
|
|
|
int detail { 0 };
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
|
class WEB_API UIEvent : public DOM::Event {
|
2022-08-28 13:42:07 +02:00
|
|
|
|
WEB_PLATFORM_OBJECT(UIEvent, DOM::Event);
|
2024-11-15 04:01:23 +13:00
|
|
|
|
GC_DECLARE_ALLOCATOR(UIEvent);
|
2022-08-08 22:29:40 +02:00
|
|
|
|
|
2020-07-28 19:38:25 +02:00
|
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
|
[[nodiscard]] static GC::Ref<UIEvent> create(JS::Realm&, FlyString const& type);
|
|
|
|
|
|
static WebIDL::ExceptionOr<GC::Ref<UIEvent>> construct_impl(JS::Realm&, FlyString const& event_name, UIEventInit const& event_init);
|
2022-02-25 17:30:39 +01:00
|
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
|
virtual ~UIEvent() override;
|
2021-10-01 19:30:50 +03:00
|
|
|
|
|
2024-11-17 21:54:03 +01:00
|
|
|
|
GC::Ptr<HTML::WindowProxy> const view() const { return m_view; }
|
2021-10-01 19:18:19 +03:00
|
|
|
|
int detail() const { return m_detail; }
|
2022-04-09 12:45:05 -03:00
|
|
|
|
virtual u32 which() const { return 0; }
|
2021-10-01 19:18:19 +03:00
|
|
|
|
|
2024-11-17 21:54:03 +01:00
|
|
|
|
void init_ui_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, int detail)
|
2022-02-25 17:31:56 +01:00
|
|
|
|
{
|
2024-07-17 12:35:01 +01:00
|
|
|
|
// Initializes attributes of an UIEvent object. This method has the same behavior as initEvent().
|
|
|
|
|
|
|
|
|
|
|
|
// 1. If this’s dispatch flag is set, then return.
|
|
|
|
|
|
if (dispatched())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// 2. Initialize this with type, bubbles, and cancelable.
|
|
|
|
|
|
initialize_event(type, bubbles, cancelable);
|
|
|
|
|
|
|
|
|
|
|
|
// Implementation Defined: Initialise other values.
|
2022-02-25 17:31:56 +01:00
|
|
|
|
m_view = view;
|
|
|
|
|
|
m_detail = detail;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-28 19:38:25 +02:00
|
|
|
|
protected:
|
2023-04-06 16:12:33 +02:00
|
|
|
|
UIEvent(JS::Realm&, FlyString const& event_name);
|
|
|
|
|
|
UIEvent(JS::Realm&, FlyString const& event_name, UIEventInit const& event_init);
|
2022-09-25 18:06:11 -06:00
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-08-28 13:42:07 +02:00
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
|
2024-11-17 21:54:03 +01:00
|
|
|
|
GC::Ptr<HTML::WindowProxy> m_view;
|
2021-10-01 19:18:19 +03:00
|
|
|
|
int m_detail { 0 };
|
2020-07-28 19:38:25 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|