[Win][HighDPI] Windowed plugins have incorrect placement.
authorpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Sep 2015 18:22:56 +0000 (18:22 +0000)
committerpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Sep 2015 18:22:56 +0000 (18:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149090

Reviewed by Alex Christensen.

We have to scale plugin dimensions with device scale factor.

* Plugins/PluginView.cpp:
(WebCore::PluginView::windowClipRect):
* Plugins/PluginView.h:
* Plugins/PluginViewWin.cpp:
(WebCore::PluginView::updatePluginWidget):
(WebCore::PluginView::setNPWindowRect):
(WebCore::PluginView::snapshot):
(WebCore::PluginView::deviceScaleFactor):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189919 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/win/ChangeLog
Source/WebKit/win/Plugins/PluginView.cpp
Source/WebKit/win/Plugins/PluginView.h
Source/WebKit/win/Plugins/PluginViewWin.cpp

index b24480e..4b51091 100644 (file)
@@ -1,3 +1,21 @@
+2015-09-17  Per Arne Vollan  <peavo@outlook.com>
+
+        [Win][HighDPI] Windowed plugins have incorrect placement.
+        https://bugs.webkit.org/show_bug.cgi?id=149090
+
+        Reviewed by Alex Christensen.
+
+        We have to scale plugin dimensions with device scale factor.
+
+        * Plugins/PluginView.cpp:
+        (WebCore::PluginView::windowClipRect):
+        * Plugins/PluginView.h:
+        * Plugins/PluginViewWin.cpp:
+        (WebCore::PluginView::updatePluginWidget):
+        (WebCore::PluginView::setNPWindowRect):
+        (WebCore::PluginView::snapshot):
+        (WebCore::PluginView::deviceScaleFactor):
+
 2015-09-15  Brent Fulgham  <bfulgham@apple.com>
 
         [Win] Provide a means for viewing the layer tree
index 114c0c4..6fa2a28 100644 (file)
@@ -127,7 +127,9 @@ IntRect PluginView::windowClipRect() const
     
     // Take our element and get the clip rect from the enclosing layer and frame view.
     FrameView* parentView = m_element->document().view();
-    clipRect.intersect(parentView->windowClipRectForFrameOwner(m_element, true));
+    IntRect windowClipRect = parentView->windowClipRectForFrameOwner(m_element, true);
+    windowClipRect.scale(deviceScaleFactor());
+    clipRect.intersect(windowClipRect);
 
     return clipRect;
 }
index c1d2f7b..e119fa4 100644 (file)
@@ -294,6 +294,8 @@ namespace WebCore {
         void paintIntoTransformedContext(HDC);
         PassRefPtr<Image> snapshot();
 
+        float deviceScaleFactor() const;
+
         int m_mode;
         int m_paramCount;
         char** m_paramNames;
index 11701f0..04a0c51 100644 (file)
@@ -366,6 +366,7 @@ void PluginView::updatePluginWidget()
     IntRect oldClipRect = m_clipRect;
 
     m_windowRect = IntRect(frameView.contentsToWindow(frameRect().location()), frameRect().size());
+    m_windowRect.scale(deviceScaleFactor());
     m_clipRect = windowClipRect();
     m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());
 
@@ -712,15 +713,22 @@ void PluginView::setNPWindowRect(const IntRect& rect)
     if (!m_isStarted)
         return;
 
+    float scaleFactor = deviceScaleFactor();
+
     IntPoint p = downcast<FrameView>(*parent()).contentsToWindow(rect.location());
+    p.scale(scaleFactor, scaleFactor);
+
+    IntSize s = rect.size();
+    s.scale(scaleFactor);
+
     m_npWindow.x = p.x();
     m_npWindow.y = p.y();
 
-    m_npWindow.width = rect.width();
-    m_npWindow.height = rect.height();
+    m_npWindow.width = s.width();
+    m_npWindow.height = s.height();
 
-    m_npWindow.clipRect.right = rect.width();
-    m_npWindow.clipRect.bottom = rect.height();
+    m_npWindow.clipRect.right = s.width();
+    m_npWindow.clipRect.bottom = s.height();
     m_npWindow.clipRect.left = 0;
     m_npWindow.clipRect.top = 0;
 
@@ -948,4 +956,23 @@ PassRefPtr<Image> PluginView::snapshot()
 #endif
 }
 
+float PluginView::deviceScaleFactor() const
+{
+    float scaleFactor = 1.0f;
+
+    if (!parent() || !parent()->isFrameView())
+        return scaleFactor;
+
+    // For windowless plugins, the device scale factor will be applied as for other page elements.
+    if (!m_isWindowed)
+        return scaleFactor;
+
+    FrameView& frameView = downcast<FrameView>(*parent());
+
+    if (frameView.frame().document())
+        scaleFactor = frameView.frame().document()->deviceScaleFactor();
+
+    return scaleFactor;
+}
+
 } // namespace WebCore