From 8f0971a1425e5d322af576581e225e4d0e6e5313 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Tue, 13 Sep 2016 21:05:16 +0300 Subject: Plugin positioning for windows needs to honor QT_SCALE_FACTOR Change-Id: I20a896fea05f972e6cc1ebf8b716c7acb20b65d1 Reviewed-by: Konstantin Tokarev --- Source/WebCore/plugins/win/PluginViewWin.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Source/WebCore/plugins/win/PluginViewWin.cpp b/Source/WebCore/plugins/win/PluginViewWin.cpp index b225673ab..6a34dc33c 100644 --- a/Source/WebCore/plugins/win/PluginViewWin.cpp +++ b/Source/WebCore/plugins/win/PluginViewWin.cpp @@ -356,6 +356,20 @@ static inline bool isWebViewVisible(FrameView* view) #endif // PLATFORM(QT) } +static inline IntRect toDevicePixelRatio(FrameView* view, const IntRect & rect) +{ +#if PLATFORM(QT) + if (PlatformPageClient client = view->hostWindow()->platformPageClient()) { + if (QWindow* window = client->ownerWindow()) { + IntRect scaleRect = rect; + scaleRect.scale(window->devicePixelRatio()); + return scaleRect; + } + } +#endif + return rect; +} + static inline IntPoint contentsToNativeWindow(FrameView* view, const IntPoint& point) { #if PLATFORM(QT) @@ -465,6 +479,7 @@ void PluginView::updatePluginWidget() #endif m_clipRect = windowClipRect(); m_clipRect.move(-m_windowRect.x(), -m_windowRect.y()); + IntRect scaledClipRect(toDevicePixelRatio(frameView, m_clipRect)); if (platformPluginWidget() && (!m_haveUpdatedPluginWidget || m_windowRect != oldWindowRect || m_clipRect != oldClipRect)) { HRGN rgn; @@ -479,17 +494,18 @@ void PluginView::updatePluginWidget() rgn = ::CreateRectRgn(0, 0, 0, 0); ::SetWindowRgn(platformPluginWidget(), rgn, FALSE); } else { - rgn = ::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY()); + rgn = ::CreateRectRgn(scaledClipRect.x(), scaledClipRect.y(), scaledClipRect.maxX(), scaledClipRect.maxY()); ::SetWindowRgn(platformPluginWidget(), rgn, TRUE); } if (!m_haveUpdatedPluginWidget || m_windowRect != oldWindowRect) { IntRect nativeWindowRect = contentsToNativeWindow(frameView, frameRect()); + nativeWindowRect = IntRect(toDevicePixelRatio(frameView, nativeWindowRect)); ::MoveWindow(platformPluginWidget(), nativeWindowRect.x(), nativeWindowRect.y(), nativeWindowRect.width(), nativeWindowRect.height(), TRUE); } if (clipToZeroRect) { - rgn = ::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY()); + rgn = ::CreateRectRgn(scaledClipRect.x(), scaledClipRect.y(), scaledClipRect.maxX(), scaledClipRect.maxY()); ::SetWindowRgn(platformPluginWidget(), rgn, TRUE); } @@ -839,11 +855,14 @@ void PluginView::setParentVisible(bool visible) } } -void PluginView::setNPWindowRect(const IntRect& rect) +void PluginView::setNPWindowRect(const IntRect& winRect) { if (!m_isStarted) return; + ASSERT(parent()->isFrameView()); + IntRect rect(toDevicePixelRatio(toFrameView(parent()), winRect)); + #if OS(WINCE) IntRect r = toFrameView(parent())->contentsToWindow(rect); m_npWindow.x = r.x(); -- cgit v1.2.1