Bug 941051, use one pixel sized instead of zero pixel sized anchor rectangles to prevent it from being treated as empty during intersection with screen test, fixes arrow panel placement issues, r=neil

This commit is contained in:
Neil Deakin 2014-01-30 11:48:09 -05:00
parent 7e89cec279
commit 061f773e92
2 changed files with 17 additions and 12 deletions

View File

@ -904,22 +904,22 @@ nsMenuPopupFrame::AdjustPositionForAnchorAlign(nsRect& anchorRect,
case POPUPALIGNMENT_LEFTCENTER:
pnt = nsPoint(anchorRect.x, anchorRect.y + anchorRect.height / 2);
anchorRect.y = pnt.y;
anchorRect.height = 0;
anchorRect.height = 1;
break;
case POPUPALIGNMENT_RIGHTCENTER:
pnt = nsPoint(anchorRect.XMost(), anchorRect.y + anchorRect.height / 2);
anchorRect.y = pnt.y;
anchorRect.height = 0;
anchorRect.height = 1;
break;
case POPUPALIGNMENT_TOPCENTER:
pnt = nsPoint(anchorRect.x + anchorRect.width / 2, anchorRect.y);
anchorRect.x = pnt.x;
anchorRect.width = 0;
anchorRect.width = 1;
break;
case POPUPALIGNMENT_BOTTOMCENTER:
pnt = nsPoint(anchorRect.x + anchorRect.width / 2, anchorRect.YMost());
anchorRect.x = pnt.x;
anchorRect.width = 0;
anchorRect.width = 1;
break;
case POPUPALIGNMENT_TOPRIGHT:
pnt = anchorRect.TopRight();

View File

@ -231,26 +231,26 @@ function checkPanelPosition(panel)
case "top":
adj = vwinpos + parseInt(getComputedStyle(panel, "").marginTop);
if (iscentered)
adj += anchorRect.height / 2;
is(Math.round(panelRect.top), Math.round(anchorRect.top * zoomFactor + + adj), "anchored on top");
adj += Math.round(anchorRect.height) / 2;
isWithinHalfPixel(panelRect.top, anchorRect.top * zoomFactor + adj, "anchored on top");
break;
case "bottom":
adj = vwinpos + parseInt(getComputedStyle(panel, "").marginBottom);
if (iscentered)
adj += anchorRect.height / 2;
is(Math.round(panelRect.bottom), Math.round(anchorRect.bottom * zoomFactor + - adj), "anchored on bottom");
adj += Math.round(anchorRect.height) / 2;
isWithinHalfPixel(panelRect.bottom, anchorRect.bottom * zoomFactor - adj, "anchored on bottom");
break;
case "left":
adj = hwinpos + parseInt(getComputedStyle(panel, "").marginLeft);
if (iscentered)
adj += anchorRect.width / 2;
is(Math.round(panelRect.left), Math.round((anchorRect.left * zoomFactor + adj)), "anchored on left ");
adj += Math.round(anchorRect.width) / 2;
isWithinHalfPixel(panelRect.left, anchorRect.left * zoomFactor + adj, "anchored on left ");
break;
case "right":
adj = hwinpos + parseInt(getComputedStyle(panel, "").marginRight);
if (iscentered)
adj += anchorRect.width / 2;
is(Math.round(panelRect.right), Math.round(anchorRect.right * zoomFactor + - adj), "anchored on right");
adj += Math.round(anchorRect.width) / 2;
isWithinHalfPixel(panelRect.right, anchorRect.right * zoomFactor - adj, "anchored on right");
break;
}
@ -265,6 +265,11 @@ function checkPanelPosition(panel)
panel.hidePopup();
}
function isWithinHalfPixel(a, b)
{
return Math.abs(a - b) <= 0.5;
}
function checkBigPanel(panel)
{
ok(panel.firstChild.getBoundingClientRect().height < 2800, "big panel height");