mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 22:24:57 +00:00
LibWeb: Add a PageClient callback for image context menu requests
When the user right-clicks on an image, you might want to show a special context menu, separate from the regular link context menu. This patch only implements enough of the functionality to get this working in a single-process context.
This commit is contained in:
parent
d00bfd0eaa
commit
91b49dd9d0
5 changed files with 22 additions and 0 deletions
|
@ -36,6 +36,7 @@
|
|||
#include <LibGUI/ScrollBar.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/ImageDecoder.h>
|
||||
#include <LibGfx/ShareableBitmap.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/ElementFactory.h>
|
||||
|
@ -171,6 +172,16 @@ void InProcessWebView::page_did_request_link_context_menu(const Gfx::IntPoint& c
|
|||
on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)));
|
||||
}
|
||||
|
||||
void InProcessWebView::page_did_request_image_context_menu(const Gfx::IntPoint& content_position, const URL& url, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers, const Gfx::Bitmap* bitmap)
|
||||
{
|
||||
if (!on_image_context_menu_request)
|
||||
return;
|
||||
Gfx::ShareableBitmap shareable_bitmap;
|
||||
if (bitmap)
|
||||
shareable_bitmap = Gfx::ShareableBitmap(*bitmap);
|
||||
on_image_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)), shareable_bitmap);
|
||||
}
|
||||
|
||||
void InProcessWebView::page_did_click_link(const URL& url, const String& target, unsigned modifiers)
|
||||
{
|
||||
if (on_link_click)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue