Bug 1427999 - Use GetToolbarButtonMetrics() to get correct titlebar button size at nsNativeThemeGTK::GetMinimumWidgetSize, r?jhorak draft
authorMartin Stransky <stransky@redhat.com>
Mon, 22 Jan 2018 12:09:09 +0100
changeset 724098 f7e8a06560835da59400925e7ffd711ccdc1e288
parent 724097 b51524e1eece9273d11ec3283716b8ed2c861356
child 747050 f6cb48bc30751959f97cb6b79987bac004cdf099
push id96643
push userstransky@redhat.com
push dateWed, 24 Jan 2018 14:20:23 +0000
reviewersjhorak
bugs1427999
milestone60.0a1
Bug 1427999 - Use GetToolbarButtonMetrics() to get correct titlebar button size at nsNativeThemeGTK::GetMinimumWidgetSize, r?jhorak MozReview-Commit-ID: HfPUk30LaJn
widget/gtk/WidgetStyleCache.cpp
widget/gtk/nsNativeThemeGTK.cpp
--- 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