Bug 1788273 - Tweak popup alignment so that it looks good on mirrored wayland popups. r=dao,mak

When these panels had arrows, I guess the bottomcenter topleft alignment
made sense so that you could precisely align the arrow, but that's not
what we do now.

Don't use bottomcenter / leftcenter / rightcenter, since we really want
the sides to align.

This shouldn't change behavior on any platform except Linux + Wayland,
where the alignment looks good now in the case of bug 1784876.

Differential Revision: https://phabricator.services.mozilla.com/D156099
This commit is contained in:
Emilio Cobos Álvarez
2022-09-02 11:18:54 +00:00
parent 197428c9a8
commit 72c00adfaa
29 changed files with 32 additions and 173 deletions

View File

@@ -279,7 +279,7 @@ var gXPInstallObserver = {
if (gUnifiedExtensions.isEnabled) { if (gUnifiedExtensions.isEnabled) {
options.popupOptions = { options.popupOptions = {
position: "bottomcenter topright", position: "bottomright topright",
x: 2, x: 2,
y: 0, y: 0,
}; };
@@ -516,7 +516,7 @@ var gXPInstallObserver = {
if (gUnifiedExtensions.isEnabled) { if (gUnifiedExtensions.isEnabled) {
options.popupOptions = { options.popupOptions = {
position: "bottomcenter topright", position: "bottomright topright",
x: 2, x: 2,
y: 0, y: 0,
}; };

View File

@@ -344,7 +344,7 @@ var BrowserPageActions = {
let anchorNode = this.panelAnchorNodeForAction(action); let anchorNode = this.panelAnchorNodeForAction(action);
PanelMultiView.openPopup(panelNode, anchorNode, { PanelMultiView.openPopup(panelNode, anchorNode, {
position: "bottomcenter topright", position: "bottomright topright",
triggerEvent: event, triggerEvent: event,
}).catch(Cu.reportError); }).catch(Cu.reportError);
}, },
@@ -921,7 +921,7 @@ var BrowserPageActions = {
showPanel(event = null) { showPanel(event = null) {
this.panelNode.hidden = false; this.panelNode.hidden = false;
PanelMultiView.openPopup(this.panelNode, this.mainButtonNode, { PanelMultiView.openPopup(this.panelNode, this.mainButtonNode, {
position: "bottomcenter topright", position: "bottomright topright",
triggerEvent: event, triggerEvent: event,
}).catch(Cu.reportError); }).catch(Cu.reportError);
}, },

View File

@@ -284,7 +284,7 @@ var StarUI = {
isNewBookmark: this._isNewBookmark, isNewBookmark: this._isNewBookmark,
}); });
this.panel.openPopup(BookmarkingUI.anchor, "bottomcenter topright"); this.panel.openPopup(BookmarkingUI.anchor, "bottomright topright");
}, },
_createPanelIfNeeded() { _createPanelIfNeeded() {

View File

@@ -1204,7 +1204,7 @@ var gIdentityHandler = {
// Now open the popup, anchored off the primary chrome element // Now open the popup, anchored off the primary chrome element
PanelMultiView.openPopup(this._identityPopup, this._identityIconBox, { PanelMultiView.openPopup(this._identityPopup, this._identityIconBox, {
position: "bottomcenter topleft", position: "bottomleft topleft",
triggerEvent: event, triggerEvent: event,
}).catch(Cu.reportError); }).catch(Cu.reportError);
}, },

View File

@@ -37,7 +37,7 @@ var gPermissionPanel = {
* will be used as the anchor. * will be used as the anchor.
*/ */
_popupAnchorNode: null, _popupAnchorNode: null,
_popupPosition: "bottomcenter topleft", _popupPosition: "bottomleft topleft",
setAnchor(anchorNode, popupPosition) { setAnchor(anchorNode, popupPosition) {
this._popupAnchorNode = anchorNode; this._popupAnchorNode = anchorNode;
this._popupPosition = popupPosition; this._popupPosition = popupPosition;

View File

@@ -2175,7 +2175,7 @@ var gProtectionsHandler = {
this._protectionsPopup, this._protectionsPopup,
this._trackingProtectionIconContainer, this._trackingProtectionIconContainer,
{ {
position: "bottomcenter topleft", position: "bottomleft topleft",
triggerEvent: event, triggerEvent: event,
} }
).catch(Cu.reportError); ).catch(Cu.reportError);

View File

@@ -56,7 +56,7 @@ var gSharedTabWarning = {
); );
allowForSessionCheckbox.checked = false; allowForSessionCheckbox.checked = false;
panel.openPopup(tab, "bottomcenter topleft", 0, 0); panel.openPopup(tab, "bottomleft topleft", 0, 0);
return true; return true;
}, },

View File

@@ -291,7 +291,7 @@
hidden="true" hidden="true"
flip="slide" flip="slide"
orient="vertical" orient="vertical"
position="bottomcenter topleft"> position="bottomleft topleft">
<toolbarbutton id="sidebar-switcher-bookmarks" <toolbarbutton id="sidebar-switcher-bookmarks"
data-l10n-id="sidebar-menu-bookmarks" data-l10n-id="sidebar-menu-bookmarks"
class="subviewbutton" class="subviewbutton"
@@ -458,7 +458,7 @@
type="arrow" type="arrow"
hidden="true" hidden="true"
flip="slide" flip="slide"
position="bottomcenter topright" position="bottomright topright"
tabspecific="true" tabspecific="true"
noautofocus="true"> noautofocus="true">
<panelmultiview id="pageActionPanelMultiView" <panelmultiview id="pageActionPanelMultiView"
@@ -478,7 +478,7 @@
role="alert" role="alert"
type="arrow" type="arrow"
flip="slide" flip="slide"
position="bottomcenter topright" position="bottomright topright"
tabspecific="true" tabspecific="true"
noautofocus="true"> noautofocus="true">
<hbox id="confirmation-hint-checkmark-animation-container"> <hbox id="confirmation-hint-checkmark-animation-container">

View File

@@ -2670,12 +2670,12 @@ CustomizeMode.prototype = {
if (panelOnTheLeft) { if (panelOnTheLeft) {
// Tested in RTL, these get inverted automatically, so this does the // Tested in RTL, these get inverted automatically, so this does the
// right thing without taking RTL into account explicitly. // right thing without taking RTL into account explicitly.
position = "leftcenter topright"; position = "topleft topright";
if (toolbarContainer) { if (toolbarContainer) {
offsetX = 8; offsetX = 8;
} }
} else { } else {
position = "rightcenter topleft"; position = "topright topleft";
if (toolbarContainer) { if (toolbarContainer) {
offsetX = -8; offsetX = -8;
} }

View File

@@ -7,7 +7,7 @@
role="group" role="group"
type="arrow" type="arrow"
noautofocus="true" noautofocus="true"
position="bottomcenter topright" position="bottomright topright"
hidden="true"> hidden="true">
<panelmultiview mainViewId="widget-overflow-mainView"> <panelmultiview mainViewId="widget-overflow-mainView">
<panelview id="widget-overflow-mainView" <panelview id="widget-overflow-mainView"
@@ -67,7 +67,7 @@
<html:template id="panicButtonNotificationTemplate"> <html:template id="panicButtonNotificationTemplate">
<panel id="panic-button-success-notification" <panel id="panic-button-success-notification"
type="arrow" type="arrow"
position="bottomcenter topright" position="bottomright topright"
hidden="true" hidden="true"
role="alert" role="alert"
orient="vertical"> orient="vertical">
@@ -220,7 +220,7 @@
type="arrow" type="arrow"
hidden="true" hidden="true"
flip="slide" flip="slide"
position="bottomcenter topright" position="bottomright topright"
noautofocus="true"> noautofocus="true">
<panelmultiview id="appMenu-multiView" mainViewId="appMenu-protonMainView" <panelmultiview id="appMenu-multiView" mainViewId="appMenu-protonMainView"
viewCacheId="appMenu-viewCache"> viewCacheId="appMenu-viewCache">
@@ -233,7 +233,7 @@
role="group" role="group"
type="arrow" type="arrow"
flip="slide" flip="slide"
position="bottomcenter topright" position="bottomright topright"
tabspecific="true"> tabspecific="true">
<popupnotification id="extension-new-tab-notification" <popupnotification id="extension-new-tab-notification"
class="extension-controlled-notification" class="extension-controlled-notification"

View File

@@ -489,7 +489,7 @@ const PanelUI = {
try { try {
viewShown = await PanelMultiView.openPopup(tempPanel, anchor, { viewShown = await PanelMultiView.openPopup(tempPanel, anchor, {
position: "bottomcenter topright", position: "bottomright topright",
triggerEvent: aEvent, triggerEvent: aEvent,
}); });
} catch (ex) { } catch (ex) {
@@ -855,7 +855,7 @@ const PanelUI = {
el.removeAttribute("data-lazy-l10n-id"); el.removeAttribute("data-lazy-l10n-id");
}); });
this.notificationPanel.openPopup(anchor, "bottomcenter topright"); this.notificationPanel.openPopup(anchor, "bottomright topright");
}, },
_clearNotificationPanel() { _clearNotificationPanel() {

View File

@@ -85,7 +85,7 @@ async function openPopup(panelIndex, viewIndex) {
PanelMultiView.openPopup( PanelMultiView.openPopup(
gPanels[panelIndex], gPanels[panelIndex],
gPanelAnchors[panelIndex], gPanelAnchors[panelIndex],
"bottomcenter topright" "bottomright topright"
); );
await promiseShown; await promiseShown;
@@ -440,7 +440,7 @@ add_task(async function test_cancel_mainview_event_sequence() {
PanelMultiView.openPopup( PanelMultiView.openPopup(
gPanels[0], gPanels[0],
gPanelAnchors[0], gPanelAnchors[0],
"bottomcenter topright" "bottomright topright"
); );
await promiseHidden; await promiseHidden;
@@ -519,7 +519,7 @@ add_task(async function test_close_while_showing_mainview_event_sequence() {
PanelMultiView.openPopup( PanelMultiView.openPopup(
gPanels[0], gPanels[0],
gPanelAnchors[0], gPanelAnchors[0],
"bottomcenter topright" "bottomright topright"
); );
await promiseHiding; await promiseHiding;
await promiseHidden; await promiseHidden;

View File

@@ -37,7 +37,7 @@ let gIframeIframe;
async function openPopup() { async function openPopup() {
let shown = BrowserTestUtils.waitForEvent(gMainView, "ViewShown"); let shown = BrowserTestUtils.waitForEvent(gMainView, "ViewShown");
PanelMultiView.openPopup(gPanel, gAnchor, "bottomcenter topright"); PanelMultiView.openPopup(gPanel, gAnchor, "bottomright topright");
await shown; await shown;
} }

View File

@@ -638,7 +638,7 @@ var DownloadsPanel = {
PanelMultiView.openPopup( PanelMultiView.openPopup(
this.panel, this.panel,
anchor, anchor,
"bottomcenter topright", "bottomright topright",
0, 0,
0, 0,
false, false,

View File

@@ -594,7 +594,7 @@
this.setAttribute("flip", "both"); this.setAttribute("flip", "both");
this.setAttribute("side", "top"); this.setAttribute("side", "top");
this.setAttribute("position", "bottomcenter topright"); this.setAttribute("position", "bottomright topright");
} }
_setSideAttribute(event) { _setSideAttribute(event) {

View File

@@ -249,10 +249,7 @@ class MozTranslationNotification extends MozElements.Notification {
this._getAnonElt("thanksButton").setAttribute("label", strings[3]); this._getAnonElt("thanksButton").setAttribute("label", strings[3]);
let panel = this._getAnonElt("welcomePanel"); let panel = this._getAnonElt("welcomePanel");
panel.openPopup( panel.openPopup(this._getAnonElt("messageImage"), "bottomleft topleft");
this._getAnonElt("messageImage"),
"bottomcenter topleft"
);
Services.prefs.setBoolPref(kWelcomePref, true); Services.prefs.setBoolPref(kWelcomePref, true);
}, },

View File

@@ -1297,7 +1297,7 @@ var UITour = {
tooltip.setAttribute("targetName", aAnchor.targetName); tooltip.setAttribute("targetName", aAnchor.targetName);
let alignment = "bottomcenter topright"; let alignment = "bottomright topright";
if (aAnchor.infoPanelPosition) { if (aAnchor.infoPanelPosition) {
alignment = aAnchor.infoPanelPosition; alignment = aAnchor.infoPanelPosition;
} }

View File

@@ -456,7 +456,7 @@ var ExtensionsUI = {
if (browser.ownerGlobal.gUnifiedExtensions.isEnabled) { if (browser.ownerGlobal.gUnifiedExtensions.isEnabled) {
options.popupOptions = { options.popupOptions = {
position: "bottomcenter topright", position: "bottomright topright",
x: 2, x: 2,
y: 0, y: 0,
}; };
@@ -517,7 +517,7 @@ var ExtensionsUI = {
if (browser.ownerGlobal.gUnifiedExtensions.isEnabled) { if (browser.ownerGlobal.gUnifiedExtensions.isEnabled) {
options.popupOptions = { options.popupOptions = {
position: "bottomcenter topright", position: "bottomright topright",
x: 2, x: 2,
y: 0, y: 0,
}; };

View File

@@ -4,16 +4,6 @@
@import "chrome://browser/skin/customizableui/panelUI-shared.css"; @import "chrome://browser/skin/customizableui/panelUI-shared.css";
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="top"],
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="bottom"] {
margin-inline: -13px;
}
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="left"],
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="right"] {
margin-block: -13px;
}
#notification-popup { #notification-popup {
margin-block: -4px; margin-block: -4px;
} }

View File

@@ -246,19 +246,8 @@ moz-input-box > menupopup .context-menu-add-engine > .menu-iconic-left {
border-top: 1px solid #C7C7C7; border-top: 1px solid #C7C7C7;
} }
#BMB_bookmarksPopup[side="top"],
#BMB_bookmarksPopup[side="bottom"] {
margin-inline: -17px;
}
#BMB_bookmarksPopup[side="left"],
#BMB_bookmarksPopup[side="right"] {
margin-block: -17px;
}
/* Bookmarking panel */ /* Bookmarking panel */
/* The following elements come from editBookmarkPanel.inc.xhtml. Styling that's /* The following elements come from editBookmarkPanel.inc.xhtml. Styling that's
specific to the editBookmarkPanel should be in browser.css. Styling that specific to the editBookmarkPanel should be in browser.css. Styling that
should be shared by all editBookmarkPanel.inc.xhtml consumers should be in should be shared by all editBookmarkPanel.inc.xhtml consumers should be in

View File

@@ -4,16 +4,6 @@
@import "chrome://browser/skin/customizableui/panelUI-shared.css"; @import "chrome://browser/skin/customizableui/panelUI-shared.css";
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="top"],
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="bottom"] {
margin-inline: -8px;
}
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="left"],
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="right"] {
margin-block: -8px;
}
#downloadsPanel, #downloadsPanel,
#widget-overflow, #widget-overflow,
#appMenu-popup, #appMenu-popup,

View File

@@ -35,63 +35,6 @@
-moz-window-shadow: none; -moz-window-shadow: none;
} }
/* Fine-tune panel margins */
:is(
#identity-popup,
#notification-popup
)[type="arrow"]:is([side="top"], [side="bottom"]) {
margin-inline: -16px;
}
:is(
#identity-popup,
#notification-popup
)[type="arrow"]:is([side="left"], [side="right"]) {
margin-block: -16px;
}
#permission-popup[type="arrow"]:is([side="top"], [side="bottom"]) {
margin-inline: calc(-24px - 2 * var(--urlbar-container-padding));
}
#permission-popup[type="arrow"]:is([side="left"], [side="right"]) {
margin-block: calc(-24px - 2 * var(--urlbar-container-padding));
}
#protections-popup[type="arrow"]:is([side="top"], [side="bottom"]) {
margin-inline: calc(-20px + 2 * var(--urlbar-container-padding));
}
#protections-popup[type="arrow"]:is([side="left"],[side="right"]) {
margin-block: calc(-20px + 2 * var(--urlbar-container-padding));
}
@media (-moz-platform: macos) {
:is(
#identity-popup,
#notification-popup,
#permission-popup
)[type="arrow"]:is([side="top"],[side="bottom"]) {
margin-inline: calc(-12px - 2 * var(--urlbar-container-padding));
}
:is(
#identity-popup,
#notification-popup,
#permission-popup
)[type="arrow"]:is([side="left"],[side="right"]) {
margin-block: calc(-12px - 2 * var(--urlbar-container-padding));
}
#protections-popup[type="arrow"]:is([side="top"], [side="bottom"]) {
margin-inline: calc(-16px + 2 * var(--urlbar-container-padding));
}
#protections-popup[type="arrow"]:is([side="left"],[side="right"]) {
margin-block: calc(-16px + 2 * var(--urlbar-container-padding));
}
}
/* Show the right elements for the right connection states. */ /* Show the right elements for the right connection states. */
#identity-popup[customroot=true] [when-customroot=true], #identity-popup[customroot=true] [when-customroot=true],
#identity-popup[connection=not-secure] [when-connection~=not-secure], #identity-popup[connection=not-secure] [when-connection~=not-secure],

View File

@@ -210,16 +210,6 @@ toolbar .toolbarbutton-1:focus-visible {
/* bookmarks menu button */ /* bookmarks menu button */
#BMB_bookmarksPopup[side="top"],
#BMB_bookmarksPopup[side="bottom"] {
margin-inline: -20px;
}
#BMB_bookmarksPopup[side="left"],
#BMB_bookmarksPopup[side="right"] {
margin-block: -20px;
}
/* ::::: bookmark buttons ::::: */ /* ::::: bookmark buttons ::::: */
#personal-toolbar-empty-description, #personal-toolbar-empty-description,

View File

@@ -4,16 +4,6 @@
@import "chrome://browser/skin/customizableui/panelUI-shared.css"; @import "chrome://browser/skin/customizableui/panelUI-shared.css";
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="top"],
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="bottom"] {
margin-inline: -13px;
}
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="left"],
#customizationui-widget-panel[viewId="PanelUI-profiler"][type="arrow"][side="right"] {
margin-block: -13px;
}
#notification-popup { #notification-popup {
margin-block: -4px; margin-block: -4px;
} }

View File

@@ -41,7 +41,7 @@
this.setAttribute("side", "top"); this.setAttribute("side", "top");
} }
if (!this.hasAttribute("position")) { if (!this.hasAttribute("position")) {
this.setAttribute("position", "bottomcenter topleft"); this.setAttribute("position", "bottomleft topleft");
} }
if (!this.hasAttribute("consumeoutsideclicks")) { if (!this.hasAttribute("consumeoutsideclicks")) {
this.setAttribute("consumeoutsideclicks", "false"); this.setAttribute("consumeoutsideclicks", "false");

View File

@@ -1345,7 +1345,7 @@ PopupNotifications.prototype = {
if (popupOptions) { if (popupOptions) {
this.panel.openPopup(anchorElement, popupOptions); this.panel.openPopup(anchorElement, popupOptions);
} else { } else {
this.panel.openPopup(anchorElement, "bottomcenter topleft", 0, 0); this.panel.openPopup(anchorElement, "bottomleft topleft", 0, 0);
} }
}); });
}, },

View File

@@ -35,16 +35,6 @@ panel[type="arrow"] {
background-color: transparent; background-color: transparent;
} }
panel[type="arrow"][side="top"],
panel[type="arrow"][side="bottom"] {
margin-inline: -20px;
}
panel[type="arrow"][side="left"],
panel[type="arrow"][side="right"] {
margin-block: -20px;
}
:is(panel, menupopup)::part(content) { :is(panel, menupopup)::part(content) {
display: -moz-box; display: -moz-box;
-moz-box-flex: 1; -moz-box-flex: 1;

View File

@@ -38,16 +38,6 @@ panel[type="arrow"] {
background: transparent; background: transparent;
} }
panel[type="arrow"][side="top"],
panel[type="arrow"][side="bottom"] {
margin-inline: -16px;
}
panel[type="arrow"][side="left"],
panel[type="arrow"][side="right"] {
margin-block: -16px;
}
:is(panel, menupopup)::part(content) { :is(panel, menupopup)::part(content) {
display: -moz-box; display: -moz-box;
-moz-box-flex: 1; -moz-box-flex: 1;

View File

@@ -80,16 +80,6 @@ panel[type="arrow"] {
border: none; border: none;
} }
panel[type="arrow"][side="top"],
panel[type="arrow"][side="bottom"] {
margin-inline: -20px;
}
panel[type="arrow"][side="left"],
panel[type="arrow"][side="right"] {
margin-block: -20px;
}
:is(panel, menupopup)::part(content) { :is(panel, menupopup)::part(content) {
display: -moz-box; display: -moz-box;
-moz-box-flex: 1; -moz-box-flex: 1;