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 titlebarContent = $("titlebar-content");
let titlebarButtons = $("titlebar-buttonbox");
let menubar = $("toolbar-menubar");
if (allowed) {
@ -155,10 +156,13 @@ var TabsInTitlebar = {
// Reset the custom titlebar height if the menubar is shown,
// 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("autohide") != "true")) {
$("titlebar-buttonbox").style.removeProperty("height");
menubar.getAttribute("autohide") != "true")) {
titlebarButtons.style.removeProperty("height");
}
// Try to avoid reflows in this code by calculating dimensions first and
@ -168,7 +172,7 @@ var TabsInTitlebar = {
let fullTabsHeight = rect($("TabsToolbar")).height;
// Buttons first:
let captionButtonsBoxWidth = rect($("titlebar-buttonbox")).width;
let captionButtonsBoxWidth = rect(titlebarButtons).width;
let secondaryButtonsWidth, menuHeight, fullMenuHeight, menuStyles;
if (AppConstants.platform == "macosx") {
@ -188,12 +192,11 @@ var TabsInTitlebar = {
// 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.
if (AppConstants.isPlatformAndVersionAtLeast("win", "10.0") &&
!menuHeight) {
if (buttonsShouldMatchTabHeight && !menuHeight) {
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
@ -260,9 +263,7 @@ var TabsInTitlebar = {
this._sizePlaceholder("fullscreen-button", secondaryButtonsWidth);
}
// Reset the margins and padding that might have been modified:
titlebarContent.style.marginTop = "";
titlebarContent.style.marginBottom = "";
// Reset styles that might have been modified:
titlebar.style.marginBottom = "";
menubar.style.paddingBottom = "";
}

View File

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

View File

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