Bug 1498356 - Move border and padding from -moz-window-titlebar* to -moz-window-button-box on GTK backend, r=dao
authorMartin Stransky <stransky@redhat.com>
Fri, 12 Oct 2018 16:16:50 +0000
changeset 489396 d2b32aa2055fecc143a03013b06afbac1ad91836
parent 489395 3df978f11b6d4017d88295335458283c38d697cd
child 489397 74d5645c1fc68035f61d31cc93ccbe727fcb16fa
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersdao
bugs1498356
milestone64.0a1
Bug 1498356 - Move border and padding from -moz-window-titlebar* to -moz-window-button-box on GTK backend, r=dao This is based on patch by Mike Conley (:mconley) The left/right toolbox placement can be adjusted later as we know at toolkit level where the buttons are so we can set border/padding accordingly. Depends on D8529 Differential Revision: https://phabricator.services.mozilla.com/D8549
widget/gtk/gtk3drawing.cpp
widget/gtk/gtkdrawing.h
widget/gtk/nsNativeThemeGTK.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -2566,16 +2566,23 @@ moz_gtk_get_widget_border(WidgetNodeType
                                               left, top, right, bottom);
 
             GtkStyleContext* labelStyle = GetStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL);
             moz_gtk_add_margin_border_padding(labelStyle,
                                               left, top, right, bottom);
 
             return MOZ_GTK_SUCCESS;
         }
+    case MOZ_GTK_HEADER_BAR_BUTTON_BOX:
+        {
+            style = GetStyleContext(MOZ_GTK_HEADER_BAR);
+            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:
     case MOZ_GTK_RADIOBUTTON:
     case MOZ_GTK_SCROLLBAR_BUTTON:
--- a/widget/gtk/gtkdrawing.h
+++ b/widget/gtk/gtkdrawing.h
@@ -322,16 +322,18 @@ typedef enum {
   /* Paints a GtkComboBox entry arrow widget. */
   MOZ_GTK_COMBOBOX_ENTRY_ARROW,
   /* Used for scrolled window shell. */
   MOZ_GTK_SCROLLED_WINDOW,
   /* Paints a GtkHeaderBar */
   MOZ_GTK_HEADER_BAR,
   /* Paints a GtkHeaderBar in maximized state */
   MOZ_GTK_HEADER_BAR_MAXIMIZED,
+  /* Container for GtkHeaderBar buttons */
+  MOZ_GTK_HEADER_BAR_BUTTON_BOX,
   /* Paints GtkHeaderBar title buttons.
    * Keep the order here as MOZ_GTK_HEADER_BAR_BUTTON_* are processed
    * as an array from MOZ_GTK_HEADER_BAR_BUTTON_CLOSE to the last one.
    */
   MOZ_GTK_HEADER_BAR_BUTTON_CLOSE,
   MOZ_GTK_HEADER_BAR_BUTTON_MINIMIZE,
   MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE,
 
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -795,16 +795,19 @@ nsNativeThemeGTK::GetGtkWidgetAndState(S
     aGtkWidgetType = MOZ_GTK_INFO_BAR;
     break;
   case StyleAppearance::MozWindowTitlebar:
     aGtkWidgetType = MOZ_GTK_HEADER_BAR;
     break;
   case StyleAppearance::MozWindowTitlebarMaximized:
     aGtkWidgetType = MOZ_GTK_HEADER_BAR_MAXIMIZED;
     break;
+  case StyleAppearance::MozWindowButtonBox:
+    aGtkWidgetType = MOZ_GTK_HEADER_BAR_BUTTON_BOX;
+    break;
   case StyleAppearance::MozWindowButtonClose:
     aGtkWidgetType = MOZ_GTK_HEADER_BAR_BUTTON_CLOSE;
     break;
   case StyleAppearance::MozWindowButtonMinimize:
     aGtkWidgetType = MOZ_GTK_HEADER_BAR_BUTTON_MINIMIZE;
     break;
   case StyleAppearance::MozWindowButtonMaximize:
     aGtkWidgetType = MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE;
@@ -1430,16 +1433,17 @@ nsNativeThemeGTK::GetWidgetPadding(nsDev
   if (aWidgetType == StyleAppearance::MenulistButton &&
       StaticPrefs::layout_css_webkit_appearance_enabled()) {
     aWidgetType = StyleAppearance::Menulist;
   }
 
   switch (aWidgetType) {
     case StyleAppearance::ButtonFocus:
     case StyleAppearance::Toolbarbutton:
+    case StyleAppearance::MozWindowButtonBox:
     case StyleAppearance::MozWindowButtonClose:
     case StyleAppearance::MozWindowButtonMinimize:
     case StyleAppearance::MozWindowButtonMaximize:
     case StyleAppearance::MozWindowButtonRestore:
     case StyleAppearance::Dualbutton:
     case StyleAppearance::TabScrollArrowBack:
     case StyleAppearance::TabScrollArrowForward:
     case StyleAppearance::MenulistButton:
@@ -2011,16 +2015,17 @@ nsNativeThemeGTK::ThemeSupportsWidget(ns
   case StyleAppearance::Splitter:
   case StyleAppearance::Window:
   case StyleAppearance::Dialog:
 #ifdef MOZ_WIDGET_GTK
   case StyleAppearance::MozGtkInfoBar:
 #endif
     return !IsWidgetStyled(aPresContext, aFrame, aWidgetType);
 
+  case StyleAppearance::MozWindowButtonBox:
   case StyleAppearance::MozWindowButtonClose:
   case StyleAppearance::MozWindowButtonMinimize:
   case StyleAppearance::MozWindowButtonMaximize:
   case StyleAppearance::MozWindowButtonRestore:
   case StyleAppearance::MozWindowTitlebar:
   case StyleAppearance::MozWindowTitlebarMaximized:
     // GtkHeaderBar is available on GTK 3.10+, which is used for styling
     // title bars and title buttons.