/* * Copyright (c) 2024, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web { class DragAndDropEventHandler { public: void visit_edges(JS::Cell::Visitor& visitor) const; bool has_ongoing_drag_and_drop_operation() const { return !m_drag_data_store.is_null(); } bool handle_drag_start(JS::Realm&, CSSPixelPoint screen_position, CSSPixelPoint page_offset, CSSPixelPoint client_offset, CSSPixelPoint offset, unsigned button, unsigned buttons, unsigned modifiers, Vector files); bool handle_drag_move(JS::Realm&, JS::NonnullGCPtr, JS::NonnullGCPtr, CSSPixelPoint screen_position, CSSPixelPoint page_offset, CSSPixelPoint client_offset, CSSPixelPoint offset, unsigned button, unsigned buttons, unsigned modifiers); bool handle_drag_leave(JS::Realm&, CSSPixelPoint screen_position, CSSPixelPoint page_offset, CSSPixelPoint client_offset, CSSPixelPoint offset, unsigned button, unsigned buttons, unsigned modifiers); bool handle_drop(JS::Realm&, CSSPixelPoint screen_position, CSSPixelPoint page_offset, CSSPixelPoint client_offset, CSSPixelPoint offset, unsigned button, unsigned buttons, unsigned modifiers); private: enum class Cancelled { No, Yes, }; bool handle_drag_end(JS::Realm&, Cancelled, CSSPixelPoint screen_position, CSSPixelPoint page_offset, CSSPixelPoint client_offset, CSSPixelPoint offset, unsigned button, unsigned buttons, unsigned modifiers); JS::NonnullGCPtr fire_a_drag_and_drop_event( JS::Realm&, JS::GCPtr target, FlyString const& name, CSSPixelPoint screen_position, CSSPixelPoint page_offset, CSSPixelPoint client_offset, CSSPixelPoint offset, unsigned button, unsigned buttons, unsigned modifiers, JS::GCPtr related_target = nullptr); bool allow_text_drop(JS::NonnullGCPtr) const; void reset(); RefPtr m_drag_data_store; // https://html.spec.whatwg.org/multipage/dnd.html#source-node JS::GCPtr m_source_node; // https://html.spec.whatwg.org/multipage/dnd.html#immediate-user-selection JS::GCPtr m_immediate_user_selection; // https://html.spec.whatwg.org/multipage/dnd.html#current-target-element JS::GCPtr m_current_target_element; // https://html.spec.whatwg.org/multipage/dnd.html#current-drag-operation FlyString m_current_drag_operation; }; }