diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index e5b69d7d36..fea6bd164e 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -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(); }; diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h index cc2664879f..ba37fcd625 100644 --- a/Userland/Applications/Browser/Tab.h +++ b/Userland/Applications/Browser/Tab.h @@ -72,6 +72,7 @@ public: Function()> on_get_cookies_entries; Function()> on_get_local_storage_entries; Function()> on_get_session_storage_entries; + Function on_take_screenshot; WebDriverEndpoints& webdriver_endpoints() { return m_webdriver_endpoints; } diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index 90f5ad2fa3..8a801d1502 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -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); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index 2cd1b3559a..a081c4dc26 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -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 on_context_menu_request; Function on_link_click; Function on_link_context_menu_request;