mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:02:06 +00:00
LibWebView+WebContent: Add an IPC to take a full document screenshot
This commit is contained in:
parent
59b1dfa4e5
commit
95e591b61b
5 changed files with 22 additions and 0 deletions
|
@ -622,6 +622,11 @@ Gfx::ShareableBitmap OutOfProcessWebView::take_element_screenshot(i32 element_id
|
|||
return client().take_element_screenshot(element_id);
|
||||
}
|
||||
|
||||
Gfx::ShareableBitmap OutOfProcessWebView::take_document_screenshot()
|
||||
{
|
||||
return client().take_document_screenshot();
|
||||
}
|
||||
|
||||
Messages::WebContentServer::WebdriverExecuteScriptResponse OutOfProcessWebView::webdriver_execute_script(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async)
|
||||
{
|
||||
return client().webdriver_execute_script(body, json_arguments, timeout, async);
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
|
||||
Gfx::ShareableBitmap take_screenshot() const;
|
||||
Gfx::ShareableBitmap take_element_screenshot(i32 element_id);
|
||||
Gfx::ShareableBitmap take_document_screenshot();
|
||||
|
||||
Messages::WebContentServer::WebdriverExecuteScriptResponse webdriver_execute_script(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async);
|
||||
|
||||
|
|
|
@ -708,6 +708,20 @@ Messages::WebContentServer::TakeElementScreenshotResponse ConnectionFromClient::
|
|||
return { bitmap->to_shareable_bitmap() };
|
||||
}
|
||||
|
||||
Messages::WebContentServer::TakeDocumentScreenshotResponse ConnectionFromClient::take_document_screenshot()
|
||||
{
|
||||
auto* document = page().top_level_browsing_context().active_document();
|
||||
if (!document || !document->document_element())
|
||||
return { {} };
|
||||
|
||||
auto rect = calculate_absolute_rect_of_element(page(), *document->document_element());
|
||||
|
||||
auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, rect.size()).release_value_but_fixme_should_propagate_errors();
|
||||
m_page_host->paint(rect, *bitmap);
|
||||
|
||||
return { bitmap->to_shareable_bitmap() };
|
||||
}
|
||||
|
||||
Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text()
|
||||
{
|
||||
return page().focused_context().selected_text();
|
||||
|
|
|
@ -96,6 +96,7 @@ private:
|
|||
virtual Messages::WebContentServer::GetElementRectResponse get_element_rect(i32 element_id) override;
|
||||
virtual Messages::WebContentServer::IsElementEnabledResponse is_element_enabled(i32 element_id) override;
|
||||
virtual Messages::WebContentServer::TakeElementScreenshotResponse take_element_screenshot(i32 element_id) override;
|
||||
virtual Messages::WebContentServer::TakeDocumentScreenshotResponse take_document_screenshot() override;
|
||||
|
||||
virtual Messages::WebContentServer::GetLocalStorageEntriesResponse get_local_storage_entries() override;
|
||||
virtual Messages::WebContentServer::GetSessionStorageEntriesResponse get_session_storage_entries() override;
|
||||
|
|
|
@ -53,6 +53,7 @@ endpoint WebContentServer
|
|||
get_element_rect(i32 element_id) => (Gfx::IntRect rect)
|
||||
is_element_enabled(i32 element_id) => (bool enabled)
|
||||
take_element_screenshot(i32 element_id) => (Gfx::ShareableBitmap data)
|
||||
take_document_screenshot() => (Gfx::ShareableBitmap data)
|
||||
|
||||
webdriver_execute_script(String body, Vector<String> json_arguments, Optional<u64> timeout, bool async) => (Web::WebDriver::ExecuteScriptResultType result_type, String json_result)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue