summaryrefslogtreecommitdiff
path: root/firefox-gtk3-20.patch
blob: cc7ee93d4ab44e003ab2d1acfc0f44ec6d6c5007 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
diff -up firefox-43.0/widget/gtk/gtk3drawing.c.gtk3-20 firefox-43.0/widget/gtk/gtk3drawing.c
--- firefox-43.0/widget/gtk/gtk3drawing.c.gtk3-20	2015-12-08 19:06:46.000000000 +0100
+++ firefox-43.0/widget/gtk/gtk3drawing.c	2015-12-16 20:40:48.591930885 +0100
@@ -17,15 +17,29 @@
 
 #include <math.h>
 
+typedef struct {
+		GtkWidget* 				widget;
+    GtkStyleContext*	styleScrollbar;
+    GtkStyleContext*	styleTrough;
+    GtkStyleContext*	styleSlider;
+} GtkWidgetScrollbar;
+
+typedef struct {
+		GtkWidget* 				widget;
+    GtkStyleContext*	styleButton;
+    GtkStyleContext*	styleCheck;
+    GtkStyleContext*	styleLabel;
+} GtkWidgetToogleBox;
+
 static GtkWidget* gProtoWindow;
 static GtkWidget* gProtoLayout;
 static GtkWidget* gButtonWidget;
 static GtkWidget* gToggleButtonWidget;
 static GtkWidget* gButtonArrowWidget;
-static GtkWidget* gCheckboxWidget;
-static GtkWidget* gRadiobuttonWidget;
-static GtkWidget* gHorizScrollbarWidget;
-static GtkWidget* gVertScrollbarWidget;
+static GtkWidgetToogleBox gCheckbox;
+static GtkWidgetToogleBox gRadiobutton;
+static GtkWidgetScrollbar gVertScrollbar;
+static GtkWidgetScrollbar gHorizScrollbar;
 static GtkWidget* gSpinWidget;
 static GtkWidget* gHScaleWidget;
 static GtkWidget* gVScaleWidget;
@@ -97,6 +111,33 @@ GetStateFlagsFromGtkWidgetState(GtkWidge
     return stateFlags;
 }
 
+GtkStyleContext *
+moz_gtk_style_create(GtkCssNode *node, GtkStyleContext *parent)
+{
+  GtkWidgetPath *path;
+  GtkStyleContext *context;
+
+  if (parent)
+    path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
+  else
+    path = gtk_widget_path_new ();
+
+  gtk_widget_path_append_type (path, node->type);
+  if (node->name)
+    gtk_widget_path_iter_set_object_name (path, -1, node->name);
+  if (node->class1)
+    gtk_widget_path_iter_add_class (path, -1, node->class1);
+  if (node->class2)
+    gtk_widget_path_iter_add_class (path, -1, node->class2);
+
+  context = gtk_style_context_new ();
+  gtk_style_context_set_path (context, path);
+  gtk_style_context_set_parent (context, parent);
+  gtk_widget_path_unref (path);
+
+  return context;
+}
+
 /* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
    that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
    things they may want to do. */
@@ -195,9 +236,21 @@ ensure_button_arrow_widget()
 static gint
 ensure_checkbox_widget()
 {
-    if (!gCheckboxWidget) {
-        gCheckboxWidget = gtk_check_button_new_with_label("M");
-        setup_widget_prototype(gCheckboxWidget);
+   if (!gCheckbox.widget) {
+        GtkCssNode path[] = {
+    		    { GTK_TYPE_LABEL, "checkbutton", NULL, NULL },
+		        { G_TYPE_NONE, "check", NULL, NULL },
+				    { G_TYPE_NONE, "label", NULL, NULL }
+        };
+
+        gCheckbox.widget = gtk_check_button_new_with_label("M");
+        setup_widget_prototype(gCheckbox.widget);
+
+			  gCheckbox.styleButton = moz_gtk_style_create(&path[0], NULL);
+			  gCheckbox.styleCheck = moz_gtk_style_create(&path[1],
+                                                    gCheckbox.styleButton);
+			  gCheckbox.styleLabel = moz_gtk_style_create(&path[2],
+                                                    gCheckbox.styleButton);
     }
     return MOZ_GTK_SUCCESS;
 }
@@ -205,9 +258,21 @@ ensure_checkbox_widget()
 static gint
 ensure_radiobutton_widget()
 {
-    if (!gRadiobuttonWidget) {
-        gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
-        setup_widget_prototype(gRadiobuttonWidget);
+    if (!gRadiobutton.widget) {
+        GtkCssNode path[] = {
+		        { GTK_TYPE_LABEL, "radiobutton", NULL, NULL },
+    		    { G_TYPE_NONE, "radio", NULL, NULL },
+    				{ G_TYPE_NONE, "label", NULL, NULL }
+        };
+
+        gRadiobutton.widget = gtk_radio_button_new_with_label(NULL, "M");
+        setup_widget_prototype(gRadiobutton.widget);
+
+        gRadiobutton.styleButton = moz_gtk_style_create(&path[0], NULL);
+        gRadiobutton.styleCheck = moz_gtk_style_create(&path[1],
+                                                       gRadiobutton.styleButton);
+			  gRadiobutton.styleLabel = moz_gtk_style_create(&path[2],
+                                                       gRadiobutton.styleButton);
     }
     return MOZ_GTK_SUCCESS;
 }
@@ -215,13 +280,31 @@ ensure_radiobutton_widget()
 static gint
 ensure_scrollbar_widget()
 {
-    if (!gVertScrollbarWidget) {
-        gVertScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
-        setup_widget_prototype(gVertScrollbarWidget);
-    }
-    if (!gHorizScrollbarWidget) {
-        gHorizScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
-        setup_widget_prototype(gHorizScrollbarWidget);
+    if (!gVertScrollbar.widget && !gHorizScrollbar.widget) {
+        GtkCssNode path[] = {
+            { GTK_TYPE_SCROLLBAR, "scrollbar", "horizontal", NULL },
+            { GTK_TYPE_SCROLLBAR, "scrollbar", "vertical", NULL },
+            { G_TYPE_NONE, "trough", NULL, NULL },
+            { G_TYPE_NONE, "slider", NULL, NULL }
+        };
+
+        gVertScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
+        setup_widget_prototype(gVertScrollbar.widget);
+
+		    gVertScrollbar.styleScrollbar = moz_gtk_style_create(path+1, NULL);
+		    gVertScrollbar.styleTrough = moz_gtk_style_create(path+2, 
+                                     		gVertScrollbar.styleScrollbar);
+		    gVertScrollbar.styleSlider = moz_gtk_style_create(path+3, 
+                                     		gVertScrollbar.styleTrough);
+
+        gHorizScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
+        setup_widget_prototype(gHorizScrollbar.widget);
+
+		    gHorizScrollbar.styleScrollbar = moz_gtk_style_create(path, NULL);
+		    gHorizScrollbar.styleTrough = moz_gtk_style_create(path+2, 
+                                      		gHorizScrollbar.styleScrollbar);
+		    gHorizScrollbar.styleSlider = moz_gtk_style_create(path+3, 
+                                          gHorizScrollbar.styleTrough);
     }
     return MOZ_GTK_SUCCESS;
 }
@@ -757,7 +840,7 @@ moz_gtk_checkbox_get_metrics(gint* indic
 {
     ensure_checkbox_widget();
 
-    gtk_widget_style_get (gCheckboxWidget,
+    gtk_widget_style_get (gCheckbox.widget,
                           "indicator_size", indicator_size,
                           "indicator_spacing", indicator_spacing,
                           NULL);
@@ -770,7 +853,7 @@ moz_gtk_radio_get_metrics(gint* indicato
 {
     ensure_radiobutton_widget();
 
-    gtk_widget_style_get (gRadiobuttonWidget,
+    gtk_widget_style_get (gRadiobutton.widget,
                           "indicator_size", indicator_size,
                           "indicator_spacing", indicator_spacing,
                           NULL);
@@ -961,15 +1044,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
     gint indicator_size, indicator_spacing;
     gint x, y, width, height;
     gint focus_x, focus_y, focus_width, focus_height;
-    GtkWidget *w;
-    GtkStyleContext *style;
+    GtkWidgetToogleBox *w;
 
     if (isradio) {
         moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
-        w = gRadiobuttonWidget;
+        w = &gRadiobutton;
     } else {
         moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
-        w = gCheckboxWidget;
+        w = &gCheckbox;
     }
 
     // XXX we should assert rect->height >= indicator_size too
@@ -988,11 +1070,9 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
     focus_width = width + 2 * indicator_spacing;
     focus_height = height + 2 * indicator_spacing;
   
-    style = gtk_widget_get_style_context(w);
-
-    gtk_widget_set_sensitive(w, !state->disabled);
-    gtk_widget_set_direction(w, direction);
-    gtk_style_context_save(style);
+    gtk_widget_set_sensitive(w->widget, !state->disabled);
+    gtk_widget_set_direction(w->widget, direction);
+    gtk_style_context_save(w->styleCheck);
 
     if (selected)
         state_flags |= checkbox_check_state;
@@ -1000,13 +1080,12 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
     if (inconsistent)
         state_flags |= GTK_STATE_FLAG_INCONSISTENT;
 
-    gtk_style_context_set_state(style, state_flags);
+    gtk_style_context_set_state(w->styleCheck, state_flags);
 
     if (isradio) {
-        gtk_style_context_add_class(style, GTK_STYLE_CLASS_RADIO);
-        gtk_render_option(style, cr, x, y, width, height);
+        gtk_render_option(w->styleCheck, cr, x, y, width, height);
         if (state->focused) {
-            gtk_render_focus(style, cr, focus_x, focus_y,
+            gtk_render_focus(w->styleCheck, cr, focus_x, focus_y,
                             focus_width, focus_height);
         }
     }
@@ -1015,15 +1094,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
         * 'indeterminate' type on checkboxes. In GTK, the shadow type
         * must also be changed for the state to be drawn.
         */        
-        gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
-        gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), inconsistent);
-        gtk_render_check(style, cr, x, y, width, height);        
+        gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckbox.widget), inconsistent);
+        gtk_render_check(w->styleCheck, cr, x, y, width, height);
         if (state->focused) {
-            gtk_render_focus(style, cr, 
+            gtk_render_focus(w->styleCheck, cr,
                              focus_x, focus_y, focus_width, focus_height);
         }
     }
-    gtk_style_context_restore(style);
+    gtk_style_context_restore(w->styleCheck);
 
     return MOZ_GTK_SUCCESS;
 }
@@ -1109,9 +1187,9 @@ moz_gtk_scrollbar_button_paint(cairo_t *
     ensure_scrollbar_widget();
 
     if (flags & MOZ_GTK_STEPPER_VERTICAL)
-        scrollbar = gVertScrollbarWidget;
+        scrollbar = gVertScrollbar.widget;
     else
-        scrollbar = gHorizScrollbarWidget;
+        scrollbar = gHorizScrollbar.widget;
 
     gtk_widget_set_direction(scrollbar, direction);
 
@@ -1177,26 +1255,22 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
                                GtkTextDirection direction)
 {
     GtkStyleContext* style;
-    GtkScrollbar *scrollbar;
-
     ensure_scrollbar_widget();
 
-    if (widget ==  MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL)
-        scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
-    else
-        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
-
-    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
+    if (widget ==  MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL) {
+        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
+        style = gHorizScrollbar.styleTrough;
+    }
+    else {
+        gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
+        style = gVertScrollbar.styleTrough;
+    }
     
     if (flags & MOZ_GTK_TRACK_OPAQUE) {
         style = gtk_widget_get_style_context(GTK_WIDGET(gProtoWindow));
         gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
     }
 
-    style = gtk_widget_get_style_context(GTK_WIDGET(scrollbar));
-    gtk_style_context_save(style);
-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
-
     gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
     gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
 
@@ -1204,7 +1278,6 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
         gtk_render_focus(style, cr,
                          rect->x, rect->y, rect->width, rect->height);
     }
-    gtk_style_context_restore(style);
     return MOZ_GTK_SUCCESS;
 }
 
@@ -1222,19 +1295,16 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
 
     ensure_scrollbar_widget();
 
-    if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL)
-        scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
-    else
-        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
-
-    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
-
-    style = gtk_widget_get_style_context(GTK_WIDGET(scrollbar));
-    gtk_style_context_save(style);
+    if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) {
+        style = gHorizScrollbar.styleSlider;
+        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
+    }
+    else {
+        style = gVertScrollbar.styleSlider;
+        gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
+    }
 
-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_SLIDER);
     gtk_style_context_set_state(style, state_flags);
-
     gtk_style_context_get_margin (style, state_flags, &margin);
 
     gtk_render_slider(style, cr,
@@ -1245,8 +1315,6 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
                      (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
                      GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
 
-    gtk_style_context_restore(style);
-
     return MOZ_GTK_SUCCESS;
 }
 
@@ -1801,29 +1869,27 @@ moz_gtk_container_paint(cairo_t *cr, Gdk
                         gboolean isradio, GtkTextDirection direction)
 {
     GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
-    GtkStyleContext* style;
-    GtkWidget *widget;
+    GtkWidgetToogleBox *widget;
 
     if (isradio) {
         ensure_radiobutton_widget();
-        widget = gRadiobuttonWidget;
+        widget = &gRadiobutton;
     } else {
         ensure_checkbox_widget();
-        widget = gCheckboxWidget;
+        widget = &gCheckbox;
     }
-    gtk_widget_set_direction(widget, direction);
+    gtk_widget_set_direction(widget->widget, direction);
 
-    style = gtk_widget_get_style_context(widget);
-    gtk_style_context_save(style);
-    gtk_style_context_set_state(style, state_flags);
+    gtk_style_context_save(widget->styleButton);
+    gtk_style_context_set_state(widget->styleButton, state_flags);
   
     /* this is for drawing a prelight box */
     if (state_flags & GTK_STATE_FLAG_PRELIGHT) {
-        gtk_render_background(style, cr,
+        gtk_render_background(widget->styleButton, cr,
                               rect->x, rect->y, rect->width, rect->height);
     }
   
-    gtk_style_context_restore(style);
+    gtk_style_context_restore(widget->styleButton);
   
     return MOZ_GTK_SUCCESS;
 }
@@ -1833,32 +1899,25 @@ moz_gtk_toggle_label_paint(cairo_t *cr,
                            GtkWidgetState* state, 
                            gboolean isradio, GtkTextDirection direction)
 {
-    GtkStyleContext *style;
-    GtkWidget *widget;
+    GtkWidgetToogleBox *widget;
 
     if (!state->focused)
         return MOZ_GTK_SUCCESS;
 
     if (isradio) {
         ensure_radiobutton_widget();
-        widget = gRadiobuttonWidget;
+        widget = &gRadiobutton;
     } else {
         ensure_checkbox_widget();
-        widget = gCheckboxWidget;
-    }
-    style = gtk_widget_get_style_context(widget);
-    gtk_style_context_save(style);
-    if (isradio) {
-      gtk_style_context_add_class(style, GTK_STYLE_CLASS_RADIO);
-    } else {
-      gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
+        widget = &gCheckbox;
     }
-    gtk_widget_set_direction(widget, direction);
+    gtk_style_context_save(widget->styleLabel);
+    gtk_widget_set_direction(widget->widget, direction);
 
-    gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
-    gtk_render_focus(style, cr,
+    gtk_style_context_set_state(widget->styleLabel, GetStateFlagsFromGtkWidgetState(state));
+    gtk_render_focus(widget->styleLabel, cr,
                     rect->x, rect->y, rect->width, rect->height);
-    gtk_style_context_restore(style);
+    gtk_style_context_restore(widget->styleLabel);
 
     return MOZ_GTK_SUCCESS;
 }
@@ -2841,10 +2900,10 @@ moz_gtk_get_widget_border(GtkThemeWidget
         {
             if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
                 ensure_checkbox_widget();
-                w = gCheckboxWidget;
+                w = gCheckbox.widget;
             } else {
                 ensure_radiobutton_widget();
-                w = gRadiobuttonWidget;
+                w = gRadiobutton.widget;
             }
             style = gtk_widget_get_style_context(w);
 
@@ -3123,7 +3182,7 @@ moz_gtk_get_scrollbar_metrics(MozGtkScro
 {
     ensure_scrollbar_widget();
 
-    gtk_widget_style_get (gHorizScrollbarWidget,
+    gtk_widget_style_get (gHorizScrollbar.widget,
                           "slider_width", &metrics->slider_width,
                           "trough_border", &metrics->trough_border,
                           "stepper_size", &metrics->stepper_size,
@@ -3131,7 +3190,7 @@ moz_gtk_get_scrollbar_metrics(MozGtkScro
                           NULL);
 
     metrics->min_slider_size = 
-        gtk_range_get_min_slider_size(GTK_RANGE(gHorizScrollbarWidget));
+        gtk_range_get_min_slider_size(GTK_RANGE(gHorizScrollbar.widget));
 
     return MOZ_GTK_SUCCESS;
 }
@@ -3377,7 +3436,7 @@ GtkWidget* moz_gtk_get_scrollbar_widget(
 {
     MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
     ensure_scrollbar_widget();
-    return gHorizScrollbarWidget;
+    return gHorizScrollbar.widget;
 }
 
 gboolean moz_gtk_has_scrollbar_buttons(void)
@@ -3385,7 +3444,7 @@ gboolean moz_gtk_has_scrollbar_buttons(v
     gboolean backward, forward, secondary_backward, secondary_forward;
     MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
     ensure_scrollbar_widget();
-    gtk_widget_style_get (gHorizScrollbarWidget,
+    gtk_widget_style_get (gHorizScrollbar.widget,
                           "has-backward-stepper", &backward,
                           "has-forward-stepper", &forward,
                           "has-secondary-backward-stepper", &secondary_backward,
@@ -3414,10 +3473,10 @@ moz_gtk_shutdown()
     gButtonWidget = NULL;
     gToggleButtonWidget = NULL;
     gButtonArrowWidget = NULL;
-    gCheckboxWidget = NULL;
-    gRadiobuttonWidget = NULL;
-    gHorizScrollbarWidget = NULL;
-    gVertScrollbarWidget = NULL;
+//    gCheckboxWidget = NULL;
+//    gRadiobuttonWidget = NULL;
+//    gHorizScrollbarWidget = NULL;
+//    gVertScrollbarWidget = NULL;
     gSpinWidget = NULL;
     gHScaleWidget = NULL;
     gVScaleWidget = NULL;
diff -up firefox-43.0/widget/gtk/gtkdrawing.h.gtk3-20 firefox-43.0/widget/gtk/gtkdrawing.h
--- firefox-43.0/widget/gtk/gtkdrawing.h.gtk3-20	2015-12-08 19:06:46.000000000 +0100
+++ firefox-43.0/widget/gtk/gtkdrawing.h	2015-12-16 20:38:30.313116412 +0100
@@ -67,6 +67,13 @@ typedef enum {
   MOZ_GTK_TAB_SELECTED        = 1 << 10
 } GtkTabFlags;
 
+typedef struct {
+  GType type;
+  const gchar *name;
+  const gchar *class1;
+  const gchar *class2;
+} GtkCssNode;
+
 /** flags for menuitems **/
 typedef enum {
   /* menuitem is part of the menubar */
@@ -464,6 +471,10 @@ gboolean moz_gtk_images_in_buttons(void)
  */
 gboolean moz_gtk_has_scrollbar_buttons(void);
 
+
+GtkStyleContext *
+moz_gtk_style_create(GtkCssNode *node, GtkStyleContext *parent);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff -up firefox-43.0/widget/gtk/mozgtk/mozgtk.c.gtk3-20 firefox-43.0/widget/gtk/mozgtk/mozgtk.c
--- firefox-43.0/widget/gtk/mozgtk/mozgtk.c.gtk3-20	2015-12-08 19:06:46.000000000 +0100
+++ firefox-43.0/widget/gtk/mozgtk/mozgtk.c	2015-12-16 20:38:30.313116412 +0100
@@ -547,6 +547,7 @@ STUB(gtk_style_context_get_border_color)
 STUB(gtk_style_context_get_color)
 STUB(gtk_style_context_get_margin)
 STUB(gtk_style_context_get_padding)
+STUB(gtk_style_context_get_state)
 STUB(gtk_style_context_has_class)
 STUB(gtk_style_context_new)
 STUB(gtk_style_context_remove_class)
@@ -574,6 +575,12 @@ STUB(gtk_color_chooser_get_type)
 STUB(gtk_color_chooser_set_rgba)
 STUB(gtk_color_chooser_get_rgba)
 STUB(gtk_color_chooser_set_use_alpha)
+STUB(gtk_style_context_get_path)
+STUB(gtk_widget_path_copy)
+STUB(gtk_widget_path_iter_set_object_name)
+STUB(gtk_widget_path_iter_add_class)
+STUB(gtk_style_context_set_parent)
+STUB(gtk_widget_path_unref)
 #endif
 
 #ifdef GTK2_SYMBOLS
diff -up firefox-43.0/widget/gtk/nsLookAndFeel.cpp.gtk3-20 firefox-43.0/widget/gtk/nsLookAndFeel.cpp
--- firefox-43.0/widget/gtk/nsLookAndFeel.cpp.gtk3-20	2015-12-08 19:06:46.000000000 +0100
+++ firefox-43.0/widget/gtk/nsLookAndFeel.cpp	2015-12-16 20:38:30.314116418 +0100
@@ -983,7 +983,7 @@ nsLookAndFeel::Init()
     style = create_context(path);
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_SCROLLBAR);
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
-    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
     sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color);
     g_object_unref(style);
 
@@ -991,18 +991,18 @@ nsLookAndFeel::Init()
     style = create_context(path);
     gtk_style_context_save(style);
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
-    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
     sMozWindowBackground = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sMozWindowText = GDK_RGBA_TO_NS_RGBA(color);
     gtk_style_context_restore(style);
 
     // tooltip foreground and background
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
-    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
     sInfoBackground = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sInfoText = GDK_RGBA_TO_NS_RGBA(color);
     g_object_unref(style);
 
@@ -1017,20 +1017,26 @@ nsLookAndFeel::Init()
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 
     style = gtk_widget_get_style_context(accel_label);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sMenuText = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_INSENSITIVE, &color);
+    gtk_style_context_save(style);
+    gtk_style_context_set_state(style, GTK_STATE_FLAG_INSENSITIVE);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color);
+    gtk_style_context_restore(style);
 
     style = gtk_widget_get_style_context(menu);
-    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
     sMenuBackground = GDK_RGBA_TO_NS_RGBA(color);
 
     style = gtk_widget_get_style_context(menuitem);
-    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
+    gtk_style_context_save(style);
+    gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
+    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
     sMenuHover = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sMenuHoverText = GDK_RGBA_TO_NS_RGBA(color);
+    gtk_style_context_restore(style);
 
     g_object_unref(menu);
 #endif
@@ -1139,44 +1145,53 @@ nsLookAndFeel::Init()
             GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]);
     }
 #else
+    GtkCssNode labelPath[] = {
+       { GTK_TYPE_LABEL, "label", "view", NULL },
+       { G_TYPE_NONE, "selection", NULL, NULL }
+    };
+
+    GtkStyleContext *styleLabel;
+    GtkStyleContext *styleSelection;
+
     // Text colors
-    style = gtk_widget_get_style_context(textView);
-    gtk_style_context_save(style);
-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_VIEW);
-    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    styleLabel = moz_gtk_style_create(labelPath, NULL);
+    styleSelection = moz_gtk_style_create(labelPath+1, styleLabel);
+    gtk_style_context_get_background_color(styleLabel, gtk_style_context_get_state(styleLabel), &color);
     sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_color(styleLabel, gtk_style_context_get_state(styleLabel), &color);
     sMozFieldText = GDK_RGBA_TO_NS_RGBA(color);
 
     // Selected text and background
-    gtk_style_context_get_background_color(style,
-        static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
-        &color);
+    gtk_style_context_set_state (styleLabel, GTK_STATE_FLAG_SELECTED);
+    gtk_style_context_get_background_color(styleSelection, gtk_style_context_get_state(styleSelection), &color);
     sTextSelectedBackground = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(style,
-        static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
-        &color);
+    gtk_style_context_get_color(styleSelection, gtk_style_context_get_state(styleSelection), &color);
     sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_restore(style);
 
     // Button text, background, border
     style = gtk_widget_get_style_context(label);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sButtonText = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
+    gtk_style_context_save(style);
+    gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
+    gtk_style_context_restore(style);
 
     // Combobox text color
     style = gtk_widget_get_style_context(comboboxLabel);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sComboBoxText = GDK_RGBA_TO_NS_RGBA(color);
 
     // Menubar text and hover text colors    
     style = gtk_widget_get_style_context(menuBar);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sMenuBarText = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
+    gtk_style_context_save(style);
+    gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sMenuBarHoverText = GDK_RGBA_TO_NS_RGBA(color);
+    gtk_style_context_restore(style);
 
     // GTK's guide to fancy odd row background colors:
     // 1) Check if a theme explicitly defines an odd row color
@@ -1189,7 +1204,7 @@ nsLookAndFeel::Init()
     // Get odd row background color
     gtk_style_context_save(style);
     gtk_style_context_add_region(style, GTK_STYLE_REGION_ROW, GTK_REGION_ODD);
-    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
     sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color);
     gtk_style_context_restore(style);
 
@@ -1199,7 +1214,7 @@ nsLookAndFeel::Init()
     // TODO GTK3 - update sFrameOuterLightBorder 
     // for GTK_BORDER_STYLE_INSET/OUTSET/GROVE/RIDGE border styles (Bug 978172).
     style = gtk_widget_get_style_context(frame);
-    gtk_style_context_get_border_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_border_color(style, gtk_style_context_get_state(style), &color);
     sFrameInnerDarkBorder = sFrameOuterLightBorder = GDK_RGBA_TO_NS_RGBA(color);
 
     gtk_widget_path_free(path);
@@ -1211,9 +1226,11 @@ nsLookAndFeel::Init()
     gtk_container_add(GTK_CONTAINER(parent), infoBar);
     gtk_container_add(GTK_CONTAINER(infoBarContent), infoBarLabel);
     style = gtk_widget_get_style_context(infoBarLabel);
+    gtk_style_context_save(style);
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_INFO);
-    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
     sInfoBarText = GDK_RGBA_TO_NS_RGBA(color);
+    gtk_style_context_restore(style);
 #endif
     // Some themes have a unified menu bar, and support window dragging on it
     gboolean supports_menubar_drag = FALSE;
bgstack15