Unreviewed, rolling out r194362.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Dec 2015 20:37:33 +0000 (20:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Dec 2015 20:37:33 +0000 (20:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152508

crashes release bot (Requested by mcatanzaro on #webkit).

Reverted changeset:

"[GTK] Everything broken in GTK+ 3.19"
https://bugs.webkit.org/show_bug.cgi?id=150550
http://trac.webkit.org/changeset/194362

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194370 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/gtk/GRefPtrGtk.cpp
Source/WebCore/platform/gtk/GRefPtrGtk.h
Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
Source/WebCore/rendering/RenderThemeGtk.cpp

index f0b53dd..b95c4fa 100644 (file)
@@ -1,3 +1,16 @@
+2015-12-22  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r194362.
+        https://bugs.webkit.org/show_bug.cgi?id=152508
+
+        crashes release bot (Requested by mcatanzaro on #webkit).
+
+        Reverted changeset:
+
+        "[GTK] Everything broken in GTK+ 3.19"
+        https://bugs.webkit.org/show_bug.cgi?id=150550
+        http://trac.webkit.org/changeset/194362
+
 2015-12-22  Keith Miller  <keith_miller@apple.com>
 
         Remove OverridesHasInstance from TypeInfoFlags
index 7b4d692..3c28eb7 100644 (file)
@@ -72,22 +72,6 @@ template <> void derefGPtr(GdkCursor* ptr)
     if (ptr)
         gdk_cursor_unref(ptr);
 }
-
-#else
-
-template <> GtkWidgetPath* refGPtr(GtkWidgetPath* ptr)
-{
-    if (ptr)
-        gtk_widget_path_ref(ptr);
-    return ptr;
-}
-
-template <> void derefGPtr(GtkWidgetPath* ptr)
-{
-    if (ptr)
-        gtk_widget_path_unref(ptr);
-}
-
 #endif
 
 }
index c737e3d..8f0426d 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <wtf/glib/GRefPtr.h>
 
-typedef struct _GtkWidgetPath GtkWidgetPath;
 typedef struct _SecretValue SecretValue;
 
 namespace WTF {
@@ -39,9 +38,6 @@ template <> void derefGPtr(SecretValue* ptr);
 #ifdef GTK_API_VERSION_2
 template <> GdkCursor* refGPtr(GdkCursor* ptr);
 template <> void derefGPtr(GdkCursor* ptr);
-#else
-template <> GtkWidgetPath* refGPtr(GtkWidgetPath* ptr);
-template <> void derefGPtr(GtkWidgetPath* ptr);
 #endif
 
 }
index 16983e1..efaab30 100644 (file)
@@ -163,12 +163,6 @@ IntRect ScrollbarThemeGtk::trackRect(Scrollbar& scrollbar, bool)
 }
 
 #ifndef GTK_API_VERSION_2
-
-#if !GTK_CHECK_VERSION(3, 19, 2)
-// Currently we use a static GtkStyleContext for GTK+ < 3.19, and a bunch of unique
-// GtkStyleContexts for GTK+ >= 3.19. This is crazy and definitely should not be necessary, but I
-// couldn't find any other way to not break one version or the other. Ideally one of the two
-// people on the planet who really understand GTK+ styles would fix this.
 class ScrollbarStyleContext {
     WTF_MAKE_NONCOPYABLE(ScrollbarStyleContext); WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -197,7 +191,6 @@ static GtkStyleContext* gtkScrollbarStyleContext()
     static NeverDestroyed<ScrollbarStyleContext> styleContext;
     return styleContext.get().context();
 }
-#endif
 
 ScrollbarThemeGtk::ScrollbarThemeGtk()
 {
@@ -206,28 +199,14 @@ ScrollbarThemeGtk::ScrollbarThemeGtk()
 
 void ScrollbarThemeGtk::themeChanged()
 {
-#if !GTK_CHECK_VERSION(3, 19, 2)
     gtk_style_context_invalidate(gtkScrollbarStyleContext());
-#endif
     updateThemeProperties();
 }
 
 void ScrollbarThemeGtk::updateThemeProperties()
 {
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
-
-    gtk_style_context_set_path(styleContext.get(), path.get());
-#else
-    GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
-#endif
-
     gtk_style_context_get_style(
-        styleContext.get(),
+        gtkScrollbarStyleContext(),
         "min-slider-length", &m_minThumbLength,
         "slider-width", &m_thumbFatness,
         "trough-border", &m_troughBorderWidth,
@@ -293,19 +272,11 @@ IntRect ScrollbarThemeGtk::thumbRect(Scrollbar& scrollbar, const IntRect& uncons
     return IntRect(trackRect.x() + (trackRect.width() - m_thumbFatness) / 2, trackRect.y() + thumbPos, m_thumbFatness, thumbLength(scrollbar));
 }
 
-
-static const char* orientationStyleClass(ScrollbarOrientation orientation)
-{
-    return orientation == VerticalScrollbar ? "vertical" : "horizontal";
-}
-
-#if !GTK_CHECK_VERSION(3, 19, 2)
 static void applyScrollbarStyleContextClasses(GtkStyleContext* context, ScrollbarOrientation orientation)
 {
     gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCROLLBAR);
-    gtk_style_context_add_class(context, orientationStyleClass(orientation));
+    gtk_style_context_add_class(context, orientation == VerticalScrollbar ?  GTK_STYLE_CLASS_VERTICAL : GTK_STYLE_CLASS_HORIZONTAL);
 }
-#endif
 
 static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect)
 {
@@ -325,129 +296,62 @@ void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext& context, Scrollbar
     if (m_troughUnderSteppers)
         fullScrollbarRect = IntRect(scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height());
 
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
-    gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation()));
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
-
-    gtk_style_context_set_path(styleContext.get(), path.get());
-#else
-    GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
-    gtk_style_context_save(styleContext.get());
+    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+    gtk_style_context_save(styleContext);
 
-    applyScrollbarStyleContextClasses(styleContext.get(), scrollbar.orientation());
-    gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_TROUGH);
-#endif
+    applyScrollbarStyleContextClasses(styleContext, scrollbar.orientation());
+    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_TROUGH);
 
-    adjustRectAccordingToMargin(styleContext.get(), static_cast<GtkStateFlags>(0), fullScrollbarRect);
-    gtk_render_background(styleContext.get(), context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
-    gtk_render_frame(styleContext.get(), context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
+    adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(0), fullScrollbarRect);
+    gtk_render_background(styleContext, context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
+    gtk_render_frame(styleContext, context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
 
-#if !GTK_CHECK_VERSION(3, 19, 2)
-    gtk_style_context_restore(styleContext.get());
-#endif
+    gtk_style_context_restore(styleContext);
 }
 
 void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext& context, Scrollbar& scrollbar)
 {
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
-    gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation()));
-
-    gtk_style_context_set_path(styleContext.get(), path.get());
-#else
-    GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
-    gtk_style_context_save(styleContext.get());
-
-    applyScrollbarStyleContextClasses(styleContext.get(), scrollbar.orientation());
-    gtk_style_context_add_class(styleContext.get(), "scrolled-window");
-#endif
+    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+    gtk_style_context_save(styleContext);
 
-    gtk_render_frame(styleContext.get(), context.platformContext()->cr(), scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height());
+    applyScrollbarStyleContextClasses(styleContext, scrollbar.orientation());
+    gtk_style_context_add_class(styleContext, "scrolled-window");
+    gtk_render_frame(styleContext, context.platformContext()->cr(), scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height());
 
-#if !GTK_CHECK_VERSION(3, 19, 2)
-    gtk_style_context_restore(styleContext.get());
-#endif
+    gtk_style_context_restore(styleContext);
 }
 
 void ScrollbarThemeGtk::paintThumb(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect)
 {
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
-    gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation()));
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 2, "slider");
-
-    gtk_style_context_set_path(styleContext.get(), path.get());
-#else
-    GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
-    gtk_style_context_save(styleContext.get());
-#endif
+    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+    gtk_style_context_save(styleContext);
 
     ScrollbarOrientation orientation = scrollbar.orientation();
-#if !GTK_CHECK_VERSION(3, 19, 2)
-    applyScrollbarStyleContextClasses(styleContext.get(), orientation);
-    gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_SLIDER);
-#endif
+    applyScrollbarStyleContextClasses(styleContext, orientation);
+    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_SLIDER);
 
     guint flags = 0;
     if (scrollbar.pressedPart() == ThumbPart)
         flags |= GTK_STATE_FLAG_ACTIVE;
     if (scrollbar.hoveredPart() == ThumbPart)
         flags |= GTK_STATE_FLAG_PRELIGHT;
-    gtk_style_context_set_state(styleContext.get(), static_cast<GtkStateFlags>(flags));
+    gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags));
 
     IntRect thumbRect(rect);
-    adjustRectAccordingToMargin(styleContext.get(), static_cast<GtkStateFlags>(flags), thumbRect);
-    gtk_render_slider(styleContext.get(), context.platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),
+    adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(flags), thumbRect);
+    gtk_render_slider(styleContext, context.platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),
         orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
 
-#if !GTK_CHECK_VERSION(3, 19, 2)
-    gtk_style_context_restore(styleContext.get());
-#endif
+    gtk_style_context_restore(styleContext);
 }
 
 void ScrollbarThemeGtk::paintButton(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect, ScrollbarPart part)
 {
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
-    gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation()));
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "button");
-
-    gtk_style_context_set_path(styleContext.get(), path.get());
-#else
-    GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
-    gtk_style_context_save(styleContext.get());
-#endif
+    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+    gtk_style_context_save(styleContext);
 
     ScrollbarOrientation orientation = scrollbar.orientation();
-#if !GTK_CHECK_VERSION(3, 19, 2)
-    applyScrollbarStyleContextClasses(styleContext.get(), orientation);
-#endif
+    applyScrollbarStyleContextClasses(styleContext, orientation);
 
     guint flags = 0;
     if ((BackButtonStartPart == part && scrollbar.currentPos())
@@ -460,17 +364,14 @@ void ScrollbarThemeGtk::paintButton(GraphicsContext& context, Scrollbar& scrollb
             flags |= GTK_STATE_FLAG_PRELIGHT;
     } else
         flags |= GTK_STATE_FLAG_INSENSITIVE;
-    gtk_style_context_set_state(styleContext.get(), static_cast<GtkStateFlags>(flags));
+    gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags));
 
-#if !GTK_CHECK_VERSION(3, 19, 2)
-    gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_BUTTON);
-#endif
-
-    gtk_render_background(styleContext.get(), context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
-    gtk_render_frame(styleContext.get(), context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_BUTTON);
+    gtk_render_background(styleContext, context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+    gtk_render_frame(styleContext, context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
 
     gfloat arrowScaling;
-    gtk_style_context_get_style(styleContext.get(), "arrow-scaling", &arrowScaling, nullptr);
+    gtk_style_context_get_style(styleContext, "arrow-scaling", &arrowScaling, nullptr);
 
     double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling;
     FloatPoint arrowPoint(
@@ -479,7 +380,7 @@ void ScrollbarThemeGtk::paintButton(GraphicsContext& context, Scrollbar& scrollb
 
     if (flags & GTK_STATE_FLAG_ACTIVE) {
         gint arrowDisplacementX, arrowDisplacementY;
-        gtk_style_context_get_style(styleContext.get(), "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);
+        gtk_style_context_get_style(styleContext, "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);
         arrowPoint.move(arrowDisplacementX, arrowDisplacementY);
     }
 
@@ -489,11 +390,9 @@ void ScrollbarThemeGtk::paintButton(GraphicsContext& context, Scrollbar& scrollb
     else
         angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2);
 
-    gtk_render_arrow(styleContext.get(), context.platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
+    gtk_render_arrow(styleContext, context.platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
 
-#if !GTK_CHECK_VERSION(3, 19, 2)
-    gtk_style_context_restore(styleContext.get());
-#endif
+    gtk_style_context_restore(styleContext);
 }
 
 bool ScrollbarThemeGtk::paint(Scrollbar& scrollbar, GraphicsContext& graphicsContext, const IntRect& damageRect)
index 620f7c1..828f277 100644 (file)
@@ -152,62 +152,34 @@ static GRefPtr<GtkStyleContext> createStyleContext(GType widgetType)
         initialized = true;
     }
 
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-    gtk_widget_path_append_type(path.get(), widgetType);
+    GtkWidgetPath* path = gtk_widget_path_new();
+    gtk_widget_path_append_type(path, widgetType);
 
-#if GTK_CHECK_VERSION(3, 19, 2)
-    // Pick a good default object path for the style context based on the widget type. This will
-    // usually need to be overridden manually, but it doesn't hurt to have a good default.
     if (widgetType == GTK_TYPE_ENTRY)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "entry");
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_ENTRY);
     else if (widgetType == GTK_TYPE_ARROW)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "button"); // Note: not a typo.
+        gtk_widget_path_iter_add_class(path, 0, "arrow");
     else if (widgetType == GTK_TYPE_BUTTON) {
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "button");
-        gtk_widget_path_iter_add_class(path.get(), 0, "text-button");
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON);
+        gtk_widget_path_iter_add_class(path, 0, "text-button");
     } else if (widgetType == GTK_TYPE_SCALE)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCALE);
     else if (widgetType == GTK_TYPE_SEPARATOR)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "separator");
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SEPARATOR);
     else if (widgetType == GTK_TYPE_PROGRESS_BAR)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_PROGRESSBAR);
     else if (widgetType == GTK_TYPE_SPIN_BUTTON)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "spinbutton");
-    else if (widgetType == GTK_TYPE_TREE_VIEW) {
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "treeview");
-        gtk_widget_path_iter_add_class(path.get(), 0, "view");
-    } else if (widgetType == GTK_TYPE_CHECK_BUTTON)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "checkbutton");
-    else if (widgetType == GTK_TYPE_RADIO_BUTTON)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "radiobutton");
-    else if (widgetType == GTK_TYPE_COMBO_BOX)
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "combobox");
-#else
-    if (widgetType == GTK_TYPE_ENTRY)
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_ENTRY);
-    else if (widgetType == GTK_TYPE_ARROW)
-        gtk_widget_path_iter_add_class(path.get(), 0, "arrow");
-    else if (widgetType == GTK_TYPE_BUTTON) {
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_BUTTON);
-        gtk_widget_path_iter_add_class(path.get(), 0, "text-button");
-    } else if (widgetType == GTK_TYPE_SCALE)
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SCALE);
-    else if (widgetType == GTK_TYPE_SEPARATOR)
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SEPARATOR);
-    else if (widgetType == GTK_TYPE_PROGRESS_BAR)
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_PROGRESSBAR);
-    else if (widgetType == GTK_TYPE_SPIN_BUTTON)
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SPINBUTTON);
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SPINBUTTON);
     else if (widgetType == GTK_TYPE_TREE_VIEW)
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_VIEW);
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_VIEW);
     else if (widgetType == GTK_TYPE_CHECK_BUTTON)
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_CHECK);
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_CHECK);
     else if (widgetType == GTK_TYPE_RADIO_BUTTON)
-        gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_RADIO);
-#endif
+        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_RADIO);
 
     GRefPtr<GtkStyleContext> context = adoptGRef(gtk_style_context_new());
-    gtk_style_context_set_path(context.get(), path.get());
+    gtk_style_context_set_path(context.get(), path);
+    gtk_widget_path_free(path);
 
     return context;
 }
@@ -480,7 +452,9 @@ static void setToggleSize(GType widgetType, RenderStyle& style)
     if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto())
         return;
 
-    // Other ports hard-code this to 13. GTK+ users tend to demand the native look.
+    // Other ports hard-code this to 13 which is also the default value defined by GTK+.
+    // GTK+ users tend to demand the native look.
+    // It could be made a configuration option values other than 13 actually break site compatibility.
     gint indicatorSize;
     gtk_style_context_get_style(context.get(), "indicator-size", &indicatorSize, nullptr);
 
@@ -494,37 +468,6 @@ static void setToggleSize(GType widgetType, RenderStyle& style)
 static void paintToggle(const RenderThemeGtk* theme, GType widgetType, const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& fullRect)
 {
     GRefPtr<GtkStyleContext> context = createStyleContext(widgetType);
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    if (widgetType == GTK_TYPE_CHECK_BUTTON) {
-        if (theme->isChecked(renderObject) || theme->isIndeterminate(renderObject)) {
-            gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);
-            gtk_widget_path_iter_set_object_name(path.get(), 0, "checkbutton");
-        } else {
-            gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);
-            gtk_widget_path_iter_set_object_name(path.get(), 0, "button");
-            gtk_widget_path_iter_add_class(path.get(), 0, "check");
-        }
-
-        gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);
-        gtk_widget_path_iter_set_object_name(path.get(), 1, "check");
-    } else if (widgetType == GTK_TYPE_RADIO_BUTTON) {
-        if (theme->isChecked(renderObject) || theme->isIndeterminate(renderObject)) {
-            gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);
-            gtk_widget_path_iter_set_object_name(path.get(), 0, "radiobutton");
-        } else {
-            gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);
-            gtk_widget_path_iter_set_object_name(path.get(), 0, "button");
-            gtk_widget_path_iter_add_class(path.get(), 0, "radio");
-        }
-
-        gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);
-        gtk_widget_path_iter_set_object_name(path.get(), 1, "radio");
-    }
-
-    gtk_style_context_set_path(context.get(), path.get());
-#endif
 
     // Some themes do not render large toggle buttons properly, so we simply
     // shrink the rectangle back down to the default size and then center it
@@ -544,12 +487,7 @@ static void paintToggle(const RenderThemeGtk* theme, GType widgetType, const Ren
     }
 
     gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
-
-#if GTK_CHECK_VERSION(3, 19, 2)
-    gtk_style_context_add_class(context.get(), "toggle");
-#else
     gtk_style_context_add_class(context.get(), widgetType == GTK_TYPE_CHECK_BUTTON ? GTK_STYLE_CLASS_CHECK : GTK_STYLE_CLASS_RADIO);
-#endif
 
     guint flags = 0;
     if (!theme->isEnabled(renderObject))
@@ -676,9 +614,7 @@ bool RenderThemeGtk::paintButton(const RenderObject& renderObject, const PaintIn
     GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_BUTTON);
 
     gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
-#if !GTK_CHECK_VERSION(3, 19, 2)
     gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON);
-#endif
 
     renderButton(this, context.get(), renderObject, paintInfo, rect);
 
@@ -707,20 +643,8 @@ static void getComboBoxMetrics(RenderStyle& style, GtkBorder& border, int& focus
         return;
 
     GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_COMBO_BOX);
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_COMBO_BOX);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "combobox");
 
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_COMBO_BOX);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "button");
-    gtk_widget_path_iter_add_class(path.get(), 1, "combo");
-
-    gtk_style_context_set_path(context.get(), path.get());
-#else
     gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON);
-#endif
     gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(style.direction())));
 
     gtk_style_context_set_state(context.get(), static_cast<GtkStateFlags>(0));
@@ -735,9 +659,7 @@ static void getComboBoxMetrics(RenderStyle& style, GtkBorder& border, int& focus
 
     GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(style.direction()));
     gtk_style_context_set_direction(context.get(), direction);
-#if !GTK_CHECK_VERSION(3, 19, 2)
     gtk_style_context_add_class(context.get(), "separator");
-#endif
 
     gboolean wideSeparators;
     gint separatorWidth;
@@ -799,9 +721,7 @@ bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const Paint
     // Paint the button.
     GRefPtr<GtkStyleContext> buttonStyleContext = createStyleContext(GTK_TYPE_BUTTON);
     gtk_style_context_set_direction(buttonStyleContext.get(), direction);
-#if !GTK_CHECK_VERSION(3, 19, 2)
     gtk_style_context_add_class(buttonStyleContext.get(), GTK_STYLE_CLASS_BUTTON);
-#endif
     renderButton(this, buttonStyleContext.get(), renderObject, paintInfo, rect);
 
     // Get the inner rectangle.
@@ -838,10 +758,8 @@ bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const Paint
     GRefPtr<GtkStyleContext> arrowStyleContext = createStyleContext(GTK_TYPE_ARROW);
 
     gtk_style_context_set_direction(arrowStyleContext.get(), direction);
-#if !GTK_CHECK_VERSION(3, 19, 2)
     gtk_style_context_add_class(arrowStyleContext.get(), "arrow");
     gtk_style_context_add_class(arrowStyleContext.get(), GTK_STYLE_CLASS_BUTTON);
-#endif
 
     gfloat arrowScaling;
     gtk_style_context_get_style(arrowStyleContext.get(), "arrow-scaling", &arrowScaling, nullptr);
@@ -861,18 +779,9 @@ bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const Paint
 
     // Paint the separator if needed.
     GRefPtr<GtkStyleContext> separatorStyleContext = createStyleContext(GTK_TYPE_COMBO_BOX);
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SEPARATOR);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "separator");
-
-    gtk_style_context_set_path(separatorStyleContext.get(), path.get());
-#else
-    gtk_style_context_add_class(separatorStyleContext.get(), "separator");
-#endif
 
     gtk_style_context_set_direction(separatorStyleContext.get(), direction);
+    gtk_style_context_add_class(separatorStyleContext.get(), "separator");
 
     gboolean wideSeparators;
     gint separatorWidth;
@@ -922,9 +831,7 @@ bool RenderThemeGtk::paintTextField(const RenderObject& renderObject, const Pain
     GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_ENTRY);
 
     gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
-#if !GTK_CHECK_VERSION(3, 19, 2)
     gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_ENTRY);
-#endif
 
     guint flags = 0;
     if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
@@ -1134,9 +1041,7 @@ void RenderThemeGtk::adjustSliderThumbStyle(StyleResolver& styleResolver, Render
 
 static void applySliderStyleContextClasses(GtkStyleContext* context, ControlPart part)
 {
-#if !GTK_CHECK_VERSION(3, 19, 2)
     gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCALE);
-#endif
     if (part == SliderHorizontalPart || part == SliderThumbHorizontalPart)
         gtk_style_context_add_class(context, GTK_STYLE_CLASS_HORIZONTAL);
     else if (part == SliderVerticalPart || part == SliderThumbVerticalPart)
@@ -1149,23 +1054,10 @@ bool RenderThemeGtk::paintSliderTrack(const RenderObject& renderObject, const Pa
     ASSERT_UNUSED(part, part == SliderHorizontalPart || part == SliderVerticalPart || part == MediaVolumeSliderPart);
 
     GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_SCALE);
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
-
-    gtk_style_context_set_path(context.get(), path.get());
-#endif
 
     gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject.style().direction()));
     applySliderStyleContextClasses(context.get(), part);
-#if !GTK_CHECK_VERSION(3, 19, 2)
     gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH);
-#endif
 
     if (!isEnabled(renderObject))
         gtk_style_context_set_state(context.get(), GTK_STATE_FLAG_INSENSITIVE);
@@ -1190,24 +1082,10 @@ bool RenderThemeGtk::paintSliderThumb(const RenderObject& renderObject, const Pa
     ASSERT(part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart || part == MediaVolumeSliderThumbPart);
 
     GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_SCALE);
-#if GTK_CHECK_VERSION(3, 19, 2)
-    // FIXME: The entire slider is too wide, stretching the thumb into an oval rather than a circle.
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
-    gtk_widget_path_iter_set_object_name(path.get(), 2, "slider");
-
-    gtk_style_context_set_path(context.get(), path.get());
-#endif
 
     gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject.style().direction()));
     applySliderStyleContextClasses(context.get(), part);
+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_SLIDER);
 
     guint flags = 0;
     if (!isEnabled(renderObject))
@@ -1249,42 +1127,16 @@ bool RenderThemeGtk::paintProgressBar(const RenderObject& renderObject, const Pa
         return true;
 
     GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_PROGRESS_BAR);
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
-
-    gtk_style_context_set_path(context.get(), path.get());
-#else
     gtk_style_context_save(context.get());
+
     gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH);
-#endif
 
     gtk_render_background(context.get(), paintInfo.context().platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
     gtk_render_frame(context.get(), paintInfo.context().platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
 
-#if GTK_CHECK_VERSION(3, 19, 2)
-    path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
-    gtk_widget_path_iter_set_object_name(path.get(), 2, "progress");
-
-    gtk_style_context_set_path(context.get(), path.get());
-#else
     gtk_style_context_restore(context.get());
-    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_PROGRESSBAR);
-#endif
 
+    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_PROGRESSBAR);
     gtk_style_context_set_state(context.get(), static_cast<GtkStateFlags>(0));
 
     GtkBorder padding;
@@ -1336,21 +1188,7 @@ static void paintSpinArrowButton(RenderTheme* theme, GtkStyleContext* context, c
     ASSERT(arrowType == GTK_ARROW_UP || arrowType == GTK_ARROW_DOWN);
 
     gtk_style_context_save(context);
-
-#if GTK_CHECK_VERSION(3, 19, 2)
-    GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SPIN_BUTTON);
-    gtk_widget_path_iter_set_object_name(path.get(), 0, "spinbutton");
-
-    gtk_widget_path_append_type(path.get(), GTK_TYPE_SPIN_BUTTON);
-    gtk_widget_path_iter_set_object_name(path.get(), 1, "button");
-    gtk_widget_path_iter_add_class(path.get(), 1, arrowType == GTK_ARROW_UP ? "up" : "down");
-
-    gtk_style_context_set_path(context, path.get());
-#else
     gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
-#endif
 
     GtkTextDirection direction = gtk_style_context_get_direction(context);
     guint state = static_cast<guint>(gtk_style_context_get_state(context));
@@ -1451,28 +1289,16 @@ enum StyleColorType { StyleColorBackground, StyleColorForeground };
 
 static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType colorType)
 {
-    GRefPtr<GtkStyleContext> context = createStyleContext(widgetType);
-#if GTK_CHECK_VERSION(3, 19, 2)
-    if (widgetType == GTK_TYPE_ENTRY) {
-        GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
-
-        gtk_widget_path_append_type(path.get(), GTK_TYPE_ENTRY);
-        gtk_widget_path_iter_set_object_name(path.get(), 0, "entry");
-
-        gtk_widget_path_append_type(path.get(), GTK_TYPE_ENTRY);
-        gtk_widget_path_iter_set_object_name(path.get(), 1, "selection");
-
-        gtk_style_context_set_path(context.get(), path.get());
-    }
-#endif
 
+    GRefPtr<GtkStyleContext> context = createStyleContext(widgetType);
+    // Recent GTK+ versions (> 3.14) require to explicitly set the state before getting the color.
     gtk_style_context_set_state(context.get(), state);
 
     GdkRGBA gdkRGBAColor;
     if (colorType == StyleColorBackground)
-        gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor);
+        gtk_style_context_get_background_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor);
     else
-        gtk_style_context_get_color(context.get(), state, &gdkRGBAColor);
+        gtk_style_context_get_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor);
     return gdkRGBAColor;
 }