зеркало из https://github.com/mozilla/gecko-dev.git
Bug 467442 - take transforms into account for popup placement, r=bz,f=tnikkel
--HG-- extra : rebase_source : fd3acd246c9bee79feba59ac382048848b059866
This commit is contained in:
Родитель
961881d5da
Коммит
ef353be5a0
|
@ -1156,15 +1156,22 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aS
|
|||
}
|
||||
}
|
||||
|
||||
// the dimensions of the anchor in its app units
|
||||
nsRect parentRect = aAnchorFrame->GetScreenRectInAppUnits();
|
||||
// In order to deal with transforms, possibly on an ancestor of the <iframe>
|
||||
// or <browser> containing our anchor, we need the root prescontext:
|
||||
nsPresContext* rootPresContext = presContext->GetRootPresContext();
|
||||
nsIFrame* referenceFrame = rootPresContext->FrameManager()->GetRootFrame();
|
||||
|
||||
// the anchor may be in a different document with a different scale,
|
||||
// so adjust the size so that it is in the app units of the popup instead
|
||||
// of the anchor.
|
||||
parentRect = parentRect.ConvertAppUnitsRoundOut(
|
||||
aAnchorFrame->PresContext()->AppUnitsPerDevPixel(),
|
||||
presContext->AppUnitsPerDevPixel());
|
||||
// the dimensions of the anchor
|
||||
nsRect parentRect = aAnchorFrame->GetRectRelativeToSelf();
|
||||
// Relative to the root
|
||||
parentRect = nsLayoutUtils::TransformFrameRectToAncestor(aAnchorFrame,
|
||||
parentRect,
|
||||
referenceFrame);
|
||||
// Relative to the screen
|
||||
parentRect.MoveBy(referenceFrame->GetScreenRectInAppUnits().TopLeft());
|
||||
// In its own app units
|
||||
parentRect.ConvertAppUnitsRoundOut(rootPresContext->AppUnitsPerDevPixel(),
|
||||
presContext->AppUnitsPerDevPixel());
|
||||
|
||||
// Set the popup's size to the preferred size. Below, this size will be
|
||||
// adjusted to fit on the screen or within the content area. If the anchor
|
||||
|
|
|
@ -9,6 +9,7 @@ support-files =
|
|||
[test_bug393970.xul]
|
||||
[test_bug398982-1.xul]
|
||||
[test_bug398982-2.xul]
|
||||
[test_bug467442.xul]
|
||||
[test_bug477754.xul]
|
||||
[test_bug703150.xul]
|
||||
[test_popupSizeTo.xul]
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=467442
|
||||
-->
|
||||
<window title="Mozilla Bug 467442"
|
||||
onload="onload()"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<popupset>
|
||||
<panel id="panel">
|
||||
Hello.
|
||||
</panel>
|
||||
</popupset>
|
||||
<hbox>
|
||||
<button id="anchor" label="Anchor hello on here" style="transform: translate(100px, 0)"/>
|
||||
</hbox>
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function onload() {
|
||||
/** Test for Bug 467442 **/
|
||||
let panel = document.getElementById("panel");
|
||||
let anchor = document.getElementById("anchor");
|
||||
|
||||
panel.addEventListener("popupshown", function onpopupshown() {
|
||||
panel.removeEventListener("popupshown", onpopupshown);
|
||||
let panelRect = panel.getBoundingClientRect();
|
||||
let anchorRect = anchor.getBoundingClientRect();
|
||||
is(panelRect.left, anchorRect.left, "Panel should be anchored to the button");
|
||||
panel.addEventListener("popuphidden", function onpopuphidden() {
|
||||
panel.removeEventListener("popuphidden", onpopuphidden);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
panel.hidePopup();
|
||||
});
|
||||
|
||||
panel.openPopup(anchor, "after_start", 0, 0, false, false);
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=467442"
|
||||
target="_blank">Mozilla Bug 467442</a>
|
||||
</body>
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче