Bug 824963 part 2 - Prevent flipping panels when panel is already oriented in the direction to be flipped. r=enn

This commit is contained in:
Mark Hammond 2013-04-19 10:47:27 +10:00
parent ab11667c8b
commit 6ac3505bed

View File

@ -1010,10 +1010,14 @@ nsMenuPopupFrame::FlipOrResize(nscoord& aScreenPoint, nscoord aSize,
popupSize = startpos - aScreenPoint - aMarginEnd;
}
else {
// flip such that the popup is to the right or bottom of the anchor
// point instead. However, when flipping use the same margin size.
// If the newly calculated position is different than the existing
// position, flip such that the popup is to the right or bottom of the
// anchor point instead . However, when flipping use the same margin
// size.
nscoord newScreenPoint = endpos + aMarginEnd;
if (newScreenPoint != aScreenPoint) {
*aFlipSide = true;
aScreenPoint = endpos + aMarginEnd;
aScreenPoint = newScreenPoint;
// check if the new position is still off the right or bottom edge of
// the screen. If so, resize the popup.
if (aScreenPoint + aSize > aScreenEnd) {
@ -1021,6 +1025,7 @@ nsMenuPopupFrame::FlipOrResize(nscoord& aScreenPoint, nscoord aSize,
}
}
}
}
else {
aScreenPoint = aScreenBegin;
}
@ -1045,10 +1050,13 @@ nsMenuPopupFrame::FlipOrResize(nscoord& aScreenPoint, nscoord aSize,
}
}
else {
// flip such that the popup is to the left or top of the anchor point
// instead.
// if the newly calculated position is different than the existing
// position, we flip such that the popup is to the left or top of the
// anchor point instead.
nscoord newScreenPoint = startpos - aSize - aMarginBegin - aOffsetForContextMenu;
if (newScreenPoint != aScreenPoint) {
*aFlipSide = true;
aScreenPoint = startpos - aSize - aMarginBegin - aOffsetForContextMenu;
aScreenPoint = newScreenPoint;
// check if the new position is still off the left or top edge of the
// screen. If so, resize the popup.
@ -1060,6 +1068,7 @@ nsMenuPopupFrame::FlipOrResize(nscoord& aScreenPoint, nscoord aSize,
}
}
}
}
else {
aScreenPoint = aScreenEnd - aSize;
}