Backed out changeset 83ba2c6e25eb because of bug 514891
authorDão Gottwald <dao@mozilla.com>
Mon, 07 Sep 2009 14:17:30 +0200
changeset 32282 ce62745a7c9c72cd51034b9f9710af3d2e45d038
parent 32229 83ba2c6e25eb1fb9f3962eebeb4e041176133fb9
child 32283 28930fd5b4f6ba67cbc5d4b806aae1c6938d8fb9
push id8967
push userdgottwald@mozilla.com
push dateMon, 07 Sep 2009 12:18:27 +0000
treeherdermozilla-central@28930fd5b4f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs514891
milestone1.9.3a1pre
backs out83ba2c6e25eb1fb9f3962eebeb4e041176133fb9
Backed out changeset 83ba2c6e25eb because of bug 514891
layout/xul/base/src/nsMenuPopupFrame.cpp
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -953,18 +953,16 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
   PRBool hFlip = PR_FALSE, vFlip = PR_FALSE;
   
   nsMargin margin(0, 0, 0, 0);
   GetStyleMargin()->GetMargin(margin);
 
   // the screen rectangle of the root frame, in dev pixels.
   nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();
 
-  nsCOMPtr<nsIScreenManager> screenManager(
-    do_GetService("@mozilla.org/gfx/screenmanager;1"));
   nsIDeviceContext* devContext = presContext->DeviceContext();
   nscoord offsetForContextMenu = 0;
   // if mScreenXPos and mScreenYPos are -1, then we are anchored. If they
   // have other values, then the popup appears unanchored at that screen
   // coordinate.
   if (mScreenXPos == -1 && mScreenYPos == -1) {
     // if we are anchored, there are certain things we don't want to do when
     // repositioning the popup to fit on the screen, such as end up positioned
@@ -1009,37 +1007,16 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
       offsetForContextMenu = presContext->DevPixelsToAppUnits(offsetForContextMenuDev);
     }
 
     // next, convert into app units accounting for the scaling
     screenPoint.x = presContext->DevPixelsToAppUnits(
                       nsPresContext::CSSPixelsToAppUnits(mScreenXPos) / factor);
     screenPoint.y = presContext->DevPixelsToAppUnits(
                       nsPresContext::CSSPixelsToAppUnits(mScreenYPos) / factor);
-
-    // The screen coordinates are relative to the screen that the window is on,
-    // so adjust them based on the topleft of the screen we are on so that they
-    // are in the absolute screen space.
-    if (screenManager) {
-      // get the screen that the root frame is on
-      nsCOMPtr<nsIScreen> screen;
-      screenManager->ScreenForRect(
-        presContext->AppUnitsToDevPixels(rootScreenRect.x),
-        presContext->AppUnitsToDevPixels(rootScreenRect.y),
-        presContext->AppUnitsToDevPixels(rootScreenRect.width),
-        presContext->AppUnitsToDevPixels(rootScreenRect.height),
-        getter_AddRefs(screen));
-      nsIntRect screenRectPixels;
-      screen->GetRect(&screenRectPixels.x, &screenRectPixels.y,
-                      &screenRectPixels.width, &screenRectPixels.height);
-      nsRect screenRect =
-        screenRectPixels.ToAppUnits(presContext->AppUnitsPerDevPixel());
-      screenPoint += screenRect.TopLeft();
-    }
-
     anchorRect = nsRect(screenPoint, nsSize(0, 0));
 
     // add the margins on the popup
     screenPoint.MoveBy(margin.left + offsetForContextMenu,
                        margin.top + offsetForContextMenu);
 
     // screen positioned popups can be flipped vertically but never horizontally
     vFlip = PR_TRUE;
@@ -1051,25 +1028,26 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
     hFlip = vFlip = PR_FALSE;
 
   // screenRect will hold the rectangle of the available screen space. It
   // will be reduced by the OS chrome such as menubars. It addition, for
   // content shells, it will be the area of the content rather than the
   // screen.
   nsIntRect screenRectPixels;
   nsCOMPtr<nsIScreen> screen;
-  if (screenManager) {
+  nsCOMPtr<nsIScreenManager> sm(do_GetService("@mozilla.org/gfx/screenmanager;1"));
+  if (sm) {
     // for context 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.
     nsPoint pnt = mInContentShell ? rootScreenRect.TopLeft() : anchorRect.TopLeft();
-    screenManager->ScreenForRect(presContext->AppUnitsToDevPixels(pnt.x),
-                                 presContext->AppUnitsToDevPixels(pnt.y),
-                                 1, 1, getter_AddRefs(screen));
+    sm->ScreenForRect(presContext->AppUnitsToDevPixels(pnt.x),
+                      presContext->AppUnitsToDevPixels(pnt.y),
+                      1, 1, getter_AddRefs(screen));
     if (screen) {
       if (mMenuCanOverlapOSBar)
         screen->GetRect(&screenRectPixels.x, &screenRectPixels.y,
                         &screenRectPixels.width, &screenRectPixels.height);
       else
         screen->GetAvailRect(&screenRectPixels.x, &screenRectPixels.y,
                              &screenRectPixels.width, &screenRectPixels.height);
     }