summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWebView
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-11-02 12:58:22 -0400
committerLinus Groh <mail@linusgroh.de>2022-11-02 17:55:37 +0000
commitd60358580228d3387bd3631a62d4a4c22451cc6d (patch)
treece7622b6ad4fec5f22e576a7507687640058eec8 /Userland/Libraries/LibWebView
parent819598aecf91a81e25aceba5ef512fd57d3252a6 (diff)
downloadserenity-d60358580228d3387bd3631a62d4a4c22451cc6d.zip
Browser+LibWebView: Add a Tab hook to take a screenshot
Diffstat (limited to 'Userland/Libraries/LibWebView')
-rw-r--r--Userland/Libraries/LibWebView/OutOfProcessWebView.cpp7
-rw-r--r--Userland/Libraries/LibWebView/OutOfProcessWebView.h2
2 files changed, 9 insertions, 0 deletions
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<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;