mozilla-gtk3_20.patch
branchfirefox45
changeset 908 b29b47737173
parent 907 3ccb278a9ceb
child 909 c6717354928b
equal deleted inserted replaced
907:3ccb278a9ceb 908:b29b47737173
     1 diff -up firefox-45.0.1/widget/gtk/gtk3drawing.c.gtk3-20 firefox-45.0.1/widget/gtk/gtk3drawing.c
     1 diff -up firefox-45.0.2/widget/gtk/gtk3drawing.c.gtk3-20 firefox-45.0.2/widget/gtk/gtk3drawing.c
     2 --- firefox-45.0.1/widget/gtk/gtk3drawing.c.gtk3-20	2016-03-15 23:37:46.000000000 +0100
     2 --- firefox-45.0.2/widget/gtk/gtk3drawing.c.gtk3-20	2016-04-08 01:55:04.000000000 +0200
     3 +++ firefox-45.0.1/widget/gtk/gtk3drawing.c	2016-04-05 14:40:27.846088625 +0200
     3 +++ firefox-45.0.2/widget/gtk/gtk3drawing.c	2016-04-20 18:49:52.897795872 +0200
     4 @@ -17,32 +17,78 @@
     4 @@ -17,32 +17,79 @@
     5  
     5  
     6  #include <math.h>
     6  #include <math.h>
     7  
     7  
     8 +#define MOZ_WIDGET_STYLES 4
     8 +#define MOZ_WIDGET_STYLES 4
     9 +
     9 +
    20 +            GtkStyleContext*  style;
    20 +            GtkStyleContext*  style;
    21 +        } button;
    21 +        } button;
    22 +
    22 +
    23 +        struct {
    23 +        struct {
    24 +            GtkStyleContext*  style;
    24 +            GtkStyleContext*  style;
       
    25 +            GtkStyleContext*  styleContents;
    25 +            GtkStyleContext*  styleTrough;
    26 +            GtkStyleContext*  styleTrough;
    26 +            GtkStyleContext*  styleSlider;
    27 +            GtkStyleContext*  styleSlider;
    27 +        } scroll;
    28 +        } scroll;
    28 +
    29 +
    29 +        struct {
    30 +        struct {
    87 -static GtkWidget* gProgressWidget;
    88 -static GtkWidget* gProgressWidget;
    88 +static MozGtkWidget gProgressBar;
    89 +static MozGtkWidget gProgressBar;
    89  static GtkWidget* gTabWidget;
    90  static GtkWidget* gTabWidget;
    90  static GtkWidget* gTooltipWidget;
    91  static GtkWidget* gTooltipWidget;
    91  static GtkWidget* gMenuBarWidget;
    92  static GtkWidget* gMenuBarWidget;
    92 @@ -78,6 +124,37 @@ static gboolean is_initialized;
    93 @@ -78,6 +125,37 @@ static gboolean is_initialized;
    93  #define GTK_STATE_FLAG_CHECKED (1 << 11)
    94  #define GTK_STATE_FLAG_CHECKED (1 << 11)
    94  #endif
    95  #endif
    95  
    96  
    96 +void moz_gtk_widget_free(MozGtkWidget *aMozWidget)
    97 +void moz_gtk_widget_free(MozGtkWidget *aMozWidget)
    97 +{
    98 +{
   125 +                          GtkBorder *padding);
   126 +                          GtkBorder *padding);
   126 +
   127 +
   127  static GtkStateFlags
   128  static GtkStateFlags
   128  GetStateFlagsFromGtkWidgetState(GtkWidgetState* state)
   129  GetStateFlagsFromGtkWidgetState(GtkWidgetState* state)
   129  {
   130  {
   130 @@ -97,6 +174,41 @@ GetStateFlagsFromGtkWidgetState(GtkWidge
   131 @@ -97,6 +175,41 @@ GetStateFlagsFromGtkWidgetState(GtkWidge
   131      return stateFlags;
   132      return stateFlags;
   132  }
   133  }
   133  
   134  
   134 +GtkStyleContext *
   135 +GtkStyleContext *
   135 +moz_gtk_style_create(GtkCssNode *node, GtkStyleContext *parent)
   136 +moz_gtk_style_create(GtkCssNode *node, GtkStyleContext *parent)
   167 +}
   168 +}
   168 +
   169 +
   169  /* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
   170  /* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
   170     that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
   171     that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
   171     things they may want to do. */
   172     things they may want to do. */
   172 @@ -141,9 +253,16 @@ setup_widget_prototype(GtkWidget* widget
   173 @@ -141,9 +254,16 @@ setup_widget_prototype(GtkWidget* widget
   173  static gint
   174  static gint
   174  ensure_button_widget()
   175  ensure_button_widget()
   175  {
   176  {
   176 -    if (!gButtonWidget) {
   177 -    if (!gButtonWidget) {
   177 -        gButtonWidget = gtk_button_new_with_label("M");
   178 -        gButtonWidget = gtk_button_new_with_label("M");
   187 +
   188 +
   188 +        gButton.button.style = moz_gtk_style_create(&path[0], NULL);
   189 +        gButton.button.style = moz_gtk_style_create(&path[0], NULL);
   189      }
   190      }
   190      return MOZ_GTK_SUCCESS;
   191      return MOZ_GTK_SUCCESS;
   191  }
   192  }
   192 @@ -195,9 +314,21 @@ ensure_button_arrow_widget()
   193 @@ -195,9 +315,21 @@ ensure_button_arrow_widget()
   193  static gint
   194  static gint
   194  ensure_checkbox_widget()
   195  ensure_checkbox_widget()
   195  {
   196  {
   196 -    if (!gCheckboxWidget) {
   197 -    if (!gCheckboxWidget) {
   197 -        gCheckboxWidget = gtk_check_button_new_with_label("M");
   198 -        gCheckboxWidget = gtk_check_button_new_with_label("M");
   212 +        gCheckbox.check.styleLabel = moz_gtk_style_create(&path[2],
   213 +        gCheckbox.check.styleLabel = moz_gtk_style_create(&path[2],
   213 +                                       gCheckbox.check.style);
   214 +                                       gCheckbox.check.style);
   214      }
   215      }
   215      return MOZ_GTK_SUCCESS;
   216      return MOZ_GTK_SUCCESS;
   216  }
   217  }
   217 @@ -205,9 +336,21 @@ ensure_checkbox_widget()
   218 @@ -205,9 +337,21 @@ ensure_checkbox_widget()
   218  static gint
   219  static gint
   219  ensure_radiobutton_widget()
   220  ensure_radiobutton_widget()
   220  {
   221  {
   221 -    if (!gRadiobuttonWidget) {
   222 -    if (!gRadiobuttonWidget) {
   222 -        gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
   223 -        gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
   237 +        gRadiobutton.check.styleLabel = moz_gtk_style_create(&path[2],
   238 +        gRadiobutton.check.styleLabel = moz_gtk_style_create(&path[2],
   238 +                                          gRadiobutton.check.style);
   239 +                                          gRadiobutton.check.style);
   239      }
   240      }
   240      return MOZ_GTK_SUCCESS;
   241      return MOZ_GTK_SUCCESS;
   241  }
   242  }
   242 @@ -215,13 +358,31 @@ ensure_radiobutton_widget()
   243 @@ -215,25 +359,62 @@ ensure_radiobutton_widget()
   243  static gint
   244  static gint
   244  ensure_scrollbar_widget()
   245  ensure_scrollbar_widget()
   245  {
   246  {
   246 -    if (!gVertScrollbarWidget) {
   247 -    if (!gVertScrollbarWidget) {
   247 -        gVertScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
   248 -        gVertScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
   248 -        setup_widget_prototype(gVertScrollbarWidget);
   249 -        setup_widget_prototype(gVertScrollbarWidget);
   249 -    }
   250 -    }
   250 -    if (!gHorizScrollbarWidget) {
   251 -    if (!gHorizScrollbarWidget) {
   251 -        gHorizScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
   252 -        gHorizScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
   252 -        setup_widget_prototype(gHorizScrollbarWidget);
   253 -        setup_widget_prototype(gHorizScrollbarWidget);
       
   254 -    }
   253 +    if (!gVertScrollbar.widget && !gHorizScrollbar.widget) {
   255 +    if (!gVertScrollbar.widget && !gHorizScrollbar.widget) {
   254 +        GtkCssNode path[] = {
   256 +        GtkCssNode path[] = {
   255 +            { GTK_TYPE_SCROLLBAR, "scrollbar", "horizontal", NULL },
   257 +            { GTK_TYPE_SCROLLBAR, "scrollbar", "horizontal", "bottom"},
   256 +            { GTK_TYPE_SCROLLBAR, "scrollbar", "vertical", NULL },
   258 +            { GTK_TYPE_SCROLLBAR, "scrollbar", "vertical", "right" },
   257 +            { GTK_TYPE_SCROLLBAR, "trough", NULL, NULL },
   259 +            { G_TYPE_NONE, "contents", NULL, NULL },
   258 +            { GTK_TYPE_SCROLLBAR, "slider", NULL, NULL }
   260 +            { G_TYPE_NONE, "trough", NULL, NULL },
       
   261 +            { G_TYPE_NONE, "slider", NULL, NULL }
   259 +        };
   262 +        };
       
   263 +
       
   264 +        gHorizScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
       
   265 +        setup_widget_prototype(gHorizScrollbar.widget);
       
   266 +
       
   267 +        gHorizScrollbar.scroll.style = moz_gtk_style_create(path, NULL);
       
   268 +        gHorizScrollbar.scroll.styleContents = moz_gtk_style_create(path+2, 
       
   269 +                                               gHorizScrollbar.scroll.style);
       
   270 +        gHorizScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3, 
       
   271 +                                               gHorizScrollbar.scroll.styleContents);
       
   272 +        gHorizScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4, 
       
   273 +                                               gHorizScrollbar.scroll.styleTrough);
   260 +
   274 +
   261 +        gVertScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
   275 +        gVertScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
   262 +        setup_widget_prototype(gVertScrollbar.widget);
   276 +        setup_widget_prototype(gVertScrollbar.widget);
   263 +
   277 +
   264 +        gVertScrollbar.scroll.style = moz_gtk_style_create(path+1, NULL);
   278 +        gVertScrollbar.scroll.style = moz_gtk_style_create(path+1, NULL);
   265 +        gVertScrollbar.scroll.styleTrough = moz_gtk_style_create(path+2, 
   279 +        gVertScrollbar.scroll.styleContents = moz_gtk_style_create(path+2, 
   266 +                                              gVertScrollbar.scroll.style);
   280 +                                              gVertScrollbar.scroll.style);
   267 +        gVertScrollbar.scroll.styleSlider = moz_gtk_style_create(path+3, 
   281 +        gVertScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3, 
       
   282 +                                              gVertScrollbar.scroll.styleContents);
       
   283 +        gVertScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4, 
   268 +                                              gVertScrollbar.scroll.styleTrough);
   284 +                                              gVertScrollbar.scroll.styleTrough);
   269 +
   285 +
   270 +        gHorizScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
   286 +     }
   271 +        setup_widget_prototype(gHorizScrollbar.widget);
       
   272 +
       
   273 +        gHorizScrollbar.scroll.style = moz_gtk_style_create(path, NULL);
       
   274 +        gHorizScrollbar.scroll.styleTrough = moz_gtk_style_create(path+2, 
       
   275 +                                               gHorizScrollbar.scroll.style);
       
   276 +        gHorizScrollbar.scroll.styleSlider = moz_gtk_style_create(path+3, 
       
   277 +                                               gHorizScrollbar.scroll.styleTrough);
       
   278      }
       
   279      return MOZ_GTK_SUCCESS;
   287      return MOZ_GTK_SUCCESS;
   280  }
   288  }
   281 @@ -229,11 +390,24 @@ ensure_scrollbar_widget()
   289  
   282  static gint
   290  static gint
   283  ensure_spin_widget()
   291  ensure_spin_widget()
   284  {
   292  {
   285 -  if (!gSpinWidget) {
   293 -  if (!gSpinWidget) {
   286 -    gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
   294 -    gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
   306 +    }
   314 +    }
   307 +    return MOZ_GTK_SUCCESS;
   315 +    return MOZ_GTK_SUCCESS;
   308  }
   316  }
   309  
   317  
   310  static gint
   318  static gint
   311 @@ -253,9 +427,19 @@ ensure_scale_widget()
   319 @@ -253,9 +434,19 @@ ensure_scale_widget()
   312  static gint
   320  static gint
   313  ensure_entry_widget()
   321  ensure_entry_widget()
   314  {
   322  {
   315 -    if (!gEntryWidget) {
   323 -    if (!gEntryWidget) {
   316 -        gEntryWidget = gtk_entry_new();
   324 -        gEntryWidget = gtk_entry_new();
   329 +        gEntry.entry.styleSelection = moz_gtk_style_create(&path[1], 
   337 +        gEntry.entry.styleSelection = moz_gtk_style_create(&path[1], 
   330 +                                                           gEntry.entry.style);
   338 +                                                           gEntry.entry.style);
   331      }
   339      }
   332      return MOZ_GTK_SUCCESS;
   340      return MOZ_GTK_SUCCESS;
   333  }
   341  }
   334 @@ -387,9 +571,9 @@ moz_gtk_get_combo_box_entry_inner_widget
   342 @@ -387,9 +578,9 @@ moz_gtk_get_combo_box_entry_inner_widget
   335          g_object_add_weak_pointer(G_OBJECT(widget),
   343          g_object_add_weak_pointer(G_OBJECT(widget),
   336                                    (gpointer) &gComboBoxEntryButtonWidget);
   344                                    (gpointer) &gComboBoxEntryButtonWidget);
   337      } else if (GTK_IS_ENTRY(widget)) {
   345      } else if (GTK_IS_ENTRY(widget)) {
   338 -        gComboBoxEntryTextareaWidget = widget;
   346 -        gComboBoxEntryTextareaWidget = widget;
   339 +        gComboBoxEntryTextarea.widget = widget;
   347 +        gComboBoxEntryTextarea.widget = widget;
   341 -                                  (gpointer) &gComboBoxEntryTextareaWidget);
   349 -                                  (gpointer) &gComboBoxEntryTextareaWidget);
   342 +                                  (gpointer) &gComboBoxEntryTextarea.widget);
   350 +                                  (gpointer) &gComboBoxEntryTextarea.widget);
   343      } else
   351      } else
   344          return;
   352          return;
   345      gtk_widget_realize(widget);
   353      gtk_widget_realize(widget);
   346 @@ -411,7 +595,7 @@ ensure_combo_box_entry_widgets()
   354 @@ -411,7 +602,7 @@ ensure_combo_box_entry_widgets()
   347  {
   355  {
   348      GtkWidget* buttonChild;
   356      GtkWidget* buttonChild;
   349  
   357  
   350 -    if (gComboBoxEntryTextareaWidget &&
   358 -    if (gComboBoxEntryTextareaWidget &&
   351 +    if (gComboBoxEntryTextarea.widget &&
   359 +    if (gComboBoxEntryTextarea.widget &&
   352              gComboBoxEntryButtonWidget &&
   360              gComboBoxEntryButtonWidget &&
   353              gComboBoxEntryArrowWidget)
   361              gComboBoxEntryArrowWidget)
   354          return MOZ_GTK_SUCCESS;
   362          return MOZ_GTK_SUCCESS;
   355 @@ -427,9 +611,9 @@ ensure_combo_box_entry_widgets()
   363 @@ -427,9 +618,9 @@ ensure_combo_box_entry_widgets()
   356                           moz_gtk_get_combo_box_entry_inner_widgets,
   364                           moz_gtk_get_combo_box_entry_inner_widgets,
   357                           NULL);
   365                           NULL);
   358  
   366  
   359 -    if (!gComboBoxEntryTextareaWidget) {
   367 -    if (!gComboBoxEntryTextareaWidget) {
   360 +    if (!gComboBoxEntryTextarea.widget) {
   368 +    if (!gComboBoxEntryTextarea.widget) {
   362 -        gComboBoxEntryTextareaWidget = gEntryWidget;
   370 -        gComboBoxEntryTextareaWidget = gEntryWidget;
   363 +        gComboBoxEntryTextarea.widget = gEntry.widget;
   371 +        gComboBoxEntryTextarea.widget = gEntry.widget;
   364      }
   372      }
   365  
   373  
   366      if (gComboBoxEntryButtonWidget) {
   374      if (gComboBoxEntryButtonWidget) {
   367 @@ -528,9 +712,21 @@ ensure_tab_widget()
   375 @@ -528,9 +719,21 @@ ensure_tab_widget()
   368  static gint
   376  static gint
   369  ensure_progress_widget()
   377  ensure_progress_widget()
   370  {
   378  {
   371 -    if (!gProgressWidget) {
   379 -    if (!gProgressWidget) {
   372 -        gProgressWidget = gtk_progress_bar_new();
   380 -        gProgressWidget = gtk_progress_bar_new();
   387 +        gProgressBar.progress.styleProgress = moz_gtk_style_create(&path[2],
   395 +        gProgressBar.progress.styleProgress = moz_gtk_style_create(&path[2],
   388 +                                                gProgressBar.progress.styleTrough);
   396 +                                                gProgressBar.progress.styleTrough);
   389      }
   397      }
   390      return MOZ_GTK_SUCCESS;
   398      return MOZ_GTK_SUCCESS;
   391  }
   399  }
   392 @@ -636,6 +832,11 @@ static gint
   400 @@ -636,6 +839,11 @@ static gint
   393  ensure_check_menu_item_widget()
   401  ensure_check_menu_item_widget()
   394  {
   402  {
   395      if (!gCheckMenuItemWidget) {
   403      if (!gCheckMenuItemWidget) {
   396 +        GtkCssNode path[] = {
   404 +        GtkCssNode path[] = {
   397 +           { GTK_TYPE_CHECK_MENU_ITEM, "menuitem", NULL, NULL },
   405 +           { GTK_TYPE_CHECK_MENU_ITEM, "menuitem", NULL, NULL },
   399 +        };
   407 +        };
   400 +
   408 +
   401          ensure_menu_popup_widget();
   409          ensure_menu_popup_widget();
   402          gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
   410          gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
   403          gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
   411          gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
   404 @@ -757,7 +958,7 @@ moz_gtk_checkbox_get_metrics(gint* indic
   412 @@ -757,7 +965,7 @@ moz_gtk_checkbox_get_metrics(gint* indic
   405  {
   413  {
   406      ensure_checkbox_widget();
   414      ensure_checkbox_widget();
   407  
   415  
   408 -    gtk_widget_style_get (gCheckboxWidget,
   416 -    gtk_widget_style_get (gCheckboxWidget,
   409 +    gtk_widget_style_get (gCheckbox.widget,
   417 +    gtk_widget_style_get (gCheckbox.widget,
   410                            "indicator_size", indicator_size,
   418                            "indicator_size", indicator_size,
   411                            "indicator_spacing", indicator_spacing,
   419                            "indicator_spacing", indicator_spacing,
   412                            NULL);
   420                            NULL);
   413 @@ -770,7 +971,7 @@ moz_gtk_radio_get_metrics(gint* indicato
   421 @@ -770,7 +978,7 @@ moz_gtk_radio_get_metrics(gint* indicato
   414  {
   422  {
   415      ensure_radiobutton_widget();
   423      ensure_radiobutton_widget();
   416  
   424  
   417 -    gtk_widget_style_get (gRadiobuttonWidget,
   425 -    gtk_widget_style_get (gRadiobuttonWidget,
   418 +    gtk_widget_style_get (gRadiobutton.widget,
   426 +    gtk_widget_style_get (gRadiobutton.widget,
   419                            "indicator_size", indicator_size,
   427                            "indicator_size", indicator_size,
   420                            "indicator_spacing", indicator_spacing,
   428                            "indicator_spacing", indicator_spacing,
   421                            NULL);
   429                            NULL);
   422 @@ -783,13 +984,12 @@ moz_gtk_get_focus_outline_size(gint* foc
   430 @@ -783,13 +991,12 @@ moz_gtk_get_focus_outline_size(gint* foc
   423  {
   431  {
   424      GtkBorder border;
   432      GtkBorder border;
   425      GtkBorder padding;
   433      GtkBorder padding;
   426 -    GtkStyleContext *style;
   434 -    GtkStyleContext *style;
   427 +    GtkStyleContext* style = gEntry.entry.style;
   435 +    GtkStyleContext* style = gEntry.entry.style;
   434 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
   442 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
   435 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   443 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   436      *focus_h_width = border.left + padding.left;
   444      *focus_h_width = border.left + padding.left;
   437      *focus_v_width = border.top + padding.top;
   445      *focus_v_width = border.top + padding.top;
   438      return MOZ_GTK_SUCCESS;
   446      return MOZ_GTK_SUCCESS;
   439 @@ -826,7 +1026,7 @@ moz_gtk_button_get_default_overflow(gint
   447 @@ -826,7 +1033,7 @@ moz_gtk_button_get_default_overflow(gint
   440      GtkBorder* default_outside_border;
   448      GtkBorder* default_outside_border;
   441  
   449  
   442      ensure_button_widget();
   450      ensure_button_widget();
   443 -    gtk_widget_style_get(gButtonWidget,
   451 -    gtk_widget_style_get(gButtonWidget,
   444 +    gtk_widget_style_get(gButton.widget,
   452 +    gtk_widget_style_get(gButton.widget,
   445                           "default-outside-border", &default_outside_border,
   453                           "default-outside-border", &default_outside_border,
   446                           NULL);
   454                           NULL);
   447  
   455  
   448 @@ -849,7 +1049,7 @@ moz_gtk_button_get_default_border(gint*
   456 @@ -849,7 +1056,7 @@ moz_gtk_button_get_default_border(gint*
   449      GtkBorder* default_border;
   457      GtkBorder* default_border;
   450  
   458  
   451      ensure_button_widget();
   459      ensure_button_widget();
   452 -    gtk_widget_style_get(gButtonWidget,
   460 -    gtk_widget_style_get(gButtonWidget,
   453 +    gtk_widget_style_get(gButton.widget,
   461 +    gtk_widget_style_get(gButton.widget,
   454                           "default-border", &default_border,
   462                           "default-border", &default_border,
   455                           NULL);
   463                           NULL);
   456  
   464  
   457 @@ -940,7 +1140,7 @@ moz_gtk_button_paint(cairo_t *cr, GdkRec
   465 @@ -940,7 +1147,7 @@ moz_gtk_button_paint(cairo_t *cr, GdkRec
   458  
   466  
   459      if (state->focused) {
   467      if (state->focused) {
   460          GtkBorder border;
   468          GtkBorder border;
   461 -        gtk_style_context_get_border(style, state_flags, &border);
   469 -        gtk_style_context_get_border(style, state_flags, &border);
   462 +        moz_gtk_get_style_border(style, state_flags, &border);
   470 +        moz_gtk_get_style_border(style, state_flags, &border);
   463          x += border.left;
   471          x += border.left;
   464          y += border.top;
   472          y += border.top;
   465          width -= (border.left + border.right);
   473          width -= (border.left + border.right);
   466 @@ -961,15 +1161,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
   474 @@ -961,15 +1168,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
   467      gint indicator_size, indicator_spacing;
   475      gint indicator_size, indicator_spacing;
   468      gint x, y, width, height;
   476      gint x, y, width, height;
   469      gint focus_x, focus_y, focus_width, focus_height;
   477      gint focus_x, focus_y, focus_width, focus_height;
   470 -    GtkWidget *w;
   478 -    GtkWidget *w;
   471 -    GtkStyleContext *style;
   479 -    GtkStyleContext *style;
   480 -        w = gCheckboxWidget;
   488 -        w = gCheckboxWidget;
   481 +        w = &gCheckbox;
   489 +        w = &gCheckbox;
   482      }
   490      }
   483  
   491  
   484      // XXX we should assert rect->height >= indicator_size too
   492      // XXX we should assert rect->height >= indicator_size too
   485 @@ -988,11 +1187,9 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
   493 @@ -988,11 +1194,9 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
   486      focus_width = width + 2 * indicator_spacing;
   494      focus_width = width + 2 * indicator_spacing;
   487      focus_height = height + 2 * indicator_spacing;
   495      focus_height = height + 2 * indicator_spacing;
   488    
   496    
   489 -    style = gtk_widget_get_style_context(w);
   497 -    style = gtk_widget_get_style_context(w);
   490 -
   498 -
   495 +    gtk_widget_set_direction(w->widget, direction);
   503 +    gtk_widget_set_direction(w->widget, direction);
   496 +    gtk_style_context_save(w->check.styleCheck);
   504 +    gtk_style_context_save(w->check.styleCheck);
   497  
   505  
   498      if (selected)
   506      if (selected)
   499          state_flags |= checkbox_check_state;
   507          state_flags |= checkbox_check_state;
   500 @@ -1000,13 +1197,15 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
   508 @@ -1000,13 +1204,15 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
   501      if (inconsistent)
   509      if (inconsistent)
   502          state_flags |= GTK_STATE_FLAG_INCONSISTENT;
   510          state_flags |= GTK_STATE_FLAG_INCONSISTENT;
   503  
   511  
   504 -    gtk_style_context_set_state(style, state_flags);
   512 -    gtk_style_context_set_state(style, state_flags);
   505 +    gtk_style_context_set_state(w->check.styleCheck, state_flags);
   513 +    gtk_style_context_set_state(w->check.styleCheck, state_flags);
   515 -            gtk_render_focus(style, cr, focus_x, focus_y,
   523 -            gtk_render_focus(style, cr, focus_x, focus_y,
   516 +            gtk_render_focus(w->check.styleCheck, cr, focus_x, focus_y,
   524 +            gtk_render_focus(w->check.styleCheck, cr, focus_x, focus_y,
   517                              focus_width, focus_height);
   525                              focus_width, focus_height);
   518          }
   526          }
   519      }
   527      }
   520 @@ -1015,15 +1214,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
   528 @@ -1015,15 +1221,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
   521          * 'indeterminate' type on checkboxes. In GTK, the shadow type
   529          * 'indeterminate' type on checkboxes. In GTK, the shadow type
   522          * must also be changed for the state to be drawn.
   530          * must also be changed for the state to be drawn.
   523          */        
   531          */        
   524 -        gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
   532 -        gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
   525 -        gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), inconsistent);
   533 -        gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), inconsistent);
   535 -    gtk_style_context_restore(style);
   543 -    gtk_style_context_restore(style);
   536 +    gtk_style_context_restore(w->check.styleCheck);
   544 +    gtk_style_context_restore(w->check.styleCheck);
   537  
   545  
   538      return MOZ_GTK_SUCCESS;
   546      return MOZ_GTK_SUCCESS;
   539  }
   547  }
   540 @@ -1040,8 +1238,8 @@ calculate_button_inner_rect(GtkWidget* b
   548 @@ -1040,8 +1245,8 @@ calculate_button_inner_rect(GtkWidget* b
   541      style = gtk_widget_get_style_context(button);
   549      style = gtk_widget_get_style_context(button);
   542  
   550  
   543      /* This mirrors gtkbutton's child positioning */
   551      /* This mirrors gtkbutton's child positioning */
   544 -    gtk_style_context_get_border(style, 0, &border);
   552 -    gtk_style_context_get_border(style, 0, &border);
   545 -    gtk_style_context_get_padding(style, 0, &padding);
   553 -    gtk_style_context_get_padding(style, 0, &padding);
   546 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
   554 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
   547 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   555 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   548  
   556  
   549      inner_rect->x = rect->x + border.left + padding.left;
   557      inner_rect->x = rect->x + border.left + padding.left;
   550      inner_rect->y = rect->y + padding.top + border.top;
   558      inner_rect->y = rect->y + padding.top + border.top;
   551 @@ -1107,9 +1305,9 @@ moz_gtk_scrollbar_button_paint(cairo_t *
   559 @@ -1107,9 +1312,9 @@ moz_gtk_scrollbar_button_paint(cairo_t *
   552      ensure_scrollbar_widget();
   560      ensure_scrollbar_widget();
   553  
   561  
   554      if (flags & MOZ_GTK_STEPPER_VERTICAL)
   562      if (flags & MOZ_GTK_STEPPER_VERTICAL)
   555 -        scrollbar = gVertScrollbarWidget;
   563 -        scrollbar = gVertScrollbarWidget;
   556 +        scrollbar = gVertScrollbar.widget;
   564 +        scrollbar = gVertScrollbar.widget;
   558 -        scrollbar = gHorizScrollbarWidget;
   566 -        scrollbar = gHorizScrollbarWidget;
   559 +        scrollbar = gHorizScrollbar.widget;
   567 +        scrollbar = gHorizScrollbar.widget;
   560  
   568  
   561      gtk_widget_set_direction(scrollbar, direction);
   569      gtk_widget_set_direction(scrollbar, direction);
   562  
   570  
   563 @@ -1175,26 +1373,23 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
   571 @@ -1175,26 +1380,23 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
   564                                 GtkTextDirection direction)
   572                                 GtkTextDirection direction)
   565  {
   573  {
   566      GtkStyleContext* style;
   574      GtkStyleContext* style;
   567 -    GtkScrollbar *scrollbar;
   575 -    GtkScrollbar *scrollbar;
   568  
   576  
   574 -        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
   582 -        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
   575 -
   583 -
   576 -    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
   584 -    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
   577 +    if (widget == MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL) {
   585 +    if (widget == MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL) {
   578 +        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
   586 +        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
   579 +        style = gHorizScrollbar.scroll.styleTrough;
   587 +        style = gHorizScrollbar.scroll.style;
   580 +    } 
   588 +    } 
   581 +    else {
   589 +    else {
   582 +        gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
   590 +        gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
   583 +        style = gVertScrollbar.scroll.styleTrough;
   591 +        style = gVertScrollbar.scroll.style;
   584 +    }
   592 +    }
   585      
   593      
   586      if (flags & MOZ_GTK_TRACK_OPAQUE) {
   594      if (flags & MOZ_GTK_TRACK_OPAQUE) {
   587          style = gtk_widget_get_style_context(GTK_WIDGET(gProtoWindow));
   595          style = gtk_widget_get_style_context(GTK_WIDGET(gProtoWindow));
   588          gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   596          gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   593 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
   601 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
   594 -
   602 -
   595      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   603      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   596      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
   604      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
   597  
   605  
   598 @@ -1202,7 +1397,6 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
   606 @@ -1202,7 +1404,6 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
   599          gtk_render_focus(style, cr,
   607          gtk_render_focus(style, cr,
   600                           rect->x, rect->y, rect->width, rect->height);
   608                           rect->x, rect->y, rect->width, rect->height);
   601      }
   609      }
   602 -    gtk_style_context_restore(style);
   610 -    gtk_style_context_restore(style);
   603      return MOZ_GTK_SUCCESS;
   611      return MOZ_GTK_SUCCESS;
   604  }
   612  }
   605  
   613  
   606 @@ -1214,25 +1408,21 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
   614 @@ -1214,25 +1415,21 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
   607  {
   615  {
   608      GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
   616      GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
   609      GtkStyleContext* style;
   617      GtkStyleContext* style;
   610 -    GtkScrollbar *scrollbar;
   618 -    GtkScrollbar *scrollbar;
   611      GtkAdjustment *adj;
   619      GtkAdjustment *adj;
   635      gtk_style_context_set_state(style, state_flags);
   643      gtk_style_context_set_state(style, state_flags);
   636 -
   644 -
   637      gtk_style_context_get_margin (style, state_flags, &margin);
   645      gtk_style_context_get_margin (style, state_flags, &margin);
   638  
   646  
   639      gtk_render_slider(style, cr,
   647      gtk_render_slider(style, cr,
   640 @@ -1243,8 +1433,6 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
   648 @@ -1243,8 +1440,6 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
   641                       (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
   649                       (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
   642                       GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
   650                       GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
   643  
   651  
   644 -    gtk_style_context_restore(style);
   652 -    gtk_style_context_restore(style);
   645 -
   653 -
   646      return MOZ_GTK_SUCCESS;
   654      return MOZ_GTK_SUCCESS;
   647  }
   655  }
   648  
   656  
   649 @@ -1255,8 +1443,8 @@ moz_gtk_spin_paint(cairo_t *cr, GdkRecta
   657 @@ -1255,8 +1450,8 @@ moz_gtk_spin_paint(cairo_t *cr, GdkRecta
   650      GtkStyleContext* style;
   658      GtkStyleContext* style;
   651  
   659  
   652      ensure_spin_widget();
   660      ensure_spin_widget();
   653 -    gtk_widget_set_direction(gSpinWidget, direction);
   661 -    gtk_widget_set_direction(gSpinWidget, direction);
   654 -    style = gtk_widget_get_style_context(gSpinWidget);
   662 -    style = gtk_widget_get_style_context(gSpinWidget);
   655 +    gtk_widget_set_direction(gSpin.widget, direction);
   663 +    gtk_widget_set_direction(gSpin.widget, direction);
   656 +    style = gSpin.spin.style;
   664 +    style = gSpin.spin.style;
   657      gtk_style_context_save(style);
   665      gtk_style_context_save(style);
   658      gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
   666      gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
   659      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   667      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   660 @@ -1275,11 +1463,10 @@ moz_gtk_spin_updown_paint(cairo_t *cr, G
   668 @@ -1275,11 +1470,10 @@ moz_gtk_spin_updown_paint(cairo_t *cr, G
   661      GtkStyleContext* style;
   669      GtkStyleContext* style;
   662  
   670  
   663      ensure_spin_widget();
   671      ensure_spin_widget();
   664 -    style = gtk_widget_get_style_context(gSpinWidget);
   672 -    style = gtk_widget_get_style_context(gSpinWidget);
   665 +    style = gSpin.spin.style;
   673 +    style = gSpin.spin.style;
   669 -    gtk_widget_set_direction(gSpinWidget, direction);
   677 -    gtk_widget_set_direction(gSpinWidget, direction);
   670 +    gtk_widget_set_direction(gSpin.widget, direction);
   678 +    gtk_widget_set_direction(gSpin.widget, direction);
   671  
   679  
   672      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   680      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   673      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
   681      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
   674 @@ -1445,15 +1632,13 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec
   682 @@ -1445,15 +1639,13 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec
   675  static gint
   683  static gint
   676  moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect,
   684  moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect,
   677                      GtkWidgetState* state,
   685                      GtkWidgetState* state,
   678 -                    GtkWidget* widget, GtkTextDirection direction)
   686 -                    GtkWidget* widget, GtkTextDirection direction)
   679 +                    MozGtkWidget* w, GtkTextDirection direction)
   687 +                    MozGtkWidget* w, GtkTextDirection direction)
   688 -    style = gtk_widget_get_style_context(widget);
   696 -    style = gtk_widget_get_style_context(widget);
   689 +    gtk_widget_set_direction(w->widget, direction);
   697 +    gtk_widget_set_direction(w->widget, direction);
   690  
   698  
   691      if (draw_focus_outline_only) {
   699      if (draw_focus_outline_only) {
   692          // Inflate the given 'rect' with the focus outline size.
   700          // Inflate the given 'rect' with the focus outline size.
   693 @@ -1473,10 +1658,9 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRect
   701 @@ -1473,10 +1665,9 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRect
   694       * textarea window uses gtk_paint_flat_box when exposed */
   702       * textarea window uses gtk_paint_flat_box when exposed */
   695  
   703  
   696      /* This gets us a lovely greyish disabledish look */
   704      /* This gets us a lovely greyish disabledish look */
   697 -    gtk_widget_set_sensitive(widget, !state->disabled);
   705 -    gtk_widget_set_sensitive(widget, !state->disabled);
   698 +    gtk_widget_set_sensitive(w->widget, !state->disabled);
   706 +    gtk_widget_set_sensitive(w->widget, !state->disabled);
   700      gtk_style_context_save(style);
   708      gtk_style_context_save(style);
   701 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_ENTRY);
   709 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_ENTRY);
   702    
   710    
   703      /* Now paint the shadow and focus border.
   711      /* Now paint the shadow and focus border.
   704       * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad
   712       * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad
   705 @@ -1526,7 +1710,7 @@ moz_gtk_treeview_paint(cairo_t *cr, GdkR
   713 @@ -1526,7 +1717,7 @@ moz_gtk_treeview_paint(cairo_t *cr, GdkR
   706      style = gtk_widget_get_style_context(gScrolledWindowWidget);
   714      style = gtk_widget_get_style_context(gScrolledWindowWidget);
   707      gtk_style_context_save(style);
   715      gtk_style_context_save(style);
   708      gtk_style_context_add_class(style, GTK_STYLE_CLASS_FRAME);    
   716      gtk_style_context_add_class(style, GTK_STYLE_CLASS_FRAME);    
   709 -    gtk_style_context_get_border(style, state_flags, &border);
   717 -    gtk_style_context_get_border(style, state_flags, &border);
   710 +    moz_gtk_get_style_border(style, state_flags, &border);
   718 +    moz_gtk_get_style_border(style, state_flags, &border);
   711      xthickness = border.left;
   719      xthickness = border.left;
   712      ythickness = border.top;    
   720      ythickness = border.top;    
   713  
   721  
   714 @@ -1697,7 +1881,7 @@ moz_gtk_combo_box_paint(cairo_t *cr, Gdk
   722 @@ -1697,7 +1888,7 @@ moz_gtk_combo_box_paint(cairo_t *cr, Gdk
   715          if (direction == GTK_TEXT_DIR_LTR) {
   723          if (direction == GTK_TEXT_DIR_LTR) {
   716              GtkBorder padding;
   724              GtkBorder padding;
   717              GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
   725              GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
   718 -            gtk_style_context_get_padding(style, state_flags, &padding);
   726 -            gtk_style_context_get_padding(style, state_flags, &padding);
   719 +            moz_gtk_get_style_padding(style, state_flags, &padding);
   727 +            moz_gtk_get_style_padding(style, state_flags, &padding);
   720              arrow_rect.x -= padding.left;
   728              arrow_rect.x -= padding.left;
   721          }
   729          }
   722          else
   730          else
   723 @@ -1799,29 +1983,27 @@ moz_gtk_container_paint(cairo_t *cr, Gdk
   731 @@ -1799,29 +1990,27 @@ moz_gtk_container_paint(cairo_t *cr, Gdk
   724                          gboolean isradio, GtkTextDirection direction)
   732                          gboolean isradio, GtkTextDirection direction)
   725  {
   733  {
   726      GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
   734      GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
   727 -    GtkStyleContext* style;
   735 -    GtkStyleContext* style;
   728 -    GtkWidget *widget;
   736 -    GtkWidget *widget;
   756 -    gtk_style_context_restore(style);
   764 -    gtk_style_context_restore(style);
   757 +    gtk_style_context_restore(widget->check.style);
   765 +    gtk_style_context_restore(widget->check.style);
   758    
   766    
   759      return MOZ_GTK_SUCCESS;
   767      return MOZ_GTK_SUCCESS;
   760  }
   768  }
   761 @@ -1831,32 +2013,26 @@ moz_gtk_toggle_label_paint(cairo_t *cr,
   769 @@ -1831,32 +2020,26 @@ moz_gtk_toggle_label_paint(cairo_t *cr,
   762                             GtkWidgetState* state, 
   770                             GtkWidgetState* state, 
   763                             gboolean isradio, GtkTextDirection direction)
   771                             gboolean isradio, GtkTextDirection direction)
   764  {
   772  {
   765 -    GtkStyleContext *style;
   773 -    GtkStyleContext *style;
   766 -    GtkWidget *widget;
   774 -    GtkWidget *widget;
   774 -        widget = gRadiobuttonWidget;
   782 -        widget = gRadiobuttonWidget;
   775 +        widget = &gRadiobutton;
   783 +        widget = &gRadiobutton;
   776      } else {
   784      } else {
   777          ensure_checkbox_widget();
   785          ensure_checkbox_widget();
   778 -        widget = gCheckboxWidget;
   786 -        widget = gCheckboxWidget;
   779 -    }
   787 +        widget = &gCheckbox;
       
   788      }
   780 -    style = gtk_widget_get_style_context(widget);
   789 -    style = gtk_widget_get_style_context(widget);
   781 -    gtk_style_context_save(style);
   790 -    gtk_style_context_save(style);
   782 -    if (isradio) {
   791 -    if (isradio) {
   783 -      gtk_style_context_add_class(style, GTK_STYLE_CLASS_RADIO);
   792 -      gtk_style_context_add_class(style, GTK_STYLE_CLASS_RADIO);
   784 -    } else {
   793 -    } else {
   785 -      gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
   794 -      gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
   786 +        widget = &gCheckbox;
   795 -    }
   787      }
       
   788 -    gtk_widget_set_direction(widget, direction);
   796 -    gtk_widget_set_direction(widget, direction);
   789 +    gtk_style_context_save(widget->check.styleLabel);
   797 +    gtk_style_context_save(widget->check.styleLabel);
   790 +    gtk_widget_set_direction(widget->widget, direction);
   798 +    gtk_widget_set_direction(widget->widget, direction);
   791  
   799  
   792 -    gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
   800 -    gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
   798 -    gtk_style_context_restore(style);
   806 -    gtk_style_context_restore(style);
   799 +    gtk_style_context_restore(widget->check.styleLabel);
   807 +    gtk_style_context_restore(widget->check.styleLabel);
   800  
   808  
   801      return MOZ_GTK_SUCCESS;
   809      return MOZ_GTK_SUCCESS;
   802  }
   810  }
   803 @@ -1917,7 +2093,7 @@ moz_gtk_toolbar_separator_paint(cairo_t
   811 @@ -1917,7 +2100,7 @@ moz_gtk_toolbar_separator_paint(cairo_t
   804                            rect->height * (end_fraction - start_fraction));
   812                            rect->height * (end_fraction - start_fraction));
   805      } else {
   813      } else {
   806          GtkBorder padding;
   814          GtkBorder padding;
   807 -        gtk_style_context_get_padding(style, 0, &padding);
   815 -        gtk_style_context_get_padding(style, 0, &padding);
   808 +        gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   816 +        gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   809      
   817      
   810          paint_width = padding.left;
   818          paint_width = padding.left;
   811          if (paint_width > rect->width)
   819          if (paint_width > rect->width)
   812 @@ -2004,18 +2180,13 @@ static gint
   820 @@ -2004,18 +2187,13 @@ static gint
   813  moz_gtk_progressbar_paint(cairo_t *cr, GdkRectangle* rect,
   821  moz_gtk_progressbar_paint(cairo_t *cr, GdkRectangle* rect,
   814                            GtkTextDirection direction)
   822                            GtkTextDirection direction)
   815  {
   823  {
   816 -    GtkStyleContext* style;
   824 -    GtkStyleContext* style;
   817 -
   825 -
   831 +    gtk_render_frame(gProgressBar.progress.styleTrough, cr,
   839 +    gtk_render_frame(gProgressBar.progress.styleTrough, cr,
   832 +                     rect->x, rect->y, rect->width, rect->height);
   840 +                     rect->x, rect->y, rect->width, rect->height);
   833  
   841  
   834      return MOZ_GTK_SUCCESS;
   842      return MOZ_GTK_SUCCESS;
   835  }
   843  }
   836 @@ -2025,15 +2196,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
   844 @@ -2025,15 +2203,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
   837                               GtkTextDirection direction,
   845                               GtkTextDirection direction,
   838                               GtkThemeWidgetType widget)
   846                               GtkThemeWidgetType widget)
   839  {
   847  {
   840 -    GtkStyleContext* style;
   848 -    GtkStyleContext* style;
   841 -
   849 -
   848 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR);
   856 -    gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR);
   849 +    gtk_widget_set_direction(gProgressBar.widget, direction);
   857 +    gtk_widget_set_direction(gProgressBar.widget, direction);
   850  
   858  
   851      if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
   859      if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
   852          widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
   860          widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
   853 @@ -2072,12 +2236,14 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
   861 @@ -2072,12 +2243,14 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
   854      // gtk_render_activity was used to render progress chunks on GTK versions
   862      // gtk_render_activity was used to render progress chunks on GTK versions
   855      // before 3.13.7, see bug 1173907.
   863      // before 3.13.7, see bug 1173907.
   856      if (!gtk_check_version(3, 13, 7)) {
   864      if (!gtk_check_version(3, 13, 7)) {
   857 -      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   865 -      gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
   858 -      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
   866 -      gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
   867      }
   875      }
   868 -    gtk_style_context_restore(style);
   876 -    gtk_style_context_restore(style);
   869  
   877  
   870      return MOZ_GTK_SUCCESS;
   878      return MOZ_GTK_SUCCESS;
   871  }
   879  }
   872 @@ -2094,7 +2260,7 @@ moz_gtk_get_tab_thickness(void)
   880 @@ -2094,7 +2267,7 @@ moz_gtk_get_tab_thickness(void)
   873  
   881  
   874      style = gtk_widget_get_style_context(gTabWidget);
   882      style = gtk_widget_get_style_context(gTabWidget);
   875      gtk_style_context_add_class(style, GTK_STYLE_CLASS_NOTEBOOK);
   883      gtk_style_context_add_class(style, GTK_STYLE_CLASS_NOTEBOOK);
   876 -    gtk_style_context_get_border(style, 0, &border);
   884 -    gtk_style_context_get_border(style, 0, &border);
   877 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
   885 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
   878  
   886  
   879      if (border.top < 2)
   887      if (border.top < 2)
   880          return 2; /* some themes don't set ythickness correctly */
   888          return 2; /* some themes don't set ythickness correctly */
   881 @@ -2290,7 +2456,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
   889 @@ -2290,7 +2463,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
   882        gtk_style_context_save(style);
   890        gtk_style_context_save(style);
   883        moz_gtk_tab_prepare_style_context(style, flags);
   891        moz_gtk_tab_prepare_style_context(style, flags);
   884  
   892  
   885 -      gtk_style_context_get_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
   893 -      gtk_style_context_get_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
   886 +      moz_gtk_get_style_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
   894 +      moz_gtk_get_style_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
   887  
   895  
   888        focusRect.x += padding.left;
   896        focusRect.x += padding.left;
   889        focusRect.width -= (padding.left + padding.right);
   897        focusRect.width -= (padding.left + padding.right);
   890 @@ -2406,7 +2572,7 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *
   898 @@ -2406,7 +2579,7 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *
   891  }
   899  }
   892  
   900  
   893  static gint
   901  static gint
   894 -moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect,
   902 -moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect,
   895 +moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state,
   903 +moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state,
   896                         GtkTextDirection direction)
   904                         GtkTextDirection direction)
   897  {
   905  {
   898      GtkStyleContext* style;
   906      GtkStyleContext* style;
   899 @@ -2467,7 +2633,7 @@ moz_gtk_menu_separator_paint(cairo_t *cr
   907 @@ -2467,7 +2640,7 @@ moz_gtk_menu_separator_paint(cairo_t *cr
   900      border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
   908      border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
   901  
   909  
   902      style = gtk_widget_get_style_context(gMenuSeparatorWidget);
   910      style = gtk_widget_get_style_context(gMenuSeparatorWidget);
   903 -    gtk_style_context_get_padding(style, 0, &padding);
   911 -    gtk_style_context_get_padding(style, 0, &padding);
   904 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   912 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   905  
   913  
   906      x = rect->x + border_width;
   914      x = rect->x + border_width;
   907      y = rect->y + border_width;
   915      y = rect->y + border_width;
   908 @@ -2521,7 +2687,8 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
   916 @@ -2521,7 +2694,8 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
   909              item_widget = gMenuItemWidget;
   917              item_widget = gMenuItemWidget;
   910          }
   918          }
   911          style = gtk_widget_get_style_context(item_widget);
   919          style = gtk_widget_get_style_context(item_widget);
   912 -        gtk_style_context_save(style);
   920 -        gtk_style_context_save(style);
   913 +// TODO - FIX!
   921 +// TODO - FIX!
   914 +//        gtk_style_context_save(style);
   922 +//        gtk_style_context_save(style);
   915  
   923  
   916          if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
   924          if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
   917              gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
   925              gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
   918 @@ -2540,7 +2707,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
   926 @@ -2540,7 +2714,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
   919  
   927  
   920          gtk_render_background(style, cr, x, y, w, h);
   928          gtk_render_background(style, cr, x, y, w, h);
   921          gtk_render_frame(style, cr, x, y, w, h);
   929          gtk_render_frame(style, cr, x, y, w, h);
   922 -        gtk_style_context_restore(style);
   930 -        gtk_style_context_restore(style);
   923 +//        gtk_style_context_restore(style);
   931 +//        gtk_style_context_restore(style);
   924      }
   932      }
   925  
   933  
   926      return MOZ_GTK_SUCCESS;
   934      return MOZ_GTK_SUCCESS;
   927 @@ -2556,7 +2723,10 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, Gd
   935 @@ -2556,7 +2730,10 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, Gd
   928  
   936  
   929      ensure_menu_item_widget();
   937      ensure_menu_item_widget();
   930      gtk_widget_set_direction(gMenuItemWidget, direction);
   938      gtk_widget_set_direction(gMenuItemWidget, direction);
   931 -
   939 -
   932 +/*
   940 +/*
   934 +                                                     GTK_STATE_FLAG_DIR_RTL;
   942 +                                                     GTK_STATE_FLAG_DIR_RTL;
   935 +*/
   943 +*/
   936      style = gtk_widget_get_style_context(gMenuItemWidget);
   944      style = gtk_widget_get_style_context(gMenuItemWidget);
   937      gtk_style_context_save(style);
   945      gtk_style_context_save(style);
   938      gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUITEM);
   946      gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUITEM);
   939 @@ -2606,7 +2776,7 @@ moz_gtk_check_menu_item_paint(cairo_t *c
   947 @@ -2606,7 +2783,7 @@ moz_gtk_check_menu_item_paint(cairo_t *c
   940      }
   948      }
   941      
   949      
   942      gtk_style_context_set_state(style, state_flags);
   950      gtk_style_context_set_state(style, state_flags);
   943 -    gtk_style_context_get_padding(style, state_flags, &padding);
   951 -    gtk_style_context_get_padding(style, state_flags, &padding);
   944 +    moz_gtk_get_style_padding(style, state_flags, &padding);
   952 +    moz_gtk_get_style_padding(style, state_flags, &padding);
   945  
   953  
   946      offset = gtk_container_get_border_width(GTK_CONTAINER(gCheckMenuItemWidget)) +
   954      offset = gtk_container_get_border_width(GTK_CONTAINER(gCheckMenuItemWidget)) +
   947                                              padding.left + 2;
   955                                              padding.left + 2;
   948 @@ -2658,7 +2828,7 @@ moz_gtk_add_style_border(GtkStyleContext
   956 @@ -2658,7 +2835,7 @@ moz_gtk_add_style_border(GtkStyleContext
   949  {
   957  {
   950      GtkBorder border;
   958      GtkBorder border;
   951  
   959  
   952 -    gtk_style_context_get_border(style, 0, &border);
   960 -    gtk_style_context_get_border(style, 0, &border);
   953 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
   961 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
   954  
   962  
   955      *left += border.left;
   963      *left += border.left;
   956      *right += border.right;
   964      *right += border.right;
   957 @@ -2667,12 +2837,22 @@ moz_gtk_add_style_border(GtkStyleContext
   965 @@ -2667,12 +2844,22 @@ moz_gtk_add_style_border(GtkStyleContext
   958  }
   966  }
   959  
   967  
   960  static void
   968  static void
   961 +moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
   969 +moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
   962 +                         GtkBorder *border)
   970 +                         GtkBorder *border)
   976 -    gtk_style_context_get_padding(style, 0, &padding);
   984 -    gtk_style_context_get_padding(style, 0, &padding);
   977 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   985 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
   978  
   986  
   979      *left += padding.left;
   987      *left += padding.left;
   980      *right += padding.right;
   988      *right += padding.right;
   981 @@ -2680,6 +2860,16 @@ moz_gtk_add_style_padding(GtkStyleContex
   989 @@ -2680,6 +2867,16 @@ moz_gtk_add_style_padding(GtkStyleContex
   982      *bottom += padding.bottom;
   990      *bottom += padding.bottom;
   983  }
   991  }
   984  
   992  
   985 +static void
   993 +static void
   986 +moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
   994 +moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
   993 +}
  1001 +}
   994 +
  1002 +
   995  gint
  1003  gint
   996  moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
  1004  moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
   997                            gint* right, gint* bottom, GtkTextDirection direction,
  1005                            gint* right, gint* bottom, GtkTextDirection direction,
   998 @@ -2694,36 +2884,27 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1006 @@ -2694,36 +2891,27 @@ moz_gtk_get_widget_border(GtkThemeWidget
   999      case MOZ_GTK_TOOLBAR_BUTTON:
  1007      case MOZ_GTK_TOOLBAR_BUTTON:
  1000          {
  1008          {
  1001              ensure_button_widget();
  1009              ensure_button_widget();
  1002 -            style = gtk_widget_get_style_context(gButtonWidget);
  1010 -            style = gtk_widget_get_style_context(gButtonWidget);
  1003  
  1011 -
  1004 -            *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButtonWidget));
  1012 -            *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButtonWidget));
  1005 -
  1013  
  1006 -            if (widget == MOZ_GTK_TOOLBAR_BUTTON) {
  1014 -            if (widget == MOZ_GTK_TOOLBAR_BUTTON) {
  1007 -                gtk_style_context_save(style);
  1015 -                gtk_style_context_save(style);
  1008 -                gtk_style_context_add_class(style, "image-button");
  1016 -                gtk_style_context_add_class(style, "image-button");
  1009 -            }
  1017 -            }
  1010 -              
  1018 -              
  1037 +            moz_gtk_add_style_padding(gEntry.entry.style, left, top, right, bottom);
  1045 +            moz_gtk_add_style_padding(gEntry.entry.style, left, top, right, bottom);
  1038 +            moz_gtk_add_style_border(gEntry.entry.style, left, top, right, bottom);
  1046 +            moz_gtk_add_style_border(gEntry.entry.style, left, top, right, bottom);
  1039  
  1047  
  1040              return MOZ_GTK_SUCCESS;
  1048              return MOZ_GTK_SUCCESS;
  1041          }
  1049          }
  1042 @@ -2759,7 +2940,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1050 @@ -2759,7 +2947,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1043          break;
  1051          break;
  1044      case MOZ_GTK_DROPDOWN_ENTRY:
  1052      case MOZ_GTK_DROPDOWN_ENTRY:
  1045          ensure_combo_box_entry_widgets();
  1053          ensure_combo_box_entry_widgets();
  1046 -        w = gComboBoxEntryTextareaWidget;
  1054 -        w = gComboBoxEntryTextareaWidget;
  1047 +        w = gComboBoxEntryTextarea.widget;
  1055 +        w = gComboBoxEntryTextarea.widget;
  1048          break;
  1056          break;
  1049      case MOZ_GTK_DROPDOWN_ARROW:
  1057      case MOZ_GTK_DROPDOWN_ARROW:
  1050          ensure_combo_box_entry_widgets();
  1058          ensure_combo_box_entry_widgets();
  1051 @@ -2795,7 +2976,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1059 @@ -2795,7 +2983,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1052  
  1060  
  1053                  if (!wide_separators) {
  1061                  if (!wide_separators) {
  1054                      style = gtk_widget_get_style_context(gComboBoxSeparatorWidget);
  1062                      style = gtk_widget_get_style_context(gComboBoxSeparatorWidget);
  1055 -                    gtk_style_context_get_border(style, 0, &border);
  1063 -                    gtk_style_context_get_border(style, 0, &border);
  1056 +                    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  1064 +                    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  1057                      separator_width = border.left;
  1065                      separator_width = border.left;
  1058                  }
  1066                  }
  1059              }
  1067              }
  1060 @@ -2814,14 +2995,17 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1068 @@ -2814,14 +3002,17 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1061          w = gTabWidget;
  1069          w = gTabWidget;
  1062          break;
  1070          break;
  1063      case MOZ_GTK_PROGRESSBAR:
  1071      case MOZ_GTK_PROGRESSBAR:
  1064 -        ensure_progress_widget();
  1072 -        ensure_progress_widget();
  1065 -        w = gProgressWidget;
  1073 -        w = gProgressWidget;
  1077 -        w = gSpinWidget;
  1085 -        w = gSpinWidget;
  1078 +        w = gSpin.widget;
  1086 +        w = gSpin.widget;
  1079          break;
  1087          break;
  1080      case MOZ_GTK_SCALE_HORIZONTAL:
  1088      case MOZ_GTK_SCALE_HORIZONTAL:
  1081          ensure_scale_widget();
  1089          ensure_scale_widget();
  1082 @@ -2840,12 +3024,13 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1090 @@ -2840,12 +3031,13 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1083          {
  1091          {
  1084              if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
  1092              if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
  1085                  ensure_checkbox_widget();
  1093                  ensure_checkbox_widget();
  1086 -                w = gCheckboxWidget;
  1094 -                w = gCheckboxWidget;
  1087 +                w = gCheckbox.widget;
  1095 +                w = gCheckbox.widget;
  1094              }
  1102              }
  1095 -            style = gtk_widget_get_style_context(w);
  1103 -            style = gtk_widget_get_style_context(w);
  1096  
  1104  
  1097              *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(w));
  1105              *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(w));
  1098              moz_gtk_add_style_border(style,
  1106              moz_gtk_add_style_border(style,
  1099 @@ -2978,6 +3163,32 @@ moz_gtk_get_combo_box_entry_button_size(
  1107 @@ -2978,6 +3170,32 @@ moz_gtk_get_combo_box_entry_button_size(
  1100  }
  1108  }
  1101  
  1109  
  1102  gint
  1110  gint
  1103 +moz_gtk_get_entry_height(gint* height)
  1111 +moz_gtk_get_entry_height(gint* height)
  1104 +{
  1112 +{
  1127 +
  1135 +
  1128 +gint
  1136 +gint
  1129  moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
  1137  moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
  1130  {
  1138  {
  1131      gint arrow_size;
  1139      gint arrow_size;
  1132 @@ -3022,7 +3233,7 @@ moz_gtk_get_toolbar_separator_width(gint
  1140 @@ -3022,7 +3240,7 @@ moz_gtk_get_toolbar_separator_width(gint
  1133                           "separator-width", &separator_width,
  1141                           "separator-width", &separator_width,
  1134                           NULL);
  1142                           NULL);
  1135      /* Just in case... */
  1143      /* Just in case... */
  1136 -    gtk_style_context_get_border(style, 0, &border);
  1144 -    gtk_style_context_get_border(style, 0, &border);
  1137 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  1145 +    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  1138      *size = MAX(*size, (wide_separators ? separator_width : border.left));
  1146      *size = MAX(*size, (wide_separators ? separator_width : border.left));
  1139      return MOZ_GTK_SUCCESS;
  1147      return MOZ_GTK_SUCCESS;
  1140  }
  1148  }
  1141 @@ -3064,7 +3275,7 @@ moz_gtk_get_menu_separator_height(gint *
  1149 @@ -3064,7 +3282,7 @@ moz_gtk_get_menu_separator_height(gint *
  1142      border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
  1150      border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
  1143  
  1151  
  1144      style = gtk_widget_get_style_context(gMenuSeparatorWidget);
  1152      style = gtk_widget_get_style_context(gMenuSeparatorWidget);
  1145 -    gtk_style_context_get_padding(style, 0, &padding);
  1153 -    gtk_style_context_get_padding(style, 0, &padding);
  1146 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
  1154 +    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
  1147  
  1155  
  1148      gtk_style_context_save(style);
  1156      gtk_style_context_save(style);
  1149      gtk_style_context_add_class(style, GTK_STYLE_CLASS_SEPARATOR);
  1157      gtk_style_context_add_class(style, GTK_STYLE_CLASS_SEPARATOR);
  1150 @@ -3122,15 +3333,21 @@ moz_gtk_get_scrollbar_metrics(MozGtkScro
  1158 @@ -3122,15 +3340,21 @@ moz_gtk_get_scrollbar_metrics(MozGtkScro
  1151  {
  1159  {
  1152      ensure_scrollbar_widget();
  1160      ensure_scrollbar_widget();
  1153  
  1161  
  1154 -    gtk_widget_style_get (gHorizScrollbarWidget,
  1162 -    gtk_widget_style_get (gHorizScrollbarWidget,
  1155 +    gtk_widget_style_get (gHorizScrollbar.widget,
  1163 +    gtk_widget_style_get (gHorizScrollbar.widget,
  1170 +            gtk_range_get_min_slider_size(GTK_RANGE(gVertScrollbar.widget));
  1178 +            gtk_range_get_min_slider_size(GTK_RANGE(gVertScrollbar.widget));
  1171 +    }
  1179 +    }
  1172  
  1180  
  1173      return MOZ_GTK_SUCCESS;
  1181      return MOZ_GTK_SUCCESS;
  1174  }
  1182  }
  1175 @@ -3155,7 +3372,7 @@ moz_gtk_images_in_buttons()
  1183 @@ -3155,7 +3379,7 @@ moz_gtk_images_in_buttons()
  1176      GtkSettings* settings;
  1184      GtkSettings* settings;
  1177  
  1185  
  1178      ensure_button_widget();
  1186      ensure_button_widget();
  1179 -    settings = gtk_widget_get_settings(gButtonWidget);
  1187 -    settings = gtk_widget_get_settings(gButtonWidget);
  1180 +    settings = gtk_widget_get_settings(gButton.widget);
  1188 +    settings = gtk_widget_get_settings(gButton.widget);
  1181  
  1189  
  1182      g_object_get(settings, "gtk-button-images", &result, NULL);
  1190      g_object_get(settings, "gtk-button-images", &result, NULL);
  1183      return result;
  1191      return result;
  1184 @@ -3183,7 +3400,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1192 @@ -3183,7 +3407,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1185          }
  1193          }
  1186          ensure_button_widget();
  1194          ensure_button_widget();
  1187          return moz_gtk_button_paint(cr, rect, state,
  1195          return moz_gtk_button_paint(cr, rect, state,
  1188 -                                    (GtkReliefStyle) flags, gButtonWidget,
  1196 -                                    (GtkReliefStyle) flags, gButtonWidget,
  1189 +                                    (GtkReliefStyle) flags, gButton.widget,
  1197 +                                    (GtkReliefStyle) flags, gButton.widget,
  1190                                      direction);
  1198                                      direction);
  1191          break;
  1199          break;
  1192      case MOZ_GTK_CHECKBUTTON:
  1200      case MOZ_GTK_CHECKBUTTON:
  1193 @@ -3233,7 +3450,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1201 @@ -3233,7 +3457,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1194      case MOZ_GTK_SPINBUTTON_ENTRY:
  1202      case MOZ_GTK_SPINBUTTON_ENTRY:
  1195          ensure_spin_widget();
  1203          ensure_spin_widget();
  1196          return moz_gtk_entry_paint(cr, rect, state,
  1204          return moz_gtk_entry_paint(cr, rect, state,
  1197 -                                   gSpinWidget, direction);
  1205 -                                   gSpinWidget, direction);
  1198 +                                   &gSpin, direction);
  1206 +                                   &gSpin, direction);
  1199          break;
  1207          break;
  1200      case MOZ_GTK_GRIPPER:
  1208      case MOZ_GTK_GRIPPER:
  1201          return moz_gtk_gripper_paint(cr, rect, state,
  1209          return moz_gtk_gripper_paint(cr, rect, state,
  1202 @@ -3260,7 +3477,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1210 @@ -3260,7 +3484,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1203      case MOZ_GTK_ENTRY:
  1211      case MOZ_GTK_ENTRY:
  1204          ensure_entry_widget();
  1212          ensure_entry_widget();
  1205          return moz_gtk_entry_paint(cr, rect, state,
  1213          return moz_gtk_entry_paint(cr, rect, state,
  1206 -                                   gEntryWidget, direction);
  1214 -                                   gEntryWidget, direction);
  1207 +                                   &gEntry, direction);
  1215 +                                   &gEntry, direction);
  1208          break;
  1216          break;
  1209      case MOZ_GTK_DROPDOWN:
  1217      case MOZ_GTK_DROPDOWN:
  1210          return moz_gtk_combo_box_paint(cr, rect, state, direction);
  1218          return moz_gtk_combo_box_paint(cr, rect, state, direction);
  1211 @@ -3272,7 +3489,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1219 @@ -3272,7 +3496,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1212      case MOZ_GTK_DROPDOWN_ENTRY:
  1220      case MOZ_GTK_DROPDOWN_ENTRY:
  1213          ensure_combo_box_entry_widgets();
  1221          ensure_combo_box_entry_widgets();
  1214          return moz_gtk_entry_paint(cr, rect, state,
  1222          return moz_gtk_entry_paint(cr, rect, state,
  1215 -                                   gComboBoxEntryTextareaWidget, direction);
  1223 -                                   gComboBoxEntryTextareaWidget, direction);
  1216 +                                   &gComboBoxEntryTextarea, direction);
  1224 +                                   &gComboBoxEntryTextarea, direction);
  1217          break;
  1225          break;
  1218      case MOZ_GTK_CHECKBUTTON_CONTAINER:
  1226      case MOZ_GTK_CHECKBUTTON_CONTAINER:
  1219      case MOZ_GTK_RADIOBUTTON_CONTAINER:
  1227      case MOZ_GTK_RADIOBUTTON_CONTAINER:
  1220 @@ -3324,7 +3541,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1228 @@ -3324,7 +3548,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1221                                                (GtkArrowType) flags, direction);
  1229                                                (GtkArrowType) flags, direction);
  1222          break;
  1230          break;
  1223      case MOZ_GTK_MENUBAR:
  1231      case MOZ_GTK_MENUBAR:
  1224 -        return moz_gtk_menu_bar_paint(cr, rect, direction);
  1232 -        return moz_gtk_menu_bar_paint(cr, rect, direction);
  1225 +        return moz_gtk_menu_bar_paint(cr, rect, state, direction);
  1233 +        return moz_gtk_menu_bar_paint(cr, rect, state, direction);
  1226          break;
  1234          break;
  1227      case MOZ_GTK_MENUPOPUP:
  1235      case MOZ_GTK_MENUPOPUP:
  1228          return moz_gtk_menu_popup_paint(cr, rect, direction);
  1236          return moz_gtk_menu_popup_paint(cr, rect, direction);
  1229 @@ -3375,7 +3592,7 @@ GtkWidget* moz_gtk_get_scrollbar_widget(
  1237 @@ -3375,7 +3599,7 @@ GtkWidget* moz_gtk_get_scrollbar_widget(
  1230  {
  1238  {
  1231      MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
  1239      MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
  1232      ensure_scrollbar_widget();
  1240      ensure_scrollbar_widget();
  1233 -    return gHorizScrollbarWidget;
  1241 -    return gHorizScrollbarWidget;
  1234 +    return gVertScrollbar.widget;
  1242 +    return gVertScrollbar.widget;
  1235  }
  1243  }
  1236  
  1244  
  1237  gboolean moz_gtk_has_scrollbar_buttons(void)
  1245  gboolean moz_gtk_has_scrollbar_buttons(void)
  1238 @@ -3383,7 +3600,7 @@ gboolean moz_gtk_has_scrollbar_buttons(v
  1246 @@ -3383,7 +3607,7 @@ gboolean moz_gtk_has_scrollbar_buttons(v
  1239      gboolean backward, forward, secondary_backward, secondary_forward;
  1247      gboolean backward, forward, secondary_backward, secondary_forward;
  1240      MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
  1248      MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
  1241      ensure_scrollbar_widget();
  1249      ensure_scrollbar_widget();
  1242 -    gtk_widget_style_get (gHorizScrollbarWidget,
  1250 -    gtk_widget_style_get (gHorizScrollbarWidget,
  1243 +    gtk_widget_style_get (gHorizScrollbar.widget,
  1251 +    gtk_widget_style_get (gHorizScrollbar.widget,
  1244                            "has-backward-stepper", &backward,
  1252                            "has-backward-stepper", &backward,
  1245                            "has-forward-stepper", &forward,
  1253                            "has-forward-stepper", &forward,
  1246                            "has-secondary-backward-stepper", &secondary_backward,
  1254                            "has-secondary-backward-stepper", &secondary_backward,
  1247 @@ -3409,17 +3626,19 @@ moz_gtk_shutdown()
  1255 @@ -3409,17 +3633,19 @@ moz_gtk_shutdown()
  1248  
  1256  
  1249      gProtoWindow = NULL;
  1257      gProtoWindow = NULL;
  1250      gProtoLayout = NULL;
  1258      gProtoLayout = NULL;
  1251 -    gButtonWidget = NULL;
  1259 -    gButtonWidget = NULL;
  1252 +
  1260 +
  1269 -    gEntryWidget = NULL;
  1277 -    gEntryWidget = NULL;
  1270 +    moz_gtk_widget_free(&gEntry);
  1278 +    moz_gtk_widget_free(&gEntry);
  1271      gComboBoxWidget = NULL;
  1279      gComboBoxWidget = NULL;
  1272      gComboBoxButtonWidget = NULL;
  1280      gComboBoxButtonWidget = NULL;
  1273      gComboBoxSeparatorWidget = NULL;
  1281      gComboBoxSeparatorWidget = NULL;
  1274 @@ -3427,12 +3646,12 @@ moz_gtk_shutdown()
  1282 @@ -3427,12 +3653,12 @@ moz_gtk_shutdown()
  1275      gComboBoxEntryWidget = NULL;
  1283      gComboBoxEntryWidget = NULL;
  1276      gComboBoxEntryButtonWidget = NULL;
  1284      gComboBoxEntryButtonWidget = NULL;
  1277      gComboBoxEntryArrowWidget = NULL;
  1285      gComboBoxEntryArrowWidget = NULL;
  1278 -    gComboBoxEntryTextareaWidget = NULL;
  1286 -    gComboBoxEntryTextareaWidget = NULL;
  1279 +    moz_gtk_widget_free(&gComboBoxEntryTextarea);
  1287 +    moz_gtk_widget_free(&gComboBoxEntryTextarea);
  1284 -    gProgressWidget = NULL;
  1292 -    gProgressWidget = NULL;
  1285 +    moz_gtk_widget_free(&gProgressBar);
  1293 +    moz_gtk_widget_free(&gProgressBar);
  1286      gTabWidget = NULL;
  1294      gTabWidget = NULL;
  1287      gTooltipWidget = NULL;
  1295      gTooltipWidget = NULL;
  1288      gMenuBarWidget = NULL;
  1296      gMenuBarWidget = NULL;
  1289 diff -up firefox-45.0.1/widget/gtk/gtkdrawing.h.gtk3-20 firefox-45.0.1/widget/gtk/gtkdrawing.h
  1297 diff -up firefox-45.0.2/widget/gtk/gtkdrawing.h.gtk3-20 firefox-45.0.2/widget/gtk/gtkdrawing.h
  1290 --- firefox-45.0.1/widget/gtk/gtkdrawing.h.gtk3-20	2016-03-15 23:37:46.000000000 +0100
  1298 --- firefox-45.0.2/widget/gtk/gtkdrawing.h.gtk3-20	2016-04-08 01:55:04.000000000 +0200
  1291 +++ firefox-45.0.1/widget/gtk/gtkdrawing.h	2016-04-05 14:40:27.847088629 +0200
  1299 +++ firefox-45.0.2/widget/gtk/gtkdrawing.h	2016-04-20 15:00:29.468048948 +0200
  1292 @@ -67,6 +67,13 @@ typedef enum {
  1300 @@ -67,6 +67,13 @@ typedef enum {
  1293    MOZ_GTK_TAB_SELECTED        = 1 << 10
  1301    MOZ_GTK_TAB_SELECTED        = 1 << 10
  1294  } GtkTabFlags;
  1302  } GtkTabFlags;
  1295  
  1303  
  1296 +typedef struct {
  1304 +typedef struct {
  1325 +
  1333 +
  1326 +
  1334 +
  1327  #ifdef __cplusplus
  1335  #ifdef __cplusplus
  1328  }
  1336  }
  1329  #endif /* __cplusplus */
  1337  #endif /* __cplusplus */
  1330 diff -up firefox-45.0.1/widget/gtk/mozgtk/mozgtk.c.gtk3-20 firefox-45.0.1/widget/gtk/mozgtk/mozgtk.c
  1338 diff -up firefox-45.0.2/widget/gtk/mozgtk/mozgtk.c.gtk3-20 firefox-45.0.2/widget/gtk/mozgtk/mozgtk.c
  1331 --- firefox-45.0.1/widget/gtk/mozgtk/mozgtk.c.gtk3-20	2016-04-05 14:40:27.799088451 +0200
  1339 --- firefox-45.0.2/widget/gtk/mozgtk/mozgtk.c.gtk3-20	2016-04-20 15:00:29.443048846 +0200
  1332 +++ firefox-45.0.1/widget/gtk/mozgtk/mozgtk.c	2016-04-05 15:16:17.401430826 +0200
  1340 +++ firefox-45.0.2/widget/gtk/mozgtk/mozgtk.c	2016-04-20 15:00:29.469048952 +0200
  1333 @@ -503,6 +503,11 @@ STUB(gtk_window_set_type_hint)
  1341 @@ -503,6 +503,11 @@ STUB(gtk_window_set_type_hint)
  1334  STUB(gtk_window_set_wmclass)
  1342  STUB(gtk_window_set_wmclass)
  1335  STUB(gtk_window_unfullscreen)
  1343  STUB(gtk_window_unfullscreen)
  1336  STUB(gtk_window_unmaximize)
  1344  STUB(gtk_window_unmaximize)
  1337 +STUB(gtk_widget_get_preferred_height_and_baseline_for_width)
  1345 +STUB(gtk_widget_get_preferred_height_and_baseline_for_width)
  1362 +STUB(gtk_style_context_set_parent)
  1370 +STUB(gtk_style_context_set_parent)
  1363 +STUB(gtk_widget_path_unref)
  1371 +STUB(gtk_widget_path_unref)
  1364  #endif
  1372  #endif
  1365  
  1373  
  1366  #ifdef GTK2_SYMBOLS
  1374  #ifdef GTK2_SYMBOLS
  1367 diff -up firefox-45.0.1/widget/gtk/nsLookAndFeel.cpp.gtk3-20 firefox-45.0.1/widget/gtk/nsLookAndFeel.cpp
  1375 diff -up firefox-45.0.2/widget/gtk/nsLookAndFeel.cpp.gtk3-20 firefox-45.0.2/widget/gtk/nsLookAndFeel.cpp
  1368 --- firefox-45.0.1/widget/gtk/nsLookAndFeel.cpp.gtk3-20	2016-03-15 23:37:46.000000000 +0100
  1376 --- firefox-45.0.2/widget/gtk/nsLookAndFeel.cpp.gtk3-20	2016-04-08 01:55:04.000000000 +0200
  1369 +++ firefox-45.0.1/widget/gtk/nsLookAndFeel.cpp	2016-04-05 14:40:27.848088632 +0200
  1377 +++ firefox-45.0.2/widget/gtk/nsLookAndFeel.cpp	2016-04-20 15:00:29.469048952 +0200
  1370 @@ -232,14 +232,18 @@ nsLookAndFeel::NativeGetColor(ColorID aI
  1378 @@ -232,14 +232,18 @@ nsLookAndFeel::NativeGetColor(ColorID aI
  1371      case eColorID_activeborder:
  1379      case eColorID_activeborder:
  1372          // active window border
  1380          // active window border
  1373          gtk_style_context_get_border_color(mBackgroundStyle, 
  1381          gtk_style_context_get_border_color(mBackgroundStyle, 
  1374 -                                           GTK_STATE_FLAG_NORMAL, &gdk_color);
  1382 -                                           GTK_STATE_FLAG_NORMAL, &gdk_color);
  1587      sInfoBarText = GDK_RGBA_TO_NS_RGBA(color);
  1595      sInfoBarText = GDK_RGBA_TO_NS_RGBA(color);
  1588 +    gtk_style_context_restore(style);
  1596 +    gtk_style_context_restore(style);
  1589  #endif
  1597  #endif
  1590      // Some themes have a unified menu bar, and support window dragging on it
  1598      // Some themes have a unified menu bar, and support window dragging on it
  1591      gboolean supports_menubar_drag = FALSE;
  1599      gboolean supports_menubar_drag = FALSE;
  1592 diff -up firefox-45.0.1/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20 firefox-45.0.1/widget/gtk/nsNativeThemeGTK.cpp
  1600 diff -up firefox-45.0.2/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20 firefox-45.0.2/widget/gtk/nsNativeThemeGTK.cpp
  1593 --- firefox-45.0.1/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20	2016-03-15 23:37:46.000000000 +0100
  1601 --- firefox-45.0.2/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20	2016-04-08 01:55:04.000000000 +0200
  1594 +++ firefox-45.0.1/widget/gtk/nsNativeThemeGTK.cpp	2016-04-05 14:40:27.848088632 +0200
  1602 +++ firefox-45.0.2/widget/gtk/nsNativeThemeGTK.cpp	2016-04-20 15:00:29.469048952 +0200
  1595 @@ -1548,9 +1548,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
  1603 @@ -1548,9 +1548,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
  1596    case NS_THEME_RADIO_CONTAINER:
  1604    case NS_THEME_RADIO_CONTAINER:
  1597    case NS_THEME_CHECKBOX_LABEL:
  1605    case NS_THEME_CHECKBOX_LABEL:
  1598    case NS_THEME_RADIO_LABEL:
  1606    case NS_THEME_RADIO_LABEL:
  1599 -  case NS_THEME_BUTTON:
  1607 -  case NS_THEME_BUTTON: