1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:27:45 +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:
Timothy Flynn 2023-12-31 09:51:02 -05:00 committed by Andreas Kling
parent 93db790974
commit d8fa226a8f
13 changed files with 121 additions and 47 deletions

View file

@ -791,14 +791,16 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
- (void)takeVisibleScreenshot:(id)sender
{
auto result = m_web_view_bridge->take_screenshot(WebView::ViewImplementation::ScreenshotType::Visible);
(void)result; // FIXME: Display an error if this failed.
m_web_view_bridge->take_screenshot(WebView::ViewImplementation::ScreenshotType::Visible)->when_rejected([](auto const& error) {
(void)error; // FIXME: Display the error.
});
}
- (void)takeFullScreenshot:(id)sender
{
auto result = m_web_view_bridge->take_screenshot(WebView::ViewImplementation::ScreenshotType::Full);
(void)result; // FIXME: Display an error if this failed.
m_web_view_bridge->take_screenshot(WebView::ViewImplementation::ScreenshotType::Full)->when_rejected([](auto const& error) {
(void)error; // FIXME: Display the error.
});
}
- (void)openLink:(id)sender