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