mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:08:12 +00:00
LibWebView+WebContent: Add an IPC to take an element screenshot
This commit is contained in:
parent
424e80ee75
commit
3c1c2994f1
5 changed files with 25 additions and 0 deletions
|
@ -691,6 +691,23 @@ Messages::WebContentServer::IsElementEnabledResponse ConnectionFromClient::is_el
|
|||
return { enabled };
|
||||
}
|
||||
|
||||
Messages::WebContentServer::TakeElementScreenshotResponse ConnectionFromClient::take_element_screenshot(i32 element_id)
|
||||
{
|
||||
auto element = find_element_by_id(element_id);
|
||||
if (!element.has_value())
|
||||
return { {} };
|
||||
|
||||
auto viewport_rect = page().top_level_browsing_context().viewport_rect();
|
||||
|
||||
auto rect = calculate_absolute_rect_of_element(page(), *element);
|
||||
rect.intersect(viewport_rect);
|
||||
|
||||
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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue