Bug 966241, revert some of bug 941051 and just use Intersect instead of IntersectRect, r=neil a=dolske
authorNeil Deakin <neil@mozilla.com>
Thu, 06 Feb 2014 20:08:31 -0500
changeset 176896 0b3a6ee571577db08e7108b8c27c724d4f1837d0
parent 176895 ae9d9ec82186e02802d8fc734c5ef2b902fc8415
child 176897 b9b50c584b38df45ef9e93823f788e55cbea3c7e
push id5192
push usermozilla@noorenberghe.ca
push dateFri, 07 Feb 2014 06:57:15 +0000
treeherdermozilla-aurora@0b3a6ee57157 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil, dolske
bugs966241, 941051
milestone29.0a2
Bug 966241, revert some of bug 941051 and just use Intersect instead of IntersectRect, r=neil a=dolske
layout/xul/nsMenuPopupFrame.cpp
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -906,32 +906,32 @@ nsMenuPopupFrame::AdjustPositionForAncho
   }
 
   // first, determine at which corner of the anchor the popup should appear
   nsPoint pnt;
   switch (popupAnchor) {
     case POPUPALIGNMENT_LEFTCENTER:
       pnt = nsPoint(anchorRect.x, anchorRect.y + anchorRect.height / 2);
       anchorRect.y = pnt.y;
-      anchorRect.height = 1;
+      anchorRect.height = 0;
       break;
     case POPUPALIGNMENT_RIGHTCENTER:
       pnt = nsPoint(anchorRect.XMost(), anchorRect.y + anchorRect.height / 2);
       anchorRect.y = pnt.y;
-      anchorRect.height = 1;
+      anchorRect.height = 0;
       break;
     case POPUPALIGNMENT_TOPCENTER:
       pnt = nsPoint(anchorRect.x + anchorRect.width / 2, anchorRect.y);
       anchorRect.x = pnt.x;
-      anchorRect.width = 1;
+      anchorRect.width = 0;
       break;
     case POPUPALIGNMENT_BOTTOMCENTER:
       pnt = nsPoint(anchorRect.x + anchorRect.width / 2, anchorRect.YMost());
       anchorRect.x = pnt.x;
-      anchorRect.width = 1;
+      anchorRect.width = 0;
       break;
     case POPUPALIGNMENT_TOPRIGHT:
       pnt = anchorRect.TopRight();
       break;
     case POPUPALIGNMENT_BOTTOMLEFT:
       pnt = anchorRect.BottomLeft();
       break;
     case POPUPALIGNMENT_BOTTOMRIGHT:
@@ -1276,29 +1276,18 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
     vFlip = FlipStyle_Outside;
   }
 
   // If a panel is being moved or has flip="none", don't constrain or flip it. But always do this for
   // content shells, so that the popup doesn't extend outside the containing frame.
   if (mInContentShell || (mFlip != FlipType_None && (!aIsMove || mPopupType != ePopupTypePanel))) {
     nsRect screenRect = GetConstraintRect(anchorRect, rootScreenRect);
 
-    // ensure that anchorRect is on screen
-    if (!anchorRect.IntersectRect(anchorRect, screenRect)) {
-      anchorRect.width = anchorRect.height = 0;
-      // if the anchor isn't within the screen, move it to the edge of the screen.
-      if (anchorRect.x < screenRect.x)
-        anchorRect.x = screenRect.x;
-      if (anchorRect.XMost() > screenRect.XMost())
-        anchorRect.x = screenRect.XMost();
-      if (anchorRect.y < screenRect.y)
-        anchorRect.y = screenRect.y;
-      if (anchorRect.YMost() > screenRect.YMost())
-        anchorRect.y = screenRect.YMost();
-    }
+    // Ensure that anchorRect is on screen.
+    anchorRect = anchorRect.Intersect(screenRect);
 
     // shrink the the popup down if it is larger than the screen size
     if (mRect.width > screenRect.width)
       mRect.width = screenRect.width;
     if (mRect.height > screenRect.height)
       mRect.height = screenRect.height;
 
     // at this point the anchor (anchorRect) is within the available screen