1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

WebContent: Always return a ShareableBitmap object from screenshot APIs

The empty value we are currently returning hits the `decltype(nullptr)`
constructor of TakeDocumentScreenshotResponse. This is interpreted as an
invalid response by LibIPC. Instead, return a Gfx::ShareableBitmap that
the client-side can handle, and e.g. display an error, rather than the
message just being dropped.
This commit is contained in:
Timothy Flynn 2023-12-09 16:35:46 -05:00 committed by Andreas Kling
parent 463931384d
commit e0450301ab

View file

@ -851,7 +851,7 @@ Messages::WebContentServer::TakeDocumentScreenshotResponse ConnectionFromClient:
{
auto* document = page().page().top_level_browsing_context().active_document();
if (!document || !document->document_element())
return { {} };
return Gfx::ShareableBitmap {};
auto const& content_size = page().content_size();
Web::DevicePixelRect rect { { 0, 0 }, content_size };
@ -859,21 +859,21 @@ Messages::WebContentServer::TakeDocumentScreenshotResponse ConnectionFromClient:
auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect.size().to_type<int>()).release_value_but_fixme_should_propagate_errors();
page().paint(rect, *bitmap);
return { bitmap->to_shareable_bitmap() };
return bitmap->to_shareable_bitmap();
}
Messages::WebContentServer::TakeDomNodeScreenshotResponse ConnectionFromClient::take_dom_node_screenshot(i32 node_id)
{
auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
if (!dom_node || !dom_node->paintable_box())
return { {} };
return Gfx::ShareableBitmap {};
auto rect = page().page().enclosing_device_rect(dom_node->paintable_box()->absolute_border_box_rect());
auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect.size().to_type<int>()).release_value_but_fixme_should_propagate_errors();
page().paint(rect, *bitmap, { .paint_overlay = Web::PaintOptions::PaintOverlay::No });
return { bitmap->to_shareable_bitmap() };
return bitmap->to_shareable_bitmap();
}
Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text()