Bug 1823336 - [wayland] For unanchored popups don't read anchor / popup gravity. r=stransky

This matches the nsMenuPopupFrame code.

There are a few places where we want to fix our position, and I unified
how we do this in the regressing bug.

ShouldFollowAnchor() = false popups like this used to just not be repositioned directly:

  https://hg.mozilla.org/mozilla-central/rev/c15f0fb1c92375ea751b3916a4c25a34403f21b2#l9.274

IsNoAutoHide() popups fixed their position once:

  https://hg.mozilla.org/mozilla-central/rev/c15f0fb1c92375ea751b3916a4c25a34403f21b2#l9.867

I unified in the noautohide behavior but in a better place here:

  https://hg.mozilla.org/mozilla-central/rev/c15f0fb1c92375ea751b3916a4c25a34403f21b2#l9.1182

But this trips this Wayland code which wasn't treating AnchorType_Point
popups properly.

The fact that this popup doesn't follow the anchor feels wrong, but is
pre-existing.

Differential Revision: https://phabricator.services.mozilla.com/D173004
This commit is contained in:
Emilio Cobos Álvarez 2023-03-21 12:32:02 +00:00
Родитель 969e510983
Коммит eb1c40734b
1 изменённых файлов: 8 добавлений и 6 удалений

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

@ -2400,13 +2400,15 @@ nsWindow::WaylandPopupGetPositionFromLayout() {
const bool isTopContextMenu = mPopupContextMenu && !mPopupAnchored;
const bool isRTL = IsPopupDirectionRTL();
int8_t popupAlign(popupFrame->GetPopupAlignment());
int8_t anchorAlign(popupFrame->GetPopupAnchor());
if (isTopContextMenu) {
anchorAlign = POPUPALIGNMENT_BOTTOMRIGHT;
popupAlign = POPUPALIGNMENT_TOPLEFT;
const bool anchored = popupFrame->IsAnchored();
int8_t popupAlign = POPUPALIGNMENT_TOPLEFT;
int8_t anchorAlign = POPUPALIGNMENT_BOTTOMRIGHT;
if (anchored) {
// See nsMenuPopupFrame::AdjustPositionForAnchorAlign.
popupAlign = popupFrame->GetPopupAlignment();
anchorAlign = popupFrame->GetPopupAnchor();
}
if (isRTL) {
if (isRTL && (anchored || isTopContextMenu)) {
popupAlign = -popupAlign;
anchorAlign = -anchorAlign;
}