diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 73a79806222..db2f74fa402 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -1157,7 +1157,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, PRBool aIsMove) hFlip = vFlip = PR_FALSE; } - nsRect screenRect = GetConstraintRect(anchorRect.TopLeft(), rootScreenRect); + nsRect screenRect = GetConstraintRect(anchorRect, rootScreenRect); // ensure that anchorRect is on screen if (!anchorRect.IntersectRect(anchorRect, screenRect)) { @@ -1235,7 +1235,8 @@ nsMenuPopupFrame::GetCurrentMenuItem() } nsRect -nsMenuPopupFrame::GetConstraintRect(nsPoint aAnchorPoint, nsRect& aRootScreenRect) +nsMenuPopupFrame::GetConstraintRect(const nsRect& aAnchorRect, + const nsRect& aRootScreenRect) { nsIntRect screenRectPixels; nsPresContext* presContext = PresContext(); @@ -1250,10 +1251,12 @@ nsMenuPopupFrame::GetConstraintRect(nsPoint aAnchorPoint, nsRect& aRootScreenRec // 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 ? aRootScreenRect.TopLeft() : aAnchorPoint; - sm->ScreenForRect(presContext->AppUnitsToDevPixels(pnt.x), - presContext->AppUnitsToDevPixels(pnt.y), - 1, 1, getter_AddRefs(screen)); + nsRect rect = mInContentShell ? aRootScreenRect : aAnchorRect; + PRInt32 width = rect.width > 0 ? presContext->AppUnitsToDevPixels(rect.width) : 1; + PRInt32 height = rect.height > 0 ? presContext->AppUnitsToDevPixels(rect.height) : 1; + sm->ScreenForRect(presContext->AppUnitsToDevPixels(rect.x), + presContext->AppUnitsToDevPixels(rect.y), + width, height, getter_AddRefs(screen)); if (screen) { // get the total screen area if the popup is allowed to overlap it. if (mMenuCanOverlapOSBar && !mInContentShell) diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index 2daeb98c006..bebe7723ad5 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -293,12 +293,12 @@ public: nsIScrollableFrame* GetScrollFrame(nsIFrame* aStart); - // For a popup that should appear at the given anchor point, determine + // For a popup that should appear anchored at the given rect, determine // the screen area that it is constrained by. This will be the available // area of the screen the popup should be displayed on. Content popups, // however, will also be constrained by the content area, given by // aRootScreenRect. All coordinates are in app units. - nsRect GetConstraintRect(nsPoint aAnchorPoint, nsRect& aRootScreenRect); + nsRect GetConstraintRect(const nsRect& aAnchorRect, const nsRect& aRootScreenRect); // Determines whether the given edges of the popup may be moved, where // aHorizontalSide and aVerticalSide are one of the NS_SIDE_* constants, or diff --git a/layout/xul/base/src/nsResizerFrame.cpp b/layout/xul/base/src/nsResizerFrame.cpp index da7fe4de9e0..5c955848a3b 100644 --- a/layout/xul/base/src/nsResizerFrame.cpp +++ b/layout/xul/base/src/nsResizerFrame.cpp @@ -227,11 +227,11 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext, } } else if (menuPopupFrame) { - nsPoint framePoint = menuPopupFrame->GetScreenRectInAppUnits().TopLeft(); + nsRect frameRect = menuPopupFrame->GetScreenRectInAppUnits(); nsIFrame* rootFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame(); nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits(); - nsRect screenRect = menuPopupFrame->GetConstraintRect(framePoint, rootScreenRect); + nsRect screenRect = menuPopupFrame->GetConstraintRect(frameRect, rootScreenRect); // round using ToInsidePixels as it's better to be a pixel too small // than be too large. If the popup is too large it could get flipped // to the opposite side of the anchor point while resizing.