[arch-commits] Commit in bluegriffon/repos (16 files)

Fabio Castelli muflone at archlinux.org
Sun Jun 11 21:58:40 UTC 2017


    Date: Sunday, June 11, 2017 @ 21:58:39
  Author: muflone
Revision: 236227

archrelease: copy trunk to community-staging-i686, community-staging-x86_64

Added:
  bluegriffon/repos/community-staging-i686/
  bluegriffon/repos/community-staging-i686/PKGBUILD
    (from rev 236226, bluegriffon/trunk/PKGBUILD)
  bluegriffon/repos/community-staging-i686/bluegriffon.desktop
    (from rev 236226, bluegriffon/trunk/bluegriffon.desktop)
  bluegriffon/repos/community-staging-i686/bluegriffon_gtk3.patch
    (from rev 236226, bluegriffon/trunk/bluegriffon_gtk3.patch)
  bluegriffon/repos/community-staging-i686/bug_1234158_firefox-gtk3-20.patch
    (from rev 236226, bluegriffon/trunk/bug_1234158_firefox-gtk3-20.patch)
  bluegriffon/repos/community-staging-i686/bug_1371991_no_lib_nss_crmf.patch
    (from rev 236226, bluegriffon/trunk/bug_1371991_no_lib_nss_crmf.patch)
  bluegriffon/repos/community-staging-i686/event__sizeof.patch
    (from rev 236226, bluegriffon/trunk/event__sizeof.patch)
  bluegriffon/repos/community-staging-i686/mozconfig
    (from rev 236226, bluegriffon/trunk/mozconfig)
  bluegriffon/repos/community-staging-x86_64/
  bluegriffon/repos/community-staging-x86_64/PKGBUILD
    (from rev 236226, bluegriffon/trunk/PKGBUILD)
  bluegriffon/repos/community-staging-x86_64/bluegriffon.desktop
    (from rev 236226, bluegriffon/trunk/bluegriffon.desktop)
  bluegriffon/repos/community-staging-x86_64/bluegriffon_gtk3.patch
    (from rev 236226, bluegriffon/trunk/bluegriffon_gtk3.patch)
  bluegriffon/repos/community-staging-x86_64/bug_1234158_firefox-gtk3-20.patch
    (from rev 236226, bluegriffon/trunk/bug_1234158_firefox-gtk3-20.patch)
  bluegriffon/repos/community-staging-x86_64/bug_1371991_no_lib_nss_crmf.patch
    (from rev 236226, bluegriffon/trunk/bug_1371991_no_lib_nss_crmf.patch)
  bluegriffon/repos/community-staging-x86_64/event__sizeof.patch
    (from rev 236226, bluegriffon/trunk/event__sizeof.patch)
  bluegriffon/repos/community-staging-x86_64/mozconfig
    (from rev 236226, bluegriffon/trunk/mozconfig)

------------------------------------------------------------+
 community-staging-i686/PKGBUILD                            |  121 
 community-staging-i686/bluegriffon.desktop                 |   16 
 community-staging-i686/bluegriffon_gtk3.patch              |   46 
 community-staging-i686/bug_1234158_firefox-gtk3-20.patch   | 1736 +++++++++++
 community-staging-i686/bug_1371991_no_lib_nss_crmf.patch   |   23 
 community-staging-i686/event__sizeof.patch                 |   18 
 community-staging-i686/mozconfig                           |   63 
 community-staging-x86_64/PKGBUILD                          |  121 
 community-staging-x86_64/bluegriffon.desktop               |   16 
 community-staging-x86_64/bluegriffon_gtk3.patch            |   46 
 community-staging-x86_64/bug_1234158_firefox-gtk3-20.patch | 1736 +++++++++++
 community-staging-x86_64/bug_1371991_no_lib_nss_crmf.patch |   23 
 community-staging-x86_64/event__sizeof.patch               |   18 
 community-staging-x86_64/mozconfig                         |   63 
 14 files changed, 4046 insertions(+)

Copied: bluegriffon/repos/community-staging-i686/PKGBUILD (from rev 236226, bluegriffon/trunk/PKGBUILD)
===================================================================
--- community-staging-i686/PKGBUILD	                        (rev 0)
+++ community-staging-i686/PKGBUILD	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,121 @@
+# $Id$
+# Maintainer: Muflone http://www.muflone.com/contacts/english/
+# Contributor: Balló György <ballogyor+arch at gmail dot com>
+
+pkgname=bluegriffon
+pkgver=2.3.1
+_mozilla_ver=f14898695ee0
+pkgrel=3
+pkgdesc="The next-generation Web Editor based on the rendering engine of Firefox"
+arch=('i686' 'x86_64')
+url="http://bluegriffon.org/"
+license=('MPL' 'GPL' 'LGPL')
+depends=('alsa-lib' 'desktop-file-utils' 'dbus-glib' 'gtk2' 'gtk3' 'hunspell' 'mozilla-common'
+         'nss' 'libevent' 'libvpx' 'libxt' 'python2' 'startup-notification')
+makedepends=('autoconf2.13' 'libpulse' 'unzip' 'zip' 'yasm')
+options=('!emptydirs')
+source=("${pkgname}-${pkgver}.tar.gz"::"https://github.com/therealglazou/${pkgname}/archive/${pkgver}.tar.gz"
+        "mozilla-central-${_mozilla_ver}.tar.bz2"::"https://hg.mozilla.org/mozilla-central/archive/${_mozilla_ver}.tar.bz2"
+        "bug_1329272_icu.patch"::"https://hg.mozilla.org/releases/mozilla-esr45/raw-diff/571b48abf054/build/autoconf/icu.m4"
+        "bug_1290037_update_keybits_in_h2.patch"::"https://hg.mozilla.org/mozilla-central/raw-rev/361ac226da2a"
+        "bug_1269171_mozalloc_in_stl_wrappers.patch"::"https://hg.mozilla.org/mozilla-central/raw-rev/68da139d0866"
+        "bug_1371991_no_lib_nss_crmf.patch"
+        "${pkgname}_gtk3.patch"
+        "bug_1234158_firefox-gtk3-20.patch"
+        "event__sizeof.patch"
+        "mozconfig"
+        "${pkgname}.desktop")
+sha256sums=('1fb0ba05a024be3029fe800ef0297e9e5ff3dcb631d04a95ca30e33e5aa261d7'
+            '0b13213b5f9b3819b56872f7fb4fa7a1170ade06f8797dc11114e5f7c8eabca2'
+            '93de8102de543bad38dc49d9ffcf7a8a2d9246594a8e7b92c38736ed6c6050cd'
+            '87fb92e45f161d47b9e3ca31bcce60555bc33d633116dab4baa3bfba6ad965c4'
+            '9d4849338dad39b978f7c15a93c3c255d72d7bfdffa897900a0bdddd771d2e17'
+            '08e40f75395d26359ce9bcce42789961900b4dc8fbab8555baba6a2895f7798d'
+            '3868f39181a258823c45e7ad62bba8e7b6e8b07c41535dd584c2dc71431f5deb'
+            'd5e1b9a702dc693184494899fc4cd57ac206e1fd5415a8e5520b8ff3b822e734'
+            'f4440c9d3826f4cda18b9d00129347fe6a22de61e11d593b1a522fa46d685ca0'
+            'eaa26dd7e4216f6efd6c98b00154abd102ec60dd920fedb0817286202bb77269'
+            '882133b77840356985a81e496b4ddc443f8f33c068cfb7ef0858497820adcfff')
+
+prepare() {
+  cd "${pkgname}-${pkgver}"
+
+  # Fix build with GTK+3
+  patch -Np1 -i "${srcdir}/${pkgname}_gtk3.patch"
+
+  cd "${srcdir}/mozilla-central-${_mozilla_ver}"
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1329272
+  patch -Np1 -i "${srcdir}/bug_1329272_icu.patch"
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1290037
+  patch -Np1 -i "${srcdir}/bug_1290037_update_keybits_in_h2.patch"
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1269171
+  patch -Np1 -i "${srcdir}/bug_1269171_mozalloc_in_stl_wrappers.patch"
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1371991
+  # https://bugs.archlinux.org/task/54395
+  patch -Np1 -i "${srcdir}/bug_1371991_no_lib_nss_crmf.patch"
+
+  # Fix for libevent 2.1
+  # Change _EVENT_SIZEOF to EVENT__SIZEOF
+  patch -Np1 -i "${srcdir}/event__sizeof.patch"
+
+  # Move files to their correct location
+  cp -r "${srcdir}/${pkgname}-${pkgver}" bluegriffon
+  cp "${srcdir}/mozconfig" .mozconfig
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1234158
+  patch -Np1 -i "${srcdir}/bug_1234158_firefox-gtk3-20.patch"
+
+  # Apply BlueGriffon's upstream customizations
+  patch -Np1 -i "bluegriffon/config/content.patch"
+
+  # python2 fix
+  find . -name \*.py -exec sed -i 's@^#.*python$@#!/usr/bin/python2@' '{}' \;
+}
+
+build() {
+  cd "${srcdir}/mozilla-central-${_mozilla_ver}"
+
+  # configure script misdetects the preprocessor without an optimization level
+  # https://bugs.archlinux.org/task/34644
+  export CPPFLAGS+=' -O2'
+  export PYTHON=python2
+
+  # Fix linking with gtk3
+  export LDFLAGS+=" $(pkg-config --libs gtk+-3.0)"
+
+  # Build the package
+  ./mach build
+}
+
+package() {
+  cd "${srcdir}/mozilla-central-${_mozilla_ver}"
+
+  # Install files
+  install -m 755 -d "${pkgdir}/usr/lib/${pkgname}"
+  cp -LR bg/dist/bin/* "${pkgdir}/usr/lib/${pkgname}"
+
+  # Install executable file
+  install -m 755 -d "${pkgdir}/usr/bin"
+  ln -sf /usr/lib/${pkgname}/${pkgname} "${pkgdir}/usr/bin/${pkgname}"
+
+  # Install icons
+  cp bluegriffon/branding/mozicon128.png bluegriffon/branding/default128.png
+  for _icon in 16 32 48 128 256; do
+      install -Dm644 bluegriffon/branding/default${_icon}.png \
+        "${pkgdir}/usr/share/icons/hicolor/${_icon}x${_icon}/apps/${pkgname}.png"
+  done
+
+  # Install desktop file
+  install -Dm644 ../${pkgname}.desktop \
+    "${pkgdir}/usr/share/applications/${pkgname}.desktop"
+
+  # Use system-provided dictionaries
+  rm -rf "${pkgdir}/usr/lib/${pkgname}/dictionaries"
+  ln -sf /usr/share/hunspell "${pkgdir}/usr/lib/${pkgname}/dictionaries"
+  rm -rf "${pkgdir}/usr/lib/${pkgname}hyphenation"
+  ln -sf /usr/share/hyphen "${pkgdir}/usr/lib/${pkgname}/hyphenation"
+}

Copied: bluegriffon/repos/community-staging-i686/bluegriffon.desktop (from rev 236226, bluegriffon/trunk/bluegriffon.desktop)
===================================================================
--- community-staging-i686/bluegriffon.desktop	                        (rev 0)
+++ community-staging-i686/bluegriffon.desktop	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,16 @@
+[Desktop Entry]
+Name=BlueGriffon
+GenericName=Web Editor
+GenericName[hu]=Webszerkesztő
+X-GNOME-FullName=BlueGriffon Web Editor
+X-GNOME-FullName[hu]=BlueGriffon webszerkesztő
+Comment=Create Web Pages
+Comment[es]=Crea páginas web
+Comment[hu]=Weboldalak készítése
+Comment[it]=Creare pagine Web
+Categories=Development;WebDevelopment;
+Exec=bluegriffon
+Icon=bluegriffon
+Terminal=false
+MimeType=text/html;application/xhtml+xml;
+Type=Application

Copied: bluegriffon/repos/community-staging-i686/bluegriffon_gtk3.patch (from rev 236226, bluegriffon/trunk/bluegriffon_gtk3.patch)
===================================================================
--- community-staging-i686/bluegriffon_gtk3.patch	                        (rev 0)
+++ community-staging-i686/bluegriffon_gtk3.patch	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,46 @@
+diff -Naur bluegriffon-2.1.1.orig/config/content.patch bluegriffon-2.1.1/config/content.patch
+--- bluegriffon-2.1.1.orig/config/content.patch	2016-07-23 21:54:18.367575963 +0000
++++ bluegriffon-2.1.1/config/content.patch	2016-07-24 00:36:03.891186550 +0000
+@@ -4714,14 +4714,8 @@
+ diff --git a/widget/gtk/nsColorPicker.cpp b/widget/gtk/nsColorPicker.cpp
+ --- a/widget/gtk/nsColorPicker.cpp
+ +++ b/widget/gtk/nsColorPicker.cpp
+-@@ -1,21 +1,24 @@
+- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+- /* This Source Code Form is subject to the terms of the Mozilla Public
+-  * License, v. 2.0. If a copy of the MPL was not distributed with this
+-  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+- 
++@@ -6,16 +6,18 @@
+  #include <gtk/gtk.h>
+-+#include <gtk/gtkcolorsel.h>
+  
+  #include "nsColor.h"
+  #include "nsColorPicker.h"
+@@ -4739,7 +4733,7 @@
+    return color_component * 255 + 0.5;
+  }
+  
+-@@ -54,38 +57,39 @@ GtkColorSelection* nsColorPicker::Widget
++@@ -54,38 +56,39 @@ GtkColorSelection* nsColorPicker::Widget
+  {
+    return GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(
+                               GTK_COLOR_SELECTION_DIALOG(widget)));
+@@ -4785,7 +4779,7 @@
+      NS_WARNING("mCallback is already set. Open called twice?");
+      return NS_ERROR_FAILURE;
+    }
+-@@ -113,16 +117,18 @@ NS_IMETHODIMP nsColorPicker::Open(nsICol
++@@ -113,16 +116,18 @@ NS_IMETHODIMP nsColorPicker::Open(nsICol
+    GtkWidget *color_chooser = gtk_color_selection_dialog_new(title);
+    
+    if (parent_window) {
+@@ -4804,7 +4798,7 @@
+                     G_CALLBACK(OnColorChanged), this);
+  #endif
+  
+-@@ -176,20 +182,38 @@ nsColorPicker::Update(GtkColorSelection*
++@@ -176,20 +181,38 @@ nsColorPicker::Update(GtkColorSelection*
+    }
+  }
+

Copied: bluegriffon/repos/community-staging-i686/bug_1234158_firefox-gtk3-20.patch (from rev 236226, bluegriffon/trunk/bug_1234158_firefox-gtk3-20.patch)
===================================================================
--- community-staging-i686/bug_1234158_firefox-gtk3-20.patch	                        (rev 0)
+++ community-staging-i686/bug_1234158_firefox-gtk3-20.patch	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,1736 @@
+diff -up firefox-47.0/widget/gtk/gtk3drawing.c.gtk3-20 firefox-47.0/widget/gtk/gtk3drawing.c
+--- firefox-47.0/widget/gtk/gtk3drawing.c.gtk3-20	2016-06-01 06:11:44.000000000 +0200
++++ firefox-47.0/widget/gtk/gtk3drawing.c	2016-06-23 10:21:37.072462099 +0200
+@@ -17,34 +17,85 @@
+ 
+ #include <math.h>
+ 
++#define MOZ_WIDGET_STYLES 4
++
++typedef struct {
++    GtkWidget*            widget;
++
++    union {
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleSelection;
++        } entry;
++
++        struct {
++            GtkStyleContext*  style;
++        } button;
++
++        struct {
++            GtkStyleContext*  style;
++        } tooltip;
++
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleContents;
++            GtkStyleContext*  styleTrough;
++            GtkStyleContext*  styleSlider;
++        } scroll;
++
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleCheck;
++            GtkStyleContext*  styleLabel;
++        } check;
++
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleTrough;
++            GtkStyleContext*  styleProgress;
++        } progress;
++
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleEntry;
++            GtkStyleContext*  styleButtonUp;
++            GtkStyleContext*  styleButtonDown;
++        } spin;
++
++        struct {
++            GtkStyleContext*  style[MOZ_WIDGET_STYLES];
++        } all;
++    };
++} MozGtkWidget;
++
+ static GtkWidget* gProtoWindow;
+ static GtkWidget* gProtoLayout;
+-static GtkWidget* gButtonWidget;
++static MozGtkWidget gButton;
+ static GtkWidget* gToggleButtonWidget;
+ static GtkWidget* gButtonArrowWidget;
+-static GtkWidget* gCheckboxWidget;
+-static GtkWidget* gRadiobuttonWidget;
+-static GtkWidget* gHorizScrollbarWidget;
+-static GtkWidget* gVertScrollbarWidget;
+-static GtkWidget* gSpinWidget;
++static MozGtkWidget gCheckbox;
++static MozGtkWidget gRadiobutton;
++static MozGtkWidget gVertScrollbar;
++static MozGtkWidget gHorizScrollbar;
++static MozGtkWidget gSpin;
+ static GtkWidget* gHScaleWidget;
+ static GtkWidget* gVScaleWidget;
+-static GtkWidget* gEntryWidget;
++static MozGtkWidget gEntry;
+ static GtkWidget* gComboBoxWidget;
+ static GtkWidget* gComboBoxButtonWidget;
+ static GtkWidget* gComboBoxArrowWidget;
+ static GtkWidget* gComboBoxSeparatorWidget;
+ static GtkWidget* gComboBoxEntryWidget;
+-static GtkWidget* gComboBoxEntryTextareaWidget;
++static MozGtkWidget gComboBoxEntryTextarea;
+ static GtkWidget* gComboBoxEntryButtonWidget;
+ static GtkWidget* gComboBoxEntryArrowWidget;
+ static GtkWidget* gHandleBoxWidget;
+ static GtkWidget* gToolbarWidget;
+ static GtkWidget* gFrameWidget;
+ static GtkWidget* gStatusbarWidget;
+-static GtkWidget* gProgressWidget;
++static MozGtkWidget gProgressBar;
+ static GtkWidget* gTabWidget;
+-static GtkWidget* gTooltipWidget;
++static MozGtkWidget gTooltip;
+ static GtkWidget* gMenuBarWidget;
+ static GtkWidget* gMenuBarItemWidget;
+ static GtkWidget* gMenuPopupWidget;
+@@ -78,6 +129,37 @@ static gboolean is_initialized;
+ #define GTK_STATE_FLAG_CHECKED (1 << 11)
+ #endif
+ 
++void moz_gtk_widget_free(MozGtkWidget *aMozWidget)
++{
++    // This was removed as a child of gProtoWindow
++    if (aMozWidget->widget) {
++        aMozWidget->widget = NULL;
++    }
++
++    for(int i = 0; i < MOZ_WIDGET_STYLES; i++) {
++        if (aMozWidget->all.style[i]) {
++            g_object_unref(aMozWidget->all.style[i]);
++            aMozWidget->all.style[i] = NULL;
++        }
++    }
++}
++
++// TODO - weak dep!! (dlsym)
++#if GTK_CHECK_VERSION(3, 19, 2)
++#define moz_gtk_path_set_class_name    gtk_widget_path_iter_set_object_name
++#else
++#define moz_gtk_path_set_class_name    gtk_widget_path_iter_add_class
++#endif
++//gtk_widget_path_iter_get_state
++
++static void
++moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
++                         GtkBorder *border);
++
++static void
++moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
++                          GtkBorder *padding);
++
+ static GtkStateFlags
+ GetStateFlagsFromGtkWidgetState(GtkWidgetState* state)
+ {
+@@ -97,6 +179,41 @@ 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)
++    moz_gtk_path_set_class_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);
++
++  if(!gtk_check_version(3, 14, 0)) {
++      /* Unfortunately, we have to explicitly set the state again here
++       * for it to take effect
++       */
++      gtk_style_context_set_state (context, gtk_widget_path_iter_get_state (path, -1));
++  }
++
++  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. */
+@@ -141,9 +258,16 @@ setup_widget_prototype(GtkWidget* widget
+ static gint
+ ensure_button_widget()
+ {
+-    if (!gButtonWidget) {
+-        gButtonWidget = gtk_button_new_with_label("M");
+-        setup_widget_prototype(gButtonWidget);
++    if (!gButton.widget) {
++        GtkCssNode path[] = { 
++            { GTK_TYPE_BUTTON, "button", NULL, NULL }
++        };
++
++        gButton.widget = gtk_button_new_with_label("M");
++        setup_widget_prototype(gButton.widget);
++        gtk_widget_show(gButton.widget);
++
++        gButton.button.style = moz_gtk_style_create(&path[0], NULL);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -195,9 +319,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_TOGGLE_BUTTON, "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.check.style = moz_gtk_style_create(&path[0], NULL);
++        gCheckbox.check.styleCheck = moz_gtk_style_create(&path[1],
++                                       gCheckbox.check.style);
++        gCheckbox.check.styleLabel = moz_gtk_style_create(&path[2],
++                                       gCheckbox.check.style);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -205,9 +341,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_TOGGLE_BUTTON, "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.check.style = moz_gtk_style_create(&path[0], NULL);
++        gRadiobutton.check.styleCheck = moz_gtk_style_create(&path[1],
++                                          gRadiobutton.check.style);
++        gRadiobutton.check.styleLabel = moz_gtk_style_create(&path[2],
++                                          gRadiobutton.check.style);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -215,25 +363,62 @@ 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", "bottom"},
++            { GTK_TYPE_SCROLLBAR, "scrollbar", "vertical", "right" },
++            { G_TYPE_NONE, "contents", NULL, NULL },
++            { G_TYPE_NONE, "trough", NULL, NULL },
++            { G_TYPE_NONE, "slider", NULL, NULL }
++        };
++
++        gHorizScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
++        setup_widget_prototype(gHorizScrollbar.widget);
++
++        gHorizScrollbar.scroll.style = moz_gtk_style_create(path, NULL);
++        gHorizScrollbar.scroll.styleContents = moz_gtk_style_create(path+2, 
++                                               gHorizScrollbar.scroll.style);
++        gHorizScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3, 
++                                               gHorizScrollbar.scroll.styleContents);
++        gHorizScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4, 
++                                               gHorizScrollbar.scroll.styleTrough);
++
++        gVertScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
++        setup_widget_prototype(gVertScrollbar.widget);
++
++        gVertScrollbar.scroll.style = moz_gtk_style_create(path+1, NULL);
++        gVertScrollbar.scroll.styleContents = moz_gtk_style_create(path+2, 
++                                              gVertScrollbar.scroll.style);
++        gVertScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3, 
++                                              gVertScrollbar.scroll.styleContents);
++        gVertScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4, 
++                                              gVertScrollbar.scroll.styleTrough);
++
++     }
+     return MOZ_GTK_SUCCESS;
+ }
+ 
+ static gint
+ ensure_spin_widget()
+ {
+-  if (!gSpinWidget) {
+-    gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
+-    setup_widget_prototype(gSpinWidget);
+-  }
+-  return MOZ_GTK_SUCCESS;
++    if (!gSpin.widget) {
++        GtkCssNode path[] = {
++            { GTK_TYPE_SPIN_BUTTON, "spinbutton", "horizontal", NULL },
++            { GTK_TYPE_SPIN_BUTTON, "spinbutton", "vertical", NULL },
++            { GTK_TYPE_ENTRY, "entry", NULL, NULL },
++            { G_TYPE_NONE, "button", "up", NULL },
++            { G_TYPE_NONE, "button", "down", NULL }
++        };
++
++        gSpin.widget = gtk_spin_button_new(NULL, 1, 0);
++        setup_widget_prototype(gSpin.widget);
++
++        gSpin.spin.style = moz_gtk_style_create(path, NULL);
++        gSpin.spin.styleButtonUp = moz_gtk_style_create(path+3, gSpin.spin.style);
++        gSpin.spin.styleButtonDown = moz_gtk_style_create(path+4, gSpin.spin.style);
++        gSpin.spin.styleEntry = moz_gtk_style_create(path+2, gSpin.spin.style);
++    }
++    return MOZ_GTK_SUCCESS;
+ }
+ 
+ static gint
+@@ -253,9 +438,19 @@ ensure_scale_widget()
+ static gint
+ ensure_entry_widget()
+ {
+-    if (!gEntryWidget) {
+-        gEntryWidget = gtk_entry_new();
+-        setup_widget_prototype(gEntryWidget);
++    if (!gEntry.widget) {
++        GtkCssNode path[] = { 
++            { GTK_TYPE_ENTRY, "entry", NULL, NULL },
++            { G_TYPE_NONE, "selection", NULL, NULL }
++        };
++
++        gEntry.widget = gtk_entry_new();
++        setup_widget_prototype(gEntry.widget);
++        gtk_widget_show(gEntry.widget);
++
++        gEntry.entry.style = moz_gtk_style_create(&path[0], NULL);
++        gEntry.entry.styleSelection = moz_gtk_style_create(&path[1], 
++                                                           gEntry.entry.style);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -387,9 +582,9 @@ moz_gtk_get_combo_box_entry_inner_widget
+         g_object_add_weak_pointer(G_OBJECT(widget),
+                                   (gpointer) &gComboBoxEntryButtonWidget);
+     } else if (GTK_IS_ENTRY(widget)) {
+-        gComboBoxEntryTextareaWidget = widget;
++        gComboBoxEntryTextarea.widget = widget;
+         g_object_add_weak_pointer(G_OBJECT(widget),
+-                                  (gpointer) &gComboBoxEntryTextareaWidget);
++                                  (gpointer) &gComboBoxEntryTextarea.widget);
+     } else
+         return;
+     gtk_widget_realize(widget);
+@@ -411,7 +606,7 @@ ensure_combo_box_entry_widgets()
+ {
+     GtkWidget* buttonChild;
+ 
+-    if (gComboBoxEntryTextareaWidget &&
++    if (gComboBoxEntryTextarea.widget &&
+             gComboBoxEntryButtonWidget &&
+             gComboBoxEntryArrowWidget)
+         return MOZ_GTK_SUCCESS;
+@@ -427,9 +622,9 @@ ensure_combo_box_entry_widgets()
+                          moz_gtk_get_combo_box_entry_inner_widgets,
+                          NULL);
+ 
+-    if (!gComboBoxEntryTextareaWidget) {
++    if (!gComboBoxEntryTextarea.widget) {
+         ensure_entry_widget();
+-        gComboBoxEntryTextareaWidget = gEntryWidget;
++        gComboBoxEntryTextarea.widget = gEntry.widget;
+     }
+ 
+     if (gComboBoxEntryButtonWidget) {
+@@ -507,12 +702,16 @@ ensure_toolbar_separator_widget()
+ static gint
+ ensure_tooltip_widget()
+ {
+-    if (!gTooltipWidget) {
+-        gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
+-        GtkStyleContext* style = gtk_widget_get_style_context(gTooltipWidget);
+-        gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
+-        gtk_widget_realize(gTooltipWidget);
+-        moz_gtk_set_widget_name(gTooltipWidget);
++    if (!gTooltip.widget) {
++        GtkCssNode path[] = {
++            { GTK_TYPE_TOOLTIP, "tooltip", "background", NULL},
++        };
++
++        gTooltip.widget = gtk_window_new(GTK_WINDOW_POPUP);
++        gtk_widget_realize(gTooltip.widget);
++        moz_gtk_set_widget_name(gTooltip.widget);
++
++        gTooltip.tooltip.style = moz_gtk_style_create(&path[0], NULL);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -530,9 +729,21 @@ ensure_tab_widget()
+ static gint
+ ensure_progress_widget()
+ {
+-    if (!gProgressWidget) {
+-        gProgressWidget = gtk_progress_bar_new();
+-        setup_widget_prototype(gProgressWidget);
++    if (!gProgressBar.widget) {
++        GtkCssNode path[] = {
++           { GTK_TYPE_LABEL, "progressbar", NULL, NULL },
++           { G_TYPE_NONE, "trough", NULL, NULL },
++           { G_TYPE_NONE, "progress", NULL, NULL },
++        };
++
++        gProgressBar.widget = gtk_progress_bar_new();
++        setup_widget_prototype(gProgressBar.widget);
++
++        gProgressBar.progress.style = moz_gtk_style_create(&path[0], NULL);
++        gProgressBar.progress.styleTrough = moz_gtk_style_create(&path[1],
++                                              gProgressBar.progress.style);
++        gProgressBar.progress.styleProgress = moz_gtk_style_create(&path[2],
++                                                gProgressBar.progress.styleTrough);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -638,6 +849,11 @@ static gint
+ ensure_check_menu_item_widget()
+ {
+     if (!gCheckMenuItemWidget) {
++        GtkCssNode path[] = {
++           { GTK_TYPE_CHECK_MENU_ITEM, "menuitem", NULL, NULL },
++           { G_TYPE_NONE, "check", NULL, NULL }
++        };
++
+         ensure_menu_popup_widget();
+         gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
+         gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
+@@ -752,7 +968,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);
+@@ -765,7 +981,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);
+@@ -778,13 +994,13 @@ moz_gtk_get_focus_outline_size(gint* foc
+ {
+     GtkBorder border;
+     GtkBorder padding;
+-    GtkStyleContext *style;
++    GtkStyleContext* style;
+ 
+     ensure_entry_widget();
+-    style = gtk_widget_get_style_context(gEntryWidget);
+ 
+-    gtk_style_context_get_border(style, 0, &border);
+-    gtk_style_context_get_padding(style, 0, &padding);
++    style = gEntry.entry.style;
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+     *focus_h_width = border.left + padding.left;
+     *focus_v_width = border.top + padding.top;
+     return MOZ_GTK_SUCCESS;
+@@ -821,7 +1037,7 @@ moz_gtk_button_get_default_overflow(gint
+     GtkBorder* default_outside_border;
+ 
+     ensure_button_widget();
+-    gtk_widget_style_get(gButtonWidget,
++    gtk_widget_style_get(gButton.widget,
+                          "default-outside-border", &default_outside_border,
+                          NULL);
+ 
+@@ -844,7 +1060,7 @@ moz_gtk_button_get_default_border(gint*
+     GtkBorder* default_border;
+ 
+     ensure_button_widget();
+-    gtk_widget_style_get(gButtonWidget,
++    gtk_widget_style_get(gButton.widget,
+                          "default-border", &default_border,
+                          NULL);
+ 
+@@ -935,7 +1151,7 @@ moz_gtk_button_paint(cairo_t *cr, GdkRec
+ 
+     if (state->focused) {
+         GtkBorder border;
+-        gtk_style_context_get_border(style, state_flags, &border);
++        moz_gtk_get_style_border(style, state_flags, &border);
+         x += border.left;
+         y += border.top;
+         width -= (border.left + border.right);
+@@ -956,15 +1172,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;
++    MozGtkWidget *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
+@@ -983,11 +1198,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->check.styleCheck);
+ 
+     if (selected)
+         state_flags |= checkbox_check_state;
+@@ -995,13 +1208,15 @@ 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->check.styleCheck, state_flags);
++
++    gtk_render_background(w->check.styleCheck, cr, x, y, width, height);
++    gtk_render_frame(w->check.styleCheck, cr, x, y, width, height);
+ 
+     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->check.styleCheck, cr, x, y, width, height);
+         if (state->focused) {
+-            gtk_render_focus(style, cr, focus_x, focus_y,
++            gtk_render_focus(w->check.styleCheck, cr, focus_x, focus_y,
+                             focus_width, focus_height);
+         }
+     }
+@@ -1010,15 +1225,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(w->widget), inconsistent);
++        gtk_render_check(w->check.styleCheck, cr, x, y, width, height);
+         if (state->focused) {
+-            gtk_render_focus(style, cr, 
++            gtk_render_focus(w->check.styleCheck, cr,
+                              focus_x, focus_y, focus_width, focus_height);
+         }
+     }
+-    gtk_style_context_restore(style);
++    gtk_style_context_restore(w->check.styleCheck);
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -1035,8 +1249,8 @@ calculate_button_inner_rect(GtkWidget* b
+     style = gtk_widget_get_style_context(button);
+ 
+     /* This mirrors gtkbutton's child positioning */
+-    gtk_style_context_get_border(style, 0, &border);
+-    gtk_style_context_get_padding(style, 0, &padding);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+ 
+     inner_rect->x = rect->x + border.left + padding.left;
+     inner_rect->y = rect->y + padding.top + border.top;
+@@ -1099,9 +1313,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);
+ 
+@@ -1181,25 +1395,22 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
+                                GtkTextDirection direction)
+ {
+     GtkStyleContext* style;
+-    GtkScrollbar *scrollbar;
+ 
+     ensure_scrollbar_widget();
+ 
+-    if (widget ==  MOZ_GTK_SCROLLBAR_HORIZONTAL)
+-        scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
+-    else
+-        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
+-
+-    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
+-    
+     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);
++     if (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) {
++        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
++        style = gHorizScrollbar.scroll.style;
++    }
++    else {
++        gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
++        style = gVertScrollbar.scroll.style;
++    }
+ 
+     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);
+@@ -1208,7 +1419,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;
+ }
+ 
+@@ -1220,24 +1430,20 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
+ {
+     GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
+     GtkStyleContext* style;
+-    GtkScrollbar *scrollbar;
+     GtkBorder margin;
+ 
+     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.scroll.styleSlider;
++        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
++    }
++    else {
++        style = gVertScrollbar.scroll.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,
+@@ -1248,8 +1454,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;
+ }
+ 
+@@ -1260,8 +1464,8 @@ moz_gtk_spin_paint(cairo_t *cr, GdkRecta
+     GtkStyleContext* style;
+ 
+     ensure_spin_widget();
+-    gtk_widget_set_direction(gSpinWidget, direction);
+-    style = gtk_widget_get_style_context(gSpinWidget);
++    gtk_widget_set_direction(gSpin.widget, direction);
++    style = gSpin.spin.style;
+     gtk_style_context_save(style);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
+     gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
+@@ -1280,11 +1484,10 @@ moz_gtk_spin_updown_paint(cairo_t *cr, G
+     GtkStyleContext* style;
+ 
+     ensure_spin_widget();
+-    style = gtk_widget_get_style_context(gSpinWidget);
++    style = gSpin.spin.style;
+     gtk_style_context_save(style);
+-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
+     gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
+-    gtk_widget_set_direction(gSpinWidget, direction);
++    gtk_widget_set_direction(gSpin.widget, direction);
+ 
+     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);
+@@ -1450,15 +1653,13 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec
+ static gint
+ moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect,
+                     GtkWidgetState* state,
+-                    GtkWidget* widget, GtkTextDirection direction)
++                    MozGtkWidget* w, GtkTextDirection direction)
+ {
+     gint x = rect->x, y = rect->y, width = rect->width, height = rect->height;
+-    GtkStyleContext* style;
+     int draw_focus_outline_only = state->depressed; // NS_THEME_FOCUS_OUTLINE
++    GtkStyleContext* style = w->entry.style;
+ 
+-    gtk_widget_set_direction(widget, direction);
+-
+-    style = gtk_widget_get_style_context(widget);
++    gtk_widget_set_direction(w->widget, direction);
+ 
+     if (draw_focus_outline_only) {
+         // Inflate the given 'rect' with the focus outline size.
+@@ -1478,10 +1679,9 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRect
+      * textarea window uses gtk_paint_flat_box when exposed */
+ 
+     /* This gets us a lovely greyish disabledish look */
+-    gtk_widget_set_sensitive(widget, !state->disabled);
++    gtk_widget_set_sensitive(w->widget, !state->disabled);
+ 
+     gtk_style_context_save(style);
+-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_ENTRY);
+   
+     /* Now paint the shadow and focus border.
+      * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad
+@@ -1531,7 +1731,7 @@ moz_gtk_treeview_paint(cairo_t *cr, GdkR
+     style = gtk_widget_get_style_context(gScrolledWindowWidget);
+     gtk_style_context_save(style);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_FRAME);    
+-    gtk_style_context_get_border(style, state_flags, &border);
++    moz_gtk_get_style_border(style, state_flags, &border);
+     xthickness = border.left;
+     ythickness = border.top;    
+ 
+@@ -1702,7 +1902,7 @@ moz_gtk_combo_box_paint(cairo_t *cr, Gdk
+         if (direction == GTK_TEXT_DIR_LTR) {
+             GtkBorder padding;
+             GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
+-            gtk_style_context_get_padding(style, state_flags, &padding);
++            moz_gtk_get_style_padding(style, state_flags, &padding);
+             arrow_rect.x -= padding.left;
+         }
+         else
+@@ -1804,29 +2004,27 @@ moz_gtk_container_paint(cairo_t *cr, Gdk
+                         gboolean isradio, GtkTextDirection direction)
+ {
+     GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
+-    GtkStyleContext* style;
+-    GtkWidget *widget;
++    MozGtkWidget *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->check.style);
++    gtk_style_context_set_state(widget->check.style, 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->check.style, cr,
+                               rect->x, rect->y, rect->width, rect->height);
+     }
+   
+-    gtk_style_context_restore(style);
++    gtk_style_context_restore(widget->check.style);
+   
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -1836,32 +2034,26 @@ moz_gtk_toggle_label_paint(cairo_t *cr,
+                            GtkWidgetState* state, 
+                            gboolean isradio, GtkTextDirection direction)
+ {
+-    GtkStyleContext *style;
+-    GtkWidget *widget;
++    MozGtkWidget *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->check.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->check.styleLabel, 
++                                GetStateFlagsFromGtkWidgetState(state));
++    gtk_render_focus(widget->check.styleLabel, cr,
+                     rect->x, rect->y, rect->width, rect->height);
+-    gtk_style_context_restore(style);
++    gtk_style_context_restore(widget->check.styleLabel);
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -1922,7 +2114,7 @@ moz_gtk_toolbar_separator_paint(cairo_t
+                           rect->height * (end_fraction - start_fraction));
+     } else {
+         GtkBorder padding;
+-        gtk_style_context_get_padding(style, 0, &padding);
++        gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+     
+         paint_width = padding.left;
+         if (paint_width > rect->width)
+@@ -1945,9 +2137,9 @@ moz_gtk_tooltip_paint(cairo_t *cr, GdkRe
+     GtkStyleContext* style;
+ 
+     ensure_tooltip_widget();
+-    gtk_widget_set_direction(gTooltipWidget, direction);
++    gtk_widget_set_direction(gTooltip.widget, direction);
+ 
+-    style = gtk_widget_get_style_context(gTooltipWidget);
++    style = gTooltip.tooltip.style;
+     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);
+     return MOZ_GTK_SUCCESS;
+@@ -2006,18 +2198,13 @@ static gint
+ moz_gtk_progressbar_paint(cairo_t *cr, GdkRectangle* rect,
+                           GtkTextDirection direction)
+ {
+-    GtkStyleContext* style;
+-
+     ensure_progress_widget();
+-    gtk_widget_set_direction(gProgressWidget, direction);
++    gtk_widget_set_direction(gProgressBar.widget, direction);
+ 
+-    style = gtk_widget_get_style_context(gProgressWidget);
+-    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);
+-    gtk_style_context_restore(style);
++    gtk_render_background(gProgressBar.progress.styleTrough, cr,
++                          rect->x, rect->y, rect->width, rect->height);
++    gtk_render_frame(gProgressBar.progress.styleTrough, cr,
++                     rect->x, rect->y, rect->width, rect->height);
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -2027,15 +2214,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
+                              GtkTextDirection direction,
+                              GtkThemeWidgetType widget)
+ {
+-    GtkStyleContext* style;
+-
+     ensure_progress_widget();
+-    gtk_widget_set_direction(gProgressWidget, direction);
+-
+-    style = gtk_widget_get_style_context(gProgressWidget);
+-    gtk_style_context_save(style);
+-    gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH);
+-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR);
++    gtk_widget_set_direction(gProgressBar.widget, direction);
+ 
+     if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
+         widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
+@@ -2074,12 +2254,14 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
+     // gtk_render_activity was used to render progress chunks on GTK versions
+     // before 3.13.7, see bug 1173907.
+     if (!gtk_check_version(3, 13, 7)) {
+-      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);
++      gtk_render_background(gProgressBar.progress.styleProgress, cr,
++                            rect->x, rect->y, rect->width, rect->height);
++      gtk_render_frame(gProgressBar.progress.styleProgress, cr,
++                       rect->x, rect->y, rect->width, rect->height);
+     } else {
+-      gtk_render_activity(style, cr, rect->x, rect->y, rect->width, rect->height);
++      gtk_render_activity(gProgressBar.progress.styleProgress, cr,
++                          rect->x, rect->y, rect->width, rect->height);
+     }
+-    gtk_style_context_restore(style);
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -2096,7 +2278,7 @@ moz_gtk_get_tab_thickness(void)
+ 
+     style = gtk_widget_get_style_context(gTabWidget);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_NOTEBOOK);
+-    gtk_style_context_get_border(style, 0, &border);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+ 
+     if (border.top < 2)
+         return 2; /* some themes don't set ythickness correctly */
+@@ -2292,7 +2474,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
+       gtk_style_context_save(style);
+       moz_gtk_tab_prepare_style_context(style, flags);
+ 
+-      gtk_style_context_get_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
++      moz_gtk_get_style_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
+ 
+       focusRect.x += padding.left;
+       focusRect.width -= (padding.left + padding.right);
+@@ -2408,7 +2590,7 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *
+ }
+ 
+ static gint
+-moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect,
++moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state,
+                        GtkTextDirection direction)
+ {
+     GtkStyleContext* style;
+@@ -2468,7 +2650,7 @@ moz_gtk_menu_separator_paint(cairo_t *cr
+     border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
+ 
+     style = gtk_widget_get_style_context(gMenuSeparatorWidget);
+-    gtk_style_context_get_padding(style, 0, &padding);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+ 
+     x = rect->x + border_width;
+     y = rect->y + border_width;
+@@ -2521,7 +2703,8 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
+             item_widget = gMenuItemWidget;
+         }
+         style = gtk_widget_get_style_context(item_widget);
+-        gtk_style_context_save(style);
++// TODO - FIX!
++//        gtk_style_context_save(style);
+ 
+         if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
+             gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
+@@ -2540,7 +2723,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
+ 
+         gtk_render_background(style, cr, x, y, w, h);
+         gtk_render_frame(style, cr, x, y, w, h);
+-        gtk_style_context_restore(style);
++//        gtk_style_context_restore(style);
+     }
+ 
+     return MOZ_GTK_SUCCESS;
+@@ -2556,7 +2739,10 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, Gd
+ 
+     ensure_menu_item_widget();
+     gtk_widget_set_direction(gMenuItemWidget, direction);
+-
++/*
++    state_flags |= (direction == GTK_TEXT_DIR_LTR) ? GTK_STATE_FLAG_DIR_LTR :
++                                                     GTK_STATE_FLAG_DIR_RTL;
++*/
+     style = gtk_widget_get_style_context(gMenuItemWidget);
+     gtk_style_context_save(style);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUITEM);
+@@ -2606,7 +2792,7 @@ moz_gtk_check_menu_item_paint(cairo_t *c
+     }
+     
+     gtk_style_context_set_state(style, state_flags);
+-    gtk_style_context_get_padding(style, state_flags, &padding);
++    moz_gtk_get_style_padding(style, state_flags, &padding);
+ 
+     offset = gtk_container_get_border_width(GTK_CONTAINER(gCheckMenuItemWidget)) +
+                                             padding.left + 2;
+@@ -2658,7 +2844,7 @@ moz_gtk_add_style_border(GtkStyleContext
+ {
+     GtkBorder border;
+ 
+-    gtk_style_context_get_border(style, 0, &border);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+ 
+     *left += border.left;
+     *right += border.right;
+@@ -2667,12 +2853,22 @@ moz_gtk_add_style_border(GtkStyleContext
+ }
+ 
+ static void
++moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
++                         GtkBorder *border)
++{
++    gtk_style_context_save(style);
++    gtk_style_context_set_state(style, state_flags);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), border);
++    gtk_style_context_restore(style);
++}
++
++static void
+ moz_gtk_add_style_padding(GtkStyleContext* style,
+                           gint* left, gint* top, gint* right, gint* bottom)
+ {
+     GtkBorder padding;
+ 
+-    gtk_style_context_get_padding(style, 0, &padding);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+ 
+     *left += padding.left;
+     *right += padding.right;
+@@ -2680,6 +2876,16 @@ moz_gtk_add_style_padding(GtkStyleContex
+     *bottom += padding.bottom;
+ }
+ 
++static void
++moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
++                          GtkBorder *padding)
++{
++    gtk_style_context_save(style);
++    gtk_style_context_set_state(style, state_flags);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), padding);
++    gtk_style_context_restore(style);
++}
++
+ gint
+ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
+                           gint* right, gint* bottom, GtkTextDirection direction,
+@@ -2694,37 +2900,35 @@ moz_gtk_get_widget_border(GtkThemeWidget
+     case MOZ_GTK_TOOLBAR_BUTTON:
+         {
+             ensure_button_widget();
+-            style = gtk_widget_get_style_context(gButtonWidget);
+-
+-            *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButtonWidget));
+ 
+-            if (widget == MOZ_GTK_TOOLBAR_BUTTON) {
+-                gtk_style_context_save(style);
+-                gtk_style_context_add_class(style, "image-button");
+-            }
+-              
+-            moz_gtk_add_style_padding(style, left, top, right, bottom);
+-                
+-            if (widget == MOZ_GTK_TOOLBAR_BUTTON)
+-                gtk_style_context_restore(style);
++            *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButton.widget));
++            moz_gtk_add_style_padding(gButton.button.style, left, top, right, bottom);
+ 
+             // XXX: Subtract 1 pixel from the border to account for the added
+             // -moz-focus-inner border (Bug 1228281).
+             *left -= 1; *top -= 1; *right -= 1; *bottom -= 1;
+-            moz_gtk_add_style_border(style, left, top, right, bottom);
++            moz_gtk_add_style_border(gButton.button.style, left, top, right, bottom);
++
+             return MOZ_GTK_SUCCESS;
+         }
+     case MOZ_GTK_ENTRY:
+         {
+             ensure_entry_widget();
+-            style = gtk_widget_get_style_context(gEntryWidget);
+ 
+             // XXX: Subtract 1 pixel from the padding to account for the default
+             // padding in forms.css. See bug 1187385.
+             *left = *top = *right = *bottom = -1;
+-            moz_gtk_add_style_padding(style, left, top, right, bottom);
+-            moz_gtk_add_style_border(style, left, top, right, bottom);
+ 
++            moz_gtk_add_style_padding(gEntry.entry.style, left, top, right, bottom);
++            moz_gtk_add_style_border(gEntry.entry.style, left, top, right, bottom);
++
++            return MOZ_GTK_SUCCESS;
++        }
++    case MOZ_GTK_TOOLTIP:
++        {
++            ensure_tooltip_widget();
++            moz_gtk_add_style_padding(gTooltip.tooltip.style, left, top, right, bottom);
++            moz_gtk_add_style_border(gTooltip.tooltip.style, left, top, right, bottom);
+             return MOZ_GTK_SUCCESS;
+         }
+     case MOZ_GTK_TREEVIEW:
+@@ -2759,7 +2963,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
+         break;
+     case MOZ_GTK_DROPDOWN_ENTRY:
+         ensure_combo_box_entry_widgets();
+-        w = gComboBoxEntryTextareaWidget;
++        w = gComboBoxEntryTextarea.widget;
+         break;
+     case MOZ_GTK_DROPDOWN_ARROW:
+         ensure_combo_box_entry_widgets();
+@@ -2795,7 +2999,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
+ 
+                 if (!wide_separators) {
+                     style = gtk_widget_get_style_context(gComboBoxSeparatorWidget);
+-                    gtk_style_context_get_border(style, 0, &border);
++                    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+                     separator_width = border.left;
+                 }
+             }
+@@ -2814,14 +3018,17 @@ moz_gtk_get_widget_border(GtkThemeWidget
+         w = gTabWidget;
+         break;
+     case MOZ_GTK_PROGRESSBAR:
+-        ensure_progress_widget();
+-        w = gProgressWidget;
+-        break;
++        {
++            ensure_progress_widget();
++            moz_gtk_add_style_border(gProgressBar.progress.styleTrough,
++                                     left, top, right, bottom);
++            return MOZ_GTK_SUCCESS;
++        }
+     case MOZ_GTK_SPINBUTTON_ENTRY:
+     case MOZ_GTK_SPINBUTTON_UP:
+     case MOZ_GTK_SPINBUTTON_DOWN:
+         ensure_spin_widget();
+-        w = gSpinWidget;
++        w = gSpin.widget;
+         break;
+     case MOZ_GTK_SCALE_HORIZONTAL:
+         ensure_scale_widget();
+@@ -2840,12 +3047,13 @@ moz_gtk_get_widget_border(GtkThemeWidget
+         {
+             if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
+                 ensure_checkbox_widget();
+-                w = gCheckboxWidget;
++                w = gCheckbox.widget;
++                style = gCheckbox.check.styleCheck;
+             } else {
+                 ensure_radiobutton_widget();
+-                w = gRadiobuttonWidget;
++                w = gRadiobutton.widget;
++                style = gRadiobutton.check.styleCheck;
+             }
+-            style = gtk_widget_get_style_context(w);
+ 
+             *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(w));
+             moz_gtk_add_style_border(style,
+@@ -2904,7 +3112,6 @@ moz_gtk_get_widget_border(GtkThemeWidget
+     case MOZ_GTK_MENUSEPARATOR:
+     /* These widgets have no borders.*/
+     case MOZ_GTK_SPINBUTTON:
+-    case MOZ_GTK_TOOLTIP:
+     case MOZ_GTK_WINDOW:
+     case MOZ_GTK_RESIZER:
+     case MOZ_GTK_MENUARROW:
+@@ -2978,6 +3185,32 @@ moz_gtk_get_combo_box_entry_button_size(
+ }
+ 
+ gint
++moz_gtk_get_entry_height(gint* height)
++{
++    GtkRequisition requisition;
++    ensure_entry_widget();
++
++    gtk_widget_get_preferred_size(gEntry.widget, NULL, &requisition);
++    *height = requisition.height;
++
++    return MOZ_GTK_SUCCESS;
++}
++
++
++gint
++moz_gtk_get_button_height(gint* height)
++{
++    GtkRequisition requisition;
++    ensure_entry_widget();
++
++    gtk_widget_get_preferred_size(gButton.widget, NULL, &requisition);
++    *height = requisition.height;
++
++    return MOZ_GTK_SUCCESS;
++}
++
++
++gint
+ moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
+ {
+     gint arrow_size;
+@@ -3030,7 +3263,7 @@ moz_gtk_get_toolbar_separator_width(gint
+                          "separator-width", &separator_width,
+                          NULL);
+     /* Just in case... */
+-    gtk_style_context_get_border(style, 0, &border);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+     *size = MAX(*size, (wide_separators ? separator_width : border.left));
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -3072,7 +3305,7 @@ moz_gtk_get_menu_separator_height(gint *
+     border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
+ 
+     style = gtk_widget_get_style_context(gMenuSeparatorWidget);
+-    gtk_style_context_get_padding(style, 0, &padding);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+ 
+     gtk_style_context_save(style);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_SEPARATOR);
+@@ -3130,15 +3363,21 @@ 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,
+                           "stepper_spacing", &metrics->stepper_spacing,
+                           NULL);
+ 
+-    metrics->min_slider_size = 
+-        gtk_range_get_min_slider_size(GTK_RANGE(gHorizScrollbarWidget));
++    if (!gtk_check_version(3,19,7)) {
++        gtk_style_context_get(gVertScrollbar.scroll.styleSlider, 
++                              gtk_style_context_get_state(gVertScrollbar.scroll.styleSlider), 
++                              "min-height", &metrics->min_slider_size, NULL);
++    } else {
++        metrics->min_slider_size = 
++            gtk_range_get_min_slider_size(GTK_RANGE(gVertScrollbar.widget));
++    }
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -3163,7 +3402,7 @@ moz_gtk_images_in_buttons()
+     GtkSettings* settings;
+ 
+     ensure_button_widget();
+-    settings = gtk_widget_get_settings(gButtonWidget);
++    settings = gtk_widget_get_settings(gButton.widget);
+ 
+     g_object_get(settings, "gtk-button-images", &result, NULL);
+     return result;
+@@ -3191,7 +3430,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+         }
+         ensure_button_widget();
+         return moz_gtk_button_paint(cr, rect, state,
+-                                    (GtkReliefStyle) flags, gButtonWidget,
++                                    (GtkReliefStyle) flags, gButton.widget,
+                                     direction);
+         break;
+     case MOZ_GTK_CHECKBUTTON:
+@@ -3241,7 +3480,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+     case MOZ_GTK_SPINBUTTON_ENTRY:
+         ensure_spin_widget();
+         return moz_gtk_entry_paint(cr, rect, state,
+-                                   gSpinWidget, direction);
++                                   &gSpin, direction);
+         break;
+     case MOZ_GTK_GRIPPER:
+         return moz_gtk_gripper_paint(cr, rect, state,
+@@ -3268,7 +3507,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+     case MOZ_GTK_ENTRY:
+         ensure_entry_widget();
+         return moz_gtk_entry_paint(cr, rect, state,
+-                                   gEntryWidget, direction);
++                                   &gEntry, direction);
+         break;
+     case MOZ_GTK_DROPDOWN:
+         return moz_gtk_combo_box_paint(cr, rect, state, direction);
+@@ -3280,7 +3519,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+     case MOZ_GTK_DROPDOWN_ENTRY:
+         ensure_combo_box_entry_widgets();
+         return moz_gtk_entry_paint(cr, rect, state,
+-                                   gComboBoxEntryTextareaWidget, direction);
++                                   &gComboBoxEntryTextarea, direction);
+         break;
+     case MOZ_GTK_CHECKBUTTON_CONTAINER:
+     case MOZ_GTK_RADIOBUTTON_CONTAINER:
+@@ -3332,7 +3571,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+                                               (GtkArrowType) flags, direction);
+         break;
+     case MOZ_GTK_MENUBAR:
+-        return moz_gtk_menu_bar_paint(cr, rect, direction);
++        return moz_gtk_menu_bar_paint(cr, rect, state, direction);
+         break;
+     case MOZ_GTK_MENUPOPUP:
+         return moz_gtk_menu_popup_paint(cr, rect, direction);
+@@ -3383,7 +3622,7 @@ GtkWidget* moz_gtk_get_scrollbar_widget(
+ {
+     MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
+     ensure_scrollbar_widget();
+-    return gHorizScrollbarWidget;
++    return gVertScrollbar.widget;
+ }
+ 
+ gboolean moz_gtk_has_scrollbar_buttons(void)
+@@ -3391,7 +3630,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,
+@@ -3403,8 +3642,8 @@ gboolean moz_gtk_has_scrollbar_buttons(v
+ gint
+ moz_gtk_shutdown()
+ {
+-    if (gTooltipWidget)
+-        gtk_widget_destroy(gTooltipWidget);
++    moz_gtk_widget_free(&gTooltip);
++
+     /* This will destroy all of our widgets */
+     if (gProtoWindow)
+         gtk_widget_destroy(gProtoWindow);
+@@ -3415,17 +3654,19 @@ moz_gtk_shutdown()
+ 
+     gProtoWindow = NULL;
+     gProtoLayout = NULL;
+-    gButtonWidget = NULL;
++
++    // MozWidgets
++    moz_gtk_widget_free(&gButton);
+     gToggleButtonWidget = NULL;
+     gButtonArrowWidget = NULL;
+-    gCheckboxWidget = NULL;
+-    gRadiobuttonWidget = NULL;
+-    gHorizScrollbarWidget = NULL;
+-    gVertScrollbarWidget = NULL;
+-    gSpinWidget = NULL;
++    moz_gtk_widget_free(&gCheckbox);
++    moz_gtk_widget_free(&gRadiobutton);
++    moz_gtk_widget_free(&gHorizScrollbar);
++    moz_gtk_widget_free(&gVertScrollbar);
++    moz_gtk_widget_free(&gSpin);
+     gHScaleWidget = NULL;
+     gVScaleWidget = NULL;
+-    gEntryWidget = NULL;
++    moz_gtk_widget_free(&gEntry);
+     gComboBoxWidget = NULL;
+     gComboBoxButtonWidget = NULL;
+     gComboBoxSeparatorWidget = NULL;
+@@ -3433,14 +3674,13 @@ moz_gtk_shutdown()
+     gComboBoxEntryWidget = NULL;
+     gComboBoxEntryButtonWidget = NULL;
+     gComboBoxEntryArrowWidget = NULL;
+-    gComboBoxEntryTextareaWidget = NULL;
++    moz_gtk_widget_free(&gComboBoxEntryTextarea);
+     gHandleBoxWidget = NULL;
+     gToolbarWidget = NULL;
+     gStatusbarWidget = NULL;
+     gFrameWidget = NULL;
+-    gProgressWidget = NULL;
++    moz_gtk_widget_free(&gProgressBar);
+     gTabWidget = NULL;
+-    gTooltipWidget = NULL;
+     gMenuBarWidget = NULL;
+     gMenuBarItemWidget = NULL;
+     gMenuPopupWidget = NULL;
+diff -up firefox-47.0/widget/gtk/gtkdrawing.h.gtk3-20 firefox-47.0/widget/gtk/gtkdrawing.h
+--- firefox-47.0/widget/gtk/gtkdrawing.h.gtk3-20	2016-05-12 19:13:34.000000000 +0200
++++ firefox-47.0/widget/gtk/gtkdrawing.h	2016-06-23 10:21:37.072462099 +0200
+@@ -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 */
+@@ -396,6 +403,9 @@ void
+ moz_gtk_get_arrow_size(GtkThemeWidgetType widgetType,
+                        gint* width, gint* height);
+ 
++gint moz_gtk_get_entry_height(gint* height);
++gint moz_gtk_get_button_height(gint* height);
++
+ /**
+  * Get the desired size of a toolbar separator
+  * size:    [OUT] the desired width
+@@ -466,6 +476,12 @@ 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-47.0/widget/gtk/mozgtk/mozgtk.c.gtk3-20 firefox-47.0/widget/gtk/mozgtk/mozgtk.c
+--- firefox-47.0/widget/gtk/mozgtk/mozgtk.c.gtk3-20	2016-05-12 19:13:34.000000000 +0200
++++ firefox-47.0/widget/gtk/mozgtk/mozgtk.c	2016-06-23 10:26:36.495774041 +0200
+@@ -504,9 +504,15 @@ STUB(gtk_window_set_type_hint)
+ STUB(gtk_window_set_wmclass)
+ STUB(gtk_window_unfullscreen)
+ STUB(gtk_window_unmaximize)
++STUB(gtk_widget_get_preferred_height_and_baseline_for_width)
++STUB(gtk_entry_get_text_area)
++STUB(gtk_check_menu_item_get_type)
++STUB(gtk_spin_button_get_type)
++STUB(gtk_button_get_type)
+ #endif
+ 
+ #ifdef GTK3_SYMBOLS
++STUB(gtk_box_new)
+ STUB(gdk_device_get_source)
+ STUB(gdk_device_manager_get_client_pointer)
+ STUB(gdk_disable_multidevice)
+@@ -581,6 +587,15 @@ 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_append_for_widget)
++STUB(gtk_widget_path_copy)
++STUB(gtk_widget_path_iter_set_object_name)
++STUB(gtk_widget_path_iter_add_class)
++STUB(gtk_widget_path_iter_get_state)
++STUB(gtk_style_context_set_parent)
++STUB(gtk_widget_path_unref)
++STUB(gtk_tooltip_get_type)
+ #endif
+ 
+ #ifdef GTK2_SYMBOLS
+diff -up firefox-47.0/widget/gtk/nsLookAndFeel.cpp.gtk3-20 firefox-47.0/widget/gtk/nsLookAndFeel.cpp
+--- firefox-47.0/widget/gtk/nsLookAndFeel.cpp.gtk3-20	2016-06-01 06:11:44.000000000 +0200
++++ firefox-47.0/widget/gtk/nsLookAndFeel.cpp	2016-06-23 10:21:37.073462100 +0200
+@@ -353,14 +353,18 @@ nsLookAndFeel::NativeGetColor(ColorID aI
+     case eColorID_activeborder:
+         // active window border
+         gtk_style_context_get_border_color(mBackgroundStyle, 
+-                                           GTK_STATE_FLAG_NORMAL, &gdk_color);
++                                           gtk_style_context_get_state(mBackgroundStyle), 
++                                           &gdk_color);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+     case eColorID_inactiveborder:
+         // inactive window border
++        gtk_style_context_save(mBackgroundStyle);
++        gtk_style_context_set_state(mBackgroundStyle, GTK_STATE_FLAG_INSENSITIVE);
+         gtk_style_context_get_border_color(mBackgroundStyle, 
+-                                           GTK_STATE_FLAG_INSENSITIVE, 
++                                           gtk_style_context_get_state(mBackgroundStyle), 
+                                            &gdk_color);
++        gtk_style_context_restore(mBackgroundStyle);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+     case eColorID_graytext: // disabled text in windows, menus, etc.
+@@ -369,9 +373,12 @@ nsLookAndFeel::NativeGetColor(ColorID aI
+         break;
+     case eColorID_inactivecaption:
+         // inactive window caption
++        gtk_style_context_save(mBackgroundStyle);
++        gtk_style_context_set_state(mBackgroundStyle, GTK_STATE_FLAG_INSENSITIVE);
+         gtk_style_context_get_background_color(mBackgroundStyle, 
+-                                               GTK_STATE_FLAG_INSENSITIVE, 
++                                               gtk_style_context_get_state(mBackgroundStyle), 
+                                                &gdk_color);
++        gtk_style_context_restore(mBackgroundStyle);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+ #endif
+@@ -497,13 +504,17 @@ nsLookAndFeel::NativeGetColor(ColorID aI
+     case eColorID__moz_buttondefault:
+       // default button border color
+         gtk_style_context_get_border_color(mButtonStyle, 
+-                                           GTK_STATE_FLAG_NORMAL, &gdk_color);
++                                           gtk_style_context_get_state(mButtonStyle),
++                                           &gdk_color);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+     case eColorID__moz_buttonhoverface:
++        gtk_style_context_save(mButtonStyle);
++        gtk_style_context_set_state(mButtonStyle, GTK_STATE_FLAG_PRELIGHT);
+         gtk_style_context_get_background_color(mButtonStyle, 
+-                                               GTK_STATE_FLAG_PRELIGHT, 
++                                               gtk_style_context_get_state(mButtonStyle), 
+                                                &gdk_color);
++        gtk_style_context_restore(mButtonStyle);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+     case eColorID__moz_buttonhovertext:
+@@ -1019,6 +1030,29 @@ create_context(GtkWidgetPath *path)
+ }
+ #endif
+ 
++GtkStyleContext*
++CreateStyleForWidget(GtkWidget* aWidget, GtkStyleContext* aParentStyle)
++{   
++  GtkWidgetPath* path =
++    gtk_widget_path_copy(gtk_style_context_get_path(aParentStyle));
++
++  // Work around https://bugzilla.gnome.org/show_bug.cgi?id=767312
++  // which exists in GTK+ 3.20.
++  gtk_widget_get_style_context(aWidget);
++
++  gtk_widget_path_append_for_widget(path, aWidget);
++  // Release any floating reference on aWidget.
++  g_object_ref_sink(aWidget);
++  g_object_unref(aWidget);
++    
++  GtkStyleContext *context = gtk_style_context_new();
++  gtk_style_context_set_path(context, path);
++  gtk_style_context_set_parent(context, aParentStyle);
++  gtk_widget_path_unref(path);
++    
++  return context;
++}
++
+ void
+ nsLookAndFeel::Init()
+ {
+@@ -1122,26 +1156,36 @@ 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);
+ 
+     // Window colors
+     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);
++    g_object_unref(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);
++    GtkCssNode tooltipPath[] = { 
++         { GTK_TYPE_TOOLTIP, "tooltip", "background", NULL},
++    };
++    style = moz_gtk_style_create(tooltipPath, NULL);
++    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);
++    {
++        GtkStyleContext* boxStyle =
++            CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0),
++                                 style);
++        GtkStyleContext* labelStyle =
++            CreateStyleForWidget(gtk_label_new(nullptr), boxStyle);
++        gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color);
++        g_object_unref(labelStyle);
++        g_object_unref(boxStyle);
++    }
+     sInfoText = GDK_RGBA_TO_NS_RGBA(color);
+     g_object_unref(style);
+ 
+@@ -1156,20 +1200,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
+@@ -1278,44 +1328,54 @@ 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;
++    GtkBorder padding;
++
+     // 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_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
+@@ -1328,7 +1388,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);
+ 
+@@ -1346,9 +1406,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;
+diff -up firefox-47.0/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20 firefox-47.0/widget/gtk/nsNativeThemeGTK.cpp
+--- firefox-47.0/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20	2016-06-01 06:11:44.000000000 +0200
++++ firefox-47.0/widget/gtk/nsNativeThemeGTK.cpp	2016-06-23 10:21:37.074462101 +0200
+@@ -1570,9 +1570,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
+   case NS_THEME_RADIO_CONTAINER:
+   case NS_THEME_CHECKBOX_LABEL:
+   case NS_THEME_RADIO_LABEL:
+-  case NS_THEME_BUTTON:
+-  case NS_THEME_DROPDOWN:
+-  case NS_THEME_TOOLBAR_BUTTON:
+   case NS_THEME_TREEVIEW_HEADER_CELL:
+     {
+       if (aWidgetType == NS_THEME_DROPDOWN) {
+@@ -1591,6 +1588,21 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
+       aResult->height += border.top + border.bottom;
+     }
+     break;
++  case NS_THEME_BUTTON:
++  case NS_THEME_DROPDOWN:
++  case NS_THEME_TOOLBAR_BUTTON:
++    {
++        moz_gtk_get_button_height(&aResult->height);
++    }
++    break;
++  case NS_THEME_FOCUS_OUTLINE:
++  case NS_THEME_NUMBER_INPUT:
++  case NS_THEME_TEXTFIELD:
++  case NS_THEME_TEXTFIELD_MULTILINE:
++    {
++        moz_gtk_get_entry_height(&aResult->height);
++    } 
++    break;
+   case NS_THEME_TOOLBAR_SEPARATOR:
+     {
+       gint separator_width;

Copied: bluegriffon/repos/community-staging-i686/bug_1371991_no_lib_nss_crmf.patch (from rev 236226, bluegriffon/trunk/bug_1371991_no_lib_nss_crmf.patch)
===================================================================
--- community-staging-i686/bug_1371991_no_lib_nss_crmf.patch	                        (rev 0)
+++ community-staging-i686/bug_1371991_no_lib_nss_crmf.patch	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,23 @@
+diff -Naur mozilla-central-f14898695ee0.orig/config/external/nss/crmf/moz.build mozilla-central-f14898695ee0/config/external/nss/crmf/moz.build
+--- mozilla-central-f14898695ee0.orig/config/external/nss/crmf/moz.build	2016-03-20 05:25:17.000000000 +0100
++++ mozilla-central-f14898695ee0/config/external/nss/crmf/moz.build	2017-06-11 21:50:40.989355686 +0200
+@@ -8,7 +8,6 @@
+ 
+ if CONFIG['MOZ_SYSTEM_NSS']:
+     OS_LIBS += [l for l in CONFIG['NSS_LIBS'] if l.startswith('-L')]
+-    OS_LIBS += ['-lcrmf']
+ else:
+     USE_LIBS += [
+         # The dependency on nss is not real, but is required to force the
+diff -Naur mozilla-central-f14898695ee0.orig/old-configure.in mozilla-central-f14898695ee0/old-configure.in
+--- mozilla-central-f14898695ee0.orig/old-configure.in	2016-03-20 05:25:17.000000000 +0100
++++ mozilla-central-f14898695ee0/old-configure.in	2017-06-11 21:48:28.725284205 +0200
+@@ -2601,7 +2601,7 @@
+ fi
+ 
+ if test -n "$MOZ_SYSTEM_NSS"; then
+-   NSS_LIBS="$NSS_LIBS -lcrmf"
++   NSS_LIBS="$NSS_LIBS"
+ else
+    NSS_CFLAGS="-I${DIST}/include/nss"
+ fi

Copied: bluegriffon/repos/community-staging-i686/event__sizeof.patch (from rev 236226, bluegriffon/trunk/event__sizeof.patch)
===================================================================
--- community-staging-i686/event__sizeof.patch	                        (rev 0)
+++ community-staging-i686/event__sizeof.patch	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,18 @@
+diff -Naur mozilla-central-f14898695ee0.orig/ipc/chromium/src/base/message_pump_libevent.cc mozilla-central-f14898695ee0/ipc/chromium/src/base/message_pump_libevent.cc
+--- mozilla-central-f14898695ee0.orig/ipc/chromium/src/base/message_pump_libevent.cc	2016-03-20 05:25:17.000000000 +0100
++++ mozilla-central-f14898695ee0/ipc/chromium/src/base/message_pump_libevent.cc	2017-06-11 19:44:51.294979917 +0200
+@@ -18,11 +18,11 @@
+ #include "event.h"
+ #include "mozilla/UniquePtr.h"
+ 
+-// This macro checks that the _EVENT_SIZEOF_* constants defined in
++// This macro checks that the EVENT__SIZEOF_* constants defined in
+ // ipc/chromiume/src/third_party/<platform>/event2/event-config.h are correct.
+ #define CHECK_EVENT_SIZEOF(TYPE, type) \
+-    static_assert(_EVENT_SIZEOF_##TYPE == sizeof(type), \
+-    "bad _EVENT_SIZEOF_"#TYPE);
++    static_assert(EVENT__SIZEOF_##TYPE == sizeof(type), \
++    "bad EVENT__SIZEOF_"#TYPE);
+ 
+ CHECK_EVENT_SIZEOF(LONG,      long);
+ CHECK_EVENT_SIZEOF(LONG_LONG, long long);

Copied: bluegriffon/repos/community-staging-i686/mozconfig (from rev 236226, bluegriffon/trunk/mozconfig)
===================================================================
--- community-staging-i686/mozconfig	                        (rev 0)
+++ community-staging-i686/mozconfig	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,63 @@
+# sh
+# Build configuration script for Arch Linux
+#
+# See http://www.mozilla.org/build/unix.html for build instructions.
+#
+
+##############################
+# tweak the following according to your wishes
+##############################
+ac_add_options --disable-debug
+ac_add_options --enable-optimize
+ac_add_options --enable-strip
+#ac_add_options --enable-debug
+#ac_add_options --disable-optimize
+
+##############################
+# I build on a 4-cpu machine ; comment out or adapt to your own case
+##############################
+mk_add_options MOZ_MAKE_FLAGS="-s -j4"
+
+##############################
+# DO NOT MODIFY BELOW THIS LINE
+##############################
+ac_add_options --enable-application=bluegriffon
+# System directories
+mk_add_options MOZ_TOOLKIT_SEARCH=
+ac_add_options --prefix=/usr
+
+mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/bg
+mk_add_options MOZ_MEDIA_NAVIGATOR=1
+
+# System libraries
+ac_add_options --with-system-nspr
+ac_add_options --with-system-nss
+ac_add_options --with-system-libevent
+ac_add_options --with-system-libvpx
+ac_add_options --enable-system-hunspell
+ac_add_options --enable-system-sqlite
+#ac_add_options --enable-system-ffi
+#ac_add_options --enable-system-cairo
+ac_add_options --enable-system-pixman
+ac_add_options --with-system-jpeg
+ac_add_options --with-system-png
+ac_add_options --with-system-zlib
+ac_add_options --with-system-bz2
+ac_add_options --with-pthreads
+
+# Features
+ac_add_options --disable-necko-wifi
+ac_add_options --disable-tests
+ac_add_options --enable-default-toolkit=cairo-gtk3
+ac_add_options --disable-crashreporter
+ac_add_options --enable-safe-browsing
+ac_add_options --enable-gio
+ac_add_options --disable-gconf
+ac_add_options --disable-updater
+ac_add_options --disable-update-packaging
+ac_add_options --disable-webrtc
+ac_add_options --enable-startup-notification
+ac_add_options --enable-pulseaudio
+ac_add_options --disable-debug-symbols
+ac_add_options --enable-media-navigator
+

Copied: bluegriffon/repos/community-staging-x86_64/PKGBUILD (from rev 236226, bluegriffon/trunk/PKGBUILD)
===================================================================
--- community-staging-x86_64/PKGBUILD	                        (rev 0)
+++ community-staging-x86_64/PKGBUILD	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,121 @@
+# $Id$
+# Maintainer: Muflone http://www.muflone.com/contacts/english/
+# Contributor: Balló György <ballogyor+arch at gmail dot com>
+
+pkgname=bluegriffon
+pkgver=2.3.1
+_mozilla_ver=f14898695ee0
+pkgrel=3
+pkgdesc="The next-generation Web Editor based on the rendering engine of Firefox"
+arch=('i686' 'x86_64')
+url="http://bluegriffon.org/"
+license=('MPL' 'GPL' 'LGPL')
+depends=('alsa-lib' 'desktop-file-utils' 'dbus-glib' 'gtk2' 'gtk3' 'hunspell' 'mozilla-common'
+         'nss' 'libevent' 'libvpx' 'libxt' 'python2' 'startup-notification')
+makedepends=('autoconf2.13' 'libpulse' 'unzip' 'zip' 'yasm')
+options=('!emptydirs')
+source=("${pkgname}-${pkgver}.tar.gz"::"https://github.com/therealglazou/${pkgname}/archive/${pkgver}.tar.gz"
+        "mozilla-central-${_mozilla_ver}.tar.bz2"::"https://hg.mozilla.org/mozilla-central/archive/${_mozilla_ver}.tar.bz2"
+        "bug_1329272_icu.patch"::"https://hg.mozilla.org/releases/mozilla-esr45/raw-diff/571b48abf054/build/autoconf/icu.m4"
+        "bug_1290037_update_keybits_in_h2.patch"::"https://hg.mozilla.org/mozilla-central/raw-rev/361ac226da2a"
+        "bug_1269171_mozalloc_in_stl_wrappers.patch"::"https://hg.mozilla.org/mozilla-central/raw-rev/68da139d0866"
+        "bug_1371991_no_lib_nss_crmf.patch"
+        "${pkgname}_gtk3.patch"
+        "bug_1234158_firefox-gtk3-20.patch"
+        "event__sizeof.patch"
+        "mozconfig"
+        "${pkgname}.desktop")
+sha256sums=('1fb0ba05a024be3029fe800ef0297e9e5ff3dcb631d04a95ca30e33e5aa261d7'
+            '0b13213b5f9b3819b56872f7fb4fa7a1170ade06f8797dc11114e5f7c8eabca2'
+            '93de8102de543bad38dc49d9ffcf7a8a2d9246594a8e7b92c38736ed6c6050cd'
+            '87fb92e45f161d47b9e3ca31bcce60555bc33d633116dab4baa3bfba6ad965c4'
+            '9d4849338dad39b978f7c15a93c3c255d72d7bfdffa897900a0bdddd771d2e17'
+            '08e40f75395d26359ce9bcce42789961900b4dc8fbab8555baba6a2895f7798d'
+            '3868f39181a258823c45e7ad62bba8e7b6e8b07c41535dd584c2dc71431f5deb'
+            'd5e1b9a702dc693184494899fc4cd57ac206e1fd5415a8e5520b8ff3b822e734'
+            'f4440c9d3826f4cda18b9d00129347fe6a22de61e11d593b1a522fa46d685ca0'
+            'eaa26dd7e4216f6efd6c98b00154abd102ec60dd920fedb0817286202bb77269'
+            '882133b77840356985a81e496b4ddc443f8f33c068cfb7ef0858497820adcfff')
+
+prepare() {
+  cd "${pkgname}-${pkgver}"
+
+  # Fix build with GTK+3
+  patch -Np1 -i "${srcdir}/${pkgname}_gtk3.patch"
+
+  cd "${srcdir}/mozilla-central-${_mozilla_ver}"
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1329272
+  patch -Np1 -i "${srcdir}/bug_1329272_icu.patch"
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1290037
+  patch -Np1 -i "${srcdir}/bug_1290037_update_keybits_in_h2.patch"
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1269171
+  patch -Np1 -i "${srcdir}/bug_1269171_mozalloc_in_stl_wrappers.patch"
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1371991
+  # https://bugs.archlinux.org/task/54395
+  patch -Np1 -i "${srcdir}/bug_1371991_no_lib_nss_crmf.patch"
+
+  # Fix for libevent 2.1
+  # Change _EVENT_SIZEOF to EVENT__SIZEOF
+  patch -Np1 -i "${srcdir}/event__sizeof.patch"
+
+  # Move files to their correct location
+  cp -r "${srcdir}/${pkgname}-${pkgver}" bluegriffon
+  cp "${srcdir}/mozconfig" .mozconfig
+
+  # https://bugzilla.mozilla.org/show_bug.cgi?id=1234158
+  patch -Np1 -i "${srcdir}/bug_1234158_firefox-gtk3-20.patch"
+
+  # Apply BlueGriffon's upstream customizations
+  patch -Np1 -i "bluegriffon/config/content.patch"
+
+  # python2 fix
+  find . -name \*.py -exec sed -i 's@^#.*python$@#!/usr/bin/python2@' '{}' \;
+}
+
+build() {
+  cd "${srcdir}/mozilla-central-${_mozilla_ver}"
+
+  # configure script misdetects the preprocessor without an optimization level
+  # https://bugs.archlinux.org/task/34644
+  export CPPFLAGS+=' -O2'
+  export PYTHON=python2
+
+  # Fix linking with gtk3
+  export LDFLAGS+=" $(pkg-config --libs gtk+-3.0)"
+
+  # Build the package
+  ./mach build
+}
+
+package() {
+  cd "${srcdir}/mozilla-central-${_mozilla_ver}"
+
+  # Install files
+  install -m 755 -d "${pkgdir}/usr/lib/${pkgname}"
+  cp -LR bg/dist/bin/* "${pkgdir}/usr/lib/${pkgname}"
+
+  # Install executable file
+  install -m 755 -d "${pkgdir}/usr/bin"
+  ln -sf /usr/lib/${pkgname}/${pkgname} "${pkgdir}/usr/bin/${pkgname}"
+
+  # Install icons
+  cp bluegriffon/branding/mozicon128.png bluegriffon/branding/default128.png
+  for _icon in 16 32 48 128 256; do
+      install -Dm644 bluegriffon/branding/default${_icon}.png \
+        "${pkgdir}/usr/share/icons/hicolor/${_icon}x${_icon}/apps/${pkgname}.png"
+  done
+
+  # Install desktop file
+  install -Dm644 ../${pkgname}.desktop \
+    "${pkgdir}/usr/share/applications/${pkgname}.desktop"
+
+  # Use system-provided dictionaries
+  rm -rf "${pkgdir}/usr/lib/${pkgname}/dictionaries"
+  ln -sf /usr/share/hunspell "${pkgdir}/usr/lib/${pkgname}/dictionaries"
+  rm -rf "${pkgdir}/usr/lib/${pkgname}hyphenation"
+  ln -sf /usr/share/hyphen "${pkgdir}/usr/lib/${pkgname}/hyphenation"
+}

Copied: bluegriffon/repos/community-staging-x86_64/bluegriffon.desktop (from rev 236226, bluegriffon/trunk/bluegriffon.desktop)
===================================================================
--- community-staging-x86_64/bluegriffon.desktop	                        (rev 0)
+++ community-staging-x86_64/bluegriffon.desktop	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,16 @@
+[Desktop Entry]
+Name=BlueGriffon
+GenericName=Web Editor
+GenericName[hu]=Webszerkesztő
+X-GNOME-FullName=BlueGriffon Web Editor
+X-GNOME-FullName[hu]=BlueGriffon webszerkesztő
+Comment=Create Web Pages
+Comment[es]=Crea páginas web
+Comment[hu]=Weboldalak készítése
+Comment[it]=Creare pagine Web
+Categories=Development;WebDevelopment;
+Exec=bluegriffon
+Icon=bluegriffon
+Terminal=false
+MimeType=text/html;application/xhtml+xml;
+Type=Application

Copied: bluegriffon/repos/community-staging-x86_64/bluegriffon_gtk3.patch (from rev 236226, bluegriffon/trunk/bluegriffon_gtk3.patch)
===================================================================
--- community-staging-x86_64/bluegriffon_gtk3.patch	                        (rev 0)
+++ community-staging-x86_64/bluegriffon_gtk3.patch	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,46 @@
+diff -Naur bluegriffon-2.1.1.orig/config/content.patch bluegriffon-2.1.1/config/content.patch
+--- bluegriffon-2.1.1.orig/config/content.patch	2016-07-23 21:54:18.367575963 +0000
++++ bluegriffon-2.1.1/config/content.patch	2016-07-24 00:36:03.891186550 +0000
+@@ -4714,14 +4714,8 @@
+ diff --git a/widget/gtk/nsColorPicker.cpp b/widget/gtk/nsColorPicker.cpp
+ --- a/widget/gtk/nsColorPicker.cpp
+ +++ b/widget/gtk/nsColorPicker.cpp
+-@@ -1,21 +1,24 @@
+- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+- /* This Source Code Form is subject to the terms of the Mozilla Public
+-  * License, v. 2.0. If a copy of the MPL was not distributed with this
+-  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+- 
++@@ -6,16 +6,18 @@
+  #include <gtk/gtk.h>
+-+#include <gtk/gtkcolorsel.h>
+  
+  #include "nsColor.h"
+  #include "nsColorPicker.h"
+@@ -4739,7 +4733,7 @@
+    return color_component * 255 + 0.5;
+  }
+  
+-@@ -54,38 +57,39 @@ GtkColorSelection* nsColorPicker::Widget
++@@ -54,38 +56,39 @@ GtkColorSelection* nsColorPicker::Widget
+  {
+    return GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(
+                               GTK_COLOR_SELECTION_DIALOG(widget)));
+@@ -4785,7 +4779,7 @@
+      NS_WARNING("mCallback is already set. Open called twice?");
+      return NS_ERROR_FAILURE;
+    }
+-@@ -113,16 +117,18 @@ NS_IMETHODIMP nsColorPicker::Open(nsICol
++@@ -113,16 +116,18 @@ NS_IMETHODIMP nsColorPicker::Open(nsICol
+    GtkWidget *color_chooser = gtk_color_selection_dialog_new(title);
+    
+    if (parent_window) {
+@@ -4804,7 +4798,7 @@
+                     G_CALLBACK(OnColorChanged), this);
+  #endif
+  
+-@@ -176,20 +182,38 @@ nsColorPicker::Update(GtkColorSelection*
++@@ -176,20 +181,38 @@ nsColorPicker::Update(GtkColorSelection*
+    }
+  }
+

Copied: bluegriffon/repos/community-staging-x86_64/bug_1234158_firefox-gtk3-20.patch (from rev 236226, bluegriffon/trunk/bug_1234158_firefox-gtk3-20.patch)
===================================================================
--- community-staging-x86_64/bug_1234158_firefox-gtk3-20.patch	                        (rev 0)
+++ community-staging-x86_64/bug_1234158_firefox-gtk3-20.patch	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,1736 @@
+diff -up firefox-47.0/widget/gtk/gtk3drawing.c.gtk3-20 firefox-47.0/widget/gtk/gtk3drawing.c
+--- firefox-47.0/widget/gtk/gtk3drawing.c.gtk3-20	2016-06-01 06:11:44.000000000 +0200
++++ firefox-47.0/widget/gtk/gtk3drawing.c	2016-06-23 10:21:37.072462099 +0200
+@@ -17,34 +17,85 @@
+ 
+ #include <math.h>
+ 
++#define MOZ_WIDGET_STYLES 4
++
++typedef struct {
++    GtkWidget*            widget;
++
++    union {
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleSelection;
++        } entry;
++
++        struct {
++            GtkStyleContext*  style;
++        } button;
++
++        struct {
++            GtkStyleContext*  style;
++        } tooltip;
++
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleContents;
++            GtkStyleContext*  styleTrough;
++            GtkStyleContext*  styleSlider;
++        } scroll;
++
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleCheck;
++            GtkStyleContext*  styleLabel;
++        } check;
++
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleTrough;
++            GtkStyleContext*  styleProgress;
++        } progress;
++
++        struct {
++            GtkStyleContext*  style;
++            GtkStyleContext*  styleEntry;
++            GtkStyleContext*  styleButtonUp;
++            GtkStyleContext*  styleButtonDown;
++        } spin;
++
++        struct {
++            GtkStyleContext*  style[MOZ_WIDGET_STYLES];
++        } all;
++    };
++} MozGtkWidget;
++
+ static GtkWidget* gProtoWindow;
+ static GtkWidget* gProtoLayout;
+-static GtkWidget* gButtonWidget;
++static MozGtkWidget gButton;
+ static GtkWidget* gToggleButtonWidget;
+ static GtkWidget* gButtonArrowWidget;
+-static GtkWidget* gCheckboxWidget;
+-static GtkWidget* gRadiobuttonWidget;
+-static GtkWidget* gHorizScrollbarWidget;
+-static GtkWidget* gVertScrollbarWidget;
+-static GtkWidget* gSpinWidget;
++static MozGtkWidget gCheckbox;
++static MozGtkWidget gRadiobutton;
++static MozGtkWidget gVertScrollbar;
++static MozGtkWidget gHorizScrollbar;
++static MozGtkWidget gSpin;
+ static GtkWidget* gHScaleWidget;
+ static GtkWidget* gVScaleWidget;
+-static GtkWidget* gEntryWidget;
++static MozGtkWidget gEntry;
+ static GtkWidget* gComboBoxWidget;
+ static GtkWidget* gComboBoxButtonWidget;
+ static GtkWidget* gComboBoxArrowWidget;
+ static GtkWidget* gComboBoxSeparatorWidget;
+ static GtkWidget* gComboBoxEntryWidget;
+-static GtkWidget* gComboBoxEntryTextareaWidget;
++static MozGtkWidget gComboBoxEntryTextarea;
+ static GtkWidget* gComboBoxEntryButtonWidget;
+ static GtkWidget* gComboBoxEntryArrowWidget;
+ static GtkWidget* gHandleBoxWidget;
+ static GtkWidget* gToolbarWidget;
+ static GtkWidget* gFrameWidget;
+ static GtkWidget* gStatusbarWidget;
+-static GtkWidget* gProgressWidget;
++static MozGtkWidget gProgressBar;
+ static GtkWidget* gTabWidget;
+-static GtkWidget* gTooltipWidget;
++static MozGtkWidget gTooltip;
+ static GtkWidget* gMenuBarWidget;
+ static GtkWidget* gMenuBarItemWidget;
+ static GtkWidget* gMenuPopupWidget;
+@@ -78,6 +129,37 @@ static gboolean is_initialized;
+ #define GTK_STATE_FLAG_CHECKED (1 << 11)
+ #endif
+ 
++void moz_gtk_widget_free(MozGtkWidget *aMozWidget)
++{
++    // This was removed as a child of gProtoWindow
++    if (aMozWidget->widget) {
++        aMozWidget->widget = NULL;
++    }
++
++    for(int i = 0; i < MOZ_WIDGET_STYLES; i++) {
++        if (aMozWidget->all.style[i]) {
++            g_object_unref(aMozWidget->all.style[i]);
++            aMozWidget->all.style[i] = NULL;
++        }
++    }
++}
++
++// TODO - weak dep!! (dlsym)
++#if GTK_CHECK_VERSION(3, 19, 2)
++#define moz_gtk_path_set_class_name    gtk_widget_path_iter_set_object_name
++#else
++#define moz_gtk_path_set_class_name    gtk_widget_path_iter_add_class
++#endif
++//gtk_widget_path_iter_get_state
++
++static void
++moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
++                         GtkBorder *border);
++
++static void
++moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
++                          GtkBorder *padding);
++
+ static GtkStateFlags
+ GetStateFlagsFromGtkWidgetState(GtkWidgetState* state)
+ {
+@@ -97,6 +179,41 @@ 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)
++    moz_gtk_path_set_class_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);
++
++  if(!gtk_check_version(3, 14, 0)) {
++      /* Unfortunately, we have to explicitly set the state again here
++       * for it to take effect
++       */
++      gtk_style_context_set_state (context, gtk_widget_path_iter_get_state (path, -1));
++  }
++
++  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. */
+@@ -141,9 +258,16 @@ setup_widget_prototype(GtkWidget* widget
+ static gint
+ ensure_button_widget()
+ {
+-    if (!gButtonWidget) {
+-        gButtonWidget = gtk_button_new_with_label("M");
+-        setup_widget_prototype(gButtonWidget);
++    if (!gButton.widget) {
++        GtkCssNode path[] = { 
++            { GTK_TYPE_BUTTON, "button", NULL, NULL }
++        };
++
++        gButton.widget = gtk_button_new_with_label("M");
++        setup_widget_prototype(gButton.widget);
++        gtk_widget_show(gButton.widget);
++
++        gButton.button.style = moz_gtk_style_create(&path[0], NULL);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -195,9 +319,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_TOGGLE_BUTTON, "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.check.style = moz_gtk_style_create(&path[0], NULL);
++        gCheckbox.check.styleCheck = moz_gtk_style_create(&path[1],
++                                       gCheckbox.check.style);
++        gCheckbox.check.styleLabel = moz_gtk_style_create(&path[2],
++                                       gCheckbox.check.style);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -205,9 +341,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_TOGGLE_BUTTON, "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.check.style = moz_gtk_style_create(&path[0], NULL);
++        gRadiobutton.check.styleCheck = moz_gtk_style_create(&path[1],
++                                          gRadiobutton.check.style);
++        gRadiobutton.check.styleLabel = moz_gtk_style_create(&path[2],
++                                          gRadiobutton.check.style);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -215,25 +363,62 @@ 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", "bottom"},
++            { GTK_TYPE_SCROLLBAR, "scrollbar", "vertical", "right" },
++            { G_TYPE_NONE, "contents", NULL, NULL },
++            { G_TYPE_NONE, "trough", NULL, NULL },
++            { G_TYPE_NONE, "slider", NULL, NULL }
++        };
++
++        gHorizScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
++        setup_widget_prototype(gHorizScrollbar.widget);
++
++        gHorizScrollbar.scroll.style = moz_gtk_style_create(path, NULL);
++        gHorizScrollbar.scroll.styleContents = moz_gtk_style_create(path+2, 
++                                               gHorizScrollbar.scroll.style);
++        gHorizScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3, 
++                                               gHorizScrollbar.scroll.styleContents);
++        gHorizScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4, 
++                                               gHorizScrollbar.scroll.styleTrough);
++
++        gVertScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
++        setup_widget_prototype(gVertScrollbar.widget);
++
++        gVertScrollbar.scroll.style = moz_gtk_style_create(path+1, NULL);
++        gVertScrollbar.scroll.styleContents = moz_gtk_style_create(path+2, 
++                                              gVertScrollbar.scroll.style);
++        gVertScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3, 
++                                              gVertScrollbar.scroll.styleContents);
++        gVertScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4, 
++                                              gVertScrollbar.scroll.styleTrough);
++
++     }
+     return MOZ_GTK_SUCCESS;
+ }
+ 
+ static gint
+ ensure_spin_widget()
+ {
+-  if (!gSpinWidget) {
+-    gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
+-    setup_widget_prototype(gSpinWidget);
+-  }
+-  return MOZ_GTK_SUCCESS;
++    if (!gSpin.widget) {
++        GtkCssNode path[] = {
++            { GTK_TYPE_SPIN_BUTTON, "spinbutton", "horizontal", NULL },
++            { GTK_TYPE_SPIN_BUTTON, "spinbutton", "vertical", NULL },
++            { GTK_TYPE_ENTRY, "entry", NULL, NULL },
++            { G_TYPE_NONE, "button", "up", NULL },
++            { G_TYPE_NONE, "button", "down", NULL }
++        };
++
++        gSpin.widget = gtk_spin_button_new(NULL, 1, 0);
++        setup_widget_prototype(gSpin.widget);
++
++        gSpin.spin.style = moz_gtk_style_create(path, NULL);
++        gSpin.spin.styleButtonUp = moz_gtk_style_create(path+3, gSpin.spin.style);
++        gSpin.spin.styleButtonDown = moz_gtk_style_create(path+4, gSpin.spin.style);
++        gSpin.spin.styleEntry = moz_gtk_style_create(path+2, gSpin.spin.style);
++    }
++    return MOZ_GTK_SUCCESS;
+ }
+ 
+ static gint
+@@ -253,9 +438,19 @@ ensure_scale_widget()
+ static gint
+ ensure_entry_widget()
+ {
+-    if (!gEntryWidget) {
+-        gEntryWidget = gtk_entry_new();
+-        setup_widget_prototype(gEntryWidget);
++    if (!gEntry.widget) {
++        GtkCssNode path[] = { 
++            { GTK_TYPE_ENTRY, "entry", NULL, NULL },
++            { G_TYPE_NONE, "selection", NULL, NULL }
++        };
++
++        gEntry.widget = gtk_entry_new();
++        setup_widget_prototype(gEntry.widget);
++        gtk_widget_show(gEntry.widget);
++
++        gEntry.entry.style = moz_gtk_style_create(&path[0], NULL);
++        gEntry.entry.styleSelection = moz_gtk_style_create(&path[1], 
++                                                           gEntry.entry.style);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -387,9 +582,9 @@ moz_gtk_get_combo_box_entry_inner_widget
+         g_object_add_weak_pointer(G_OBJECT(widget),
+                                   (gpointer) &gComboBoxEntryButtonWidget);
+     } else if (GTK_IS_ENTRY(widget)) {
+-        gComboBoxEntryTextareaWidget = widget;
++        gComboBoxEntryTextarea.widget = widget;
+         g_object_add_weak_pointer(G_OBJECT(widget),
+-                                  (gpointer) &gComboBoxEntryTextareaWidget);
++                                  (gpointer) &gComboBoxEntryTextarea.widget);
+     } else
+         return;
+     gtk_widget_realize(widget);
+@@ -411,7 +606,7 @@ ensure_combo_box_entry_widgets()
+ {
+     GtkWidget* buttonChild;
+ 
+-    if (gComboBoxEntryTextareaWidget &&
++    if (gComboBoxEntryTextarea.widget &&
+             gComboBoxEntryButtonWidget &&
+             gComboBoxEntryArrowWidget)
+         return MOZ_GTK_SUCCESS;
+@@ -427,9 +622,9 @@ ensure_combo_box_entry_widgets()
+                          moz_gtk_get_combo_box_entry_inner_widgets,
+                          NULL);
+ 
+-    if (!gComboBoxEntryTextareaWidget) {
++    if (!gComboBoxEntryTextarea.widget) {
+         ensure_entry_widget();
+-        gComboBoxEntryTextareaWidget = gEntryWidget;
++        gComboBoxEntryTextarea.widget = gEntry.widget;
+     }
+ 
+     if (gComboBoxEntryButtonWidget) {
+@@ -507,12 +702,16 @@ ensure_toolbar_separator_widget()
+ static gint
+ ensure_tooltip_widget()
+ {
+-    if (!gTooltipWidget) {
+-        gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
+-        GtkStyleContext* style = gtk_widget_get_style_context(gTooltipWidget);
+-        gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
+-        gtk_widget_realize(gTooltipWidget);
+-        moz_gtk_set_widget_name(gTooltipWidget);
++    if (!gTooltip.widget) {
++        GtkCssNode path[] = {
++            { GTK_TYPE_TOOLTIP, "tooltip", "background", NULL},
++        };
++
++        gTooltip.widget = gtk_window_new(GTK_WINDOW_POPUP);
++        gtk_widget_realize(gTooltip.widget);
++        moz_gtk_set_widget_name(gTooltip.widget);
++
++        gTooltip.tooltip.style = moz_gtk_style_create(&path[0], NULL);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -530,9 +729,21 @@ ensure_tab_widget()
+ static gint
+ ensure_progress_widget()
+ {
+-    if (!gProgressWidget) {
+-        gProgressWidget = gtk_progress_bar_new();
+-        setup_widget_prototype(gProgressWidget);
++    if (!gProgressBar.widget) {
++        GtkCssNode path[] = {
++           { GTK_TYPE_LABEL, "progressbar", NULL, NULL },
++           { G_TYPE_NONE, "trough", NULL, NULL },
++           { G_TYPE_NONE, "progress", NULL, NULL },
++        };
++
++        gProgressBar.widget = gtk_progress_bar_new();
++        setup_widget_prototype(gProgressBar.widget);
++
++        gProgressBar.progress.style = moz_gtk_style_create(&path[0], NULL);
++        gProgressBar.progress.styleTrough = moz_gtk_style_create(&path[1],
++                                              gProgressBar.progress.style);
++        gProgressBar.progress.styleProgress = moz_gtk_style_create(&path[2],
++                                                gProgressBar.progress.styleTrough);
+     }
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -638,6 +849,11 @@ static gint
+ ensure_check_menu_item_widget()
+ {
+     if (!gCheckMenuItemWidget) {
++        GtkCssNode path[] = {
++           { GTK_TYPE_CHECK_MENU_ITEM, "menuitem", NULL, NULL },
++           { G_TYPE_NONE, "check", NULL, NULL }
++        };
++
+         ensure_menu_popup_widget();
+         gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
+         gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
+@@ -752,7 +968,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);
+@@ -765,7 +981,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);
+@@ -778,13 +994,13 @@ moz_gtk_get_focus_outline_size(gint* foc
+ {
+     GtkBorder border;
+     GtkBorder padding;
+-    GtkStyleContext *style;
++    GtkStyleContext* style;
+ 
+     ensure_entry_widget();
+-    style = gtk_widget_get_style_context(gEntryWidget);
+ 
+-    gtk_style_context_get_border(style, 0, &border);
+-    gtk_style_context_get_padding(style, 0, &padding);
++    style = gEntry.entry.style;
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+     *focus_h_width = border.left + padding.left;
+     *focus_v_width = border.top + padding.top;
+     return MOZ_GTK_SUCCESS;
+@@ -821,7 +1037,7 @@ moz_gtk_button_get_default_overflow(gint
+     GtkBorder* default_outside_border;
+ 
+     ensure_button_widget();
+-    gtk_widget_style_get(gButtonWidget,
++    gtk_widget_style_get(gButton.widget,
+                          "default-outside-border", &default_outside_border,
+                          NULL);
+ 
+@@ -844,7 +1060,7 @@ moz_gtk_button_get_default_border(gint*
+     GtkBorder* default_border;
+ 
+     ensure_button_widget();
+-    gtk_widget_style_get(gButtonWidget,
++    gtk_widget_style_get(gButton.widget,
+                          "default-border", &default_border,
+                          NULL);
+ 
+@@ -935,7 +1151,7 @@ moz_gtk_button_paint(cairo_t *cr, GdkRec
+ 
+     if (state->focused) {
+         GtkBorder border;
+-        gtk_style_context_get_border(style, state_flags, &border);
++        moz_gtk_get_style_border(style, state_flags, &border);
+         x += border.left;
+         y += border.top;
+         width -= (border.left + border.right);
+@@ -956,15 +1172,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;
++    MozGtkWidget *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
+@@ -983,11 +1198,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->check.styleCheck);
+ 
+     if (selected)
+         state_flags |= checkbox_check_state;
+@@ -995,13 +1208,15 @@ 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->check.styleCheck, state_flags);
++
++    gtk_render_background(w->check.styleCheck, cr, x, y, width, height);
++    gtk_render_frame(w->check.styleCheck, cr, x, y, width, height);
+ 
+     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->check.styleCheck, cr, x, y, width, height);
+         if (state->focused) {
+-            gtk_render_focus(style, cr, focus_x, focus_y,
++            gtk_render_focus(w->check.styleCheck, cr, focus_x, focus_y,
+                             focus_width, focus_height);
+         }
+     }
+@@ -1010,15 +1225,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(w->widget), inconsistent);
++        gtk_render_check(w->check.styleCheck, cr, x, y, width, height);
+         if (state->focused) {
+-            gtk_render_focus(style, cr, 
++            gtk_render_focus(w->check.styleCheck, cr,
+                              focus_x, focus_y, focus_width, focus_height);
+         }
+     }
+-    gtk_style_context_restore(style);
++    gtk_style_context_restore(w->check.styleCheck);
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -1035,8 +1249,8 @@ calculate_button_inner_rect(GtkWidget* b
+     style = gtk_widget_get_style_context(button);
+ 
+     /* This mirrors gtkbutton's child positioning */
+-    gtk_style_context_get_border(style, 0, &border);
+-    gtk_style_context_get_padding(style, 0, &padding);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+ 
+     inner_rect->x = rect->x + border.left + padding.left;
+     inner_rect->y = rect->y + padding.top + border.top;
+@@ -1099,9 +1313,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);
+ 
+@@ -1181,25 +1395,22 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
+                                GtkTextDirection direction)
+ {
+     GtkStyleContext* style;
+-    GtkScrollbar *scrollbar;
+ 
+     ensure_scrollbar_widget();
+ 
+-    if (widget ==  MOZ_GTK_SCROLLBAR_HORIZONTAL)
+-        scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
+-    else
+-        scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
+-
+-    gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
+-    
+     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);
++     if (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) {
++        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
++        style = gHorizScrollbar.scroll.style;
++    }
++    else {
++        gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
++        style = gVertScrollbar.scroll.style;
++    }
+ 
+     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);
+@@ -1208,7 +1419,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;
+ }
+ 
+@@ -1220,24 +1430,20 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
+ {
+     GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
+     GtkStyleContext* style;
+-    GtkScrollbar *scrollbar;
+     GtkBorder margin;
+ 
+     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.scroll.styleSlider;
++        gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
++    }
++    else {
++        style = gVertScrollbar.scroll.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,
+@@ -1248,8 +1454,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;
+ }
+ 
+@@ -1260,8 +1464,8 @@ moz_gtk_spin_paint(cairo_t *cr, GdkRecta
+     GtkStyleContext* style;
+ 
+     ensure_spin_widget();
+-    gtk_widget_set_direction(gSpinWidget, direction);
+-    style = gtk_widget_get_style_context(gSpinWidget);
++    gtk_widget_set_direction(gSpin.widget, direction);
++    style = gSpin.spin.style;
+     gtk_style_context_save(style);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
+     gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
+@@ -1280,11 +1484,10 @@ moz_gtk_spin_updown_paint(cairo_t *cr, G
+     GtkStyleContext* style;
+ 
+     ensure_spin_widget();
+-    style = gtk_widget_get_style_context(gSpinWidget);
++    style = gSpin.spin.style;
+     gtk_style_context_save(style);
+-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
+     gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
+-    gtk_widget_set_direction(gSpinWidget, direction);
++    gtk_widget_set_direction(gSpin.widget, direction);
+ 
+     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);
+@@ -1450,15 +1653,13 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec
+ static gint
+ moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect,
+                     GtkWidgetState* state,
+-                    GtkWidget* widget, GtkTextDirection direction)
++                    MozGtkWidget* w, GtkTextDirection direction)
+ {
+     gint x = rect->x, y = rect->y, width = rect->width, height = rect->height;
+-    GtkStyleContext* style;
+     int draw_focus_outline_only = state->depressed; // NS_THEME_FOCUS_OUTLINE
++    GtkStyleContext* style = w->entry.style;
+ 
+-    gtk_widget_set_direction(widget, direction);
+-
+-    style = gtk_widget_get_style_context(widget);
++    gtk_widget_set_direction(w->widget, direction);
+ 
+     if (draw_focus_outline_only) {
+         // Inflate the given 'rect' with the focus outline size.
+@@ -1478,10 +1679,9 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRect
+      * textarea window uses gtk_paint_flat_box when exposed */
+ 
+     /* This gets us a lovely greyish disabledish look */
+-    gtk_widget_set_sensitive(widget, !state->disabled);
++    gtk_widget_set_sensitive(w->widget, !state->disabled);
+ 
+     gtk_style_context_save(style);
+-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_ENTRY);
+   
+     /* Now paint the shadow and focus border.
+      * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad
+@@ -1531,7 +1731,7 @@ moz_gtk_treeview_paint(cairo_t *cr, GdkR
+     style = gtk_widget_get_style_context(gScrolledWindowWidget);
+     gtk_style_context_save(style);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_FRAME);    
+-    gtk_style_context_get_border(style, state_flags, &border);
++    moz_gtk_get_style_border(style, state_flags, &border);
+     xthickness = border.left;
+     ythickness = border.top;    
+ 
+@@ -1702,7 +1902,7 @@ moz_gtk_combo_box_paint(cairo_t *cr, Gdk
+         if (direction == GTK_TEXT_DIR_LTR) {
+             GtkBorder padding;
+             GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
+-            gtk_style_context_get_padding(style, state_flags, &padding);
++            moz_gtk_get_style_padding(style, state_flags, &padding);
+             arrow_rect.x -= padding.left;
+         }
+         else
+@@ -1804,29 +2004,27 @@ moz_gtk_container_paint(cairo_t *cr, Gdk
+                         gboolean isradio, GtkTextDirection direction)
+ {
+     GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
+-    GtkStyleContext* style;
+-    GtkWidget *widget;
++    MozGtkWidget *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->check.style);
++    gtk_style_context_set_state(widget->check.style, 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->check.style, cr,
+                               rect->x, rect->y, rect->width, rect->height);
+     }
+   
+-    gtk_style_context_restore(style);
++    gtk_style_context_restore(widget->check.style);
+   
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -1836,32 +2034,26 @@ moz_gtk_toggle_label_paint(cairo_t *cr,
+                            GtkWidgetState* state, 
+                            gboolean isradio, GtkTextDirection direction)
+ {
+-    GtkStyleContext *style;
+-    GtkWidget *widget;
++    MozGtkWidget *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->check.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->check.styleLabel, 
++                                GetStateFlagsFromGtkWidgetState(state));
++    gtk_render_focus(widget->check.styleLabel, cr,
+                     rect->x, rect->y, rect->width, rect->height);
+-    gtk_style_context_restore(style);
++    gtk_style_context_restore(widget->check.styleLabel);
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -1922,7 +2114,7 @@ moz_gtk_toolbar_separator_paint(cairo_t
+                           rect->height * (end_fraction - start_fraction));
+     } else {
+         GtkBorder padding;
+-        gtk_style_context_get_padding(style, 0, &padding);
++        gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+     
+         paint_width = padding.left;
+         if (paint_width > rect->width)
+@@ -1945,9 +2137,9 @@ moz_gtk_tooltip_paint(cairo_t *cr, GdkRe
+     GtkStyleContext* style;
+ 
+     ensure_tooltip_widget();
+-    gtk_widget_set_direction(gTooltipWidget, direction);
++    gtk_widget_set_direction(gTooltip.widget, direction);
+ 
+-    style = gtk_widget_get_style_context(gTooltipWidget);
++    style = gTooltip.tooltip.style;
+     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);
+     return MOZ_GTK_SUCCESS;
+@@ -2006,18 +2198,13 @@ static gint
+ moz_gtk_progressbar_paint(cairo_t *cr, GdkRectangle* rect,
+                           GtkTextDirection direction)
+ {
+-    GtkStyleContext* style;
+-
+     ensure_progress_widget();
+-    gtk_widget_set_direction(gProgressWidget, direction);
++    gtk_widget_set_direction(gProgressBar.widget, direction);
+ 
+-    style = gtk_widget_get_style_context(gProgressWidget);
+-    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);
+-    gtk_style_context_restore(style);
++    gtk_render_background(gProgressBar.progress.styleTrough, cr,
++                          rect->x, rect->y, rect->width, rect->height);
++    gtk_render_frame(gProgressBar.progress.styleTrough, cr,
++                     rect->x, rect->y, rect->width, rect->height);
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -2027,15 +2214,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
+                              GtkTextDirection direction,
+                              GtkThemeWidgetType widget)
+ {
+-    GtkStyleContext* style;
+-
+     ensure_progress_widget();
+-    gtk_widget_set_direction(gProgressWidget, direction);
+-
+-    style = gtk_widget_get_style_context(gProgressWidget);
+-    gtk_style_context_save(style);
+-    gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH);
+-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR);
++    gtk_widget_set_direction(gProgressBar.widget, direction);
+ 
+     if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
+         widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
+@@ -2074,12 +2254,14 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
+     // gtk_render_activity was used to render progress chunks on GTK versions
+     // before 3.13.7, see bug 1173907.
+     if (!gtk_check_version(3, 13, 7)) {
+-      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);
++      gtk_render_background(gProgressBar.progress.styleProgress, cr,
++                            rect->x, rect->y, rect->width, rect->height);
++      gtk_render_frame(gProgressBar.progress.styleProgress, cr,
++                       rect->x, rect->y, rect->width, rect->height);
+     } else {
+-      gtk_render_activity(style, cr, rect->x, rect->y, rect->width, rect->height);
++      gtk_render_activity(gProgressBar.progress.styleProgress, cr,
++                          rect->x, rect->y, rect->width, rect->height);
+     }
+-    gtk_style_context_restore(style);
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -2096,7 +2278,7 @@ moz_gtk_get_tab_thickness(void)
+ 
+     style = gtk_widget_get_style_context(gTabWidget);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_NOTEBOOK);
+-    gtk_style_context_get_border(style, 0, &border);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+ 
+     if (border.top < 2)
+         return 2; /* some themes don't set ythickness correctly */
+@@ -2292,7 +2474,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
+       gtk_style_context_save(style);
+       moz_gtk_tab_prepare_style_context(style, flags);
+ 
+-      gtk_style_context_get_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
++      moz_gtk_get_style_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
+ 
+       focusRect.x += padding.left;
+       focusRect.width -= (padding.left + padding.right);
+@@ -2408,7 +2590,7 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *
+ }
+ 
+ static gint
+-moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect,
++moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state,
+                        GtkTextDirection direction)
+ {
+     GtkStyleContext* style;
+@@ -2468,7 +2650,7 @@ moz_gtk_menu_separator_paint(cairo_t *cr
+     border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
+ 
+     style = gtk_widget_get_style_context(gMenuSeparatorWidget);
+-    gtk_style_context_get_padding(style, 0, &padding);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+ 
+     x = rect->x + border_width;
+     y = rect->y + border_width;
+@@ -2521,7 +2703,8 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
+             item_widget = gMenuItemWidget;
+         }
+         style = gtk_widget_get_style_context(item_widget);
+-        gtk_style_context_save(style);
++// TODO - FIX!
++//        gtk_style_context_save(style);
+ 
+         if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
+             gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
+@@ -2540,7 +2723,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
+ 
+         gtk_render_background(style, cr, x, y, w, h);
+         gtk_render_frame(style, cr, x, y, w, h);
+-        gtk_style_context_restore(style);
++//        gtk_style_context_restore(style);
+     }
+ 
+     return MOZ_GTK_SUCCESS;
+@@ -2556,7 +2739,10 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, Gd
+ 
+     ensure_menu_item_widget();
+     gtk_widget_set_direction(gMenuItemWidget, direction);
+-
++/*
++    state_flags |= (direction == GTK_TEXT_DIR_LTR) ? GTK_STATE_FLAG_DIR_LTR :
++                                                     GTK_STATE_FLAG_DIR_RTL;
++*/
+     style = gtk_widget_get_style_context(gMenuItemWidget);
+     gtk_style_context_save(style);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUITEM);
+@@ -2606,7 +2792,7 @@ moz_gtk_check_menu_item_paint(cairo_t *c
+     }
+     
+     gtk_style_context_set_state(style, state_flags);
+-    gtk_style_context_get_padding(style, state_flags, &padding);
++    moz_gtk_get_style_padding(style, state_flags, &padding);
+ 
+     offset = gtk_container_get_border_width(GTK_CONTAINER(gCheckMenuItemWidget)) +
+                                             padding.left + 2;
+@@ -2658,7 +2844,7 @@ moz_gtk_add_style_border(GtkStyleContext
+ {
+     GtkBorder border;
+ 
+-    gtk_style_context_get_border(style, 0, &border);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+ 
+     *left += border.left;
+     *right += border.right;
+@@ -2667,12 +2853,22 @@ moz_gtk_add_style_border(GtkStyleContext
+ }
+ 
+ static void
++moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
++                         GtkBorder *border)
++{
++    gtk_style_context_save(style);
++    gtk_style_context_set_state(style, state_flags);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), border);
++    gtk_style_context_restore(style);
++}
++
++static void
+ moz_gtk_add_style_padding(GtkStyleContext* style,
+                           gint* left, gint* top, gint* right, gint* bottom)
+ {
+     GtkBorder padding;
+ 
+-    gtk_style_context_get_padding(style, 0, &padding);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+ 
+     *left += padding.left;
+     *right += padding.right;
+@@ -2680,6 +2876,16 @@ moz_gtk_add_style_padding(GtkStyleContex
+     *bottom += padding.bottom;
+ }
+ 
++static void
++moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
++                          GtkBorder *padding)
++{
++    gtk_style_context_save(style);
++    gtk_style_context_set_state(style, state_flags);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), padding);
++    gtk_style_context_restore(style);
++}
++
+ gint
+ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
+                           gint* right, gint* bottom, GtkTextDirection direction,
+@@ -2694,37 +2900,35 @@ moz_gtk_get_widget_border(GtkThemeWidget
+     case MOZ_GTK_TOOLBAR_BUTTON:
+         {
+             ensure_button_widget();
+-            style = gtk_widget_get_style_context(gButtonWidget);
+-
+-            *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButtonWidget));
+ 
+-            if (widget == MOZ_GTK_TOOLBAR_BUTTON) {
+-                gtk_style_context_save(style);
+-                gtk_style_context_add_class(style, "image-button");
+-            }
+-              
+-            moz_gtk_add_style_padding(style, left, top, right, bottom);
+-                
+-            if (widget == MOZ_GTK_TOOLBAR_BUTTON)
+-                gtk_style_context_restore(style);
++            *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButton.widget));
++            moz_gtk_add_style_padding(gButton.button.style, left, top, right, bottom);
+ 
+             // XXX: Subtract 1 pixel from the border to account for the added
+             // -moz-focus-inner border (Bug 1228281).
+             *left -= 1; *top -= 1; *right -= 1; *bottom -= 1;
+-            moz_gtk_add_style_border(style, left, top, right, bottom);
++            moz_gtk_add_style_border(gButton.button.style, left, top, right, bottom);
++
+             return MOZ_GTK_SUCCESS;
+         }
+     case MOZ_GTK_ENTRY:
+         {
+             ensure_entry_widget();
+-            style = gtk_widget_get_style_context(gEntryWidget);
+ 
+             // XXX: Subtract 1 pixel from the padding to account for the default
+             // padding in forms.css. See bug 1187385.
+             *left = *top = *right = *bottom = -1;
+-            moz_gtk_add_style_padding(style, left, top, right, bottom);
+-            moz_gtk_add_style_border(style, left, top, right, bottom);
+ 
++            moz_gtk_add_style_padding(gEntry.entry.style, left, top, right, bottom);
++            moz_gtk_add_style_border(gEntry.entry.style, left, top, right, bottom);
++
++            return MOZ_GTK_SUCCESS;
++        }
++    case MOZ_GTK_TOOLTIP:
++        {
++            ensure_tooltip_widget();
++            moz_gtk_add_style_padding(gTooltip.tooltip.style, left, top, right, bottom);
++            moz_gtk_add_style_border(gTooltip.tooltip.style, left, top, right, bottom);
+             return MOZ_GTK_SUCCESS;
+         }
+     case MOZ_GTK_TREEVIEW:
+@@ -2759,7 +2963,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
+         break;
+     case MOZ_GTK_DROPDOWN_ENTRY:
+         ensure_combo_box_entry_widgets();
+-        w = gComboBoxEntryTextareaWidget;
++        w = gComboBoxEntryTextarea.widget;
+         break;
+     case MOZ_GTK_DROPDOWN_ARROW:
+         ensure_combo_box_entry_widgets();
+@@ -2795,7 +2999,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
+ 
+                 if (!wide_separators) {
+                     style = gtk_widget_get_style_context(gComboBoxSeparatorWidget);
+-                    gtk_style_context_get_border(style, 0, &border);
++                    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+                     separator_width = border.left;
+                 }
+             }
+@@ -2814,14 +3018,17 @@ moz_gtk_get_widget_border(GtkThemeWidget
+         w = gTabWidget;
+         break;
+     case MOZ_GTK_PROGRESSBAR:
+-        ensure_progress_widget();
+-        w = gProgressWidget;
+-        break;
++        {
++            ensure_progress_widget();
++            moz_gtk_add_style_border(gProgressBar.progress.styleTrough,
++                                     left, top, right, bottom);
++            return MOZ_GTK_SUCCESS;
++        }
+     case MOZ_GTK_SPINBUTTON_ENTRY:
+     case MOZ_GTK_SPINBUTTON_UP:
+     case MOZ_GTK_SPINBUTTON_DOWN:
+         ensure_spin_widget();
+-        w = gSpinWidget;
++        w = gSpin.widget;
+         break;
+     case MOZ_GTK_SCALE_HORIZONTAL:
+         ensure_scale_widget();
+@@ -2840,12 +3047,13 @@ moz_gtk_get_widget_border(GtkThemeWidget
+         {
+             if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
+                 ensure_checkbox_widget();
+-                w = gCheckboxWidget;
++                w = gCheckbox.widget;
++                style = gCheckbox.check.styleCheck;
+             } else {
+                 ensure_radiobutton_widget();
+-                w = gRadiobuttonWidget;
++                w = gRadiobutton.widget;
++                style = gRadiobutton.check.styleCheck;
+             }
+-            style = gtk_widget_get_style_context(w);
+ 
+             *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(w));
+             moz_gtk_add_style_border(style,
+@@ -2904,7 +3112,6 @@ moz_gtk_get_widget_border(GtkThemeWidget
+     case MOZ_GTK_MENUSEPARATOR:
+     /* These widgets have no borders.*/
+     case MOZ_GTK_SPINBUTTON:
+-    case MOZ_GTK_TOOLTIP:
+     case MOZ_GTK_WINDOW:
+     case MOZ_GTK_RESIZER:
+     case MOZ_GTK_MENUARROW:
+@@ -2978,6 +3185,32 @@ moz_gtk_get_combo_box_entry_button_size(
+ }
+ 
+ gint
++moz_gtk_get_entry_height(gint* height)
++{
++    GtkRequisition requisition;
++    ensure_entry_widget();
++
++    gtk_widget_get_preferred_size(gEntry.widget, NULL, &requisition);
++    *height = requisition.height;
++
++    return MOZ_GTK_SUCCESS;
++}
++
++
++gint
++moz_gtk_get_button_height(gint* height)
++{
++    GtkRequisition requisition;
++    ensure_entry_widget();
++
++    gtk_widget_get_preferred_size(gButton.widget, NULL, &requisition);
++    *height = requisition.height;
++
++    return MOZ_GTK_SUCCESS;
++}
++
++
++gint
+ moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
+ {
+     gint arrow_size;
+@@ -3030,7 +3263,7 @@ moz_gtk_get_toolbar_separator_width(gint
+                          "separator-width", &separator_width,
+                          NULL);
+     /* Just in case... */
+-    gtk_style_context_get_border(style, 0, &border);
++    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+     *size = MAX(*size, (wide_separators ? separator_width : border.left));
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -3072,7 +3305,7 @@ moz_gtk_get_menu_separator_height(gint *
+     border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
+ 
+     style = gtk_widget_get_style_context(gMenuSeparatorWidget);
+-    gtk_style_context_get_padding(style, 0, &padding);
++    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
+ 
+     gtk_style_context_save(style);
+     gtk_style_context_add_class(style, GTK_STYLE_CLASS_SEPARATOR);
+@@ -3130,15 +3363,21 @@ 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,
+                           "stepper_spacing", &metrics->stepper_spacing,
+                           NULL);
+ 
+-    metrics->min_slider_size = 
+-        gtk_range_get_min_slider_size(GTK_RANGE(gHorizScrollbarWidget));
++    if (!gtk_check_version(3,19,7)) {
++        gtk_style_context_get(gVertScrollbar.scroll.styleSlider, 
++                              gtk_style_context_get_state(gVertScrollbar.scroll.styleSlider), 
++                              "min-height", &metrics->min_slider_size, NULL);
++    } else {
++        metrics->min_slider_size = 
++            gtk_range_get_min_slider_size(GTK_RANGE(gVertScrollbar.widget));
++    }
+ 
+     return MOZ_GTK_SUCCESS;
+ }
+@@ -3163,7 +3402,7 @@ moz_gtk_images_in_buttons()
+     GtkSettings* settings;
+ 
+     ensure_button_widget();
+-    settings = gtk_widget_get_settings(gButtonWidget);
++    settings = gtk_widget_get_settings(gButton.widget);
+ 
+     g_object_get(settings, "gtk-button-images", &result, NULL);
+     return result;
+@@ -3191,7 +3430,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+         }
+         ensure_button_widget();
+         return moz_gtk_button_paint(cr, rect, state,
+-                                    (GtkReliefStyle) flags, gButtonWidget,
++                                    (GtkReliefStyle) flags, gButton.widget,
+                                     direction);
+         break;
+     case MOZ_GTK_CHECKBUTTON:
+@@ -3241,7 +3480,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+     case MOZ_GTK_SPINBUTTON_ENTRY:
+         ensure_spin_widget();
+         return moz_gtk_entry_paint(cr, rect, state,
+-                                   gSpinWidget, direction);
++                                   &gSpin, direction);
+         break;
+     case MOZ_GTK_GRIPPER:
+         return moz_gtk_gripper_paint(cr, rect, state,
+@@ -3268,7 +3507,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+     case MOZ_GTK_ENTRY:
+         ensure_entry_widget();
+         return moz_gtk_entry_paint(cr, rect, state,
+-                                   gEntryWidget, direction);
++                                   &gEntry, direction);
+         break;
+     case MOZ_GTK_DROPDOWN:
+         return moz_gtk_combo_box_paint(cr, rect, state, direction);
+@@ -3280,7 +3519,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+     case MOZ_GTK_DROPDOWN_ENTRY:
+         ensure_combo_box_entry_widgets();
+         return moz_gtk_entry_paint(cr, rect, state,
+-                                   gComboBoxEntryTextareaWidget, direction);
++                                   &gComboBoxEntryTextarea, direction);
+         break;
+     case MOZ_GTK_CHECKBUTTON_CONTAINER:
+     case MOZ_GTK_RADIOBUTTON_CONTAINER:
+@@ -3332,7 +3571,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
+                                               (GtkArrowType) flags, direction);
+         break;
+     case MOZ_GTK_MENUBAR:
+-        return moz_gtk_menu_bar_paint(cr, rect, direction);
++        return moz_gtk_menu_bar_paint(cr, rect, state, direction);
+         break;
+     case MOZ_GTK_MENUPOPUP:
+         return moz_gtk_menu_popup_paint(cr, rect, direction);
+@@ -3383,7 +3622,7 @@ GtkWidget* moz_gtk_get_scrollbar_widget(
+ {
+     MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
+     ensure_scrollbar_widget();
+-    return gHorizScrollbarWidget;
++    return gVertScrollbar.widget;
+ }
+ 
+ gboolean moz_gtk_has_scrollbar_buttons(void)
+@@ -3391,7 +3630,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,
+@@ -3403,8 +3642,8 @@ gboolean moz_gtk_has_scrollbar_buttons(v
+ gint
+ moz_gtk_shutdown()
+ {
+-    if (gTooltipWidget)
+-        gtk_widget_destroy(gTooltipWidget);
++    moz_gtk_widget_free(&gTooltip);
++
+     /* This will destroy all of our widgets */
+     if (gProtoWindow)
+         gtk_widget_destroy(gProtoWindow);
+@@ -3415,17 +3654,19 @@ moz_gtk_shutdown()
+ 
+     gProtoWindow = NULL;
+     gProtoLayout = NULL;
+-    gButtonWidget = NULL;
++
++    // MozWidgets
++    moz_gtk_widget_free(&gButton);
+     gToggleButtonWidget = NULL;
+     gButtonArrowWidget = NULL;
+-    gCheckboxWidget = NULL;
+-    gRadiobuttonWidget = NULL;
+-    gHorizScrollbarWidget = NULL;
+-    gVertScrollbarWidget = NULL;
+-    gSpinWidget = NULL;
++    moz_gtk_widget_free(&gCheckbox);
++    moz_gtk_widget_free(&gRadiobutton);
++    moz_gtk_widget_free(&gHorizScrollbar);
++    moz_gtk_widget_free(&gVertScrollbar);
++    moz_gtk_widget_free(&gSpin);
+     gHScaleWidget = NULL;
+     gVScaleWidget = NULL;
+-    gEntryWidget = NULL;
++    moz_gtk_widget_free(&gEntry);
+     gComboBoxWidget = NULL;
+     gComboBoxButtonWidget = NULL;
+     gComboBoxSeparatorWidget = NULL;
+@@ -3433,14 +3674,13 @@ moz_gtk_shutdown()
+     gComboBoxEntryWidget = NULL;
+     gComboBoxEntryButtonWidget = NULL;
+     gComboBoxEntryArrowWidget = NULL;
+-    gComboBoxEntryTextareaWidget = NULL;
++    moz_gtk_widget_free(&gComboBoxEntryTextarea);
+     gHandleBoxWidget = NULL;
+     gToolbarWidget = NULL;
+     gStatusbarWidget = NULL;
+     gFrameWidget = NULL;
+-    gProgressWidget = NULL;
++    moz_gtk_widget_free(&gProgressBar);
+     gTabWidget = NULL;
+-    gTooltipWidget = NULL;
+     gMenuBarWidget = NULL;
+     gMenuBarItemWidget = NULL;
+     gMenuPopupWidget = NULL;
+diff -up firefox-47.0/widget/gtk/gtkdrawing.h.gtk3-20 firefox-47.0/widget/gtk/gtkdrawing.h
+--- firefox-47.0/widget/gtk/gtkdrawing.h.gtk3-20	2016-05-12 19:13:34.000000000 +0200
++++ firefox-47.0/widget/gtk/gtkdrawing.h	2016-06-23 10:21:37.072462099 +0200
+@@ -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 */
+@@ -396,6 +403,9 @@ void
+ moz_gtk_get_arrow_size(GtkThemeWidgetType widgetType,
+                        gint* width, gint* height);
+ 
++gint moz_gtk_get_entry_height(gint* height);
++gint moz_gtk_get_button_height(gint* height);
++
+ /**
+  * Get the desired size of a toolbar separator
+  * size:    [OUT] the desired width
+@@ -466,6 +476,12 @@ 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-47.0/widget/gtk/mozgtk/mozgtk.c.gtk3-20 firefox-47.0/widget/gtk/mozgtk/mozgtk.c
+--- firefox-47.0/widget/gtk/mozgtk/mozgtk.c.gtk3-20	2016-05-12 19:13:34.000000000 +0200
++++ firefox-47.0/widget/gtk/mozgtk/mozgtk.c	2016-06-23 10:26:36.495774041 +0200
+@@ -504,9 +504,15 @@ STUB(gtk_window_set_type_hint)
+ STUB(gtk_window_set_wmclass)
+ STUB(gtk_window_unfullscreen)
+ STUB(gtk_window_unmaximize)
++STUB(gtk_widget_get_preferred_height_and_baseline_for_width)
++STUB(gtk_entry_get_text_area)
++STUB(gtk_check_menu_item_get_type)
++STUB(gtk_spin_button_get_type)
++STUB(gtk_button_get_type)
+ #endif
+ 
+ #ifdef GTK3_SYMBOLS
++STUB(gtk_box_new)
+ STUB(gdk_device_get_source)
+ STUB(gdk_device_manager_get_client_pointer)
+ STUB(gdk_disable_multidevice)
+@@ -581,6 +587,15 @@ 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_append_for_widget)
++STUB(gtk_widget_path_copy)
++STUB(gtk_widget_path_iter_set_object_name)
++STUB(gtk_widget_path_iter_add_class)
++STUB(gtk_widget_path_iter_get_state)
++STUB(gtk_style_context_set_parent)
++STUB(gtk_widget_path_unref)
++STUB(gtk_tooltip_get_type)
+ #endif
+ 
+ #ifdef GTK2_SYMBOLS
+diff -up firefox-47.0/widget/gtk/nsLookAndFeel.cpp.gtk3-20 firefox-47.0/widget/gtk/nsLookAndFeel.cpp
+--- firefox-47.0/widget/gtk/nsLookAndFeel.cpp.gtk3-20	2016-06-01 06:11:44.000000000 +0200
++++ firefox-47.0/widget/gtk/nsLookAndFeel.cpp	2016-06-23 10:21:37.073462100 +0200
+@@ -353,14 +353,18 @@ nsLookAndFeel::NativeGetColor(ColorID aI
+     case eColorID_activeborder:
+         // active window border
+         gtk_style_context_get_border_color(mBackgroundStyle, 
+-                                           GTK_STATE_FLAG_NORMAL, &gdk_color);
++                                           gtk_style_context_get_state(mBackgroundStyle), 
++                                           &gdk_color);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+     case eColorID_inactiveborder:
+         // inactive window border
++        gtk_style_context_save(mBackgroundStyle);
++        gtk_style_context_set_state(mBackgroundStyle, GTK_STATE_FLAG_INSENSITIVE);
+         gtk_style_context_get_border_color(mBackgroundStyle, 
+-                                           GTK_STATE_FLAG_INSENSITIVE, 
++                                           gtk_style_context_get_state(mBackgroundStyle), 
+                                            &gdk_color);
++        gtk_style_context_restore(mBackgroundStyle);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+     case eColorID_graytext: // disabled text in windows, menus, etc.
+@@ -369,9 +373,12 @@ nsLookAndFeel::NativeGetColor(ColorID aI
+         break;
+     case eColorID_inactivecaption:
+         // inactive window caption
++        gtk_style_context_save(mBackgroundStyle);
++        gtk_style_context_set_state(mBackgroundStyle, GTK_STATE_FLAG_INSENSITIVE);
+         gtk_style_context_get_background_color(mBackgroundStyle, 
+-                                               GTK_STATE_FLAG_INSENSITIVE, 
++                                               gtk_style_context_get_state(mBackgroundStyle), 
+                                                &gdk_color);
++        gtk_style_context_restore(mBackgroundStyle);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+ #endif
+@@ -497,13 +504,17 @@ nsLookAndFeel::NativeGetColor(ColorID aI
+     case eColorID__moz_buttondefault:
+       // default button border color
+         gtk_style_context_get_border_color(mButtonStyle, 
+-                                           GTK_STATE_FLAG_NORMAL, &gdk_color);
++                                           gtk_style_context_get_state(mButtonStyle),
++                                           &gdk_color);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+     case eColorID__moz_buttonhoverface:
++        gtk_style_context_save(mButtonStyle);
++        gtk_style_context_set_state(mButtonStyle, GTK_STATE_FLAG_PRELIGHT);
+         gtk_style_context_get_background_color(mButtonStyle, 
+-                                               GTK_STATE_FLAG_PRELIGHT, 
++                                               gtk_style_context_get_state(mButtonStyle), 
+                                                &gdk_color);
++        gtk_style_context_restore(mButtonStyle);
+         aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
+         break;
+     case eColorID__moz_buttonhovertext:
+@@ -1019,6 +1030,29 @@ create_context(GtkWidgetPath *path)
+ }
+ #endif
+ 
++GtkStyleContext*
++CreateStyleForWidget(GtkWidget* aWidget, GtkStyleContext* aParentStyle)
++{   
++  GtkWidgetPath* path =
++    gtk_widget_path_copy(gtk_style_context_get_path(aParentStyle));
++
++  // Work around https://bugzilla.gnome.org/show_bug.cgi?id=767312
++  // which exists in GTK+ 3.20.
++  gtk_widget_get_style_context(aWidget);
++
++  gtk_widget_path_append_for_widget(path, aWidget);
++  // Release any floating reference on aWidget.
++  g_object_ref_sink(aWidget);
++  g_object_unref(aWidget);
++    
++  GtkStyleContext *context = gtk_style_context_new();
++  gtk_style_context_set_path(context, path);
++  gtk_style_context_set_parent(context, aParentStyle);
++  gtk_widget_path_unref(path);
++    
++  return context;
++}
++
+ void
+ nsLookAndFeel::Init()
+ {
+@@ -1122,26 +1156,36 @@ 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);
+ 
+     // Window colors
+     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);
++    g_object_unref(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);
++    GtkCssNode tooltipPath[] = { 
++         { GTK_TYPE_TOOLTIP, "tooltip", "background", NULL},
++    };
++    style = moz_gtk_style_create(tooltipPath, NULL);
++    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);
++    {
++        GtkStyleContext* boxStyle =
++            CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0),
++                                 style);
++        GtkStyleContext* labelStyle =
++            CreateStyleForWidget(gtk_label_new(nullptr), boxStyle);
++        gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color);
++        g_object_unref(labelStyle);
++        g_object_unref(boxStyle);
++    }
+     sInfoText = GDK_RGBA_TO_NS_RGBA(color);
+     g_object_unref(style);
+ 
+@@ -1156,20 +1200,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
+@@ -1278,44 +1328,54 @@ 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;
++    GtkBorder padding;
++
+     // 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_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
+@@ -1328,7 +1388,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);
+ 
+@@ -1346,9 +1406,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;
+diff -up firefox-47.0/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20 firefox-47.0/widget/gtk/nsNativeThemeGTK.cpp
+--- firefox-47.0/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20	2016-06-01 06:11:44.000000000 +0200
++++ firefox-47.0/widget/gtk/nsNativeThemeGTK.cpp	2016-06-23 10:21:37.074462101 +0200
+@@ -1570,9 +1570,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
+   case NS_THEME_RADIO_CONTAINER:
+   case NS_THEME_CHECKBOX_LABEL:
+   case NS_THEME_RADIO_LABEL:
+-  case NS_THEME_BUTTON:
+-  case NS_THEME_DROPDOWN:
+-  case NS_THEME_TOOLBAR_BUTTON:
+   case NS_THEME_TREEVIEW_HEADER_CELL:
+     {
+       if (aWidgetType == NS_THEME_DROPDOWN) {
+@@ -1591,6 +1588,21 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
+       aResult->height += border.top + border.bottom;
+     }
+     break;
++  case NS_THEME_BUTTON:
++  case NS_THEME_DROPDOWN:
++  case NS_THEME_TOOLBAR_BUTTON:
++    {
++        moz_gtk_get_button_height(&aResult->height);
++    }
++    break;
++  case NS_THEME_FOCUS_OUTLINE:
++  case NS_THEME_NUMBER_INPUT:
++  case NS_THEME_TEXTFIELD:
++  case NS_THEME_TEXTFIELD_MULTILINE:
++    {
++        moz_gtk_get_entry_height(&aResult->height);
++    } 
++    break;
+   case NS_THEME_TOOLBAR_SEPARATOR:
+     {
+       gint separator_width;

Copied: bluegriffon/repos/community-staging-x86_64/bug_1371991_no_lib_nss_crmf.patch (from rev 236226, bluegriffon/trunk/bug_1371991_no_lib_nss_crmf.patch)
===================================================================
--- community-staging-x86_64/bug_1371991_no_lib_nss_crmf.patch	                        (rev 0)
+++ community-staging-x86_64/bug_1371991_no_lib_nss_crmf.patch	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,23 @@
+diff -Naur mozilla-central-f14898695ee0.orig/config/external/nss/crmf/moz.build mozilla-central-f14898695ee0/config/external/nss/crmf/moz.build
+--- mozilla-central-f14898695ee0.orig/config/external/nss/crmf/moz.build	2016-03-20 05:25:17.000000000 +0100
++++ mozilla-central-f14898695ee0/config/external/nss/crmf/moz.build	2017-06-11 21:50:40.989355686 +0200
+@@ -8,7 +8,6 @@
+ 
+ if CONFIG['MOZ_SYSTEM_NSS']:
+     OS_LIBS += [l for l in CONFIG['NSS_LIBS'] if l.startswith('-L')]
+-    OS_LIBS += ['-lcrmf']
+ else:
+     USE_LIBS += [
+         # The dependency on nss is not real, but is required to force the
+diff -Naur mozilla-central-f14898695ee0.orig/old-configure.in mozilla-central-f14898695ee0/old-configure.in
+--- mozilla-central-f14898695ee0.orig/old-configure.in	2016-03-20 05:25:17.000000000 +0100
++++ mozilla-central-f14898695ee0/old-configure.in	2017-06-11 21:48:28.725284205 +0200
+@@ -2601,7 +2601,7 @@
+ fi
+ 
+ if test -n "$MOZ_SYSTEM_NSS"; then
+-   NSS_LIBS="$NSS_LIBS -lcrmf"
++   NSS_LIBS="$NSS_LIBS"
+ else
+    NSS_CFLAGS="-I${DIST}/include/nss"
+ fi

Copied: bluegriffon/repos/community-staging-x86_64/event__sizeof.patch (from rev 236226, bluegriffon/trunk/event__sizeof.patch)
===================================================================
--- community-staging-x86_64/event__sizeof.patch	                        (rev 0)
+++ community-staging-x86_64/event__sizeof.patch	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,18 @@
+diff -Naur mozilla-central-f14898695ee0.orig/ipc/chromium/src/base/message_pump_libevent.cc mozilla-central-f14898695ee0/ipc/chromium/src/base/message_pump_libevent.cc
+--- mozilla-central-f14898695ee0.orig/ipc/chromium/src/base/message_pump_libevent.cc	2016-03-20 05:25:17.000000000 +0100
++++ mozilla-central-f14898695ee0/ipc/chromium/src/base/message_pump_libevent.cc	2017-06-11 19:44:51.294979917 +0200
+@@ -18,11 +18,11 @@
+ #include "event.h"
+ #include "mozilla/UniquePtr.h"
+ 
+-// This macro checks that the _EVENT_SIZEOF_* constants defined in
++// This macro checks that the EVENT__SIZEOF_* constants defined in
+ // ipc/chromiume/src/third_party/<platform>/event2/event-config.h are correct.
+ #define CHECK_EVENT_SIZEOF(TYPE, type) \
+-    static_assert(_EVENT_SIZEOF_##TYPE == sizeof(type), \
+-    "bad _EVENT_SIZEOF_"#TYPE);
++    static_assert(EVENT__SIZEOF_##TYPE == sizeof(type), \
++    "bad EVENT__SIZEOF_"#TYPE);
+ 
+ CHECK_EVENT_SIZEOF(LONG,      long);
+ CHECK_EVENT_SIZEOF(LONG_LONG, long long);

Copied: bluegriffon/repos/community-staging-x86_64/mozconfig (from rev 236226, bluegriffon/trunk/mozconfig)
===================================================================
--- community-staging-x86_64/mozconfig	                        (rev 0)
+++ community-staging-x86_64/mozconfig	2017-06-11 21:58:39 UTC (rev 236227)
@@ -0,0 +1,63 @@
+# sh
+# Build configuration script for Arch Linux
+#
+# See http://www.mozilla.org/build/unix.html for build instructions.
+#
+
+##############################
+# tweak the following according to your wishes
+##############################
+ac_add_options --disable-debug
+ac_add_options --enable-optimize
+ac_add_options --enable-strip
+#ac_add_options --enable-debug
+#ac_add_options --disable-optimize
+
+##############################
+# I build on a 4-cpu machine ; comment out or adapt to your own case
+##############################
+mk_add_options MOZ_MAKE_FLAGS="-s -j4"
+
+##############################
+# DO NOT MODIFY BELOW THIS LINE
+##############################
+ac_add_options --enable-application=bluegriffon
+# System directories
+mk_add_options MOZ_TOOLKIT_SEARCH=
+ac_add_options --prefix=/usr
+
+mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/bg
+mk_add_options MOZ_MEDIA_NAVIGATOR=1
+
+# System libraries
+ac_add_options --with-system-nspr
+ac_add_options --with-system-nss
+ac_add_options --with-system-libevent
+ac_add_options --with-system-libvpx
+ac_add_options --enable-system-hunspell
+ac_add_options --enable-system-sqlite
+#ac_add_options --enable-system-ffi
+#ac_add_options --enable-system-cairo
+ac_add_options --enable-system-pixman
+ac_add_options --with-system-jpeg
+ac_add_options --with-system-png
+ac_add_options --with-system-zlib
+ac_add_options --with-system-bz2
+ac_add_options --with-pthreads
+
+# Features
+ac_add_options --disable-necko-wifi
+ac_add_options --disable-tests
+ac_add_options --enable-default-toolkit=cairo-gtk3
+ac_add_options --disable-crashreporter
+ac_add_options --enable-safe-browsing
+ac_add_options --enable-gio
+ac_add_options --disable-gconf
+ac_add_options --disable-updater
+ac_add_options --disable-update-packaging
+ac_add_options --disable-webrtc
+ac_add_options --enable-startup-notification
+ac_add_options --enable-pulseaudio
+ac_add_options --disable-debug-symbols
+ac_add_options --enable-media-navigator
+



More information about the arch-commits mailing list