зеркало из https://github.com/mozilla/gecko-dev.git
Bug 628238, arrow panels not positioned correctly when the page is zoomed, r=neil
--HG-- rename : toolkit/content/tests/widgets/test_arrowpanel.xul => toolkit/content/tests/chrome/test_arrowpanel.xul
This commit is contained in:
Родитель
0c777f178e
Коммит
d39a767665
|
@ -181,6 +181,7 @@ _TEST_FILES += \
|
|||
test_tree_hier_cell.xul \
|
||||
test_mousescroll.xul \
|
||||
test_mousecapture.xul \
|
||||
test_arrowpanel.xul \
|
||||
$(NULL)
|
||||
|
||||
# test_panel_focus.xul won't work if the Full Keyboard Access preference is set to
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
style="padding: 10px;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<stack flex="1">
|
||||
<label id="topleft" value="Top Left" left="15" top="15"/>
|
||||
|
@ -17,11 +19,12 @@
|
|||
<!-- Our SimpleTest/TestRunner.js runs tests inside an iframe which sizes are W=500 H=300.
|
||||
'left' and 'top' values need to be set so that the panel (popup) has enough room to display on its 4 sides. -->
|
||||
<label id="middle" value="+/- Centered" left="225" top="135"/>
|
||||
<iframe id="frame" src="data:text/html,<input id='input'>" width="100" height="100" left="225" top="180"/>
|
||||
<iframe id="frame" type="content"
|
||||
src="data:text/html,<input id='input'>" width="100" height="100" left="225" top="120"/>
|
||||
</stack>
|
||||
|
||||
<panel id="panel" type="arrow" onpopupshown="checkPanelPosition(this)" onpopuphidden="runNextTest.next()">
|
||||
<label id="panellabel" value="This is some text" height="80"/>
|
||||
<label id="panellabel" value="This is some text." height="65"/>
|
||||
</panel>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
@ -31,6 +34,7 @@ SimpleTest.waitForExplicitFinish();
|
|||
|
||||
var expectedAnchor = null;
|
||||
var expectedSide = "", expectedAnchorEdge = "";
|
||||
var zoomFactor = 1;
|
||||
var runNextTest;
|
||||
|
||||
function startTest()
|
||||
|
@ -118,28 +122,55 @@ function nextTest()
|
|||
openPopup("after_start", frames[0].document.getElementById("input"), "top", "left");
|
||||
yield;
|
||||
|
||||
setScale(frames[0], 1.5);
|
||||
openPopup("after_start", frames[0].document.getElementById("input"), "top", "left");
|
||||
yield;
|
||||
|
||||
setScale(frames[0], 2.5);
|
||||
openPopup("before_start", frames[0].document.getElementById("input"), "bottom", "left");
|
||||
yield;
|
||||
|
||||
setScale(frames[0], 1);
|
||||
|
||||
SimpleTest.finish();
|
||||
yield;
|
||||
}
|
||||
|
||||
function setScale(win, scale)
|
||||
{
|
||||
var wn = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation);
|
||||
var shell = wn.QueryInterface(Components.interfaces.nsIDocShell);
|
||||
var docViewer = shell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
|
||||
docViewer.fullZoom = scale;
|
||||
zoomFactor = scale;
|
||||
}
|
||||
|
||||
function checkPanelPosition(panel)
|
||||
{
|
||||
var anchor = panel.anchorNode;
|
||||
let anchor = panel.anchorNode;
|
||||
let adj = 0, hwinpos = 0, vwinpos = 0;
|
||||
if (anchor.ownerDocument != document) {
|
||||
var framerect = anchor.ownerDocument.defaultView.frameElement.getBoundingClientRect();
|
||||
hwinpos = framerect.left;
|
||||
vwinpos = framerect.top;
|
||||
}
|
||||
|
||||
var panelRect = panel.getBoundingClientRect();
|
||||
var anchorRect = anchor.getBoundingClientRect();
|
||||
var labelRect = $("panellabel").getBoundingClientRect();
|
||||
switch (expectedSide) {
|
||||
case "top":
|
||||
ok(labelRect.top > anchorRect.bottom + 5, "panel label is below");
|
||||
ok(labelRect.top > vwinpos + anchorRect.bottom * zoomFactor + 5, "panel label is below");
|
||||
break;
|
||||
case "bottom":
|
||||
ok(labelRect.bottom < anchorRect.top - 5, "panel label is above");
|
||||
ok(labelRect.bottom < vwinpos + anchorRect.top * zoomFactor - 5, "panel label is above");
|
||||
break;
|
||||
case "left":
|
||||
ok(labelRect.left > anchorRect.right + 5, "panel label is right");
|
||||
ok(labelRect.left > hwinpos + anchorRect.right * zoomFactor + 5, "panel label is right");
|
||||
break;
|
||||
case "right":
|
||||
ok(labelRect.right < anchorRect.left - 5, "panel label is left");
|
||||
ok(labelRect.right < hwinpos + anchorRect.left * zoomFactor - 5, "panel label is left");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -149,37 +180,30 @@ function checkPanelPosition(panel)
|
|||
iscentered = true;
|
||||
}
|
||||
|
||||
let adj = 0, hwinpos = 0, vwinpos = 0;
|
||||
if (anchor.ownerDocument != document) {
|
||||
var framerect = anchor.ownerDocument.defaultView.frameElement.getBoundingClientRect();
|
||||
hwinpos = framerect.left;
|
||||
vwinpos = framerect.top;
|
||||
}
|
||||
|
||||
switch (expectedAnchorEdge) {
|
||||
case "top":
|
||||
adj = vwinpos + parseInt(getComputedStyle(panel, "").marginTop);
|
||||
if (iscentered)
|
||||
adj += anchorRect.height / 2;
|
||||
is(Math.round(panelRect.top), Math.round(anchorRect.top + adj), "anchored on top");
|
||||
is(Math.round(panelRect.top), Math.round(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 - adj), "anchored on bottom");
|
||||
is(Math.round(panelRect.bottom), Math.round(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 + adj), "anchored on left ");
|
||||
is(Math.round(panelRect.left), Math.round((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 - adj), "anchored on right");
|
||||
is(Math.round(panelRect.right), Math.round(anchorRect.right * zoomFactor + - adj), "anchored on right");
|
||||
break;
|
||||
}
|
||||
|
|
@ -50,7 +50,6 @@ _CHROME_FILES = \
|
|||
$(NULL)
|
||||
|
||||
_TEST_FILES = \
|
||||
test_arrowpanel.xul \
|
||||
test_contextmenu_nested.xul \
|
||||
test_tree_column_reorder.xul \
|
||||
tree_shared.js \
|
||||
|
|
|
@ -349,7 +349,20 @@
|
|||
let anchorRight = anchorLeft + anchorRect.width;
|
||||
let anchorBottom = anchorTop + anchorRect.height;
|
||||
|
||||
const epsilon = 0.1;
|
||||
try {
|
||||
let anchorWindow = anchor.ownerDocument.defaultView;
|
||||
if (anchorWindow != window) {
|
||||
let utils = anchorWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
let spp = utils.screenPixelsPerCSSPixel;
|
||||
anchorLeft *= spp;
|
||||
anchorRight *= spp;
|
||||
anchorTop *= spp;
|
||||
anchorBottom *= spp;
|
||||
}
|
||||
} catch(ex) { }
|
||||
|
||||
const epsilon = 0.2;
|
||||
|
||||
var horizPos = smallerTo(popupRight, anchorLeft, epsilon) ? -1 : smallerTo(anchorRight, popupLeft, epsilon) ? 1 : 0;
|
||||
var vertPos = smallerTo(popupBottom, anchorTop, epsilon) ? -1 : smallerTo(anchorBottom, popupTop, epsilon) ? 1 : 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче