Modified: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (194369 => 194370)
--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp 2015-12-22 20:04:56 UTC (rev 194369)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp 2015-12-22 20:37:33 UTC (rev 194370)
@@ -163,12 +163,6 @@
}
#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 NeverDestroyed<ScrollbarStyleContext> styleContext;
return styleContext.get().context();
}
-#endif
ScrollbarThemeGtk::ScrollbarThemeGtk()
{
@@ -206,28 +199,14 @@
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 @@
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 @@
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());
+ GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+ gtk_style_context_save(styleContext);
- 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()));
+ applyScrollbarStyleContextClasses(styleContext, scrollbar.orientation());
+ gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_TROUGH);
- gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
- gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
+ 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());
- 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(), GTK_STYLE_CLASS_TROUGH);
-#endif
-
- 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());
-
-#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());
+ GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+ gtk_style_context_save(styleContext);
- 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()));
+ 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());
- 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
-
- gtk_render_frame(styleContext.get(), 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());
+ GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+ gtk_style_context_save(styleContext);
- 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
-
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());
+ GtkStyleContext* styleContext = gtkScrollbarStyleContext();
+ gtk_style_context_save(styleContext);
- 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
-
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 @@
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_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());
- 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());
-
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 @@
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 @@
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)
Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.cpp (194369 => 194370)
--- trunk/Source/WebCore/rendering/RenderThemeGtk.cpp 2015-12-22 20:04:56 UTC (rev 194369)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.cpp 2015-12-22 20:37:33 UTC (rev 194370)
@@ -152,62 +152,34 @@
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 @@
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,38 +468,7 @@
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
// in the full toggle button region. The reason for not simply forcing toggle
@@ -544,12 +487,7 @@
}
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 @@
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 @@
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 @@
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 @@
// 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 @@
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,19 +779,10 @@
// 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_set_direction(separatorStyleContext.get(), direction);
gtk_style_context_add_class(separatorStyleContext.get(), "separator");
-#endif
- gtk_style_context_set_direction(separatorStyleContext.get(), direction);
-
gboolean wideSeparators;
gint separatorWidth;
gtk_style_context_get_style(separatorStyleContext.get(), "wide-separators", &wideSeparators, "separator-width", &separatorWidth, nullptr);
@@ -922,9 +831,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
}