mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-21 15:40:28 +00:00
LibWebView+UI: Move clipboard handling from the WebView to the App
Clipboard handling largely has nothing to do with the individual web views. Rather, we interact with the system clipboard at the application level. So let's move these implementations to the Application.
This commit is contained in:
parent
4f31e492e7
commit
ca082d6d73
Notes:
github-actions[bot]
2025-09-19 10:39:59 +00:00
Author: https://github.com/trflynn89
Commit: ca082d6d73
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6228
15 changed files with 131 additions and 145 deletions
|
@ -12,7 +12,6 @@
|
|||
#include <LibCore/Timer.h>
|
||||
#include <LibGfx/ImageFormats/PNGWriter.h>
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibWeb/Clipboard/SystemClipboard.h>
|
||||
#include <LibWeb/Crypto/Crypto.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWebView/Application.h>
|
||||
|
@ -452,16 +451,9 @@ void ViewImplementation::select_dropdown_closed(Optional<u32> const& selected_it
|
|||
client().async_select_dropdown_closed(page_id(), selected_item_id);
|
||||
}
|
||||
|
||||
void ViewImplementation::insert_text_into_clipboard(ByteString text) const
|
||||
{
|
||||
if (on_insert_clipboard_entry)
|
||||
on_insert_clipboard_entry({ move(text), "text/plain"_string }, {});
|
||||
}
|
||||
|
||||
void ViewImplementation::paste_text_from_clipboard()
|
||||
{
|
||||
if (on_request_clipboard_text)
|
||||
client().async_paste(page_id(), on_request_clipboard_text());
|
||||
client().async_paste(page_id(), Application::the().clipboard_text());
|
||||
}
|
||||
|
||||
void ViewImplementation::retrieved_clipboard_entries(u64 request_id, ReadonlySpan<Web::Clipboard::SystemClipboardItem> items)
|
||||
|
@ -858,7 +850,7 @@ void ViewImplementation::initialize_context_menus()
|
|||
Application::the().open_url_in_new_tab(m_context_menu_url, Web::HTML::ActivateTab::No);
|
||||
});
|
||||
m_copy_url_action = Action::create("Copy URL"sv, ActionID::CopyURL, [this]() {
|
||||
insert_text_into_clipboard(url_text_to_copy(m_context_menu_url));
|
||||
Application::the().insert_clipboard_entry({ url_text_to_copy(m_context_menu_url), "text/plain"_string });
|
||||
});
|
||||
|
||||
m_open_image_action = Action::create("Open Image"sv, ActionID::OpenImage, [this]() {
|
||||
|
@ -876,8 +868,7 @@ void ViewImplementation::initialize_context_menus()
|
|||
if (encoded.is_error())
|
||||
return;
|
||||
|
||||
if (on_insert_clipboard_entry)
|
||||
on_insert_clipboard_entry({ ByteString { encoded.value().bytes() }, "image/png"_string }, {});
|
||||
Application::the().insert_clipboard_entry({ ByteString { encoded.value().bytes() }, "image/png"_string });
|
||||
});
|
||||
|
||||
m_open_audio_action = Action::create("Open Audio"sv, ActionID::OpenAudio, [this]() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue