summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2017-12-04 10:29:25 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2017-12-05 14:12:52 +0000
commitf7103bc5fd099dd0a0772ef28930dd368e9fcf47 (patch)
treea61648d44ba24b175055c408b9fc7a4c3952c0d2
parentf979b271e158bc93b7361d4b891ed49ee58ab865 (diff)
Fix Message Bubble position for High-DPI
Task-number: QTBUG-64812 Change-Id: I9df71253cf6c541622e431b1ff444fc49269d0c3 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/web_contents_delegate_qt.cpp22
1 files changed, 18 insertions, 4 deletions
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<RenderWidgetHostViewQt *>(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)