Bug 1358713, when a popup's anchor does not have a frame originally, don't have the popup update its position to follow it, r=tn

This commit is contained in:
Neil Deakin 2017-05-05 11:13:56 -04:00
Родитель 5d0885869a
Коммит 38846a0f8f
2 изменённых файлов: 31 добавлений и 5 удалений

Просмотреть файл

@ -2510,11 +2510,13 @@ nsMenuPopupFrame::ShouldFollowAnchor(nsRect& aRect)
}
nsIFrame* anchorFrame = mAnchorContent->GetPrimaryFrame();
if (anchorFrame) {
nsPresContext* rootPresContext = PresContext()->GetRootPresContext();
if (rootPresContext) {
aRect = ComputeAnchorRect(rootPresContext, anchorFrame);
}
if (!anchorFrame) {
return false;
}
nsPresContext* rootPresContext = PresContext()->GetRootPresContext();
if (rootPresContext) {
aRect = ComputeAnchorRect(rootPresContext, anchorFrame);
}
return true;

Просмотреть файл

@ -32,6 +32,9 @@
<menuitem label="Three"/>
</menupopup>
<button id="anchorhidden" label="HiddenAnchor" hidden="true"/>
<button id="anchorextra" label="ExtraAnchor"/>
<script type="application/javascript"><![CDATA[
Components.utils.import("resource://gre/modules/Task.jsm");
@ -140,6 +143,27 @@ function runTests() {
yield popuphidden;
yield menupopuphidden;
// A popup with a hidden anchor should not update
let anchorhidden = document.getElementById("anchorhidden");
popupshown = waitForPanel(panel, "popupshown");
panel.openPopup(anchorhidden, "after_start");
yield popupshown;
let oldtop = panel.getBoundingClientRect().top;
// Show and adjust anchors. The panel should not update or hide due to this.
anchorhidden.hidden = false;
document.getElementById("anchorextra").hidden = true;
yield new Promise(r => { SimpleTest.executeSoon(r); });
let newtop = panel.getBoundingClientRect().top;
is(panel.state, "open", "panel is still open after showing anchor");
is(oldtop, newtop, "panel top did not change after showing anchor");
popuphidden = waitForPanel(panel, "popuphidden");
panel.hidePopup();
yield popuphidden;
// The panel should no longer follow anchors.
panel.setAttribute("followanchor", "false");