WebContent: Capture horizontal overflow in full document screenshots

The full-page screenshot was missing horizontal overflow content on most
web pages. Change the dimensions of the captured screenshot to match the
actual content size.
This commit is contained in:
Timothy Flynn 2022-11-05 12:28:47 -04:00 committed by Linus Groh
parent 2f5ceeac62
commit cfa5e03108
Notes: sideshowbarker 2024-07-17 04:46:16 +09:00

View File

@ -714,7 +714,16 @@ Messages::WebContentServer::TakeDocumentScreenshotResponse ConnectionFromClient:
if (!document || !document->document_element())
return { {} };
auto rect = calculate_absolute_rect_of_element(page(), *document->document_element());
auto bounding_rect = document->document_element()->get_bounding_client_rect();
auto position = calculate_absolute_position_of_element(page(), bounding_rect);
auto const& content_size = m_page_host->content_size();
Gfx::IntRect rect {
position.x(),
position.y(),
content_size.width() - position.x(),
content_size.height() - position.y(),
};
auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, rect.size()).release_value_but_fixme_should_propagate_errors();
m_page_host->paint(rect, *bitmap);