Bug 1419442 - [Linux/Titlebar rendering] Center titlebar buttons, r?dao
Linux renders titlebar buttons vertically centered so emulate that for our titlebar rendering.
When menubar is visible center titlebar buttons according menubar, othervise center against tabbar.
Also consider titlebar button sizes which are be defined by actual Gtk+ theme.
MozReview-Commit-ID: 7uWEidJ3Zn2
--- a/browser/base/content/browser-tabsintitlebar.js
+++ b/browser/base/content/browser-tabsintitlebar.js
@@ -226,17 +226,36 @@ var TabsInTitlebar = {
// Next, we calculate how much we need to stretch the titlebar down to
// go all the way to the bottom of the tab strip, if necessary.
let tabAndMenuHeight = fullTabsHeight + fullMenuHeight;
if (tabAndMenuHeight > titlebarContentHeight) {
// We need to increase the titlebar content's outer height (ie including margins)
// to match the tab and menu height:
let extraMargin = tabAndMenuHeight - titlebarContentHeight;
- if (AppConstants.platform != "macosx") {
+ if (AppConstants.platform == "linux") {
+ // Linux centers buttons at titlebar so let's emulate that.
+ if (!fullMenuHeight) {
+ // Menubar is not visible - center buttons according to tabs.
+ titlebarContent.style.marginTop = extraMargin/2 + "px";
+ titlebarContent.style.marginBottom = extraMargin/2 + "px";
+ } else {
+ if (fullMenuHeight > titlebarContentHeight) {
+ // Buttons are smaller than menubar so center them according to menubar.
+ let fullMenuHeightMargin = fullMenuHeight - titlebarContentHeight;
+ titlebarContent.style.marginTop = fullMenuHeightMargin/2 + "px";
+ titlebarContent.style.marginBottom = fullMenuHeightMargin/2 + (extraMargin - fullMenuHeightMargin) + "px";
+ } else {
+ // Buttons are bigger than menubar - place them at top with some
+ // reasonable top margin.
+ titlebarContent.style.marginTop = "2px";
+ titlebarContent.style.marginBottom = extraMargin - 2 + "px";
+ }
+ }
+ } else if (AppConstants.platform != "macosx") {
titlebarContent.style.marginBottom = extraMargin + "px";
}
titlebarContentHeight += extraMargin;
} else {
titlebarContent.style.removeProperty("margin-bottom");
}
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -2366,16 +2366,17 @@ moz_gtk_get_widget_border(WidgetNodeType
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_HEADER_BAR:
case MOZ_GTK_HEADER_BAR_MAXIMIZED:
{
style = GetStyleContext(widget);
moz_gtk_add_border_padding(style, left, top, right, bottom);
+ *top = *bottom = 0;
return MOZ_GTK_SUCCESS;
}
/* These widgets have no borders, since they are not containers. */
case MOZ_GTK_CHECKBUTTON_LABEL:
case MOZ_GTK_RADIOBUTTON_LABEL:
case MOZ_GTK_SPLITTER_HORIZONTAL:
case MOZ_GTK_SPLITTER_VERTICAL:
case MOZ_GTK_CHECKBUTTON: