LibWeb: Implement navigator.clipboard.read

This commit is contained in:
Timothy Flynn 2025-05-01 18:00:42 -04:00 committed by Tim Flynn
commit 912009f6b3
Notes: github-actions[bot] 2025-05-02 21:47:14 +00:00
5 changed files with 163 additions and 1 deletions

View file

@ -15,6 +15,11 @@
namespace Web::Clipboard {
struct ClipboardUnsanitizedFormats {
// FIXME: This should not actually be an Optional, but the IDL generator creates it as such.
Optional<Vector<String>> unsanitized;
};
class Clipboard final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(Clipboard, DOM::EventTarget);
GC_DECLARE_ALLOCATOR(Clipboard);
@ -23,6 +28,7 @@ public:
static WebIDL::ExceptionOr<GC::Ref<Clipboard>> construct_impl(JS::Realm&);
virtual ~Clipboard() override;
GC::Ref<WebIDL::Promise> read(ClipboardUnsanitizedFormats formats = {});
GC::Ref<WebIDL::Promise> read_text();
GC::Ref<WebIDL::Promise> write(GC::RootVector<GC::Root<ClipboardItem>>&);