diff options
author | Andreas Kling <kling@serenityos.org> | 2021-04-11 16:49:25 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-11 16:49:25 +0200 |
commit | 54cd8dfc4db0688fbef9571137a1b45c99226b04 (patch) | |
tree | 52276d267c0e9aa7e5f954f7aedff2e6bc46942d /Userland/Libraries/LibWeb | |
parent | e43fba0c58d9c8bb0e4bd7bf6ca915ce71fa5bd4 (diff) | |
download | serenity-54cd8dfc4db0688fbef9571137a1b45c99226b04.zip |
LibWeb+WebContent: Support image context menus in OOPWV
You can now right-click images in web content and get a context menu.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/OutOfProcessWebView.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/OutOfProcessWebView.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebContentClient.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebContentClient.h | 1 |
4 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp index c2c36024de..f417e7814c 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -322,6 +322,12 @@ void OutOfProcessWebView::notify_server_did_request_link_context_menu(Badge<WebC on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position))); } +void OutOfProcessWebView::notify_server_did_request_image_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position, const URL& url, const String&, unsigned, const Gfx::ShareableBitmap& bitmap) +{ + if (on_image_context_menu_request) + on_image_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)), bitmap); +} + void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, const String& message) { GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information); diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h index b634bc1077..d9918a8ad7 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h @@ -72,6 +72,7 @@ public: void notify_server_did_finish_loading(Badge<WebContentClient>, const URL&); void notify_server_did_request_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&); void notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers); + void notify_server_did_request_image_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers, const Gfx::ShareableBitmap&); void notify_server_did_request_alert(Badge<WebContentClient>, const String& message); bool notify_server_did_request_confirm(Badge<WebContentClient>, const String& message); String notify_server_did_request_prompt(Badge<WebContentClient>, const String& message, const String& default_); diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp index 3988db3d8e..aac858b3d7 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.cpp +++ b/Userland/Libraries/LibWeb/WebContentClient.cpp @@ -155,6 +155,11 @@ void WebContentClient::handle(const Messages::WebContentClient::DidRequestLinkCo m_view.notify_server_did_request_link_context_menu({}, message.content_position(), message.url(), message.target(), message.modifiers()); } +void WebContentClient::handle(const Messages::WebContentClient::DidRequestImageContextMenu& message) +{ + m_view.notify_server_did_request_image_context_menu({}, message.content_position(), message.url(), message.target(), message.modifiers(), message.bitmap()); +} + void WebContentClient::handle(const Messages::WebContentClient::DidGetSource& message) { m_view.notify_server_did_get_source(message.url(), message.source()); diff --git a/Userland/Libraries/LibWeb/WebContentClient.h b/Userland/Libraries/LibWeb/WebContentClient.h index 17ae95d91c..a519734148 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.h +++ b/Userland/Libraries/LibWeb/WebContentClient.h @@ -68,6 +68,7 @@ private: virtual void handle(const Messages::WebContentClient::DidStartLoading&) override; virtual void handle(const Messages::WebContentClient::DidRequestContextMenu&) override; virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override; + virtual void handle(const Messages::WebContentClient::DidRequestImageContextMenu&) override; virtual void handle(const Messages::WebContentClient::DidGetSource&) override; virtual void handle(const Messages::WebContentClient::DidJSConsoleOutput&) override; virtual void handle(const Messages::WebContentClient::DidChangeFavicon&) override; |