Bug 1519952, replace calls to boxobject screenX and screenY with the equivalent on XULElement, r=paolo

This commit is contained in:
Neil Deakin 2019-02-15 15:26:17 -05:00
parent 65399694b4
commit 1a628e76c2
22 changed files with 80 additions and 82 deletions

View file

@ -30,8 +30,8 @@
getService(SpecialPowers.Ci.nsIAccessibilityService); getService(SpecialPowers.Ci.nsIAccessibilityService);
var treecol = document.getElementById("col"); var treecol = document.getElementById("col");
var x = treecol.boxObject.screenX; var x = treecol.screenX;
var y = treecol.boxObject.screenY; var y = treecol.screenY;
var tree = document.getElementById("tree"); var tree = document.getElementById("tree");
addA11yLoadEvent(accService, () => { addA11yLoadEvent(accService, () => {

View file

@ -4645,7 +4645,7 @@ var XULBrowserWindow = {
elt.label = tooltip; elt.label = tooltip;
elt.style.direction = direction; elt.style.direction = direction;
elt.openPopupAtScreen(browser.boxObject.screenX + x, browser.boxObject.screenY + y, false, null); elt.openPopupAtScreen(browser.screenX + x, browser.screenY + y, false, null);
}, },
hideTooltip() { hideTooltip() {

View file

@ -630,14 +630,14 @@
let leftTab = tabs[0]; let leftTab = tabs[0];
let rightTab = tabs[tabs.length - 1]; let rightTab = tabs[tabs.length - 1];
let rightMovingTabScreenX = movingTabs[movingTabs.length - 1].boxObject.screenX; let rightMovingTabScreenX = movingTabs[movingTabs.length - 1].screenX;
let leftMovingTabScreenX = movingTabs[0].boxObject.screenX; let leftMovingTabScreenX = movingTabs[0].screenX;
let translateX = screenX - draggedTab._dragData.screenX; let translateX = screenX - draggedTab._dragData.screenX;
if (!pinned) { if (!pinned) {
translateX += this.arrowScrollbox.scrollbox.scrollLeft - draggedTab._dragData.scrollX; translateX += this.arrowScrollbox.scrollbox.scrollLeft - draggedTab._dragData.scrollX;
} }
let leftBound = leftTab.boxObject.screenX - leftMovingTabScreenX; let leftBound = leftTab.screenX - leftMovingTabScreenX;
let rightBound = (rightTab.boxObject.screenX + rightTab.boxObject.width) - let rightBound = (rightTab.screenX + rightTab.boxObject.width) -
(rightMovingTabScreenX + tabWidth); (rightMovingTabScreenX + tabWidth);
translateX = Math.min(Math.max(translateX, leftBound), rightBound); translateX = Math.min(Math.max(translateX, leftBound), rightBound);
@ -672,11 +672,10 @@
let mid = Math.floor((low + high) / 2); let mid = Math.floor((low + high) / 2);
if (tabs[mid] == draggedTab && ++mid > high) if (tabs[mid] == draggedTab && ++mid > high)
break; break;
let boxObject = tabs[mid].boxObject; screenX = tabs[mid].screenX + getTabShift(tabs[mid], oldIndex);
screenX = boxObject.screenX + getTabShift(tabs[mid], oldIndex);
if (screenX > tabCenter) { if (screenX > tabCenter) {
high = mid - 1; high = mid - 1;
} else if (screenX + boxObject.width < tabCenter) { } else if (screenX + tabs[mid].getBoundingClientRect().width < tabCenter) {
low = mid + 1; low = mid + 1;
} else { } else {
newIndex = tabs[mid]._tPos; newIndex = tabs[mid]._tPos;
@ -998,8 +997,8 @@
let tab = event.target.localName == "tab" ? event.target : null; let tab = event.target.localName == "tab" ? event.target : null;
if (tab && isLink) { if (tab && isLink) {
let boxObject = tab.boxObject; let boxObject = tab.boxObject;
if (event.screenX < boxObject.screenX + boxObject.width * .25 || if (event.screenX < tab.screenX + boxObject.width * .25 ||
event.screenX > boxObject.screenX + boxObject.width * .75) event.screenX > tab.screenX + boxObject.width * .75)
return null; return null;
} }
return tab; return tab;
@ -1014,11 +1013,11 @@
var tab = this._getDragTargetTab(event, isLink); var tab = this._getDragTargetTab(event, isLink);
if (!RTL_UI) { if (!RTL_UI) {
for (let i = tab ? tab._tPos : 0; i < tabs.length; i++) for (let i = tab ? tab._tPos : 0; i < tabs.length; i++)
if (event.screenX < tabs[i].boxObject.screenX + tabs[i].boxObject.width / 2) if (event.screenX < tabs[i].screenX + tabs[i].boxObject.width / 2)
return i; return i;
} else { } else {
for (let i = tab ? tab._tPos : 0; i < tabs.length; i++) for (let i = tab ? tab._tPos : 0; i < tabs.length; i++)
if (event.screenX > tabs[i].boxObject.screenX + tabs[i].boxObject.width / 2) if (event.screenX > tabs[i].screenX + tabs[i].boxObject.width / 2)
return i; return i;
} }
return tabs.length; return tabs.length;

View file

@ -1057,9 +1057,11 @@ var PanelMultiView = class extends AssociatedToNode {
// view based on the space that will be available. We cannot just use // view based on the space that will be available. We cannot just use
// window.screen.availTop and availHeight because these may return an // window.screen.availTop and availHeight because these may return an
// incorrect value when the window spans multiple screens. // incorrect value when the window spans multiple screens.
let anchorBox = this._panel.anchorNode.boxObject; let anchor = this._panel.anchorNode;
let screen = this._screenManager.screenForRect(anchorBox.screenX, let anchorBox = anchor.boxObject;
anchorBox.screenY,
let screen = this._screenManager.screenForRect(anchor.screenX,
anchor.screenY,
anchorBox.width, anchorBox.width,
anchorBox.height); anchorBox.height);
let availTop = {}, availHeight = {}; let availTop = {}, availHeight = {};
@ -1070,9 +1072,9 @@ var PanelMultiView = class extends AssociatedToNode {
// based on whether the panel will open towards the top or the bottom. // based on whether the panel will open towards the top or the bottom.
let maxHeight; let maxHeight;
if (this._panel.alignmentPosition.startsWith("before_")) { if (this._panel.alignmentPosition.startsWith("before_")) {
maxHeight = anchorBox.screenY - cssAvailTop; maxHeight = anchor.screenY - cssAvailTop;
} else { } else {
let anchorScreenBottom = anchorBox.screenY + anchorBox.height; let anchorScreenBottom = anchor.screenY + anchorBox.height;
let cssAvailHeight = availHeight.value / screen.defaultCSSScaleFactor; let cssAvailHeight = availHeight.value / screen.defaultCSSScaleFactor;
maxHeight = cssAvailTop + cssAvailHeight - anchorScreenBottom; maxHeight = cssAvailTop + cssAvailHeight - anchorScreenBottom;
} }

View file

@ -68,13 +68,12 @@ add_task(async function testPopupSelectPopup() {
return {left: r.left, bottom: r.bottom}; return {left: r.left, bottom: r.bottom};
}); });
let {boxObject} = browser;
let popupRect = selectPopup.getOuterScreenRect(); let popupRect = selectPopup.getOuterScreenRect();
is(Math.floor(boxObject.screenX + elemRect.left), popupRect.left, is(Math.floor(browser.screenX + elemRect.left), popupRect.left,
"Select popup has the correct x origin"); "Select popup has the correct x origin");
is(Math.floor(boxObject.screenY + elemRect.bottom), popupRect.top, is(Math.floor(browser.screenY + elemRect.bottom), popupRect.top,
"Select popup has the correct y origin"); "Select popup has the correct y origin");
// Close the select popup before proceeding to the next test. // Close the select popup before proceeding to the next test.

View file

@ -438,10 +438,10 @@
let newMarginTop = 0; let newMarginTop = 0;
if (scrollDir == 0) { if (scrollDir == 0) {
let elt = this.firstElementChild; let elt = this.firstElementChild;
while (elt && event.screenY > elt.boxObject.screenY + while (elt && event.screenY > elt.screenY +
elt.boxObject.height / 2) elt.boxObject.height / 2)
elt = elt.nextElementSibling; elt = elt.nextElementSibling;
newMarginTop = elt ? elt.boxObject.screenY - scrollbox.screenY : newMarginTop = elt ? elt.screenY - this._scrollBox.screenY :
scrollbox.height; scrollbox.height;
} else if (scrollDir == 1) } else if (scrollDir == 1)
newMarginTop = scrollbox.height; newMarginTop = scrollbox.height;

View file

@ -9,14 +9,14 @@ add_task(async function() {
.QueryInterface(Ci.nsIBaseWindow) .QueryInterface(Ci.nsIBaseWindow)
.devicePixelsPerDesktopPixel; .devicePixelsPerDesktopPixel;
let {bounds, rects} = TestRunner._findBoundingBox(["#tabbrowser-tabs"]); let {bounds, rects} = TestRunner._findBoundingBox(["#tabbrowser-tabs"]);
let element = document.querySelector("#tabbrowser-tabs"); let tabBar = document.querySelector("#tabbrowser-tabs");
let tabBar = element.ownerDocument.getBoxObjectFor(element); let tabBarRect = tabBar.getBoundingClientRect();
// Calculate expected values // Calculate expected values
let expectedLeft = scale * (tabBar.screenX - TestRunner.croppingPadding); let expectedLeft = scale * (tabBar.screenX - TestRunner.croppingPadding);
let expectedTop = scale * (tabBar.screenY - TestRunner.croppingPadding); let expectedTop = scale * (tabBar.screenY - TestRunner.croppingPadding);
let expectedRight = scale * (tabBar.width + TestRunner.croppingPadding * 2) + expectedLeft; let expectedRight = scale * (tabBarRect.width + TestRunner.croppingPadding * 2) + expectedLeft;
let expectedBottom = scale * (tabBar.height + TestRunner.croppingPadding * 2) + expectedTop; let expectedBottom = scale * (tabBarRect.height + TestRunner.croppingPadding * 2) + expectedTop;
// Calculate browser region // Calculate browser region
let windowLeft = window.screenX * scale; let windowLeft = window.screenX * scale;
@ -48,21 +48,21 @@ add_task(async function() {
bounds = result.bounds; bounds = result.bounds;
rects = result.rects; rects = result.rects;
element = document.querySelector("#TabsToolbar"); let tabToolbar = document.querySelector("#TabsToolbar");
let tabToolbar = element.ownerDocument.getBoxObjectFor(element); let tabToolbarRect = tabToolbar.getBoundingClientRect();
element = document.querySelector("#forward-button"); let fButton = document.querySelector("#forward-button");
let fButton = element.ownerDocument.getBoxObjectFor(element); let fButtonRect = fButton.getBoundingClientRect();
// Calculate expected values // Calculate expected values
expectedLeft = scale * (Math.min(tabToolbar.screenX, fButton.screenX) expectedLeft = scale * (Math.min(tabToolbar.screenX, fButton.screenX)
- TestRunner.croppingPadding); - TestRunner.croppingPadding);
expectedTop = scale * (Math.min(tabToolbar.screenY, fButton.screenY) expectedTop = scale * (Math.min(tabToolbar.screenY, fButton.screenY)
- TestRunner.croppingPadding); - TestRunner.croppingPadding);
expectedRight = scale * (Math.max(tabToolbar.width + tabToolbar.screenX, expectedRight = scale * (Math.max(tabToolbarRect.width + tabToolbar.screenX,
fButton.width + fButton.screenX) fButtonRect.width + fButton.screenX)
+ TestRunner.croppingPadding); + TestRunner.croppingPadding);
expectedBottom = scale * (Math.max(tabToolbar.height + tabToolbar.screenY, expectedBottom = scale * (Math.max(tabToolbarRect.height + tabToolbar.screenY,
fButton.height + fButton.screenY) fButtonRect.height + fButton.screenY)
+ TestRunner.croppingPadding ); + TestRunner.croppingPadding );
// Adjust values based on browser window // Adjust values based on browser window
@ -81,13 +81,13 @@ add_task(async function() {
is(rects[0].left, Math.max(scale * (fButton.screenX - TestRunner.croppingPadding), windowLeft), is(rects[0].left, Math.max(scale * (fButton.screenX - TestRunner.croppingPadding), windowLeft),
"Checking single selector's left position when _findBoundingBox has multiple selectors"); "Checking single selector's left position when _findBoundingBox has multiple selectors");
// Check single selector's right position // Check single selector's right position
is(rects[0].right, Math.min(scale * (fButton.width + fButton.screenX + TestRunner.croppingPadding), windowRight), is(rects[0].right, Math.min(scale * (fButtonRect.width + fButton.screenX + TestRunner.croppingPadding), windowRight),
"Checking single selector's right position when _findBoundingBox has multiple selectors"); "Checking single selector's right position when _findBoundingBox has multiple selectors");
// Check single selector's top position // Check single selector's top position
is(rects[0].top, Math.max(scale * (fButton.screenY - TestRunner.croppingPadding), windowTop), is(rects[0].top, Math.max(scale * (fButton.screenY - TestRunner.croppingPadding), windowTop),
"Checking single selector's top position when _findBoundingBox has multiple selectors"); "Checking single selector's top position when _findBoundingBox has multiple selectors");
// Check single selector's bottom position // Check single selector's bottom position
is(rects[0].bottom, Math.min(scale * (fButton.height + fButton.screenY + TestRunner.croppingPadding), windowBottom), is(rects[0].bottom, Math.min(scale * (fButtonRect.height + fButton.screenY + TestRunner.croppingPadding), windowBottom),
"Checking single selector's bottom position when _findBoundingBox has multiple selectors"); "Checking single selector's bottom position when _findBoundingBox has multiple selectors");
// Check that nonexistent selectors throws an exception // Check that nonexistent selectors throws an exception

View file

@ -257,9 +257,9 @@ var TestRunner = {
} }
// Calculate box region, convert to Rect // Calculate box region, convert to Rect
let box = element.ownerDocument.getBoxObjectFor(element); let elementRect = element.getBoundingClientRect();
let rect = new Rect(box.screenX * scale, box.screenY * scale, let rect = new Rect(element.screenX * scale, element.screenY * scale,
box.width * scale, box.height * scale); elementRect.width * scale, elementRect.height * scale);
rect.inflateFixed(this.croppingPadding * scale); rect.inflateFixed(this.croppingPadding * scale);
rect.left = Math.max(rect.left, windowLeft); rect.left = Math.max(rect.left, windowLeft);
rect.top = Math.max(rect.top, windowTop); rect.top = Math.max(rect.top, windowTop);

View file

@ -37,8 +37,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1224790
function click() { function click() {
// The bug is not reproducible with synthesizeMouseAtCenter. // The bug is not reproducible with synthesizeMouseAtCenter.
// Need to emulate native mouse event. // Need to emulate native mouse event.
synthesizeNativeOSXClick(button.boxObject.screenX + button.boxObject.width / 2, synthesizeNativeOSXClick(button.screenX + button.boxObject.width / 2,
button.boxObject.screenY + button.boxObject.height / 2); button.screenY + button.boxObject.height / 2);
} }
click(); click();
// On debug build, it's possible that the click event handler is not // On debug build, it's possible that the click event handler is not

View file

@ -38,8 +38,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1224790
function click() { function click() {
// The bug is not reproducible with synthesizeMouseAtCenter. // The bug is not reproducible with synthesizeMouseAtCenter.
// Need to emulate native mouse event. // Need to emulate native mouse event.
synthesizeNativeOSXClick(button.boxObject.screenX + button.boxObject.width / 2, synthesizeNativeOSXClick(button.screenX + button.boxObject.width / 2,
button.boxObject.screenY + button.boxObject.height / 2); button.screenY + button.boxObject.height / 2);
} }
click(); click();
// On debug build, it's possible that the click event handler is not // On debug build, it's possible that the click event handler is not

View file

@ -40,10 +40,10 @@ function doTests()
is(window.devicePixelRatio, devPxPerCSSPx, "window.devicePixelRatio"); is(window.devicePixelRatio, devPxPerCSSPx, "window.devicePixelRatio");
var windowBO = document.documentElement.boxObject; var rootElement = document.documentElement;
isRounded(window.mozInnerScreenX*devPxPerCSSPx, windowBO.screenX, isRounded(window.mozInnerScreenX*devPxPerCSSPx, rootElement.screenX,
"window screen X"); "window screen X");
isRounded(window.mozInnerScreenY*devPxPerCSSPx, windowBO.screenY, isRounded(window.mozInnerScreenY*devPxPerCSSPx, rootElement.screenY,
"window screen Y"); "window screen Y");
var f = document.getElementById("f"); var f = document.getElementById("f");

View file

@ -9,7 +9,7 @@
</head> </head>
<body> <body>
<!-- Use a XUL element here so we can get its boxObject.screenX/Y --> <!-- Use a XUL element here so we can get its screenX/Y -->
<hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1" <hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox style="width:100px;"></hbox><hbox id="h2"/> <hbox style="width:100px;"></hbox><hbox id="h2"/>

View file

@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<!-- Use a XUL element here so we can get its boxObject.screenX/Y --> <!-- Use a XUL element here so we can get its screenX/Y -->
<hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1" <hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox style="width:100px;"></hbox><hbox id="h2"/> <hbox style="width:100px;"></hbox><hbox id="h2"/>

View file

@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<!-- Use a XUL element here so we can get its boxObject.screenX/Y --> <!-- Use a XUL element here so we can get its screenX/Y -->
<hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1" <hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox style="width:100px;"></hbox><hbox id="h2"/> <hbox style="width:100px;"></hbox><hbox id="h2"/>

View file

@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<!-- Use a XUL element here so we can get its boxObject.screenX/Y --> <!-- Use a XUL element here so we can get its screenX/Y -->
<hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1" <hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox style="width:100px;"></hbox><hbox id="h2"/> <hbox style="width:100px;"></hbox><hbox id="h2"/>

View file

@ -131,7 +131,7 @@ checkClipRegionNoBounds = function checkClipRegionNoBounds(id, rects) {
function loaded() { function loaded() {
var h1 = document.getElementById("h1"); var h1 = document.getElementById("h1");
var h2 = document.getElementById("h2"); var h2 = document.getElementById("h2");
var hwidth = h2.boxObject.screenX - h1.boxObject.screenX; var hwidth = h2.screenX - h1.screenX;
if (hwidth != 100) { if (hwidth != 100) {
// Maybe it's a DPI issue // Maybe it's a DPI issue
todo(false, "Unexpected DPI?"); todo(false, "Unexpected DPI?");
@ -148,8 +148,8 @@ function loaded() {
} }
var bounds = h1.getBoundingClientRect(); var bounds = h1.getBoundingClientRect();
windowFrameX = h1.boxObject.screenX - bounds.left - window.screenX; windowFrameX = h1.screenX - bounds.left - window.screenX;
windowFrameY = h1.boxObject.screenY - bounds.top - window.screenY; windowFrameY = h1.screenY - bounds.top - window.screenY;
// Run actual test code // Run actual test code
runTests(); runTests();

View file

@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<!-- Use a XUL element here so we can get its boxObject.screenX/Y --> <!-- Use a XUL element here so we can get its screenX/Y -->
<hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1" <hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox style="width:100px;"></hbox><hbox id="h2"/> <hbox style="width:100px;"></hbox><hbox id="h2"/>
@ -41,7 +41,7 @@ function checkGeometry(id, x, y, w, h) {
function runTests() { function runTests() {
var h1 = document.getElementById("h1"); var h1 = document.getElementById("h1");
var h2 = document.getElementById("h2"); var h2 = document.getElementById("h2");
var hwidth = h2.boxObject.screenX - h1.boxObject.screenX; var hwidth = h2.screenX - h1.screenX;
if (hwidth != 100) { if (hwidth != 100) {
// Maybe it's a DPI issue // Maybe it's a DPI issue
todo(false, "Unexpected DPI?"); todo(false, "Unexpected DPI?");
@ -56,8 +56,8 @@ function runTests() {
} }
var bounds = h1.getBoundingClientRect(); var bounds = h1.getBoundingClientRect();
windowFrameX = h1.boxObject.screenX - bounds.left - window.screenX; windowFrameX = h1.screenX - bounds.left - window.screenX;
windowFrameY = h1.boxObject.screenY - bounds.top - window.screenY; windowFrameY = h1.screenY - bounds.top - window.screenY;
checkGeometry("p", 0, 0, 200, 200); checkGeometry("p", 0, 0, 200, 200);
// This one tests widget positioning in the presence of borders and padding // This one tests widget positioning in the presence of borders and padding

View file

@ -77,16 +77,16 @@ function openContextMenu() {
var mouseY = 10; var mouseY = 10;
menu = win.document.getElementById("menu"); menu = win.document.getElementById("menu");
var screenX = menu.boxObject.screenX; var screenX = menu.screenX;
var screenY = menu.boxObject.screenY; var screenY = menu.screenY;
var utils = win.windowUtils; var utils = win.windowUtils;
utils.sendMouseEvent("contextmenu", mouseX, mouseY, 2, 0, 0); utils.sendMouseEvent("contextmenu", mouseX, mouseY, 2, 0, 0);
var interval = setInterval(checkMoved, 200); var interval = setInterval(checkMoved, 200);
function checkMoved() { function checkMoved() {
if (menu.boxObject.screenX != screenX || if (menu.screenX != screenX ||
menu.boxObject.screenY != screenY) { menu.screenY != screenY) {
clearInterval(interval); clearInterval(interval);
// Wait further to check that the window does not move again. // Wait further to check that the window does not move again.
setTimeout(checkPosition, 1000); setTimeout(checkPosition, 1000);
@ -94,12 +94,11 @@ function openContextMenu() {
} }
function checkPosition() { function checkPosition() {
var menubox = menu.boxObject; var rootElement = win.document.documentElement;
var winbox = win.document.documentElement.boxObject;
var platformIsMac = navigator.userAgent.indexOf("Mac") > -1; var platformIsMac = navigator.userAgent.indexOf("Mac") > -1;
var x = menubox.screenX - winbox.screenX; var x = menu.screenX - rootElement.screenX;
var y = menubox.screenY - winbox.screenY; var y = menu.screenY - rootElement.screenY;
if (platformIsMac) if (platformIsMac)
{ {
@ -122,7 +121,7 @@ function openContextMenu() {
ok(x < mouseX, ok(x < mouseX,
"menu left " + x + " should be left of click point " + mouseX); "menu left " + x + " should be left of click point " + mouseX);
var right = x + menubox.width; var right = x + menu.boxObject.width;
if (platformIsMac) { if (platformIsMac) {
// Rather than be constrained by the right hand screen edge, OSX menus flip // Rather than be constrained by the right hand screen edge, OSX menus flip

View file

@ -52,7 +52,7 @@ function popupshown()
popup.moveToAnchor($("button2"), "after_start", 5, 4); popup.moveToAnchor($("button2"), "after_start", 5, 4);
checkCoords(popup, button2rect.left + 5, button2rect.bottom + 4, "move button2 left + 5, top + 4"); checkCoords(popup, button2rect.left + 5, button2rect.bottom + 4, "move button2 left + 5, top + 4");
popup.moveTo($("button1").boxObject.screenX + 10, $("button1").boxObject.screenY + 12); popup.moveTo($("button1").screenX + 10, $("button1").screenY + 12);
checkCoords(popup, button1rect.left + 10, button1rect.top + 12, "move to button1 screen with offset"); checkCoords(popup, button1rect.left + 10, button1rect.top + 12, "move to button1 screen with offset");
popup.moveToAnchor($("button1"), "after_start", 1, 2); popup.moveToAnchor($("button1"), "after_start", 1, 2);

View file

@ -46,21 +46,21 @@ function setScale(win, scale)
function shown() function shown()
{ {
var popup = $("popup");
if (screenTest) { if (screenTest) {
var box = $("popup").boxObject; is(popup.screenX, screenx, "screen left position");
is(box.screenX, screenx, "screen left position"); is(popup.screenY, screeny, "screen top position");
is(box.screenY, screeny, "screen top position");
} }
else { else {
var anchor = $("frame").contentDocument.getElementById("two"); var anchor = $("frame").contentDocument.getElementById("two");
is(Math.round(anchor.getBoundingClientRect().left * 2), is(Math.round(anchor.getBoundingClientRect().left * 2),
Math.round($("popup").getBoundingClientRect().left), "anchored left position"); Math.round(popup.getBoundingClientRect().left), "anchored left position");
is(Math.round(anchor.getBoundingClientRect().bottom * 2), is(Math.round(anchor.getBoundingClientRect().bottom * 2),
Math.round($("popup").getBoundingClientRect().top), "anchored top position"); Math.round(popup.getBoundingClientRect().top), "anchored top position");
} }
$("popup").hidePopup(); popup.hidePopup();
} }
function nextTest() function nextTest()
@ -71,13 +71,13 @@ function nextTest()
} }
else { else {
screenTest = true; screenTest = true;
var box = document.documentElement.boxObject; var rootElement = document.documentElement;
// - the iframe is at 4×, but out here css pixels are only 2× device pixels // - the iframe is at 4×, but out here css pixels are only 2× device pixels
// - the popup manager rounds off (or truncates) the coordinates to // - the popup manager rounds off (or truncates) the coordinates to
// integers, so ensure we pass in even numbers to openPopupAtScreen // integers, so ensure we pass in even numbers to openPopupAtScreen
screenx = (x = even(box.screenX + 120))/2; screenx = (x = even(rootElement.screenX + 120))/2;
screeny = (y = even(box.screenY + 120))/2; screeny = (y = even(rootElement.screenY + 120))/2;
setScale(window, 2); setScale(window, 2);
$("popup").openPopupAtScreen(x, y); $("popup").openPopupAtScreen(x, y);
} }

View file

@ -60,8 +60,7 @@ function nextTest()
step = "open near bottom"; step = "open near bottom";
// request that the menu be opened with a target point near the bottom of the window, // request that the menu be opened with a target point near the bottom of the window,
// so that the menu's top margin will push it completely outside the window. // so that the menu's top margin will push it completely outside the window.
var bo = document.documentElement.boxObject; popup.setAttribute("top", document.documentElement.screenY + window.innerHeight - 5);
popup.setAttribute("top", bo.screenY + window.innerHeight - 5);
synthesizeMouse(menu, 2, 2, { }); synthesizeMouse(menu, 2, 2, { });
break; break;
case "open near bottom": case "open near bottom":

View file

@ -81,7 +81,7 @@ function popupShown(event)
var panel = event.target; var panel = event.target;
if (waitSteps > 0 && navigator.platform.includes("Linux") && if (waitSteps > 0 && navigator.platform.includes("Linux") &&
panel.boxObject.screenY == 210) { panel.screenY == 210) {
waitSteps--; waitSteps--;
setTimeout(popupShown, 10, event); setTimeout(popupShown, 10, event);
return; return;
@ -213,7 +213,7 @@ var tests = [
{ {
is(event.clientY, panelrect.top + 10, is(event.clientY, panelrect.top + 10,
"popup clientY"); "popup clientY");
is(event.screenY, panel.boxObject.screenY + 10, is(event.screenY, panel.screenY + 10,
"popup screenY"); "popup screenY");
is(event.originalTarget, panel.firstChild, "popup target"); is(event.originalTarget, panel.firstChild, "popup target");
gotMouseEvent = true; gotMouseEvent = true;