mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 01:27:44 +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
|
@ -657,20 +657,20 @@ Tab::Tab(BrowserWindow& window)
|
|||
|
||||
auto take_visible_screenshot_action = GUI::Action::create(
|
||||
"Take &Visible Screenshot"sv, g_icon_bag.filetype_image, [this](auto&) {
|
||||
if (auto result = view().take_screenshot(WebView::ViewImplementation::ScreenshotType::Visible); result.is_error()) {
|
||||
auto error = String::formatted("{}", result.error()).release_value_but_fixme_should_propagate_errors();
|
||||
GUI::MessageBox::show_error(&this->window(), error);
|
||||
}
|
||||
view().take_screenshot(WebView::ViewImplementation::ScreenshotType::Visible)->when_rejected([this](auto const& error) {
|
||||
auto error_message = MUST(String::formatted("{}", error));
|
||||
GUI::MessageBox::show_error(&this->window(), error_message);
|
||||
});
|
||||
},
|
||||
this);
|
||||
take_visible_screenshot_action->set_status_tip("Save a screenshot of the visible portion of the current tab to the Downloads directory"_string);
|
||||
|
||||
auto take_full_screenshot_action = GUI::Action::create(
|
||||
"Take &Full Screenshot"sv, g_icon_bag.filetype_image, [this](auto&) {
|
||||
if (auto result = view().take_screenshot(WebView::ViewImplementation::ScreenshotType::Full); result.is_error()) {
|
||||
auto error = String::formatted("{}", result.error()).release_value_but_fixme_should_propagate_errors();
|
||||
GUI::MessageBox::show_error(&this->window(), error);
|
||||
}
|
||||
view().take_screenshot(WebView::ViewImplementation::ScreenshotType::Full)->when_rejected([this](auto const& error) {
|
||||
auto error_message = MUST(String::formatted("{}", error));
|
||||
GUI::MessageBox::show_error(&this->window(), error_message);
|
||||
});
|
||||
},
|
||||
this);
|
||||
take_full_screenshot_action->set_status_tip("Save a screenshot of the entirety of the current tab to the Downloads directory"_string);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue