ladybird/Userland/Libraries/LibWeb/Clipboard/ClipboardEvent.h
Timothy Flynn 0b0d44da27 LibWeb: Implement the ClipboardEvent IDL interface
We don't actually generate any such events ourselves. But Google Lens
will create one with the DataTransfer attribute set to that of any drop
event we send it.
2024-08-22 14:21:13 +02:00

41 lines
1.1 KiB
C++

/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Heap/GCPtr.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/DataTransfer.h>
namespace Web::Clipboard {
struct ClipboardEventInit : public DOM::EventInit {
JS::GCPtr<HTML::DataTransfer> clipboard_data;
};
// https://w3c.github.io/clipboard-apis/#clipboardevent
class ClipboardEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(ClipboardEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(ClipboardEvent);
public:
static JS::NonnullGCPtr<ClipboardEvent> construct_impl(JS::Realm&, FlyString const& event_name, ClipboardEventInit const& event_init);
virtual ~ClipboardEvent() override;
JS::GCPtr<HTML::DataTransfer> clipboard_data() { return m_clipboard_data; }
private:
ClipboardEvent(JS::Realm&, FlyString const& event_name, ClipboardEventInit const& event_init);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(JS::Cell::Visitor&) override;
JS::GCPtr<HTML::DataTransfer> m_clipboard_data;
};
}