mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
Clipboard: Avoid unnecessary IPC::Dictionary wrapper
We already have and use HashMap<DeprecatedString, DeprecatedString> nearly everywhere, which is equivalent.
This commit is contained in:
parent
67d9172885
commit
0ee5a4e308
Notes:
sideshowbarker
2024-07-17 01:46:43 +09:00
Author: https://github.com/BenWiederhake
Commit: 0ee5a4e308
Pull-request: https://github.com/SerenityOS/serenity/pull/18928
5 changed files with 13 additions and 8 deletions
|
@ -59,9 +59,14 @@ Clipboard::DataAndType Clipboard::fetch_data_and_type() const
|
||||||
{
|
{
|
||||||
auto response = connection().get_clipboard_data();
|
auto response = connection().get_clipboard_data();
|
||||||
auto type = response.mime_type();
|
auto type = response.mime_type();
|
||||||
auto metadata = response.metadata().entries();
|
auto metadata = response.metadata();
|
||||||
|
|
||||||
|
auto metadata_clone_or_error = metadata.clone();
|
||||||
|
if (metadata_clone_or_error.is_error())
|
||||||
|
return {};
|
||||||
|
|
||||||
if (!response.data().is_valid())
|
if (!response.data().is_valid())
|
||||||
return { {}, type, metadata };
|
return { {}, type, metadata_clone_or_error.release_value() };
|
||||||
auto data = ByteBuffer::copy(response.data().data<void>(), response.data().size());
|
auto data = ByteBuffer::copy(response.data().data<void>(), response.data().size());
|
||||||
if (data.is_error())
|
if (data.is_error())
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
endpoint ClipboardServer
|
endpoint ClipboardServer
|
||||||
{
|
{
|
||||||
get_clipboard_data() => (Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, IPC::Dictionary metadata)
|
get_clipboard_data() => (Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, HashMap<DeprecatedString,DeprecatedString> metadata)
|
||||||
set_clipboard_data(Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, IPC::Dictionary metadata) =|
|
set_clipboard_data(Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, HashMap<DeprecatedString,DeprecatedString> metadata) =|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ void ConnectionFromClient::die()
|
||||||
s_connections.remove(client_id());
|
s_connections.remove(client_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionFromClient::set_clipboard_data(Core::AnonymousBuffer const& data, DeprecatedString const& mime_type, IPC::Dictionary const& metadata)
|
void ConnectionFromClient::set_clipboard_data(Core::AnonymousBuffer const& data, DeprecatedString const& mime_type, HashMap<DeprecatedString, DeprecatedString> const& metadata)
|
||||||
{
|
{
|
||||||
Storage::the().set_data(data, mime_type, metadata.entries());
|
Storage::the().set_data(data, mime_type, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messages::ClipboardServer::GetClipboardDataResponse ConnectionFromClient::get_clipboard_data()
|
Messages::ClipboardServer::GetClipboardDataResponse ConnectionFromClient::get_clipboard_data()
|
||||||
|
|
|
@ -30,7 +30,7 @@ private:
|
||||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||||
|
|
||||||
virtual Messages::ClipboardServer::GetClipboardDataResponse get_clipboard_data() override;
|
virtual Messages::ClipboardServer::GetClipboardDataResponse get_clipboard_data() override;
|
||||||
virtual void set_clipboard_data(Core::AnonymousBuffer const&, DeprecatedString const&, IPC::Dictionary const&) override;
|
virtual void set_clipboard_data(Core::AnonymousBuffer const&, DeprecatedString const&, HashMap<DeprecatedString, DeprecatedString> const&) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ RefPtr<Gfx::Bitmap> ConnectionToClipboardServer::get_bitmap()
|
||||||
if (clipping.mime_type() != "image/x-serenityos")
|
if (clipping.mime_type() != "image/x-serenityos")
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
HashMap<DeprecatedString, DeprecatedString> const& metadata = clipping.metadata().entries();
|
HashMap<DeprecatedString, DeprecatedString> const& metadata = clipping.metadata();
|
||||||
auto width = metadata.get("width").value_or("0").to_uint();
|
auto width = metadata.get("width").value_or("0").to_uint();
|
||||||
if (!width.has_value() || width.value() == 0)
|
if (!width.has_value() || width.value() == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue