Bug 1240533 - Parameters to ScreenForRect need to be passed as desktop pixels, not device pixels. r=emk
authorJonathan Kew <jkew@mozilla.com>
Fri, 19 Feb 2016 21:20:57 +0000
changeset 285259 bf6afee1a737301d1df572dc99a941a3008167b9
parent 285258 7926861aed22d8853401556dd59156fe55616cfb
child 285260 f1eb5abe525ed540337e9f4d2ce85ec787daa810
push id19612
push usergwagner@mozilla.com
push dateWed, 09 Mar 2016 16:35:37 +0000
treeherderb2g-inbound@3e95b2a351a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs1240533
milestone47.0a1
Bug 1240533 - Parameters to ScreenForRect need to be passed as desktop pixels, not device pixels. r=emk
layout/xul/nsMenuPopupFrame.cpp
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -1548,19 +1548,22 @@ nsMenuPopupFrame::GetConstraintRect(cons
   // the content rather than the screen.
   nsCOMPtr<nsIScreen> screen;
   nsCOMPtr<nsIScreenManager> sm(do_GetService("@mozilla.org/gfx/screenmanager;1"));
   if (sm) {
     // for content shells, get the screen where the root frame is located.
     // This is because we need to constrain the content to this content area,
     // so we should use the same screen. Otherwise, use the screen where the
     // anchor is located.
-    LayoutDeviceIntRect rect = mInContentShell ? aRootScreenRect : aAnchorRect;
-    int32_t width = std::max(1, rect.width);
-    int32_t height = std::max(1, rect.height);
+    DesktopToLayoutDeviceScale scale =
+      PresContext()->DeviceContext()->GetDesktopToDeviceScale();
+    DesktopRect rect =
+      (mInContentShell ? aRootScreenRect : aAnchorRect) / scale;
+    int32_t width = std::max(1, NSToIntRound(rect.width));
+    int32_t height = std::max(1, NSToIntRound(rect.height));
     sm->ScreenForRect(rect.x, rect.y, width, height, getter_AddRefs(screen));
     if (screen) {
       // Non-top-level popups (which will always be panels)
       // should never overlap the OS bar:
       bool dontOverlapOSBar = aPopupLevel != ePopupLevelTop;
       // get the total screen area if the popup is allowed to overlap it.
       if (!dontOverlapOSBar && mMenuCanOverlapOSBar && !mInContentShell)
         screen->GetRect(&screenRectPixels.x, &screenRectPixels.y,