Bug 1434621 - part 1: vertically center title bar buttons on Linux. r=stransky

MozReview-Commit-ID: 4cpEAyw1a4k
This commit is contained in:
Dão Gottwald 2018-02-21 16:39:59 +01:00
parent 331d0e0c4e
commit 7514587643
3 changed files with 15 additions and 17 deletions

View File

@ -145,6 +145,7 @@ var TabsInTitlebar = {
let titlebar = $("titlebar"); let titlebar = $("titlebar");
let titlebarContent = $("titlebar-content"); let titlebarContent = $("titlebar-content");
let titlebarButtons = $("titlebar-buttonbox");
let menubar = $("toolbar-menubar"); let menubar = $("toolbar-menubar");
if (allowed) { if (allowed) {
@ -155,10 +156,13 @@ var TabsInTitlebar = {
// Reset the custom titlebar height if the menubar is shown, // Reset the custom titlebar height if the menubar is shown,
// because we will want to calculate its original height. // because we will want to calculate its original height.
if (AppConstants.isPlatformAndVersionAtLeast("win", "10.0") && let buttonsShouldMatchTabHeight =
AppConstants.isPlatformAndVersionAtLeast("win", "10.0") ||
AppConstants.platform == "linux";
if (buttonsShouldMatchTabHeight &&
(menubar.getAttribute("inactive") != "true" || (menubar.getAttribute("inactive") != "true" ||
menubar.getAttribute("autohide") != "true")) { menubar.getAttribute("autohide") != "true")) {
$("titlebar-buttonbox").style.removeProperty("height"); titlebarButtons.style.removeProperty("height");
} }
// Try to avoid reflows in this code by calculating dimensions first and // Try to avoid reflows in this code by calculating dimensions first and
@ -168,7 +172,7 @@ var TabsInTitlebar = {
let fullTabsHeight = rect($("TabsToolbar")).height; let fullTabsHeight = rect($("TabsToolbar")).height;
// Buttons first: // Buttons first:
let captionButtonsBoxWidth = rect($("titlebar-buttonbox")).width; let captionButtonsBoxWidth = rect(titlebarButtons).width;
let secondaryButtonsWidth, menuHeight, fullMenuHeight, menuStyles; let secondaryButtonsWidth, menuHeight, fullMenuHeight, menuStyles;
if (AppConstants.platform == "macosx") { if (AppConstants.platform == "macosx") {
@ -188,12 +192,11 @@ var TabsInTitlebar = {
// Begin setting CSS properties which will cause a reflow // Begin setting CSS properties which will cause a reflow
// On Windows 10, adjust the window controls to span the entire // Adjust the window controls to span the entire
// tab strip height if we're not showing a menu bar. // tab strip height if we're not showing a menu bar.
if (AppConstants.isPlatformAndVersionAtLeast("win", "10.0") && if (buttonsShouldMatchTabHeight && !menuHeight) {
!menuHeight) {
titlebarContentHeight = fullTabsHeight; titlebarContentHeight = fullTabsHeight;
$("titlebar-buttonbox").style.height = titlebarContentHeight + "px"; titlebarButtons.style.height = titlebarContentHeight + "px";
} }
// If the menubar is around (menuHeight is non-zero), try to adjust // If the menubar is around (menuHeight is non-zero), try to adjust
@ -260,9 +263,7 @@ var TabsInTitlebar = {
this._sizePlaceholder("fullscreen-button", secondaryButtonsWidth); this._sizePlaceholder("fullscreen-button", secondaryButtonsWidth);
} }
// Reset the margins and padding that might have been modified: // Reset styles that might have been modified:
titlebarContent.style.marginTop = "";
titlebarContent.style.marginBottom = "";
titlebar.style.marginBottom = ""; titlebar.style.marginBottom = "";
menubar.style.paddingBottom = ""; menubar.style.paddingBottom = "";
} }

View File

@ -315,12 +315,6 @@ toolbarpaletteitem {
.titlebar-placeholder[type="fullscreen-button"]:-moz-locale-dir(rtl) { .titlebar-placeholder[type="fullscreen-button"]:-moz-locale-dir(rtl) {
-moz-box-ordinal-group: 0; -moz-box-ordinal-group: 0;
} }
%else
/* On non-OSX, these should be start-aligned */
#titlebar-buttonbox-container {
-moz-box-align: start;
}
%endif %endif
%ifdef XP_WIN %ifdef XP_WIN

View File

@ -675,6 +675,9 @@ notification[value="translation"] menulist > .menulist-dropmarker {
*/ */
#titlebar-buttonbox { #titlebar-buttonbox {
z-index: 1; z-index: 1;
-moz-box-align: center;
padding-top: 2px;
padding-bottom: 2px;
} }
/* Render titlebar command buttons according to system config. /* Render titlebar command buttons according to system config.