зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1216284 - Tooltips do not flip correctly on OSX. r=enndeakin
--HG-- extra : rebase_source : fb1847a65adfd3d80cd0dc45e30d49729d840eff
This commit is contained in:
Родитель
ea522455d5
Коммит
acd22ee0b8
|
@ -1413,10 +1413,15 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aS
|
|||
screenPoint.MoveBy(margin.left + offsetForContextMenu.x,
|
||||
margin.top + offsetForContextMenu.y);
|
||||
|
||||
// screen positioned popups can be flipped vertically but never horizontally
|
||||
#ifdef XP_MACOSX
|
||||
hFlip = FlipStyle_Outside;
|
||||
// OSX tooltips follow standard flip rule but other popups flip horizontally not vertically
|
||||
if (mPopupType == ePopupTypeTooltip) {
|
||||
vFlip = FlipStyle_Outside;
|
||||
} else {
|
||||
hFlip = FlipStyle_Outside;
|
||||
}
|
||||
#else
|
||||
// Other OS screen positioned popups can be flipped vertically but never horizontally
|
||||
vFlip = FlipStyle_Outside;
|
||||
#endif // #ifdef XP_MACOSX
|
||||
}
|
||||
|
|
|
@ -229,10 +229,72 @@ var popupTests = [
|
|||
is(gOriginalWidth, rect.right - rect.left, testname + " tooltip is original width");
|
||||
is(gOriginalHeight, rect.bottom - rect.top, testname + " tooltip is original height");
|
||||
}
|
||||
},
|
||||
{
|
||||
testname: "hover tooltip at bottom edge of screen",
|
||||
events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
|
||||
autohide: "thetooltip",
|
||||
condition: function() {
|
||||
// Only checking OSX here because on other platforms popups and tooltips behave the same way
|
||||
// when there's not enough space to show them below (by flipping vertically)
|
||||
// However, on OSX most popups are not flipped but tooltips are.
|
||||
return navigator.platform.indexOf("Mac") > -1;
|
||||
},
|
||||
test: function() {
|
||||
var buttonRect = document.getElementById("withtext").getBoundingClientRect();
|
||||
var windowY = screen.height -
|
||||
(window.mozInnerScreenY - window.screenY ) - buttonRect.bottom;
|
||||
|
||||
moveWindowTo(window.screenX, windowY, function() {
|
||||
gButton = document.getElementById("withtooltip");
|
||||
disableNonTestMouse(true);
|
||||
synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
|
||||
synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
|
||||
synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
|
||||
disableNonTestMouse(false);
|
||||
});
|
||||
},
|
||||
result: function(testname) {
|
||||
var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
|
||||
var rect = document.getElementById("thetooltip").getBoundingClientRect();
|
||||
var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), "");
|
||||
|
||||
is(Math.round(rect.y + rect.height),
|
||||
Math.round(buttonrect.top + 4 - parseFloat(popupstyle.marginTop)),
|
||||
testname + " position of tooltip above button");
|
||||
}
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
var waitSteps = 0;
|
||||
function moveWindowTo(x, y, callback, arg)
|
||||
{
|
||||
if (!waitSteps) {
|
||||
oldx = window.screenX;
|
||||
oldy = window.screenY;
|
||||
window.moveTo(x, y);
|
||||
|
||||
waitSteps++;
|
||||
setTimeout(moveWindowTo, 100, x, y, callback, arg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.screenX == oldx && window.screenY == oldy) {
|
||||
if (waitSteps++ > 10) {
|
||||
ok(false, "Window never moved properly to " + x + "," + y);
|
||||
window.opener.wrappedJSObject.SimpleTest.finish();
|
||||
window.close();
|
||||
}
|
||||
|
||||
setTimeout(moveWindowTo, 100, x, y, callback, arg);
|
||||
}
|
||||
else {
|
||||
waitSteps = 0;
|
||||
callback(arg);
|
||||
}
|
||||
}
|
||||
|
||||
window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTest, window);
|
||||
]]>
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче