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