mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
headless-browser: Implement a stubbed clipboard API
We currently rely on UI-specific APIs to interact with the system clipboard from AppKit and Qt. We do not have access to these from headless-browser. We should ultimately implement these APIs without relying on the UI as a middle-man. For now, store a clipboard item so that we may exercise the clipboard WPT tests.
This commit is contained in:
parent
61c0f67c8c
commit
7f8f72556a
Notes:
github-actions[bot]
2025-05-02 21:47:35 +00:00
Author: https://github.com/trflynn89
Commit: 7f8f72556a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4548
Reviewed-by: https://github.com/shannonbooth
2 changed files with 19 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
||||
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -127,6 +127,20 @@ HeadlessWebView::HeadlessWebView(Core::AnonymousBuffer theme, Web::DevicePixelSi
|
|||
m_pending_prompt_text.clear();
|
||||
};
|
||||
|
||||
on_insert_clipboard_entry = [this](Web::Clipboard::SystemClipboardRepresentation entry, auto const&) {
|
||||
Web::Clipboard::SystemClipboardItem item;
|
||||
item.system_clipboard_representations.append(move(entry));
|
||||
|
||||
m_clipboard = move(item);
|
||||
};
|
||||
|
||||
on_request_clipboard_entries = [this](auto request_id) {
|
||||
if (m_clipboard.has_value())
|
||||
retrieved_clipboard_entries(request_id, { { *m_clipboard } });
|
||||
else
|
||||
retrieved_clipboard_entries(request_id, {});
|
||||
};
|
||||
|
||||
m_system_visibility_state = Web::HTML::VisibilityState::Visible;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
||||
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -51,6 +51,9 @@ private:
|
|||
|
||||
Web::Page::PendingDialog m_pending_dialog { Web::Page::PendingDialog::None };
|
||||
Optional<String> m_pending_prompt_text;
|
||||
|
||||
// FIXME: We should implement UI-agnostic platform APIs to interact with the system clipboard.
|
||||
Optional<Web::Clipboard::SystemClipboardItem> m_clipboard;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue