mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 17:12:12 +00:00
Ladybird+LibWebView+WebContent: Make the screenshot IPCs async
These IPCs are different than other IPCs in that we can't just set up a callback function to be invoked when WebContent sends us the screenshot data. There are multiple places that would set that callback, and they would step on each other's toes. Instead, the screenshot APIs on ViewImplementation now return a Promise which callers can interact with to receive the screenshot (or an error).
This commit is contained in:
parent
93db790974
commit
d8fa226a8f
13 changed files with 121 additions and 47 deletions
|
@ -254,10 +254,13 @@ void InspectorClient::context_menu_screenshot_dom_node()
|
|||
{
|
||||
VERIFY(m_context_menu_data.has_value());
|
||||
|
||||
if (auto result = m_content_web_view.take_dom_node_screenshot(m_context_menu_data->dom_node_id); result.is_error())
|
||||
append_console_warning(MUST(String::formatted("Warning: {}", result.error())));
|
||||
else
|
||||
append_console_message(MUST(String::formatted("Screenshot saved to: {}", result.value())));
|
||||
m_content_web_view.take_dom_node_screenshot(m_context_menu_data->dom_node_id)
|
||||
->when_resolved([this](auto const& path) {
|
||||
append_console_message(MUST(String::formatted("Screenshot saved to: {}", path)));
|
||||
})
|
||||
.when_rejected([this](auto const& error) {
|
||||
append_console_warning(MUST(String::formatted("Warning: {}", error)));
|
||||
});
|
||||
|
||||
m_context_menu_data.clear();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue