mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
LibWeb: Select correct context menu when right clicking image
This commit is contained in:
parent
84a81dd466
commit
382eacc08e
1 changed files with 7 additions and 9 deletions
|
@ -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);
|
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) {
|
} 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));
|
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) {
|
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())
|
if (!paint_root() || paint_root() != node->document().paint_box())
|
||||||
return true;
|
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 (button == GUI::MouseButton::Primary) {
|
||||||
if (auto result = paint_root()->hit_test(position.to_type<float>(), Painting::HitTestType::TextCursor); result.has_value()) {
|
if (auto result = paint_root()->hit_test(position.to_type<float>(), Painting::HitTestType::TextCursor); result.has_value()) {
|
||||||
auto paintable = result->paintable;
|
auto paintable = result->paintable;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue