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