From c0758882c5e017594f63c76a4e7637c760a14880 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 17 Aug 2023 18:01:05 -0400 Subject: [PATCH] WebContent: Convert image/media context menu positions to device pixels On Serenity and on my Linux machine, we have a 1:1 CSS-to-device pixel ratio. On macOS, we have a 2:1 ratio. This did not affect the Qt chrome, because we are ignoring this position and placing the context menu at the globally-accessible mouse position. The AppKit chrome will be using this position, though. This might be what caused the issue worked around by commit 8177ecb. --- Userland/Services/WebContent/PageHost.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index c02158c620..c017697248 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -302,12 +302,12 @@ void PageHost::page_did_request_link_context_menu(Web::CSSPixelPoint content_pos void PageHost::page_did_request_image_context_menu(Web::CSSPixelPoint content_position, URL const& url, DeprecatedString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer) { auto bitmap = bitmap_pointer ? bitmap_pointer->to_shareable_bitmap() : Gfx::ShareableBitmap(); - m_client.async_did_request_image_context_menu({ content_position.x().to_int(), content_position.y().to_int() }, url, target, modifiers, bitmap); + m_client.async_did_request_image_context_menu(page().css_to_device_point(content_position).to_type(), url, target, modifiers, bitmap); } void PageHost::page_did_request_media_context_menu(Web::CSSPixelPoint content_position, DeprecatedString const& target, unsigned modifiers, Web::Page::MediaContextMenu menu) { - m_client.async_did_request_media_context_menu({ content_position.x().to_int(), content_position.y().to_int() }, target, modifiers, move(menu)); + m_client.async_did_request_media_context_menu(page().css_to_device_point(content_position).to_type(), target, modifiers, move(menu)); } void PageHost::page_did_request_alert(String const& message)