LibWebView: Move headless clipboard management to LibWebView

We only supported headless clipboard management in test-web. So when WPT
tests the clipboard APIs, we would blindly try to access the Qt app,
which does not exist.

Note that the AppKit UI has no such restriction, as the NSPasteboard is
accessible even without a GUI.
This commit is contained in:
Timothy Flynn 2025-10-10 10:11:56 -04:00 committed by Tim Flynn
parent a4a15b9a1e
commit e57176b484
Notes: github-actions[bot] 2025-10-10 19:11:12 +00:00
9 changed files with 247 additions and 22 deletions

View file

@ -625,6 +625,27 @@ void Application::display_error_dialog(StringView error_message) const
warnln("{}", error_message);
}
Utf16String Application::clipboard_text() const
{
if (!m_clipboard.has_value())
return {};
if (m_clipboard->mime_type != "text/plain"sv)
return {};
return Utf16String::from_utf8(m_clipboard->data);
}
Vector<Web::Clipboard::SystemClipboardRepresentation> Application::clipboard_entries() const
{
if (!m_clipboard.has_value())
return {};
return { *m_clipboard };
}
void Application::insert_clipboard_entry(Web::Clipboard::SystemClipboardRepresentation entry)
{
m_clipboard = move(entry);
}
void Application::initialize_actions()
{
auto debug_request = [this](auto request) {