From f7103bc5fd099dd0a0772ef28930dd368e9fcf47 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Mon, 4 Dec 2017 10:29:25 +0100 Subject: Fix Message Bubble position for High-DPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-64812 Change-Id: I9df71253cf6c541622e431b1ff444fc49269d0c3 Reviewed-by: Jüri Valdmann Reviewed-by: Allan Sandfeld Jensen --- src/core/web_contents_delegate_qt.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/core/web_contents_delegate_qt.cpp') diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 7d4c671b0..26da6348a 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -79,6 +79,16 @@ namespace QtWebEngineCore { +static gfx::Rect rootViewToScreenRect(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view) +{ + RenderWidgetHostViewQt *rwhv = static_cast(web_contents->GetRenderWidgetHostView()); + if (!rwhv) + return gfx::Rect(); + content::ScreenInfo screenInfo; + rwhv->GetScreenInfo(&screenInfo); + return gfx::ScaleToEnclosingRect(anchor_in_root_view, 1 / screenInfo.device_scale_factor); +} + // Maps the LogSeverity defines in base/logging.h to the web engines message levels. static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptConsoleMessageLevel(int32_t messageLevel) { if (messageLevel < 1) @@ -457,8 +467,10 @@ void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransitio void WebContentsDelegateQt::ShowValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view, const base::string16 &main_text, const base::string16 &sub_text) { - Q_UNUSED(web_contents); - m_viewClient->showValidationMessage(toQt(anchor_in_root_view), toQt(main_text), toQt(sub_text)); + gfx::Rect anchor = rootViewToScreenRect(web_contents, anchor_in_root_view); + if (anchor.IsEmpty()) + return; + m_viewClient->showValidationMessage(toQt(anchor), toQt(main_text), toQt(sub_text)); } void WebContentsDelegateQt::HideValidationMessage(content::WebContents *web_contents) @@ -469,8 +481,10 @@ void WebContentsDelegateQt::HideValidationMessage(content::WebContents *web_cont void WebContentsDelegateQt::MoveValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view) { - Q_UNUSED(web_contents); - m_viewClient->moveValidationMessage(toQt(anchor_in_root_view)); + gfx::Rect anchor = rootViewToScreenRect(web_contents, anchor_in_root_view); + if (anchor.IsEmpty()) + return; + m_viewClient->moveValidationMessage(toQt(anchor)); } void WebContentsDelegateQt::BeforeUnloadFired(content::WebContents *tab, bool proceed, bool *proceed_to_fire_unload) -- cgit v1.2.3 From fda2f858bef4d25c711f02fbb0f2aa0127a6c3b5 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Thu, 7 Dec 2017 16:09:25 +0100 Subject: Fix favicon update from JavaScript Task-number: QTBUG-64967 Change-Id: Ida79d6cdb682d510e9a2e91e3e3ca263acf34a99 Reviewed-by: Viktor Engelmann --- src/core/web_contents_delegate_qt.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core/web_contents_delegate_qt.cpp') diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 26da6348a..4fe877e67 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -289,6 +289,9 @@ void WebContentsDelegateQt::DidUpdateFaviconURL(const std::vectorresetCandidates(); m_faviconManager->update(faviconCandidates); } -- cgit v1.2.3