summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Page
diff options
context:
space:
mode:
authorOliver Wales <oli@opvia.bio>2022-04-07 22:43:30 +0100
committerTim Flynn <trflynn89@pm.me>2022-04-08 07:59:01 -0400
commit382eacc08efcae095e4fd9650f59cf9dba163315 (patch)
tree952ca82c4afcd5251c0ede15180ba7a02ac9f1fe /Userland/Libraries/LibWeb/Page
parent84a81dd46665d3e81e87e36c46f9fdca646bacae (diff)
downloadserenity-382eacc08efcae095e4fd9650f59cf9dba163315.zip
LibWeb: Select correct context menu when right clicking image
Diffstat (limited to 'Userland/Libraries/LibWeb/Page')
-rw-r--r--Userland/Libraries/LibWeb/Page/EventHandler.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
index c34f3f2429..ae84b5284d 100644
--- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
@@ -232,8 +232,14 @@ bool EventHandler::handle_mouseup(Gfx::IntPoint const& position, unsigned button
page->client().page_did_request_link_context_menu(m_browsing_context.to_top_level_position(position), url, link->target(), modifiers);
}
} else if (button == GUI::MouseButton::Secondary) {
- if (auto* page = m_browsing_context.page())
+ if (is<HTML::HTMLImageElement>(*node)) {
+ auto& image_element = verify_cast<HTML::HTMLImageElement>(*node);
+ auto image_url = image_element.document().parse_url(image_element.src());
+ if (auto* page = m_browsing_context.page())
+ page->client().page_did_request_image_context_menu(m_browsing_context.to_top_level_position(position), image_url, "", modifiers, image_element.bitmap());
+ } else if (auto* page = m_browsing_context.page()) {
page->client().page_did_request_context_menu(m_browsing_context.to_top_level_position(position));
+ }
}
if (node.ptr() == m_mousedown_target && button == GUI::MouseButton::Primary) {
@@ -306,14 +312,6 @@ bool EventHandler::handle_mousedown(Gfx::IntPoint const& position, unsigned butt
if (!paint_root() || paint_root() != node->document().paint_box())
return true;
- if (button == GUI::MouseButton::Secondary && is<HTML::HTMLImageElement>(*node)) {
- auto& image_element = verify_cast<HTML::HTMLImageElement>(*node);
- auto image_url = image_element.document().parse_url(image_element.src());
- if (auto* page = m_browsing_context.page())
- page->client().page_did_request_image_context_menu(m_browsing_context.to_top_level_position(position), image_url, "", modifiers, image_element.bitmap());
- return true;
- }
-
if (button == GUI::MouseButton::Primary) {
if (auto result = paint_root()->hit_test(position.to_type<float>(), Painting::HitTestType::TextCursor); result.has_value()) {
auto paintable = result->paintable;