mozilla-gtk3_20.patch
changeset 934 b61e849fe451
parent 923 3cc9f17ca9bb
parent 933 7f60766aae16
child 935 9ae2b79d3bb1
equal deleted inserted replaced
923:3cc9f17ca9bb 934:b61e849fe451
     1 diff -up firefox-46.0.1/widget/gtk/gtk3drawing.c.gtk3-20 firefox-46.0.1/widget/gtk/gtk3drawing.c
       
     2 --- firefox-46.0.1/widget/gtk/gtk3drawing.c.gtk3-20	2016-05-03 07:31:12.000000000 +0200
       
     3 +++ firefox-46.0.1/widget/gtk/gtk3drawing.c	2016-05-20 15:05:08.750151522 +0200
       
     4 @@ -17,34 +17,86 @@
       
     5  
       
     6  #include <math.h>
       
     7  
       
     8 +#define MOZ_WIDGET_STYLES 4
       
     9 +
       
    10 +typedef struct {
       
    11 +    GtkWidget*            widget;
       
    12 +
       
    13 +    union {
       
    14 +        struct {
       
    15 +            GtkStyleContext*  style;
       
    16 +            GtkStyleContext*  styleSelection;
       
    17 +        } entry;
       
    18 +
       
    19 +        struct {
       
    20 +            GtkStyleContext*  style;
       
    21 +        } button;
       
    22 +
       
    23 +        struct {
       
    24 +            GtkStyleContext*  style;
       
    25 +            GtkStyleContext*  styleBackground;
       
    26 +        } tooltip;
       
    27 +
       
    28 +        struct {
       
    29 +            GtkStyleContext*  style;
       
    30 +            GtkStyleContext*  styleContents;
       
    31 +            GtkStyleContext*  styleTrough;
       
    32 +            GtkStyleContext*  styleSlider;
       
    33 +        } scroll;
       
    34 +
       
    35 +        struct {
       
    36 +            GtkStyleContext*  style;
       
    37 +            GtkStyleContext*  styleCheck;
       
    38 +            GtkStyleContext*  styleLabel;
       
    39 +        } check;
       
    40 +
       
    41 +        struct {
       
    42 +            GtkStyleContext*  style;
       
    43 +            GtkStyleContext*  styleTrough;
       
    44 +            GtkStyleContext*  styleProgress;
       
    45 +        } progress;
       
    46 +
       
    47 +        struct {
       
    48 +            GtkStyleContext*  style;
       
    49 +            GtkStyleContext*  styleEntry;
       
    50 +            GtkStyleContext*  styleButtonUp;
       
    51 +            GtkStyleContext*  styleButtonDown;
       
    52 +        } spin;
       
    53 +
       
    54 +        struct {
       
    55 +            GtkStyleContext*  style[MOZ_WIDGET_STYLES];
       
    56 +        } all;
       
    57 +    };
       
    58 +} MozGtkWidget;
       
    59 +
       
    60  static GtkWidget* gProtoWindow;
       
    61  static GtkWidget* gProtoLayout;
       
    62 -static GtkWidget* gButtonWidget;
       
    63 +static MozGtkWidget gButton;
       
    64  static GtkWidget* gToggleButtonWidget;
       
    65  static GtkWidget* gButtonArrowWidget;
       
    66 -static GtkWidget* gCheckboxWidget;
       
    67 -static GtkWidget* gRadiobuttonWidget;
       
    68 -static GtkWidget* gHorizScrollbarWidget;
       
    69 -static GtkWidget* gVertScrollbarWidget;
       
    70 -static GtkWidget* gSpinWidget;
       
    71 +static MozGtkWidget gCheckbox;
       
    72 +static MozGtkWidget gRadiobutton;
       
    73 +static MozGtkWidget gVertScrollbar;
       
    74 +static MozGtkWidget gHorizScrollbar;
       
    75 +static MozGtkWidget gSpin;
       
    76  static GtkWidget* gHScaleWidget;
       
    77  static GtkWidget* gVScaleWidget;
       
    78 -static GtkWidget* gEntryWidget;
       
    79 +static MozGtkWidget gEntry;
       
    80  static GtkWidget* gComboBoxWidget;
       
    81  static GtkWidget* gComboBoxButtonWidget;
       
    82  static GtkWidget* gComboBoxArrowWidget;
       
    83  static GtkWidget* gComboBoxSeparatorWidget;
       
    84  static GtkWidget* gComboBoxEntryWidget;
       
    85 -static GtkWidget* gComboBoxEntryTextareaWidget;
       
    86 +static MozGtkWidget gComboBoxEntryTextarea;
       
    87  static GtkWidget* gComboBoxEntryButtonWidget;
       
    88  static GtkWidget* gComboBoxEntryArrowWidget;
       
    89  static GtkWidget* gHandleBoxWidget;
       
    90  static GtkWidget* gToolbarWidget;
       
    91  static GtkWidget* gFrameWidget;
       
    92  static GtkWidget* gStatusbarWidget;
       
    93 -static GtkWidget* gProgressWidget;
       
    94 +static MozGtkWidget gProgressBar;
       
    95  static GtkWidget* gTabWidget;
       
    96 -static GtkWidget* gTooltipWidget;
       
    97 +static MozGtkWidget gTooltip;
       
    98  static GtkWidget* gMenuBarWidget;
       
    99  static GtkWidget* gMenuBarItemWidget;
       
   100  static GtkWidget* gMenuPopupWidget;
       
   101 @@ -78,6 +130,37 @@ static gboolean is_initialized;
       
   102  #define GTK_STATE_FLAG_CHECKED (1 << 11)
       
   103  #endif
       
   104  
       
   105 +void moz_gtk_widget_free(MozGtkWidget *aMozWidget)
       
   106 +{
       
   107 +    // This was removed as a child of gProtoWindow
       
   108 +    if (aMozWidget->widget) {
       
   109 +        aMozWidget->widget = NULL;
       
   110 +    }
       
   111 +
       
   112 +    for(int i = 0; i < MOZ_WIDGET_STYLES; i++) {
       
   113 +        if (aMozWidget->all.style[i]) {
       
   114 +            g_object_unref(aMozWidget->all.style[i]);
       
   115 +            aMozWidget->all.style[i] = NULL;
       
   116 +        }
       
   117 +    }
       
   118 +}
       
   119 +
       
   120 +// TODO - weak dep!! (dlsym)
       
   121 +#if GTK_CHECK_VERSION(3, 19, 2)
       
   122 +#define moz_gtk_path_set_class_name    gtk_widget_path_iter_set_object_name
       
   123 +#else
       
   124 +#define moz_gtk_path_set_class_name    gtk_widget_path_iter_add_class
       
   125 +#endif
       
   126 +//gtk_widget_path_iter_get_state
       
   127 +
       
   128 +static void
       
   129 +moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
       
   130 +                         GtkBorder *border);
       
   131 +
       
   132 +static void
       
   133 +moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
       
   134 +                          GtkBorder *padding);
       
   135 +
       
   136  static GtkStateFlags
       
   137  GetStateFlagsFromGtkWidgetState(GtkWidgetState* state)
       
   138  {
       
   139 @@ -97,6 +180,41 @@ GetStateFlagsFromGtkWidgetState(GtkWidge
       
   140      return stateFlags;
       
   141  }
       
   142  
       
   143 +GtkStyleContext *
       
   144 +moz_gtk_style_create(GtkCssNode *node, GtkStyleContext *parent)
       
   145 +{
       
   146 +  GtkWidgetPath *path;
       
   147 +  GtkStyleContext *context;
       
   148 +
       
   149 +  if (parent)
       
   150 +    path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
       
   151 +  else
       
   152 +    path = gtk_widget_path_new ();
       
   153 +
       
   154 +  gtk_widget_path_append_type (path, node->type);
       
   155 +  if (node->name)
       
   156 +    moz_gtk_path_set_class_name(path, -1, node->name);
       
   157 +  if (node->class1)
       
   158 +    gtk_widget_path_iter_add_class(path, -1, node->class1);
       
   159 +  if (node->class2)
       
   160 +    gtk_widget_path_iter_add_class(path, -1, node->class2);
       
   161 +
       
   162 +  context = gtk_style_context_new ();
       
   163 +  gtk_style_context_set_path (context, path);
       
   164 +  gtk_style_context_set_parent (context, parent);
       
   165 +
       
   166 +  if(!gtk_check_version(3, 14, 0)) {
       
   167 +      /* Unfortunately, we have to explicitly set the state again here
       
   168 +       * for it to take effect
       
   169 +       */
       
   170 +      gtk_style_context_set_state (context, gtk_widget_path_iter_get_state (path, -1));
       
   171 +  }
       
   172 +
       
   173 +  gtk_widget_path_unref (path);
       
   174 +
       
   175 +  return context;
       
   176 +}
       
   177 +
       
   178  /* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
       
   179     that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
       
   180     things they may want to do. */
       
   181 @@ -141,9 +259,16 @@ setup_widget_prototype(GtkWidget* widget
       
   182  static gint
       
   183  ensure_button_widget()
       
   184  {
       
   185 -    if (!gButtonWidget) {
       
   186 -        gButtonWidget = gtk_button_new_with_label("M");
       
   187 -        setup_widget_prototype(gButtonWidget);
       
   188 +    if (!gButton.widget) {
       
   189 +        GtkCssNode path[] = { 
       
   190 +            { GTK_TYPE_BUTTON, "button", NULL, NULL }
       
   191 +        };
       
   192 +
       
   193 +        gButton.widget = gtk_button_new_with_label("M");
       
   194 +        setup_widget_prototype(gButton.widget);
       
   195 +        gtk_widget_show(gButton.widget);
       
   196 +
       
   197 +        gButton.button.style = moz_gtk_style_create(&path[0], NULL);
       
   198      }
       
   199      return MOZ_GTK_SUCCESS;
       
   200  }
       
   201 @@ -195,9 +320,21 @@ ensure_button_arrow_widget()
       
   202  static gint
       
   203  ensure_checkbox_widget()
       
   204  {
       
   205 -    if (!gCheckboxWidget) {
       
   206 -        gCheckboxWidget = gtk_check_button_new_with_label("M");
       
   207 -        setup_widget_prototype(gCheckboxWidget);
       
   208 +   if (!gCheckbox.widget) {
       
   209 +        GtkCssNode path[] = {
       
   210 +           { GTK_TYPE_TOGGLE_BUTTON, "checkbutton", NULL, NULL },
       
   211 +           { G_TYPE_NONE, "check", NULL, NULL },
       
   212 +           { G_TYPE_NONE, "label", NULL, NULL }
       
   213 +        };
       
   214 +
       
   215 +        gCheckbox.widget = gtk_check_button_new_with_label("M");
       
   216 +        setup_widget_prototype(gCheckbox.widget);
       
   217 +
       
   218 +        gCheckbox.check.style = moz_gtk_style_create(&path[0], NULL);
       
   219 +        gCheckbox.check.styleCheck = moz_gtk_style_create(&path[1],
       
   220 +                                       gCheckbox.check.style);
       
   221 +        gCheckbox.check.styleLabel = moz_gtk_style_create(&path[2],
       
   222 +                                       gCheckbox.check.style);
       
   223      }
       
   224      return MOZ_GTK_SUCCESS;
       
   225  }
       
   226 @@ -205,9 +342,21 @@ ensure_checkbox_widget()
       
   227  static gint
       
   228  ensure_radiobutton_widget()
       
   229  {
       
   230 -    if (!gRadiobuttonWidget) {
       
   231 -        gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
       
   232 -        setup_widget_prototype(gRadiobuttonWidget);
       
   233 +    if (!gRadiobutton.widget) {
       
   234 +        GtkCssNode path[] = {
       
   235 +           { GTK_TYPE_TOGGLE_BUTTON, "radiobutton", NULL, NULL },
       
   236 +           { G_TYPE_NONE, "radio", NULL, NULL },
       
   237 +           { G_TYPE_NONE, "label", NULL, NULL }
       
   238 +        };
       
   239 +
       
   240 +        gRadiobutton.widget = gtk_radio_button_new_with_label(NULL, "M");
       
   241 +        setup_widget_prototype(gRadiobutton.widget);
       
   242 +
       
   243 +        gRadiobutton.check.style = moz_gtk_style_create(&path[0], NULL);
       
   244 +        gRadiobutton.check.styleCheck = moz_gtk_style_create(&path[1],
       
   245 +                                          gRadiobutton.check.style);
       
   246 +        gRadiobutton.check.styleLabel = moz_gtk_style_create(&path[2],
       
   247 +                                          gRadiobutton.check.style);
       
   248      }
       
   249      return MOZ_GTK_SUCCESS;
       
   250  }
       
   251 @@ -215,25 +364,62 @@ ensure_radiobutton_widget()
       
   252  static gint
       
   253  ensure_scrollbar_widget()
       
   254  {
       
   255 -    if (!gVertScrollbarWidget) {
       
   256 -        gVertScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
       
   257 -        setup_widget_prototype(gVertScrollbarWidget);
       
   258 -    }
       
   259 -    if (!gHorizScrollbarWidget) {
       
   260 -        gHorizScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
       
   261 -        setup_widget_prototype(gHorizScrollbarWidget);
       
   262 -    }
       
   263 +    if (!gVertScrollbar.widget && !gHorizScrollbar.widget) {
       
   264 +        GtkCssNode path[] = {
       
   265 +            { GTK_TYPE_SCROLLBAR, "scrollbar", "horizontal", "bottom"},
       
   266 +            { GTK_TYPE_SCROLLBAR, "scrollbar", "vertical", "right" },
       
   267 +            { G_TYPE_NONE, "contents", NULL, NULL },
       
   268 +            { G_TYPE_NONE, "trough", NULL, NULL },
       
   269 +            { G_TYPE_NONE, "slider", NULL, NULL }
       
   270 +        };
       
   271 +
       
   272 +        gHorizScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
       
   273 +        setup_widget_prototype(gHorizScrollbar.widget);
       
   274 +
       
   275 +        gHorizScrollbar.scroll.style = moz_gtk_style_create(path, NULL);
       
   276 +        gHorizScrollbar.scroll.styleContents = moz_gtk_style_create(path+2, 
       
   277 +                                               gHorizScrollbar.scroll.style);
       
   278 +        gHorizScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3, 
       
   279 +                                               gHorizScrollbar.scroll.styleContents);
       
   280 +        gHorizScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4, 
       
   281 +                                               gHorizScrollbar.scroll.styleTrough);
       
   282 +
       
   283 +        gVertScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
       
   284 +        setup_widget_prototype(gVertScrollbar.widget);
       
   285 +
       
   286 +        gVertScrollbar.scroll.style = moz_gtk_style_create(path+1, NULL);
       
   287 +        gVertScrollbar.scroll.styleContents = moz_gtk_style_create(path+2, 
       
   288 +                                              gVertScrollbar.scroll.style);
       
   289 +        gVertScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3, 
       
   290 +                                              gVertScrollbar.scroll.styleContents);
       
   291 +        gVertScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4, 
       
   292 +                                              gVertScrollbar.scroll.styleTrough);
       
   293 +
       
   294 +     }
       
   295      return MOZ_GTK_SUCCESS;
       
   296  }
       
   297  
       
   298  static gint
       
   299  ensure_spin_widget()
       
   300  {
       
   301 -  if (!gSpinWidget) {
       
   302 -    gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
       
   303 -    setup_widget_prototype(gSpinWidget);
       
   304 -  }
       
   305 -  return MOZ_GTK_SUCCESS;
       
   306 +    if (!gSpin.widget) {
       
   307 +        GtkCssNode path[] = {
       
   308 +            { GTK_TYPE_SPIN_BUTTON, "spinbutton", "horizontal", NULL },
       
   309 +            { GTK_TYPE_SPIN_BUTTON, "spinbutton", "vertical", NULL },
       
   310 +            { GTK_TYPE_ENTRY, "entry", NULL, NULL },
       
   311 +            { G_TYPE_NONE, "button", "up", NULL },
       
   312 +            { G_TYPE_NONE, "button", "down", NULL }
       
   313 +        };
       
   314 +
       
   315 +        gSpin.widget = gtk_spin_button_new(NULL, 1, 0);
       
   316 +        setup_widget_prototype(gSpin.widget);
       
   317 +
       
   318 +        gSpin.spin.style = moz_gtk_style_create(path, NULL);
       
   319 +        gSpin.spin.styleButtonUp = moz_gtk_style_create(path+3, gSpin.spin.style);
       
   320 +        gSpin.spin.styleButtonDown = moz_gtk_style_create(path+4, gSpin.spin.style);
       
   321 +        gSpin.spin.styleEntry = moz_gtk_style_create(path+2, gSpin.spin.style);
       
   322 +    }
       
   323 +    return MOZ_GTK_SUCCESS;
       
   324  }
       
   325  
       
   326  static gint
       
   327 @@ -253,9 +439,19 @@ ensure_scale_widget()
       
   328  static gint
       
   329  ensure_entry_widget()
       
   330  {
       
   331 -    if (!gEntryWidget) {
       
   332 -        gEntryWidget = gtk_entry_new();
       
   333 -        setup_widget_prototype(gEntryWidget);
       
   334 +    if (!gEntry.widget) {
       
   335 +        GtkCssNode path[] = { 
       
   336 +            { GTK_TYPE_ENTRY, "entry", NULL, NULL },
       
   337 +            { G_TYPE_NONE, "selection", NULL, NULL }
       
   338 +        };
       
   339 +
       
   340 +        gEntry.widget = gtk_entry_new();
       
   341 +        setup_widget_prototype(gEntry.widget);
       
   342 +        gtk_widget_show(gEntry.widget);
       
   343 +
       
   344 +        gEntry.entry.style = moz_gtk_style_create(&path[0], NULL);
       
   345 +        gEntry.entry.styleSelection = moz_gtk_style_create(&path[1], 
       
   346 +                                                           gEntry.entry.style);
       
   347      }
       
   348      return MOZ_GTK_SUCCESS;
       
   349  }
       
   350 @@ -387,9 +583,9 @@ moz_gtk_get_combo_box_entry_inner_widget
       
   351          g_object_add_weak_pointer(G_OBJECT(widget),
       
   352                                    (gpointer) &gComboBoxEntryButtonWidget);
       
   353      } else if (GTK_IS_ENTRY(widget)) {
       
   354 -        gComboBoxEntryTextareaWidget = widget;
       
   355 +        gComboBoxEntryTextarea.widget = widget;
       
   356          g_object_add_weak_pointer(G_OBJECT(widget),
       
   357 -                                  (gpointer) &gComboBoxEntryTextareaWidget);
       
   358 +                                  (gpointer) &gComboBoxEntryTextarea.widget);
       
   359      } else
       
   360          return;
       
   361      gtk_widget_realize(widget);
       
   362 @@ -411,7 +607,7 @@ ensure_combo_box_entry_widgets()
       
   363  {
       
   364      GtkWidget* buttonChild;
       
   365  
       
   366 -    if (gComboBoxEntryTextareaWidget &&
       
   367 +    if (gComboBoxEntryTextarea.widget &&
       
   368              gComboBoxEntryButtonWidget &&
       
   369              gComboBoxEntryArrowWidget)
       
   370          return MOZ_GTK_SUCCESS;
       
   371 @@ -427,9 +623,9 @@ ensure_combo_box_entry_widgets()
       
   372                           moz_gtk_get_combo_box_entry_inner_widgets,
       
   373                           NULL);
       
   374  
       
   375 -    if (!gComboBoxEntryTextareaWidget) {
       
   376 +    if (!gComboBoxEntryTextarea.widget) {
       
   377          ensure_entry_widget();
       
   378 -        gComboBoxEntryTextareaWidget = gEntryWidget;
       
   379 +        gComboBoxEntryTextarea.widget = gEntry.widget;
       
   380      }
       
   381  
       
   382      if (gComboBoxEntryButtonWidget) {
       
   383 @@ -507,12 +703,18 @@ ensure_toolbar_separator_widget()
       
   384  static gint
       
   385  ensure_tooltip_widget()
       
   386  {
       
   387 -    if (!gTooltipWidget) {
       
   388 -        gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
       
   389 -        GtkStyleContext* style = gtk_widget_get_style_context(gTooltipWidget);
       
   390 -        gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
       
   391 -        gtk_widget_realize(gTooltipWidget);
       
   392 -        moz_gtk_set_widget_name(gTooltipWidget);
       
   393 +    if (!gTooltip.widget) {
       
   394 +        GtkCssNode path[] = { 
       
   395 +            { GTK_TYPE_TOOLTIP, "tooltip", NULL, NULL},
       
   396 +            { GTK_TYPE_TOOLTIP, "tooltip", "background", NULL},
       
   397 +        };
       
   398 +
       
   399 +        gTooltip.widget = gtk_window_new(GTK_WINDOW_POPUP);
       
   400 +        gtk_widget_realize(gTooltip.widget);
       
   401 +        moz_gtk_set_widget_name(gTooltip.widget);
       
   402 +
       
   403 +        gTooltip.tooltip.style = moz_gtk_style_create(&path[0], NULL);
       
   404 +        gTooltip.tooltip.styleBackground = moz_gtk_style_create(&path[1], NULL);
       
   405      }
       
   406      return MOZ_GTK_SUCCESS;
       
   407  }
       
   408 @@ -530,9 +732,21 @@ ensure_tab_widget()
       
   409  static gint
       
   410  ensure_progress_widget()
       
   411  {
       
   412 -    if (!gProgressWidget) {
       
   413 -        gProgressWidget = gtk_progress_bar_new();
       
   414 -        setup_widget_prototype(gProgressWidget);
       
   415 +    if (!gProgressBar.widget) {
       
   416 +        GtkCssNode path[] = {
       
   417 +           { GTK_TYPE_LABEL, "progressbar", NULL, NULL },
       
   418 +           { G_TYPE_NONE, "trough", NULL, NULL },
       
   419 +           { G_TYPE_NONE, "progress", NULL, NULL },
       
   420 +        };
       
   421 +
       
   422 +        gProgressBar.widget = gtk_progress_bar_new();
       
   423 +        setup_widget_prototype(gProgressBar.widget);
       
   424 +
       
   425 +        gProgressBar.progress.style = moz_gtk_style_create(&path[0], NULL);
       
   426 +        gProgressBar.progress.styleTrough = moz_gtk_style_create(&path[1],
       
   427 +                                              gProgressBar.progress.style);
       
   428 +        gProgressBar.progress.styleProgress = moz_gtk_style_create(&path[2],
       
   429 +                                                gProgressBar.progress.styleTrough);
       
   430      }
       
   431      return MOZ_GTK_SUCCESS;
       
   432  }
       
   433 @@ -638,6 +852,11 @@ static gint
       
   434  ensure_check_menu_item_widget()
       
   435  {
       
   436      if (!gCheckMenuItemWidget) {
       
   437 +        GtkCssNode path[] = {
       
   438 +           { GTK_TYPE_CHECK_MENU_ITEM, "menuitem", NULL, NULL },
       
   439 +           { G_TYPE_NONE, "check", NULL, NULL }
       
   440 +        };
       
   441 +
       
   442          ensure_menu_popup_widget();
       
   443          gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
       
   444          gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
       
   445 @@ -752,7 +971,7 @@ moz_gtk_checkbox_get_metrics(gint* indic
       
   446  {
       
   447      ensure_checkbox_widget();
       
   448  
       
   449 -    gtk_widget_style_get (gCheckboxWidget,
       
   450 +    gtk_widget_style_get (gCheckbox.widget,
       
   451                            "indicator_size", indicator_size,
       
   452                            "indicator_spacing", indicator_spacing,
       
   453                            NULL);
       
   454 @@ -765,7 +984,7 @@ moz_gtk_radio_get_metrics(gint* indicato
       
   455  {
       
   456      ensure_radiobutton_widget();
       
   457  
       
   458 -    gtk_widget_style_get (gRadiobuttonWidget,
       
   459 +    gtk_widget_style_get (gRadiobutton.widget,
       
   460                            "indicator_size", indicator_size,
       
   461                            "indicator_spacing", indicator_spacing,
       
   462                            NULL);
       
   463 @@ -778,13 +997,13 @@ moz_gtk_get_focus_outline_size(gint* foc
       
   464  {
       
   465      GtkBorder border;
       
   466      GtkBorder padding;
       
   467 -    GtkStyleContext *style;
       
   468 +    GtkStyleContext* style;
       
   469  
       
   470      ensure_entry_widget();
       
   471 -    style = gtk_widget_get_style_context(gEntryWidget);
       
   472  
       
   473 -    gtk_style_context_get_border(style, 0, &border);
       
   474 -    gtk_style_context_get_padding(style, 0, &padding);
       
   475 +    style = gEntry.entry.style;
       
   476 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
       
   477 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
       
   478      *focus_h_width = border.left + padding.left;
       
   479      *focus_v_width = border.top + padding.top;
       
   480      return MOZ_GTK_SUCCESS;
       
   481 @@ -821,7 +1040,7 @@ moz_gtk_button_get_default_overflow(gint
       
   482      GtkBorder* default_outside_border;
       
   483  
       
   484      ensure_button_widget();
       
   485 -    gtk_widget_style_get(gButtonWidget,
       
   486 +    gtk_widget_style_get(gButton.widget,
       
   487                           "default-outside-border", &default_outside_border,
       
   488                           NULL);
       
   489  
       
   490 @@ -844,7 +1063,7 @@ moz_gtk_button_get_default_border(gint*
       
   491      GtkBorder* default_border;
       
   492  
       
   493      ensure_button_widget();
       
   494 -    gtk_widget_style_get(gButtonWidget,
       
   495 +    gtk_widget_style_get(gButton.widget,
       
   496                           "default-border", &default_border,
       
   497                           NULL);
       
   498  
       
   499 @@ -935,7 +1154,7 @@ moz_gtk_button_paint(cairo_t *cr, GdkRec
       
   500  
       
   501      if (state->focused) {
       
   502          GtkBorder border;
       
   503 -        gtk_style_context_get_border(style, state_flags, &border);
       
   504 +        moz_gtk_get_style_border(style, state_flags, &border);
       
   505          x += border.left;
       
   506          y += border.top;
       
   507          width -= (border.left + border.right);
       
   508 @@ -956,15 +1175,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
       
   509      gint indicator_size, indicator_spacing;
       
   510      gint x, y, width, height;
       
   511      gint focus_x, focus_y, focus_width, focus_height;
       
   512 -    GtkWidget *w;
       
   513 -    GtkStyleContext *style;
       
   514 +    MozGtkWidget *w;
       
   515  
       
   516      if (isradio) {
       
   517          moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
       
   518 -        w = gRadiobuttonWidget;
       
   519 +        w = &gRadiobutton;
       
   520      } else {
       
   521          moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
       
   522 -        w = gCheckboxWidget;
       
   523 +        w = &gCheckbox;
       
   524      }
       
   525  
       
   526      // XXX we should assert rect->height >= indicator_size too
       
   527 @@ -983,11 +1201,9 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
       
   528      focus_width = width + 2 * indicator_spacing;
       
   529      focus_height = height + 2 * indicator_spacing;
       
   530    
       
   531 -    style = gtk_widget_get_style_context(w);
       
   532 -
       
   533 -    gtk_widget_set_sensitive(w, !state->disabled);
       
   534 -    gtk_widget_set_direction(w, direction);
       
   535 -    gtk_style_context_save(style);
       
   536 +    gtk_widget_set_sensitive(w->widget, !state->disabled);
       
   537 +    gtk_widget_set_direction(w->widget, direction);
       
   538 +    gtk_style_context_save(w->check.styleCheck);
       
   539  
       
   540      if (selected)
       
   541          state_flags |= checkbox_check_state;
       
   542 @@ -995,13 +1211,15 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
       
   543      if (inconsistent)
       
   544          state_flags |= GTK_STATE_FLAG_INCONSISTENT;
       
   545  
       
   546 -    gtk_style_context_set_state(style, state_flags);
       
   547 +    gtk_style_context_set_state(w->check.styleCheck, state_flags);
       
   548 +
       
   549 +    gtk_render_background(w->check.styleCheck, cr, x, y, width, height);
       
   550 +    gtk_render_frame(w->check.styleCheck, cr, x, y, width, height);
       
   551  
       
   552      if (isradio) {
       
   553 -        gtk_style_context_add_class(style, GTK_STYLE_CLASS_RADIO);
       
   554 -        gtk_render_option(style, cr, x, y, width, height);
       
   555 +        gtk_render_option(w->check.styleCheck, cr, x, y, width, height);
       
   556          if (state->focused) {
       
   557 -            gtk_render_focus(style, cr, focus_x, focus_y,
       
   558 +            gtk_render_focus(w->check.styleCheck, cr, focus_x, focus_y,
       
   559                              focus_width, focus_height);
       
   560          }
       
   561      }
       
   562 @@ -1010,15 +1228,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
       
   563          * 'indeterminate' type on checkboxes. In GTK, the shadow type
       
   564          * must also be changed for the state to be drawn.
       
   565          */        
       
   566 -        gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
       
   567 -        gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), inconsistent);
       
   568 -        gtk_render_check(style, cr, x, y, width, height);        
       
   569 +        gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(w->widget), inconsistent);
       
   570 +        gtk_render_check(w->check.styleCheck, cr, x, y, width, height);
       
   571          if (state->focused) {
       
   572 -            gtk_render_focus(style, cr, 
       
   573 +            gtk_render_focus(w->check.styleCheck, cr,
       
   574                               focus_x, focus_y, focus_width, focus_height);
       
   575          }
       
   576      }
       
   577 -    gtk_style_context_restore(style);
       
   578 +    gtk_style_context_restore(w->check.styleCheck);
       
   579  
       
   580      return MOZ_GTK_SUCCESS;
       
   581  }
       
   582 @@ -1035,8 +1252,8 @@ calculate_button_inner_rect(GtkWidget* b
       
   583      style = gtk_widget_get_style_context(button);
       
   584  
       
   585      /* This mirrors gtkbutton's child positioning */
       
   586 -    gtk_style_context_get_border(style, 0, &border);
       
   587 -    gtk_style_context_get_padding(style, 0, &padding);
       
   588 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
       
   589 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
       
   590  
       
   591      inner_rect->x = rect->x + border.left + padding.left;
       
   592      inner_rect->y = rect->y + padding.top + border.top;
       
   593 @@ -1099,9 +1316,9 @@ moz_gtk_scrollbar_button_paint(cairo_t *
       
   594      ensure_scrollbar_widget();
       
   595  
       
   596      if (flags & MOZ_GTK_STEPPER_VERTICAL)
       
   597 -        scrollbar = gVertScrollbarWidget;
       
   598 +        scrollbar = gVertScrollbar.widget;
       
   599      else
       
   600 -        scrollbar = gHorizScrollbarWidget;
       
   601 +        scrollbar = gHorizScrollbar.widget;
       
   602  
       
   603      gtk_widget_set_direction(scrollbar, direction);
       
   604  
       
   605 @@ -1181,25 +1398,22 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
       
   606                                 GtkTextDirection direction)
       
   607  {
       
   608      GtkStyleContext* style;
       
   609 -    GtkScrollbar *scrollbar;
       
   610  
       
   611      ensure_scrollbar_widget();
       
   612  
       
   613 -    if (widget ==  MOZ_GTK_SCROLLBAR_HORIZONTAL)
       
   614 -        scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
       
   615 -    else
       
   616 -        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
       
   617 -
       
   618 -    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
       
   619 -    
       
   620      if (flags & MOZ_GTK_TRACK_OPAQUE) {
       
   621          style = gtk_widget_get_style_context(GTK_WIDGET(gProtoWindow));
       
   622          gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   623      }
       
   624  
       
   625 -    style = gtk_widget_get_style_context(GTK_WIDGET(scrollbar));
       
   626 -    gtk_style_context_save(style);
       
   627 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
       
   628 +     if (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) {
       
   629 +        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
       
   630 +        style = gHorizScrollbar.scroll.style;
       
   631 +    }
       
   632 +    else {
       
   633 +        gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
       
   634 +        style = gVertScrollbar.scroll.style;
       
   635 +    }
       
   636  
       
   637      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   638      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   639 @@ -1208,7 +1422,6 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
       
   640          gtk_render_focus(style, cr,
       
   641                           rect->x, rect->y, rect->width, rect->height);
       
   642      }
       
   643 -    gtk_style_context_restore(style);
       
   644      return MOZ_GTK_SUCCESS;
       
   645  }
       
   646  
       
   647 @@ -1220,24 +1433,20 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
       
   648  {
       
   649      GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
       
   650      GtkStyleContext* style;
       
   651 -    GtkScrollbar *scrollbar;
       
   652      GtkBorder margin;
       
   653  
       
   654      ensure_scrollbar_widget();
       
   655  
       
   656 -    if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL)
       
   657 -        scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
       
   658 -    else
       
   659 -        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
       
   660 -
       
   661 -    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
       
   662 -
       
   663 -    style = gtk_widget_get_style_context(GTK_WIDGET(scrollbar));
       
   664 -    gtk_style_context_save(style);
       
   665 +    if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) {
       
   666 +        style = gHorizScrollbar.scroll.styleSlider;
       
   667 +        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
       
   668 +    }
       
   669 +    else {
       
   670 +        style = gVertScrollbar.scroll.styleSlider; 
       
   671 +        gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
       
   672 +    }
       
   673  
       
   674 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_SLIDER);
       
   675      gtk_style_context_set_state(style, state_flags);
       
   676 -
       
   677      gtk_style_context_get_margin (style, state_flags, &margin);
       
   678  
       
   679      gtk_render_slider(style, cr,
       
   680 @@ -1248,8 +1457,6 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
       
   681                       (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
       
   682                       GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
       
   683  
       
   684 -    gtk_style_context_restore(style);
       
   685 -
       
   686      return MOZ_GTK_SUCCESS;
       
   687  }
       
   688  
       
   689 @@ -1260,8 +1467,8 @@ moz_gtk_spin_paint(cairo_t *cr, GdkRecta
       
   690      GtkStyleContext* style;
       
   691  
       
   692      ensure_spin_widget();
       
   693 -    gtk_widget_set_direction(gSpinWidget, direction);
       
   694 -    style = gtk_widget_get_style_context(gSpinWidget);
       
   695 +    gtk_widget_set_direction(gSpin.widget, direction);
       
   696 +    style = gSpin.spin.style;
       
   697      gtk_style_context_save(style);
       
   698      gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
       
   699      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   700 @@ -1280,11 +1487,10 @@ moz_gtk_spin_updown_paint(cairo_t *cr, G
       
   701      GtkStyleContext* style;
       
   702  
       
   703      ensure_spin_widget();
       
   704 -    style = gtk_widget_get_style_context(gSpinWidget);
       
   705 +    style = gSpin.spin.style;
       
   706      gtk_style_context_save(style);
       
   707 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
       
   708      gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
       
   709 -    gtk_widget_set_direction(gSpinWidget, direction);
       
   710 +    gtk_widget_set_direction(gSpin.widget, direction);
       
   711  
       
   712      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   713      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   714 @@ -1450,15 +1656,13 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec
       
   715  static gint
       
   716  moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect,
       
   717                      GtkWidgetState* state,
       
   718 -                    GtkWidget* widget, GtkTextDirection direction)
       
   719 +                    MozGtkWidget* w, GtkTextDirection direction)
       
   720  {
       
   721      gint x = rect->x, y = rect->y, width = rect->width, height = rect->height;
       
   722 -    GtkStyleContext* style;
       
   723      int draw_focus_outline_only = state->depressed; // NS_THEME_FOCUS_OUTLINE
       
   724 +    GtkStyleContext* style = w->entry.style;
       
   725  
       
   726 -    gtk_widget_set_direction(widget, direction);
       
   727 -
       
   728 -    style = gtk_widget_get_style_context(widget);
       
   729 +    gtk_widget_set_direction(w->widget, direction);
       
   730  
       
   731      if (draw_focus_outline_only) {
       
   732          // Inflate the given 'rect' with the focus outline size.
       
   733 @@ -1478,10 +1682,9 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRect
       
   734       * textarea window uses gtk_paint_flat_box when exposed */
       
   735  
       
   736      /* This gets us a lovely greyish disabledish look */
       
   737 -    gtk_widget_set_sensitive(widget, !state->disabled);
       
   738 +    gtk_widget_set_sensitive(w->widget, !state->disabled);
       
   739  
       
   740      gtk_style_context_save(style);
       
   741 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_ENTRY);
       
   742    
       
   743      /* Now paint the shadow and focus border.
       
   744       * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad
       
   745 @@ -1531,7 +1734,7 @@ moz_gtk_treeview_paint(cairo_t *cr, GdkR
       
   746      style = gtk_widget_get_style_context(gScrolledWindowWidget);
       
   747      gtk_style_context_save(style);
       
   748      gtk_style_context_add_class(style, GTK_STYLE_CLASS_FRAME);    
       
   749 -    gtk_style_context_get_border(style, state_flags, &border);
       
   750 +    moz_gtk_get_style_border(style, state_flags, &border);
       
   751      xthickness = border.left;
       
   752      ythickness = border.top;    
       
   753  
       
   754 @@ -1702,7 +1905,7 @@ moz_gtk_combo_box_paint(cairo_t *cr, Gdk
       
   755          if (direction == GTK_TEXT_DIR_LTR) {
       
   756              GtkBorder padding;
       
   757              GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
       
   758 -            gtk_style_context_get_padding(style, state_flags, &padding);
       
   759 +            moz_gtk_get_style_padding(style, state_flags, &padding);
       
   760              arrow_rect.x -= padding.left;
       
   761          }
       
   762          else
       
   763 @@ -1804,29 +2007,27 @@ moz_gtk_container_paint(cairo_t *cr, Gdk
       
   764                          gboolean isradio, GtkTextDirection direction)
       
   765  {
       
   766      GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
       
   767 -    GtkStyleContext* style;
       
   768 -    GtkWidget *widget;
       
   769 +    MozGtkWidget *widget;
       
   770  
       
   771      if (isradio) {
       
   772          ensure_radiobutton_widget();
       
   773 -        widget = gRadiobuttonWidget;
       
   774 +        widget = &gRadiobutton;
       
   775      } else {
       
   776          ensure_checkbox_widget();
       
   777 -        widget = gCheckboxWidget;
       
   778 +        widget = &gCheckbox;
       
   779      }
       
   780 -    gtk_widget_set_direction(widget, direction);
       
   781 +    gtk_widget_set_direction(widget->widget, direction);
       
   782  
       
   783 -    style = gtk_widget_get_style_context(widget);
       
   784 -    gtk_style_context_save(style);
       
   785 -    gtk_style_context_set_state(style, state_flags);
       
   786 +    gtk_style_context_save(widget->check.style);
       
   787 +    gtk_style_context_set_state(widget->check.style, state_flags);
       
   788    
       
   789      /* this is for drawing a prelight box */
       
   790      if (state_flags & GTK_STATE_FLAG_PRELIGHT) {
       
   791 -        gtk_render_background(style, cr,
       
   792 +        gtk_render_background(widget->check.style, cr,
       
   793                                rect->x, rect->y, rect->width, rect->height);
       
   794      }
       
   795    
       
   796 -    gtk_style_context_restore(style);
       
   797 +    gtk_style_context_restore(widget->check.style);
       
   798    
       
   799      return MOZ_GTK_SUCCESS;
       
   800  }
       
   801 @@ -1836,32 +2037,26 @@ moz_gtk_toggle_label_paint(cairo_t *cr,
       
   802                             GtkWidgetState* state, 
       
   803                             gboolean isradio, GtkTextDirection direction)
       
   804  {
       
   805 -    GtkStyleContext *style;
       
   806 -    GtkWidget *widget;
       
   807 +    MozGtkWidget *widget;
       
   808  
       
   809      if (!state->focused)
       
   810          return MOZ_GTK_SUCCESS;
       
   811  
       
   812      if (isradio) {
       
   813          ensure_radiobutton_widget();
       
   814 -        widget = gRadiobuttonWidget;
       
   815 +        widget = &gRadiobutton;
       
   816      } else {
       
   817          ensure_checkbox_widget();
       
   818 -        widget = gCheckboxWidget;
       
   819 -    }
       
   820 -    style = gtk_widget_get_style_context(widget);
       
   821 -    gtk_style_context_save(style);
       
   822 -    if (isradio) {
       
   823 -      gtk_style_context_add_class(style, GTK_STYLE_CLASS_RADIO);
       
   824 -    } else {
       
   825 -      gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
       
   826 +        widget = &gCheckbox;
       
   827      }
       
   828 -    gtk_widget_set_direction(widget, direction);
       
   829 +    gtk_style_context_save(widget->check.styleLabel);
       
   830 +    gtk_widget_set_direction(widget->widget, direction);
       
   831  
       
   832 -    gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
       
   833 -    gtk_render_focus(style, cr,
       
   834 +    gtk_style_context_set_state(widget->check.styleLabel, 
       
   835 +                                GetStateFlagsFromGtkWidgetState(state));
       
   836 +    gtk_render_focus(widget->check.styleLabel, cr,
       
   837                      rect->x, rect->y, rect->width, rect->height);
       
   838 -    gtk_style_context_restore(style);
       
   839 +    gtk_style_context_restore(widget->check.styleLabel);
       
   840  
       
   841      return MOZ_GTK_SUCCESS;
       
   842  }
       
   843 @@ -1922,7 +2117,7 @@ moz_gtk_toolbar_separator_paint(cairo_t
       
   844                            rect->height * (end_fraction - start_fraction));
       
   845      } else {
       
   846          GtkBorder padding;
       
   847 -        gtk_style_context_get_padding(style, 0, &padding);
       
   848 +        gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
       
   849      
       
   850          paint_width = padding.left;
       
   851          if (paint_width > rect->width)
       
   852 @@ -1945,9 +2140,9 @@ moz_gtk_tooltip_paint(cairo_t *cr, GdkRe
       
   853      GtkStyleContext* style;
       
   854  
       
   855      ensure_tooltip_widget();
       
   856 -    gtk_widget_set_direction(gTooltipWidget, direction);
       
   857 +    gtk_widget_set_direction(gTooltip.widget, direction);
       
   858  
       
   859 -    style = gtk_widget_get_style_context(gTooltipWidget);
       
   860 +    style = gTooltip.tooltip.styleBackground;
       
   861      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   862      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   863      return MOZ_GTK_SUCCESS;
       
   864 @@ -2006,18 +2201,13 @@ static gint
       
   865  moz_gtk_progressbar_paint(cairo_t *cr, GdkRectangle* rect,
       
   866                            GtkTextDirection direction)
       
   867  {
       
   868 -    GtkStyleContext* style;
       
   869 -
       
   870      ensure_progress_widget();
       
   871 -    gtk_widget_set_direction(gProgressWidget, direction);
       
   872 +    gtk_widget_set_direction(gProgressBar.widget, direction);
       
   873  
       
   874 -    style = gtk_widget_get_style_context(gProgressWidget);
       
   875 -    gtk_style_context_save(style);
       
   876 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
       
   877 -    
       
   878 -    gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   879 -    gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   880 -    gtk_style_context_restore(style);
       
   881 +    gtk_render_background(gProgressBar.progress.styleTrough, cr,
       
   882 +                          rect->x, rect->y, rect->width, rect->height);
       
   883 +    gtk_render_frame(gProgressBar.progress.styleTrough, cr,
       
   884 +                     rect->x, rect->y, rect->width, rect->height);
       
   885  
       
   886      return MOZ_GTK_SUCCESS;
       
   887  }
       
   888 @@ -2027,15 +2217,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
       
   889                               GtkTextDirection direction,
       
   890                               GtkThemeWidgetType widget)
       
   891  {
       
   892 -    GtkStyleContext* style;
       
   893 -
       
   894      ensure_progress_widget();
       
   895 -    gtk_widget_set_direction(gProgressWidget, direction);
       
   896 -
       
   897 -    style = gtk_widget_get_style_context(gProgressWidget);
       
   898 -    gtk_style_context_save(style);
       
   899 -    gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH);
       
   900 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR);
       
   901 +    gtk_widget_set_direction(gProgressBar.widget, direction);
       
   902  
       
   903      if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
       
   904          widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
       
   905 @@ -2074,12 +2257,14 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
       
   906      // gtk_render_activity was used to render progress chunks on GTK versions
       
   907      // before 3.13.7, see bug 1173907.
       
   908      if (!gtk_check_version(3, 13, 7)) {
       
   909 -      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   910 -      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   911 +      gtk_render_background(gProgressBar.progress.styleProgress, cr,
       
   912 +                            rect->x, rect->y, rect->width, rect->height);
       
   913 +      gtk_render_frame(gProgressBar.progress.styleProgress, cr,
       
   914 +                       rect->x, rect->y, rect->width, rect->height);
       
   915      } else {
       
   916 -      gtk_render_activity(style, cr, rect->x, rect->y, rect->width, rect->height);
       
   917 +      gtk_render_activity(gProgressBar.progress.styleProgress, cr,
       
   918 +                          rect->x, rect->y, rect->width, rect->height);
       
   919      }
       
   920 -    gtk_style_context_restore(style);
       
   921  
       
   922      return MOZ_GTK_SUCCESS;
       
   923  }
       
   924 @@ -2096,7 +2281,7 @@ moz_gtk_get_tab_thickness(void)
       
   925  
       
   926      style = gtk_widget_get_style_context(gTabWidget);
       
   927      gtk_style_context_add_class(style, GTK_STYLE_CLASS_NOTEBOOK);
       
   928 -    gtk_style_context_get_border(style, 0, &border);
       
   929 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
       
   930  
       
   931      if (border.top < 2)
       
   932          return 2; /* some themes don't set ythickness correctly */
       
   933 @@ -2292,7 +2477,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
       
   934        gtk_style_context_save(style);
       
   935        moz_gtk_tab_prepare_style_context(style, flags);
       
   936  
       
   937 -      gtk_style_context_get_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
       
   938 +      moz_gtk_get_style_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
       
   939  
       
   940        focusRect.x += padding.left;
       
   941        focusRect.width -= (padding.left + padding.right);
       
   942 @@ -2408,7 +2593,7 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *
       
   943  }
       
   944  
       
   945  static gint
       
   946 -moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect,
       
   947 +moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state,
       
   948                         GtkTextDirection direction)
       
   949  {
       
   950      GtkStyleContext* style;
       
   951 @@ -2468,7 +2653,7 @@ moz_gtk_menu_separator_paint(cairo_t *cr
       
   952      border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
       
   953  
       
   954      style = gtk_widget_get_style_context(gMenuSeparatorWidget);
       
   955 -    gtk_style_context_get_padding(style, 0, &padding);
       
   956 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
       
   957  
       
   958      x = rect->x + border_width;
       
   959      y = rect->y + border_width;
       
   960 @@ -2521,7 +2706,8 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
       
   961              item_widget = gMenuItemWidget;
       
   962          }
       
   963          style = gtk_widget_get_style_context(item_widget);
       
   964 -        gtk_style_context_save(style);
       
   965 +// TODO - FIX!
       
   966 +//        gtk_style_context_save(style);
       
   967  
       
   968          if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
       
   969              gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
       
   970 @@ -2540,7 +2726,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
       
   971  
       
   972          gtk_render_background(style, cr, x, y, w, h);
       
   973          gtk_render_frame(style, cr, x, y, w, h);
       
   974 -        gtk_style_context_restore(style);
       
   975 +//        gtk_style_context_restore(style);
       
   976      }
       
   977  
       
   978      return MOZ_GTK_SUCCESS;
       
   979 @@ -2556,7 +2742,10 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, Gd
       
   980  
       
   981      ensure_menu_item_widget();
       
   982      gtk_widget_set_direction(gMenuItemWidget, direction);
       
   983 -
       
   984 +/*
       
   985 +    state_flags |= (direction == GTK_TEXT_DIR_LTR) ? GTK_STATE_FLAG_DIR_LTR :
       
   986 +                                                     GTK_STATE_FLAG_DIR_RTL;
       
   987 +*/
       
   988      style = gtk_widget_get_style_context(gMenuItemWidget);
       
   989      gtk_style_context_save(style);
       
   990      gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUITEM);
       
   991 @@ -2606,7 +2795,7 @@ moz_gtk_check_menu_item_paint(cairo_t *c
       
   992      }
       
   993      
       
   994      gtk_style_context_set_state(style, state_flags);
       
   995 -    gtk_style_context_get_padding(style, state_flags, &padding);
       
   996 +    moz_gtk_get_style_padding(style, state_flags, &padding);
       
   997  
       
   998      offset = gtk_container_get_border_width(GTK_CONTAINER(gCheckMenuItemWidget)) +
       
   999                                              padding.left + 2;
       
  1000 @@ -2658,7 +2847,7 @@ moz_gtk_add_style_border(GtkStyleContext
       
  1001  {
       
  1002      GtkBorder border;
       
  1003  
       
  1004 -    gtk_style_context_get_border(style, 0, &border);
       
  1005 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
       
  1006  
       
  1007      *left += border.left;
       
  1008      *right += border.right;
       
  1009 @@ -2667,12 +2856,22 @@ moz_gtk_add_style_border(GtkStyleContext
       
  1010  }
       
  1011  
       
  1012  static void
       
  1013 +moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
       
  1014 +                         GtkBorder *border)
       
  1015 +{
       
  1016 +    gtk_style_context_save(style);
       
  1017 +    gtk_style_context_set_state(style, state_flags);
       
  1018 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), border);
       
  1019 +    gtk_style_context_restore(style);
       
  1020 +}
       
  1021 +
       
  1022 +static void
       
  1023  moz_gtk_add_style_padding(GtkStyleContext* style,
       
  1024                            gint* left, gint* top, gint* right, gint* bottom)
       
  1025  {
       
  1026      GtkBorder padding;
       
  1027  
       
  1028 -    gtk_style_context_get_padding(style, 0, &padding);
       
  1029 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
       
  1030  
       
  1031      *left += padding.left;
       
  1032      *right += padding.right;
       
  1033 @@ -2680,6 +2879,16 @@ moz_gtk_add_style_padding(GtkStyleContex
       
  1034      *bottom += padding.bottom;
       
  1035  }
       
  1036  
       
  1037 +static void
       
  1038 +moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
       
  1039 +                          GtkBorder *padding)
       
  1040 +{
       
  1041 +    gtk_style_context_save(style);
       
  1042 +    gtk_style_context_set_state(style, state_flags);
       
  1043 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), padding);
       
  1044 +    gtk_style_context_restore(style);
       
  1045 +}
       
  1046 +
       
  1047  gint
       
  1048  moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
       
  1049                            gint* right, gint* bottom, GtkTextDirection direction,
       
  1050 @@ -2694,37 +2903,35 @@ moz_gtk_get_widget_border(GtkThemeWidget
       
  1051      case MOZ_GTK_TOOLBAR_BUTTON:
       
  1052          {
       
  1053              ensure_button_widget();
       
  1054 -            style = gtk_widget_get_style_context(gButtonWidget);
       
  1055 -
       
  1056 -            *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButtonWidget));
       
  1057  
       
  1058 -            if (widget == MOZ_GTK_TOOLBAR_BUTTON) {
       
  1059 -                gtk_style_context_save(style);
       
  1060 -                gtk_style_context_add_class(style, "image-button");
       
  1061 -            }
       
  1062 -              
       
  1063 -            moz_gtk_add_style_padding(style, left, top, right, bottom);
       
  1064 -                
       
  1065 -            if (widget == MOZ_GTK_TOOLBAR_BUTTON)
       
  1066 -                gtk_style_context_restore(style);
       
  1067 +            *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButton.widget));
       
  1068 +            moz_gtk_add_style_padding(gButton.button.style, left, top, right, bottom);
       
  1069  
       
  1070              // XXX: Subtract 1 pixel from the border to account for the added
       
  1071              // -moz-focus-inner border (Bug 1228281).
       
  1072              *left -= 1; *top -= 1; *right -= 1; *bottom -= 1;
       
  1073 -            moz_gtk_add_style_border(style, left, top, right, bottom);
       
  1074 +            moz_gtk_add_style_border(gButton.button.style, left, top, right, bottom);
       
  1075 +
       
  1076              return MOZ_GTK_SUCCESS;
       
  1077          }
       
  1078      case MOZ_GTK_ENTRY:
       
  1079          {
       
  1080              ensure_entry_widget();
       
  1081 -            style = gtk_widget_get_style_context(gEntryWidget);
       
  1082  
       
  1083              // XXX: Subtract 1 pixel from the padding to account for the default
       
  1084              // padding in forms.css. See bug 1187385.
       
  1085              *left = *top = *right = *bottom = -1;
       
  1086 -            moz_gtk_add_style_padding(style, left, top, right, bottom);
       
  1087 -            moz_gtk_add_style_border(style, left, top, right, bottom);
       
  1088  
       
  1089 +            moz_gtk_add_style_padding(gEntry.entry.style, left, top, right, bottom);
       
  1090 +            moz_gtk_add_style_border(gEntry.entry.style, left, top, right, bottom);
       
  1091 +
       
  1092 +            return MOZ_GTK_SUCCESS;
       
  1093 +        }
       
  1094 +    case MOZ_GTK_TOOLTIP:
       
  1095 +        {
       
  1096 +            ensure_tooltip_widget();
       
  1097 +            moz_gtk_add_style_padding(gTooltip.tooltip.styleBackground, left, top, right, bottom);
       
  1098 +            moz_gtk_add_style_border(gTooltip.tooltip.styleBackground, left, top, right, bottom);
       
  1099              return MOZ_GTK_SUCCESS;
       
  1100          }
       
  1101      case MOZ_GTK_TREEVIEW:
       
  1102 @@ -2759,7 +2966,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
       
  1103          break;
       
  1104      case MOZ_GTK_DROPDOWN_ENTRY:
       
  1105          ensure_combo_box_entry_widgets();
       
  1106 -        w = gComboBoxEntryTextareaWidget;
       
  1107 +        w = gComboBoxEntryTextarea.widget;
       
  1108          break;
       
  1109      case MOZ_GTK_DROPDOWN_ARROW:
       
  1110          ensure_combo_box_entry_widgets();
       
  1111 @@ -2795,7 +3002,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
       
  1112  
       
  1113                  if (!wide_separators) {
       
  1114                      style = gtk_widget_get_style_context(gComboBoxSeparatorWidget);
       
  1115 -                    gtk_style_context_get_border(style, 0, &border);
       
  1116 +                    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
       
  1117                      separator_width = border.left;
       
  1118                  }
       
  1119              }
       
  1120 @@ -2814,14 +3021,17 @@ moz_gtk_get_widget_border(GtkThemeWidget
       
  1121          w = gTabWidget;
       
  1122          break;
       
  1123      case MOZ_GTK_PROGRESSBAR:
       
  1124 -        ensure_progress_widget();
       
  1125 -        w = gProgressWidget;
       
  1126 -        break;
       
  1127 +        {
       
  1128 +            ensure_progress_widget();
       
  1129 +            moz_gtk_add_style_border(gProgressBar.progress.styleTrough,
       
  1130 +                                     left, top, right, bottom);
       
  1131 +            return MOZ_GTK_SUCCESS;
       
  1132 +        }
       
  1133      case MOZ_GTK_SPINBUTTON_ENTRY:
       
  1134      case MOZ_GTK_SPINBUTTON_UP:
       
  1135      case MOZ_GTK_SPINBUTTON_DOWN:
       
  1136          ensure_spin_widget();
       
  1137 -        w = gSpinWidget;
       
  1138 +        w = gSpin.widget;
       
  1139          break;
       
  1140      case MOZ_GTK_SCALE_HORIZONTAL:
       
  1141          ensure_scale_widget();
       
  1142 @@ -2840,12 +3050,13 @@ moz_gtk_get_widget_border(GtkThemeWidget
       
  1143          {
       
  1144              if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
       
  1145                  ensure_checkbox_widget();
       
  1146 -                w = gCheckboxWidget;
       
  1147 +                w = gCheckbox.widget;
       
  1148 +                style = gCheckbox.check.styleCheck;
       
  1149              } else {
       
  1150                  ensure_radiobutton_widget();
       
  1151 -                w = gRadiobuttonWidget;
       
  1152 +                w = gRadiobutton.widget;
       
  1153 +                style = gRadiobutton.check.styleCheck;
       
  1154              }
       
  1155 -            style = gtk_widget_get_style_context(w);
       
  1156  
       
  1157              *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(w));
       
  1158              moz_gtk_add_style_border(style,
       
  1159 @@ -2904,7 +3115,6 @@ moz_gtk_get_widget_border(GtkThemeWidget
       
  1160      case MOZ_GTK_MENUSEPARATOR:
       
  1161      /* These widgets have no borders.*/
       
  1162      case MOZ_GTK_SPINBUTTON:
       
  1163 -    case MOZ_GTK_TOOLTIP:
       
  1164      case MOZ_GTK_WINDOW:
       
  1165      case MOZ_GTK_RESIZER:
       
  1166      case MOZ_GTK_MENUARROW:
       
  1167 @@ -2978,6 +3188,32 @@ moz_gtk_get_combo_box_entry_button_size(
       
  1168  }
       
  1169  
       
  1170  gint
       
  1171 +moz_gtk_get_entry_height(gint* height)
       
  1172 +{
       
  1173 +    GtkRequisition requisition;
       
  1174 +    ensure_entry_widget();
       
  1175 +
       
  1176 +    gtk_widget_get_preferred_size(gEntry.widget, NULL, &requisition);
       
  1177 +    *height = requisition.height;
       
  1178 +
       
  1179 +    return MOZ_GTK_SUCCESS;
       
  1180 +}
       
  1181 +
       
  1182 +
       
  1183 +gint
       
  1184 +moz_gtk_get_button_height(gint* height)
       
  1185 +{
       
  1186 +    GtkRequisition requisition;
       
  1187 +    ensure_entry_widget();
       
  1188 +
       
  1189 +    gtk_widget_get_preferred_size(gButton.widget, NULL, &requisition);
       
  1190 +    *height = requisition.height;
       
  1191 +
       
  1192 +    return MOZ_GTK_SUCCESS;
       
  1193 +}
       
  1194 +
       
  1195 +
       
  1196 +gint
       
  1197  moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
       
  1198  {
       
  1199      gint arrow_size;
       
  1200 @@ -3030,7 +3266,7 @@ moz_gtk_get_toolbar_separator_width(gint
       
  1201                           "separator-width", &separator_width,
       
  1202                           NULL);
       
  1203      /* Just in case... */
       
  1204 -    gtk_style_context_get_border(style, 0, &border);
       
  1205 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
       
  1206      *size = MAX(*size, (wide_separators ? separator_width : border.left));
       
  1207      return MOZ_GTK_SUCCESS;
       
  1208  }
       
  1209 @@ -3072,7 +3308,7 @@ moz_gtk_get_menu_separator_height(gint *
       
  1210      border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
       
  1211  
       
  1212      style = gtk_widget_get_style_context(gMenuSeparatorWidget);
       
  1213 -    gtk_style_context_get_padding(style, 0, &padding);
       
  1214 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
       
  1215  
       
  1216      gtk_style_context_save(style);
       
  1217      gtk_style_context_add_class(style, GTK_STYLE_CLASS_SEPARATOR);
       
  1218 @@ -3130,15 +3366,21 @@ moz_gtk_get_scrollbar_metrics(MozGtkScro
       
  1219  {
       
  1220      ensure_scrollbar_widget();
       
  1221  
       
  1222 -    gtk_widget_style_get (gHorizScrollbarWidget,
       
  1223 +    gtk_widget_style_get (gHorizScrollbar.widget,
       
  1224                            "slider_width", &metrics->slider_width,
       
  1225                            "trough_border", &metrics->trough_border,
       
  1226                            "stepper_size", &metrics->stepper_size,
       
  1227                            "stepper_spacing", &metrics->stepper_spacing,
       
  1228                            NULL);
       
  1229  
       
  1230 -    metrics->min_slider_size = 
       
  1231 -        gtk_range_get_min_slider_size(GTK_RANGE(gHorizScrollbarWidget));
       
  1232 +    if (!gtk_check_version(3,19,7)) {
       
  1233 +        gtk_style_context_get(gVertScrollbar.scroll.styleSlider, 
       
  1234 +                              gtk_style_context_get_state(gVertScrollbar.scroll.styleSlider), 
       
  1235 +                              "min-height", &metrics->min_slider_size, NULL);
       
  1236 +    } else {
       
  1237 +        metrics->min_slider_size = 
       
  1238 +            gtk_range_get_min_slider_size(GTK_RANGE(gVertScrollbar.widget));
       
  1239 +    }
       
  1240  
       
  1241      return MOZ_GTK_SUCCESS;
       
  1242  }
       
  1243 @@ -3163,7 +3405,7 @@ moz_gtk_images_in_buttons()
       
  1244      GtkSettings* settings;
       
  1245  
       
  1246      ensure_button_widget();
       
  1247 -    settings = gtk_widget_get_settings(gButtonWidget);
       
  1248 +    settings = gtk_widget_get_settings(gButton.widget);
       
  1249  
       
  1250      g_object_get(settings, "gtk-button-images", &result, NULL);
       
  1251      return result;
       
  1252 @@ -3191,7 +3433,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
       
  1253          }
       
  1254          ensure_button_widget();
       
  1255          return moz_gtk_button_paint(cr, rect, state,
       
  1256 -                                    (GtkReliefStyle) flags, gButtonWidget,
       
  1257 +                                    (GtkReliefStyle) flags, gButton.widget,
       
  1258                                      direction);
       
  1259          break;
       
  1260      case MOZ_GTK_CHECKBUTTON:
       
  1261 @@ -3241,7 +3483,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
       
  1262      case MOZ_GTK_SPINBUTTON_ENTRY:
       
  1263          ensure_spin_widget();
       
  1264          return moz_gtk_entry_paint(cr, rect, state,
       
  1265 -                                   gSpinWidget, direction);
       
  1266 +                                   &gSpin, direction);
       
  1267          break;
       
  1268      case MOZ_GTK_GRIPPER:
       
  1269          return moz_gtk_gripper_paint(cr, rect, state,
       
  1270 @@ -3268,7 +3510,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
       
  1271      case MOZ_GTK_ENTRY:
       
  1272          ensure_entry_widget();
       
  1273          return moz_gtk_entry_paint(cr, rect, state,
       
  1274 -                                   gEntryWidget, direction);
       
  1275 +                                   &gEntry, direction);
       
  1276          break;
       
  1277      case MOZ_GTK_DROPDOWN:
       
  1278          return moz_gtk_combo_box_paint(cr, rect, state, direction);
       
  1279 @@ -3280,7 +3522,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
       
  1280      case MOZ_GTK_DROPDOWN_ENTRY:
       
  1281          ensure_combo_box_entry_widgets();
       
  1282          return moz_gtk_entry_paint(cr, rect, state,
       
  1283 -                                   gComboBoxEntryTextareaWidget, direction);
       
  1284 +                                   &gComboBoxEntryTextarea, direction);
       
  1285          break;
       
  1286      case MOZ_GTK_CHECKBUTTON_CONTAINER:
       
  1287      case MOZ_GTK_RADIOBUTTON_CONTAINER:
       
  1288 @@ -3332,7 +3574,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
       
  1289                                                (GtkArrowType) flags, direction);
       
  1290          break;
       
  1291      case MOZ_GTK_MENUBAR:
       
  1292 -        return moz_gtk_menu_bar_paint(cr, rect, direction);
       
  1293 +        return moz_gtk_menu_bar_paint(cr, rect, state, direction);
       
  1294          break;
       
  1295      case MOZ_GTK_MENUPOPUP:
       
  1296          return moz_gtk_menu_popup_paint(cr, rect, direction);
       
  1297 @@ -3383,7 +3625,7 @@ GtkWidget* moz_gtk_get_scrollbar_widget(
       
  1298  {
       
  1299      MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
       
  1300      ensure_scrollbar_widget();
       
  1301 -    return gHorizScrollbarWidget;
       
  1302 +    return gVertScrollbar.widget;
       
  1303  }
       
  1304  
       
  1305  gboolean moz_gtk_has_scrollbar_buttons(void)
       
  1306 @@ -3391,7 +3633,7 @@ gboolean moz_gtk_has_scrollbar_buttons(v
       
  1307      gboolean backward, forward, secondary_backward, secondary_forward;
       
  1308      MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
       
  1309      ensure_scrollbar_widget();
       
  1310 -    gtk_widget_style_get (gHorizScrollbarWidget,
       
  1311 +    gtk_widget_style_get (gHorizScrollbar.widget,
       
  1312                            "has-backward-stepper", &backward,
       
  1313                            "has-forward-stepper", &forward,
       
  1314                            "has-secondary-backward-stepper", &secondary_backward,
       
  1315 @@ -3403,8 +3645,8 @@ gboolean moz_gtk_has_scrollbar_buttons(v
       
  1316  gint
       
  1317  moz_gtk_shutdown()
       
  1318  {
       
  1319 -    if (gTooltipWidget)
       
  1320 -        gtk_widget_destroy(gTooltipWidget);
       
  1321 +    moz_gtk_widget_free(&gTooltip);
       
  1322 +
       
  1323      /* This will destroy all of our widgets */
       
  1324      if (gProtoWindow)
       
  1325          gtk_widget_destroy(gProtoWindow);
       
  1326 @@ -3415,17 +3657,19 @@ moz_gtk_shutdown()
       
  1327  
       
  1328      gProtoWindow = NULL;
       
  1329      gProtoLayout = NULL;
       
  1330 -    gButtonWidget = NULL;
       
  1331 +
       
  1332 +    // MozWidgets
       
  1333 +    moz_gtk_widget_free(&gButton);
       
  1334      gToggleButtonWidget = NULL;
       
  1335      gButtonArrowWidget = NULL;
       
  1336 -    gCheckboxWidget = NULL;
       
  1337 -    gRadiobuttonWidget = NULL;
       
  1338 -    gHorizScrollbarWidget = NULL;
       
  1339 -    gVertScrollbarWidget = NULL;
       
  1340 -    gSpinWidget = NULL;
       
  1341 +    moz_gtk_widget_free(&gCheckbox);
       
  1342 +    moz_gtk_widget_free(&gRadiobutton);
       
  1343 +    moz_gtk_widget_free(&gHorizScrollbar);
       
  1344 +    moz_gtk_widget_free(&gVertScrollbar);
       
  1345 +    moz_gtk_widget_free(&gSpin);
       
  1346      gHScaleWidget = NULL;
       
  1347      gVScaleWidget = NULL;
       
  1348 -    gEntryWidget = NULL;
       
  1349 +    moz_gtk_widget_free(&gEntry);
       
  1350      gComboBoxWidget = NULL;
       
  1351      gComboBoxButtonWidget = NULL;
       
  1352      gComboBoxSeparatorWidget = NULL;
       
  1353 @@ -3433,14 +3677,13 @@ moz_gtk_shutdown()
       
  1354      gComboBoxEntryWidget = NULL;
       
  1355      gComboBoxEntryButtonWidget = NULL;
       
  1356      gComboBoxEntryArrowWidget = NULL;
       
  1357 -    gComboBoxEntryTextareaWidget = NULL;
       
  1358 +    moz_gtk_widget_free(&gComboBoxEntryTextarea);
       
  1359      gHandleBoxWidget = NULL;
       
  1360      gToolbarWidget = NULL;
       
  1361      gStatusbarWidget = NULL;
       
  1362      gFrameWidget = NULL;
       
  1363 -    gProgressWidget = NULL;
       
  1364 +    moz_gtk_widget_free(&gProgressBar);
       
  1365      gTabWidget = NULL;
       
  1366 -    gTooltipWidget = NULL;
       
  1367      gMenuBarWidget = NULL;
       
  1368      gMenuBarItemWidget = NULL;
       
  1369      gMenuPopupWidget = NULL;
       
  1370 diff -up firefox-46.0.1/widget/gtk/gtkdrawing.h.gtk3-20 firefox-46.0.1/widget/gtk/gtkdrawing.h
       
  1371 --- firefox-46.0.1/widget/gtk/gtkdrawing.h.gtk3-20	2016-05-03 07:31:12.000000000 +0200
       
  1372 +++ firefox-46.0.1/widget/gtk/gtkdrawing.h	2016-05-19 15:20:11.656519199 +0200
       
  1373 @@ -67,6 +67,13 @@ typedef enum {
       
  1374    MOZ_GTK_TAB_SELECTED        = 1 << 10
       
  1375  } GtkTabFlags;
       
  1376  
       
  1377 +typedef struct {
       
  1378 +  GType type;
       
  1379 +  const gchar *name;
       
  1380 +  const gchar *class1;
       
  1381 +  const gchar *class2;
       
  1382 +} GtkCssNode;
       
  1383 +
       
  1384  /** flags for menuitems **/
       
  1385  typedef enum {
       
  1386    /* menuitem is part of the menubar */
       
  1387 @@ -396,6 +403,9 @@ void
       
  1388  moz_gtk_get_arrow_size(GtkThemeWidgetType widgetType,
       
  1389                         gint* width, gint* height);
       
  1390  
       
  1391 +gint moz_gtk_get_entry_height(gint* height);
       
  1392 +gint moz_gtk_get_button_height(gint* height);
       
  1393 +
       
  1394  /**
       
  1395   * Get the desired size of a toolbar separator
       
  1396   * size:    [OUT] the desired width
       
  1397 @@ -466,6 +476,12 @@ gboolean moz_gtk_images_in_buttons(void)
       
  1398   */
       
  1399  gboolean moz_gtk_has_scrollbar_buttons(void);
       
  1400  
       
  1401 +
       
  1402 +GtkStyleContext *
       
  1403 +moz_gtk_style_create(GtkCssNode *node, GtkStyleContext *parent);
       
  1404 +
       
  1405 +
       
  1406 +
       
  1407  #ifdef __cplusplus
       
  1408  }
       
  1409  #endif /* __cplusplus */
       
  1410 diff -up firefox-46.0.1/widget/gtk/mozgtk/mozgtk.c.gtk3-20 firefox-46.0.1/widget/gtk/mozgtk/mozgtk.c
       
  1411 --- firefox-46.0.1/widget/gtk/mozgtk/mozgtk.c.gtk3-20	2016-05-03 07:31:12.000000000 +0200
       
  1412 +++ firefox-46.0.1/widget/gtk/mozgtk/mozgtk.c	2016-05-20 10:40:19.442320669 +0200
       
  1413 @@ -504,6 +504,11 @@ STUB(gtk_window_set_type_hint)
       
  1414  STUB(gtk_window_set_wmclass)
       
  1415  STUB(gtk_window_unfullscreen)
       
  1416  STUB(gtk_window_unmaximize)
       
  1417 +STUB(gtk_widget_get_preferred_height_and_baseline_for_width)
       
  1418 +STUB(gtk_entry_get_text_area)
       
  1419 +STUB(gtk_check_menu_item_get_type)
       
  1420 +STUB(gtk_spin_button_get_type)
       
  1421 +STUB(gtk_button_get_type)
       
  1422  #endif
       
  1423  
       
  1424  #ifdef GTK3_SYMBOLS
       
  1425 @@ -581,6 +586,14 @@ STUB(gtk_color_chooser_get_type)
       
  1426  STUB(gtk_color_chooser_set_rgba)
       
  1427  STUB(gtk_color_chooser_get_rgba)
       
  1428  STUB(gtk_color_chooser_set_use_alpha)
       
  1429 +STUB(gtk_style_context_get_path)
       
  1430 +STUB(gtk_widget_path_copy)
       
  1431 +STUB(gtk_widget_path_iter_set_object_name)
       
  1432 +STUB(gtk_widget_path_iter_add_class)
       
  1433 +STUB(gtk_widget_path_iter_get_state)
       
  1434 +STUB(gtk_style_context_set_parent)
       
  1435 +STUB(gtk_widget_path_unref)
       
  1436 +STUB(gtk_tooltip_get_type)
       
  1437  #endif
       
  1438  
       
  1439  #ifdef GTK2_SYMBOLS
       
  1440 diff -up firefox-46.0.1/widget/gtk/nsLookAndFeel.cpp.gtk3-20 firefox-46.0.1/widget/gtk/nsLookAndFeel.cpp
       
  1441 --- firefox-46.0.1/widget/gtk/nsLookAndFeel.cpp.gtk3-20	2016-05-03 07:31:12.000000000 +0200
       
  1442 +++ firefox-46.0.1/widget/gtk/nsLookAndFeel.cpp	2016-05-20 13:53:54.085049707 +0200
       
  1443 @@ -353,14 +353,18 @@ nsLookAndFeel::NativeGetColor(ColorID aI
       
  1444      case eColorID_activeborder:
       
  1445          // active window border
       
  1446          gtk_style_context_get_border_color(mBackgroundStyle, 
       
  1447 -                                           GTK_STATE_FLAG_NORMAL, &gdk_color);
       
  1448 +                                           gtk_style_context_get_state(mBackgroundStyle), 
       
  1449 +                                           &gdk_color);
       
  1450          aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
       
  1451          break;
       
  1452      case eColorID_inactiveborder:
       
  1453          // inactive window border
       
  1454 +        gtk_style_context_save(mBackgroundStyle);
       
  1455 +        gtk_style_context_set_state(mBackgroundStyle, GTK_STATE_FLAG_INSENSITIVE);
       
  1456          gtk_style_context_get_border_color(mBackgroundStyle, 
       
  1457 -                                           GTK_STATE_FLAG_INSENSITIVE, 
       
  1458 +                                           gtk_style_context_get_state(mBackgroundStyle), 
       
  1459                                             &gdk_color);
       
  1460 +        gtk_style_context_restore(mBackgroundStyle);
       
  1461          aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
       
  1462          break;
       
  1463      case eColorID_graytext: // disabled text in windows, menus, etc.
       
  1464 @@ -369,9 +373,12 @@ nsLookAndFeel::NativeGetColor(ColorID aI
       
  1465          break;
       
  1466      case eColorID_inactivecaption:
       
  1467          // inactive window caption
       
  1468 +        gtk_style_context_save(mBackgroundStyle);
       
  1469 +        gtk_style_context_set_state(mBackgroundStyle, GTK_STATE_FLAG_INSENSITIVE);
       
  1470          gtk_style_context_get_background_color(mBackgroundStyle, 
       
  1471 -                                               GTK_STATE_FLAG_INSENSITIVE, 
       
  1472 +                                               gtk_style_context_get_state(mBackgroundStyle), 
       
  1473                                                 &gdk_color);
       
  1474 +        gtk_style_context_restore(mBackgroundStyle);
       
  1475          aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
       
  1476          break;
       
  1477  #endif
       
  1478 @@ -497,13 +504,17 @@ nsLookAndFeel::NativeGetColor(ColorID aI
       
  1479      case eColorID__moz_buttondefault:
       
  1480        // default button border color
       
  1481          gtk_style_context_get_border_color(mButtonStyle, 
       
  1482 -                                           GTK_STATE_FLAG_NORMAL, &gdk_color);
       
  1483 +                                           gtk_style_context_get_state(mButtonStyle),
       
  1484 +                                           &gdk_color);
       
  1485          aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
       
  1486          break;
       
  1487      case eColorID__moz_buttonhoverface:
       
  1488 +        gtk_style_context_save(mButtonStyle);
       
  1489 +        gtk_style_context_set_state(mButtonStyle, GTK_STATE_FLAG_PRELIGHT);
       
  1490          gtk_style_context_get_background_color(mButtonStyle, 
       
  1491 -                                               GTK_STATE_FLAG_PRELIGHT, 
       
  1492 +                                               gtk_style_context_get_state(mButtonStyle), 
       
  1493                                                 &gdk_color);
       
  1494 +        gtk_style_context_restore(mButtonStyle);
       
  1495          aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
       
  1496          break;
       
  1497      case eColorID__moz_buttonhovertext:
       
  1498 @@ -1110,27 +1126,29 @@ nsLookAndFeel::Init()
       
  1499      style = create_context(path);
       
  1500      gtk_style_context_add_class(style, GTK_STYLE_CLASS_SCROLLBAR);
       
  1501      gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
       
  1502 -    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1503 +    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
       
  1504      sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color);
       
  1505      g_object_unref(style);
       
  1506  
       
  1507      // Window colors
       
  1508      style = create_context(path);
       
  1509 -    gtk_style_context_save(style);
       
  1510      gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
       
  1511 -    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1512 +    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
       
  1513      sMozWindowBackground = GDK_RGBA_TO_NS_RGBA(color);
       
  1514 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1515 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1516      sMozWindowText = GDK_RGBA_TO_NS_RGBA(color);
       
  1517 -    gtk_style_context_restore(style);
       
  1518 +    g_object_unref(style);
       
  1519  
       
  1520      // tooltip foreground and background
       
  1521 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
       
  1522 +    GtkCssNode tooltipPath[] = { 
       
  1523 +         { GTK_TYPE_TOOLTIP, "tooltip", NULL, NULL},
       
  1524 +    };
       
  1525 +    style = moz_gtk_style_create(tooltipPath, NULL);
       
  1526 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1527 +    sInfoText = GDK_RGBA_TO_NS_RGBA(color);
       
  1528      gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
       
  1529 -    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1530 +    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
       
  1531      sInfoBackground = GDK_RGBA_TO_NS_RGBA(color);
       
  1532 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1533 -    sInfoText = GDK_RGBA_TO_NS_RGBA(color);
       
  1534      g_object_unref(style);
       
  1535  
       
  1536      // menu foreground & menu background
       
  1537 @@ -1144,20 +1162,26 @@ nsLookAndFeel::Init()
       
  1538      gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
       
  1539  
       
  1540      style = gtk_widget_get_style_context(accel_label);
       
  1541 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1542 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1543      sMenuText = GDK_RGBA_TO_NS_RGBA(color);
       
  1544 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_INSENSITIVE, &color);
       
  1545 +    gtk_style_context_save(style);
       
  1546 +    gtk_style_context_set_state(style, GTK_STATE_FLAG_INSENSITIVE);
       
  1547 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1548      sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color);
       
  1549 +    gtk_style_context_restore(style);
       
  1550  
       
  1551      style = gtk_widget_get_style_context(menu);
       
  1552 -    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1553 +    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
       
  1554      sMenuBackground = GDK_RGBA_TO_NS_RGBA(color);
       
  1555  
       
  1556      style = gtk_widget_get_style_context(menuitem);
       
  1557 -    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
       
  1558 +    gtk_style_context_save(style);
       
  1559 +    gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
       
  1560 +    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
       
  1561      sMenuHover = GDK_RGBA_TO_NS_RGBA(color);
       
  1562 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
       
  1563 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1564      sMenuHoverText = GDK_RGBA_TO_NS_RGBA(color);
       
  1565 +    gtk_style_context_restore(style);
       
  1566  
       
  1567      g_object_unref(menu);
       
  1568  #endif
       
  1569 @@ -1266,44 +1290,54 @@ nsLookAndFeel::Init()
       
  1570              GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]);
       
  1571      }
       
  1572  #else
       
  1573 +    GtkCssNode labelPath[] = {
       
  1574 +       { GTK_TYPE_LABEL, "label", "view", NULL },
       
  1575 +       { G_TYPE_NONE, "selection", NULL, NULL }
       
  1576 +    };
       
  1577 +
       
  1578 +    GtkStyleContext *styleLabel;
       
  1579 +    GtkStyleContext *styleSelection;
       
  1580 +    GtkBorder padding;
       
  1581 +
       
  1582      // Text colors
       
  1583 -    style = gtk_widget_get_style_context(textView);
       
  1584 -    gtk_style_context_save(style);
       
  1585 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_VIEW);
       
  1586 -    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1587 +    styleLabel = moz_gtk_style_create(labelPath, NULL);
       
  1588 +    styleSelection = moz_gtk_style_create(labelPath+1, styleLabel);
       
  1589 +
       
  1590 +    gtk_style_context_get_background_color(styleLabel, gtk_style_context_get_state(styleLabel), &color);
       
  1591      sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color);
       
  1592 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1593 +    gtk_style_context_get_color(styleLabel, gtk_style_context_get_state(styleLabel), &color);
       
  1594      sMozFieldText = GDK_RGBA_TO_NS_RGBA(color);
       
  1595  
       
  1596      // Selected text and background
       
  1597 -    gtk_style_context_get_background_color(style,
       
  1598 -        static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
       
  1599 -        &color);
       
  1600 +    gtk_style_context_get_background_color(styleSelection, gtk_style_context_get_state(styleSelection), &color);
       
  1601      sTextSelectedBackground = GDK_RGBA_TO_NS_RGBA(color);
       
  1602 -    gtk_style_context_get_color(style,
       
  1603 -        static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
       
  1604 -        &color);
       
  1605 +    gtk_style_context_get_color(styleSelection, gtk_style_context_get_state(styleSelection), &color);
       
  1606      sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color);
       
  1607 -    gtk_style_context_restore(style);
       
  1608  
       
  1609      // Button text, background, border
       
  1610      style = gtk_widget_get_style_context(label);
       
  1611 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1612 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1613      sButtonText = GDK_RGBA_TO_NS_RGBA(color);
       
  1614 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
       
  1615 +    gtk_style_context_save(style);
       
  1616 +    gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
       
  1617 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1618      sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
       
  1619 +    gtk_style_context_restore(style);
       
  1620  
       
  1621      // Combobox text color
       
  1622      style = gtk_widget_get_style_context(comboboxLabel);
       
  1623 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1624 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1625      sComboBoxText = GDK_RGBA_TO_NS_RGBA(color);
       
  1626  
       
  1627      // Menubar text and hover text colors    
       
  1628      style = gtk_widget_get_style_context(menuBar);
       
  1629 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1630 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1631      sMenuBarText = GDK_RGBA_TO_NS_RGBA(color);
       
  1632 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
       
  1633 +    gtk_style_context_save(style);
       
  1634 +    gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
       
  1635 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1636      sMenuBarHoverText = GDK_RGBA_TO_NS_RGBA(color);
       
  1637 +    gtk_style_context_restore(style);
       
  1638  
       
  1639      // GTK's guide to fancy odd row background colors:
       
  1640      // 1) Check if a theme explicitly defines an odd row color
       
  1641 @@ -1316,7 +1350,7 @@ nsLookAndFeel::Init()
       
  1642      // Get odd row background color
       
  1643      gtk_style_context_save(style);
       
  1644      gtk_style_context_add_region(style, GTK_STYLE_REGION_ROW, GTK_REGION_ODD);
       
  1645 -    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1646 +    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
       
  1647      sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color);
       
  1648      gtk_style_context_restore(style);
       
  1649  
       
  1650 @@ -1334,9 +1368,11 @@ nsLookAndFeel::Init()
       
  1651      gtk_container_add(GTK_CONTAINER(parent), infoBar);
       
  1652      gtk_container_add(GTK_CONTAINER(infoBarContent), infoBarLabel);
       
  1653      style = gtk_widget_get_style_context(infoBarLabel);
       
  1654 +    gtk_style_context_save(style);
       
  1655      gtk_style_context_add_class(style, GTK_STYLE_CLASS_INFO);
       
  1656 -    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
       
  1657 +    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
       
  1658      sInfoBarText = GDK_RGBA_TO_NS_RGBA(color);
       
  1659 +    gtk_style_context_restore(style);
       
  1660  #endif
       
  1661      // Some themes have a unified menu bar, and support window dragging on it
       
  1662      gboolean supports_menubar_drag = FALSE;
       
  1663 diff -up firefox-46.0.1/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20 firefox-46.0.1/widget/gtk/nsNativeThemeGTK.cpp
       
  1664 --- firefox-46.0.1/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20	2016-05-03 07:31:12.000000000 +0200
       
  1665 +++ firefox-46.0.1/widget/gtk/nsNativeThemeGTK.cpp	2016-05-19 15:20:11.658519202 +0200
       
  1666 @@ -1567,9 +1567,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
       
  1667    case NS_THEME_RADIO_CONTAINER:
       
  1668    case NS_THEME_CHECKBOX_LABEL:
       
  1669    case NS_THEME_RADIO_LABEL:
       
  1670 -  case NS_THEME_BUTTON:
       
  1671 -  case NS_THEME_DROPDOWN:
       
  1672 -  case NS_THEME_TOOLBAR_BUTTON:
       
  1673    case NS_THEME_TREEVIEW_HEADER_CELL:
       
  1674      {
       
  1675        if (aWidgetType == NS_THEME_DROPDOWN) {
       
  1676 @@ -1588,6 +1585,21 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
       
  1677        aResult->height += border.top + border.bottom;
       
  1678      }
       
  1679      break;
       
  1680 +  case NS_THEME_BUTTON:
       
  1681 +  case NS_THEME_DROPDOWN:
       
  1682 +  case NS_THEME_TOOLBAR_BUTTON:
       
  1683 +    {
       
  1684 +        moz_gtk_get_button_height(&aResult->height);
       
  1685 +    }
       
  1686 +    break;
       
  1687 +  case NS_THEME_FOCUS_OUTLINE:
       
  1688 +  case NS_THEME_NUMBER_INPUT:
       
  1689 +  case NS_THEME_TEXTFIELD:
       
  1690 +  case NS_THEME_TEXTFIELD_MULTILINE:
       
  1691 +    {
       
  1692 +        moz_gtk_get_entry_height(&aResult->height);
       
  1693 +    } 
       
  1694 +    break;
       
  1695    case NS_THEME_TOOLBAR_SEPARATOR:
       
  1696      {
       
  1697        gint separator_width;