[Win] Popup menus have incorrect placement when device scale factor != 1.
authorpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Aug 2015 17:15:51 +0000 (17:15 +0000)
committerpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Aug 2015 17:15:51 +0000 (17:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147880

Reviewed by Brent Fulgham.

We need to take the device scaling factor into account when calculating
the position and size of the popup menu.

* platform/win/PopupMenuWin.cpp:
(WebCore::PopupMenuWin::calculatePositionAndSize):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/win/PopupMenuWin.cpp

index e897646..c1faabb 100644 (file)
@@ -1,3 +1,16 @@
+2015-08-11  Per Arne Vollan  <peavo@outlook.com>
+
+        [Win] Popup menus have incorrect placement when device scale factor != 1.
+        https://bugs.webkit.org/show_bug.cgi?id=147880
+
+        Reviewed by Brent Fulgham.
+
+        We need to take the device scaling factor into account when calculating
+        the position and size of the popup menu.
+
+        * platform/win/PopupMenuWin.cpp:
+        (WebCore::PopupMenuWin::calculatePositionAndSize):
+
 2015-08-11  Chris Dumez  <cdumez@apple.com>
 
         [WebIDL] All interface objects must have a property named "name"
index 1967fae..842c3cc 100644 (file)
@@ -288,7 +288,7 @@ void PopupMenuWin::calculatePositionAndSize(const IntRect& r, FrameView* v)
     IntRect absoluteBounds = ((RenderMenuList*)m_popupClient)->absoluteBoundingBoxRect();
     IntRect absoluteScreenCoords(v->contentsToWindow(absoluteBounds.location()), absoluteBounds.size());
     POINT absoluteLocation(absoluteScreenCoords.location());
-    if (!::ClientToScreen(v->hostWindow()->platformPageClient(), &absoluteLocation))
+    if (!::ClientToScreen(hostWindow, &absoluteLocation))
         return;
     absoluteScreenCoords.setLocation(absoluteLocation);
 
@@ -313,11 +313,15 @@ void PopupMenuWin::calculatePositionAndSize(const IntRect& r, FrameView* v)
     // r is in absolute document coordinates, but we want to be in screen coordinates.
 
     // First, move to WebView coordinates
-    IntRect rScreenCoords(v->contentsToWindow(r.location()), r.size());
+    IntRect rScaled = r;
+    Page* page = v->frame().page();
+    if (page)
+        rScaled.scale(page->deviceScaleFactor());
+    IntRect rScreenCoords(v->contentsToWindow(rScaled.location()), rScaled.size());
 
     // Then, translate to screen coordinates
     POINT location(rScreenCoords.location());
-    if (!::ClientToScreen(v->hostWindow()->platformPageClient(), &location))
+    if (!::ClientToScreen(hostWindow, &location))
         return;
 
     rScreenCoords.setLocation(location);