From 0594ae2db5ec3514ed4c14134b16b3a1b04f3c1f Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Mon, 22 Jan 2018 12:09:09 +0100 Subject: [PATCH] Bug 1427999 - Use GetToolbarButtonMetrics() to get correct titlebar button size at nsNativeThemeGTK::GetMinimumWidgetSize, r=jhorak MozReview-Commit-ID: HfPUk30LaJn --HG-- extra : rebase_source : ef406e78e686a6ae190a0fbdb9aa945e40503ac6 --- widget/gtk/WidgetStyleCache.cpp | 8 ++++++++ widget/gtk/nsNativeThemeGTK.cpp | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/widget/gtk/WidgetStyleCache.cpp b/widget/gtk/WidgetStyleCache.cpp index c5bfbd55b900..41c5111e319c 100644 --- a/widget/gtk/WidgetStyleCache.cpp +++ b/widget/gtk/WidgetStyleCache.cpp @@ -555,6 +555,14 @@ CreateHeaderBar(WidgetNodeType aWidgetType) // Emulate what create_titlebar() at gtkwindow.c does. GtkStyleContext* style = gtk_widget_get_style_context(headerbar); gtk_style_context_add_class(style, "titlebar"); + + // TODO: Define default-decoration titlebar style as workaround + // to ensure the titlebar buttons does not overflow outside. + // Recently the titlebar size is calculated as + // tab size + titlebar border/padding (default-decoration has 6px padding + // at default Adwaita theme). + // We need to fix titlebar size calculation to also include + // titlebar button sizes. (Bug 1419442) gtk_style_context_add_class(style, "default-decoration"); return headerbar; diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index cc40f77b69b0..c82f25650f8d 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -1575,6 +1575,16 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, *aIsOverridable = false; } break; + case NS_THEME_WINDOW_BUTTON_CLOSE: + case NS_THEME_WINDOW_BUTTON_MINIMIZE: + case NS_THEME_WINDOW_BUTTON_MAXIMIZE: + case NS_THEME_WINDOW_BUTTON_RESTORE: + { + const ToolbarButtonGTKMetrics* metrics = GetToolbarButtonMetrics(); + aResult->width = metrics->minSizeWithBorderMargin.width; + aResult->height = metrics->minSizeWithBorderMargin.height; + break; + } case NS_THEME_CHECKBOX_CONTAINER: case NS_THEME_RADIO_CONTAINER: case NS_THEME_CHECKBOX_LABEL: @@ -1583,10 +1593,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, case NS_THEME_MENULIST: case NS_THEME_TOOLBARBUTTON: case NS_THEME_TREEHEADERCELL: - case NS_THEME_WINDOW_BUTTON_CLOSE: - case NS_THEME_WINDOW_BUTTON_MINIMIZE: - case NS_THEME_WINDOW_BUTTON_MAXIMIZE: - case NS_THEME_WINDOW_BUTTON_RESTORE: { if (aWidgetType == NS_THEME_MENULIST) { // Include the arrow size.