mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Browser+LibWebView: Add a Tab hook to take a screenshot
This commit is contained in:
parent
819598aecf
commit
d603585802
4 changed files with 14 additions and 0 deletions
|
@ -583,6 +583,10 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
|
|||
return active_tab().view().get_session_storage_entries();
|
||||
};
|
||||
|
||||
new_tab.on_take_screenshot = [this]() {
|
||||
return active_tab().view().take_screenshot();
|
||||
};
|
||||
|
||||
new_tab.webdriver_endpoints().on_get_document_element = [this]() {
|
||||
return active_tab().view().get_document_element();
|
||||
};
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
Function<Vector<Web::Cookie::Cookie>()> on_get_cookies_entries;
|
||||
Function<OrderedHashMap<String, String>()> on_get_local_storage_entries;
|
||||
Function<OrderedHashMap<String, String>()> on_get_session_storage_entries;
|
||||
Function<Gfx::ShareableBitmap()> on_take_screenshot;
|
||||
|
||||
WebDriverEndpoints& webdriver_endpoints() { return m_webdriver_endpoints; }
|
||||
|
||||
|
|
|
@ -585,6 +585,13 @@ void OutOfProcessWebView::set_window_size(Gfx::IntSize const& size)
|
|||
client().async_set_window_size(size);
|
||||
}
|
||||
|
||||
Gfx::ShareableBitmap OutOfProcessWebView::take_screenshot() const
|
||||
{
|
||||
if (auto* bitmap = m_client_state.has_usable_bitmap ? m_client_state.front_bitmap.bitmap.ptr() : m_backup_bitmap.ptr())
|
||||
return bitmap->to_shareable_bitmap();
|
||||
return {};
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::focusin_event(GUI::FocusEvent&)
|
||||
{
|
||||
client().async_set_has_focus(true);
|
||||
|
|
|
@ -75,6 +75,8 @@ public:
|
|||
void set_window_position(Gfx::IntPoint const&);
|
||||
void set_window_size(Gfx::IntSize const&);
|
||||
|
||||
Gfx::ShareableBitmap take_screenshot() const;
|
||||
|
||||
Function<void(Gfx::IntPoint const& screen_position)> on_context_menu_request;
|
||||
Function<void(const AK::URL&, String const& target, unsigned modifiers)> on_link_click;
|
||||
Function<void(const AK::URL&, Gfx::IntPoint const& screen_position)> on_link_context_menu_request;
|
||||
|
|
Loading…
Add table
Reference in a new issue