Bug 575328 - Fix for search suggestions box appears on wrong monitor in multiple monitor environment when window is maximized. r=enndeakin.

This commit is contained in:
Felipe Gomes 2010-08-02 10:06:04 -05:00
Родитель 332e0bc938
Коммит 184e83f7d3
3 изменённых файлов: 13 добавлений и 10 удалений

Просмотреть файл

@ -1157,7 +1157,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, PRBool aIsMove)
hFlip = vFlip = PR_FALSE; hFlip = vFlip = PR_FALSE;
} }
nsRect screenRect = GetConstraintRect(anchorRect.TopLeft(), rootScreenRect); nsRect screenRect = GetConstraintRect(anchorRect, rootScreenRect);
// ensure that anchorRect is on screen // ensure that anchorRect is on screen
if (!anchorRect.IntersectRect(anchorRect, screenRect)) { if (!anchorRect.IntersectRect(anchorRect, screenRect)) {
@ -1235,7 +1235,8 @@ nsMenuPopupFrame::GetCurrentMenuItem()
} }
nsRect nsRect
nsMenuPopupFrame::GetConstraintRect(nsPoint aAnchorPoint, nsRect& aRootScreenRect) nsMenuPopupFrame::GetConstraintRect(const nsRect& aAnchorRect,
const nsRect& aRootScreenRect)
{ {
nsIntRect screenRectPixels; nsIntRect screenRectPixels;
nsPresContext* presContext = PresContext(); 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, // 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 // so we should use the same screen. Otherwise, use the screen where the
// anchor is located. // anchor is located.
nsPoint pnt = mInContentShell ? aRootScreenRect.TopLeft() : aAnchorPoint; nsRect rect = mInContentShell ? aRootScreenRect : aAnchorRect;
sm->ScreenForRect(presContext->AppUnitsToDevPixels(pnt.x), PRInt32 width = rect.width > 0 ? presContext->AppUnitsToDevPixels(rect.width) : 1;
presContext->AppUnitsToDevPixels(pnt.y), PRInt32 height = rect.height > 0 ? presContext->AppUnitsToDevPixels(rect.height) : 1;
1, 1, getter_AddRefs(screen)); sm->ScreenForRect(presContext->AppUnitsToDevPixels(rect.x),
presContext->AppUnitsToDevPixels(rect.y),
width, height, getter_AddRefs(screen));
if (screen) { if (screen) {
// get the total screen area if the popup is allowed to overlap it. // get the total screen area if the popup is allowed to overlap it.
if (mMenuCanOverlapOSBar && !mInContentShell) if (mMenuCanOverlapOSBar && !mInContentShell)

Просмотреть файл

@ -293,12 +293,12 @@ public:
nsIScrollableFrame* GetScrollFrame(nsIFrame* aStart); 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 // 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, // area of the screen the popup should be displayed on. Content popups,
// however, will also be constrained by the content area, given by // however, will also be constrained by the content area, given by
// aRootScreenRect. All coordinates are in app units. // 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 // Determines whether the given edges of the popup may be moved, where
// aHorizontalSide and aVerticalSide are one of the NS_SIDE_* constants, or // aHorizontalSide and aVerticalSide are one of the NS_SIDE_* constants, or

Просмотреть файл

@ -227,11 +227,11 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
} }
} }
else if (menuPopupFrame) { else if (menuPopupFrame) {
nsPoint framePoint = menuPopupFrame->GetScreenRectInAppUnits().TopLeft(); nsRect frameRect = menuPopupFrame->GetScreenRectInAppUnits();
nsIFrame* rootFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame(); nsIFrame* rootFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame();
nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits(); 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 // 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 // than be too large. If the popup is too large it could get flipped
// to the opposite side of the anchor point while resizing. // to the opposite side of the anchor point while resizing.