#pragma once
#if ENABLE(DRAG_SUPPORT)
#include <WebCore/DragActions.h>
#include <WebCore/IntPoint.h>
#include <WebCore/SelectionData.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/RunLoop.h>
#include <wtf/glib/GRefPtr.h>
typedef struct _GtkWidget GtkWidget;
#if USE(GTK4)
typedef struct _GdkDrop GdkDrop;
#else
typedef struct _GdkDragContext GdkDragContext;
typedef struct _GtkSelectionData GtkSelectionData;
#endif
namespace WebKit {
class ShareableBitmap;
class DropTarget {
WTF_MAKE_NONCOPYABLE(DropTarget); WTF_MAKE_FAST_ALLOCATED;
public:
explicit DropTarget(GtkWidget*);
~DropTarget();
void didPerformAction();
private:
void accept(unsigned = 0);
void enter(WebCore::IntPoint&&, unsigned = 0);
void update(WebCore::IntPoint&&, unsigned = 0);
void leave();
void drop(WebCore::IntPoint&&, unsigned = 0);
#if USE(GTK4)
void loadData(const char* mimeType, CompletionHandler<void(GRefPtr<GBytes>&&)>&&);
void didLoadData();
#else
void dataReceived(WebCore::IntPoint&&, GtkSelectionData*, unsigned, unsigned);
void leaveTimerFired();
#endif
GtkWidget* m_webView { nullptr };
#if USE(GTK4)
GRefPtr<GdkDrop> m_drop;
#else
GRefPtr<GdkDragContext> m_drop;
#endif
Optional<WebCore::IntPoint> m_position;
unsigned m_dataRequestCount { 0 };
Optional<WebCore::SelectionData> m_selectionData;
Optional<WebCore::DragOperation> m_operation;
#if USE(GTK4)
GRefPtr<GCancellable> m_cancellable;
#else
RunLoop::Timer<DropTarget> m_leaveTimer;
#endif
};
}
#endif // ENABLE(DRAG_SUPPORT)