/src/serenity/Userland/Libraries/LibWeb/HTML/DragEvent.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2024, Maciej <sppmacd@pm.me> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/FlyString.h> |
10 | | #include <LibWeb/DOM/Event.h> |
11 | | #include <LibWeb/HTML/DataTransfer.h> |
12 | | #include <LibWeb/UIEvents/MouseEvent.h> |
13 | | |
14 | | namespace Web::HTML { |
15 | | |
16 | | struct DragEventInit : public UIEvents::MouseEventInit { |
17 | | JS::GCPtr<DataTransfer> data_transfer; |
18 | | }; |
19 | | |
20 | | // https://html.spec.whatwg.org/multipage/dnd.html#the-dragevent-interface |
21 | | class DragEvent : public UIEvents::MouseEvent { |
22 | | WEB_PLATFORM_OBJECT(DragEvent, UIEvents::MouseEvent); |
23 | | JS_DECLARE_ALLOCATOR(DragEvent); |
24 | | |
25 | | public: |
26 | | [[nodiscard]] static JS::NonnullGCPtr<DragEvent> create(JS::Realm&, FlyString const& event_name, DragEventInit const& event_init = {}, double page_x = 0, double page_y = 0, double offset_x = 0, double offset_y = 0); |
27 | | static WebIDL::ExceptionOr<JS::NonnullGCPtr<DragEvent>> construct_impl(JS::Realm&, FlyString const& event_name, DragEventInit const& event_init); |
28 | | |
29 | | virtual ~DragEvent() override; |
30 | | |
31 | 0 | JS::GCPtr<DataTransfer> data_transfer() { return m_data_transfer; } |
32 | | |
33 | | private: |
34 | | DragEvent(JS::Realm&, FlyString const& event_name, DragEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y); |
35 | | |
36 | | virtual void initialize(JS::Realm&) override; |
37 | | virtual void visit_edges(JS::Cell::Visitor&) override; |
38 | | |
39 | | JS::GCPtr<DataTransfer> m_data_transfer; |
40 | | }; |
41 | | |
42 | | } |