Bug 1427999 - Use GetToolbarButtonMetrics() to get correct titlebar button size at nsNativeThemeGTK::GetMinimumWidgetSize, r?jhorak
MozReview-Commit-ID: HfPUk30LaJn
--- a/widget/gtk/WidgetStyleCache.cpp
+++ b/widget/gtk/WidgetStyleCache.cpp
@@ -550,16 +550,24 @@ CreateHeaderBar(WidgetNodeType aWidgetTy
sWidgetStorage[MOZ_GTK_WINDOW_MAXIMIZED] = window;
} else {
AddToWindowContainer(headerbar);
}
// 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;
}
// TODO - Also return style for buttons located at Maximized toolbar.
static GtkWidget*
CreateHeaderBarButton(WidgetNodeType aWidgetType)
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -1570,28 +1570,34 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
case NS_THEME_BUTTON_ARROW_NEXT:
case NS_THEME_BUTTON_ARROW_PREVIOUS:
{
moz_gtk_get_arrow_size(MOZ_GTK_TOOLBARBUTTON_ARROW,
&aResult->width, &aResult->height);
*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:
case NS_THEME_RADIO_LABEL:
case NS_THEME_BUTTON:
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.
moz_gtk_get_arrow_size(MOZ_GTK_DROPDOWN,
&aResult->width, &aResult->height);
}
// else the minimum size is missing consideration of container
// descendants; the value returned here will not be helpful, but the