Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp (197250 => 197251)
--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp 2016-02-27 15:09:16 UTC (rev 197250)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp 2016-02-27 15:09:36 UTC (rev 197251)
@@ -30,6 +30,7 @@
#include "CSSValueKeywords.h"
#include "GraphicsContext.h"
#include "GtkVersioning.h"
+#include "GRefPtrGtk.h"
#include "HTMLNames.h"
#include "MediaControlElements.h"
#include "Page.h"
@@ -66,35 +67,64 @@
initialized = true;
}
- GtkWidgetPath* path = gtk_widget_path_new();
- gtk_widget_path_append_type(path, widgetType);
+ GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
+ gtk_widget_path_append_type(path.get(), 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_add_class(path, 0, GTK_STYLE_CLASS_ENTRY);
+ gtk_widget_path_iter_set_object_name(path.get(), 0, "entry");
else if (widgetType == GTK_TYPE_ARROW)
- gtk_widget_path_iter_add_class(path, 0, "arrow");
+ gtk_widget_path_iter_set_object_name(path.get(), 0, "button"); // Note: not a typo.
else if (widgetType == GTK_TYPE_BUTTON) {
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON);
- gtk_widget_path_iter_add_class(path, 0, "text-button");
+ gtk_widget_path_iter_set_object_name(path.get(), 0, "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, 0, GTK_STYLE_CLASS_SCALE);
+ gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");
else if (widgetType == GTK_TYPE_SEPARATOR)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SEPARATOR);
+ gtk_widget_path_iter_set_object_name(path.get(), 0, "separator");
else if (widgetType == GTK_TYPE_PROGRESS_BAR)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_PROGRESSBAR);
+ gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");
else if (widgetType == GTK_TYPE_SPIN_BUTTON)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SPINBUTTON);
+ 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);
else if (widgetType == GTK_TYPE_TREE_VIEW)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_VIEW);
+ gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_VIEW);
else if (widgetType == GTK_TYPE_CHECK_BUTTON)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_CHECK);
+ gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_CHECK);
else if (widgetType == GTK_TYPE_RADIO_BUTTON)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_RADIO);
+ gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_RADIO);
+#endif
GRefPtr<GtkStyleContext> context = adoptGRef(gtk_style_context_new());
- gtk_style_context_set_path(context.get(), path);
- gtk_widget_path_free(path);
+ gtk_style_context_set_path(context.get(), path.get());
return context;
}
@@ -181,7 +211,7 @@
adjustRectForFocus(context.get(), rect);
}
-static void setToggleSize(GType widgetType, RenderStyle& style)
+static void setToggleSize(GType widgetType, RenderStyle* style)
{
GRefPtr<GtkStyleContext> context = createStyleContext(widgetType);
@@ -189,9 +219,7 @@
if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
return;
- // 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.
+ // Other ports hard-code this to 13. GTK+ users tend to demand the native look.
gint indicatorSize;
gtk_style_context_get_style(context.get(), "indicator-size", &indicatorSize, nullptr);
@@ -205,7 +233,38 @@
static void paintToggle(const RenderThemeGtk* theme, GType widgetType, 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
@@ -224,7 +283,12 @@
}
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) || theme->isReadOnlyControl(renderObject))
@@ -351,7 +415,9 @@
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);
@@ -366,8 +432,20 @@
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));
@@ -382,7 +460,9 @@
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;
@@ -441,7 +521,9 @@
// 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.
@@ -477,8 +559,10 @@
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);
@@ -498,10 +582,19 @@
// 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_style_context_set_direction(separatorStyleContext.get(), direction);
+ 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);
+
gboolean wideSeparators;
gint separatorWidth;
gtk_style_context_get_style(separatorStyleContext.get(), "wide-separators", &wideSeparators, "separator-width", &separatorWidth, nullptr);
@@ -545,7 +638,9 @@
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))
@@ -573,7 +668,9 @@
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)
@@ -586,10 +683,23 @@
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) || isReadOnlyControl(renderObject))
gtk_style_context_set_state(context.get(), GTK_STATE_FLAG_INSENSITIVE);
@@ -614,10 +724,24 @@
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) || isReadOnlyControl(renderObject))
@@ -660,16 +784,42 @@
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;
@@ -720,7 +870,21 @@
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));
@@ -851,14 +1015,27 @@
static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType colorType)
{
GRefPtr<GtkStyleContext> context = createStyleContext(widgetType);
- // Recent GTK+ versions (> 3.14) require to explicitly set the state before getting the color.
+#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
+
gtk_style_context_set_state(context.get(), state);
GdkRGBA gdkRGBAColor;
if (colorType == StyleColorBackground)
- gtk_style_context_get_background_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor);
+ gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor);
else
- gtk_style_context_get_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor);
+ gtk_style_context_get_color(context.get(), state, &gdkRGBAColor);
return gdkRGBAColor;
}
Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp (197250 => 197251)
--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp 2016-02-27 15:09:16 UTC (rev 197250)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp 2016-02-27 15:09:36 UTC (rev 197251)
@@ -28,6 +28,7 @@
#ifndef GTK_API_VERSION_2
+#include "GRefPtrGtk.h"
#include "PlatformContextCairo.h"
#include "PlatformMouseEvent.h"
#include "ScrollView.h"
@@ -37,6 +38,11 @@
namespace WebCore {
+#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:
@@ -65,10 +71,13 @@
DEFINE_STATIC_LOCAL(ScrollbarStyleContext, styleContext, ());
return styleContext.context();
}
+#endif
void ScrollbarThemeGtk::themeChanged()
{
+#if !GTK_CHECK_VERSION(3, 19, 2)
gtk_style_context_invalidate(gtkScrollbarStyleContext());
+#endif
updateThemeProperties();
}
@@ -79,8 +88,19 @@
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(
- gtkScrollbarStyleContext(),
+ styleContext.get(),
"min-slider-length", &m_minThumbLength,
"slider-width", &m_thumbFatness,
"trough-border", &m_troughBorderWidth,
@@ -95,11 +115,18 @@
updateScrollbarsFrameThickness();
}
+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, orientation == VerticalScrollbar ? GTK_STYLE_CLASS_VERTICAL : GTK_STYLE_CLASS_HORIZONTAL);
}
+#endif
static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect)
{
@@ -119,62 +146,129 @@
if (m_troughUnderSteppers)
fullScrollbarRect = IntRect(scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
- GtkStyleContext* styleContext = gtkScrollbarStyleContext();
- gtk_style_context_save(styleContext);
+#if GTK_CHECK_VERSION(3, 19, 2)
+ GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
+ GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
- 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(), 0, "scrollbar");
+ gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar->orientation()));
- 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_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
+ gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
- gtk_style_context_restore(styleContext);
+ 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
}
void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
{
- GtkStyleContext* styleContext = gtkScrollbarStyleContext();
- gtk_style_context_save(styleContext);
+#if GTK_CHECK_VERSION(3, 19, 2)
+ GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
+ GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
- 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_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
+
+ 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);
+#endif
}
void ScrollbarThemeGtk::paintThumb(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
{
- GtkStyleContext* styleContext = gtkScrollbarStyleContext();
- gtk_style_context_save(styleContext);
+#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
+
ScrollbarOrientation orientation = scrollbar->orientation();
- applyScrollbarStyleContextClasses(styleContext, orientation);
- gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_SLIDER);
+#if !GTK_CHECK_VERSION(3, 19, 2)
+ applyScrollbarStyleContextClasses(styleContext.get(), orientation);
+ gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_SLIDER);
+#endif
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, static_cast<GtkStateFlags>(flags));
+ gtk_style_context_set_state(styleContext.get(), static_cast<GtkStateFlags>(flags));
IntRect thumbRect(rect);
- adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(flags), thumbRect);
- gtk_render_slider(styleContext, context->platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),
+ adjustRectAccordingToMargin(styleContext.get(), static_cast<GtkStateFlags>(flags), thumbRect);
+ gtk_render_slider(styleContext.get(), 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);
+#endif
}
void ScrollbarThemeGtk::paintButton(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect, ScrollbarPart part)
{
- GtkStyleContext* styleContext = gtkScrollbarStyleContext();
- gtk_style_context_save(styleContext);
+#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
+
ScrollbarOrientation orientation = scrollbar->orientation();
- applyScrollbarStyleContextClasses(styleContext, orientation);
+#if !GTK_CHECK_VERSION(3, 19, 2)
+ applyScrollbarStyleContextClasses(styleContext.get(), orientation);
+#endif
guint flags = 0;
if ((BackButtonStartPart == part && scrollbar->currentPos())
@@ -187,14 +281,16 @@
flags |= GTK_STATE_FLAG_PRELIGHT;
} else
flags |= GTK_STATE_FLAG_INSENSITIVE;
- gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags));
+ gtk_style_context_set_state(styleContext.get(), static_cast<GtkStateFlags>(flags));
- 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());
+#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());
gfloat arrowScaling;
- gtk_style_context_get_style(styleContext, "arrow-scaling", &arrowScaling, NULL);
+ gtk_style_context_get_style(styleContext.get(), "arrow-scaling", &arrowScaling, nullptr);
double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling;
FloatPoint arrowPoint(rect.x() + (rect.width() - arrowSize) / 2,
@@ -202,7 +298,7 @@
if (flags & GTK_STATE_FLAG_ACTIVE) {
gint arrowDisplacementX, arrowDisplacementY;
- gtk_style_context_get_style(styleContext, "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);
+ gtk_style_context_get_style(styleContext.get(), "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);
arrowPoint.move(arrowDisplacementX, arrowDisplacementY);
}
@@ -213,9 +309,11 @@
angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2);
}
- gtk_render_arrow(styleContext, context->platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
+ gtk_render_arrow(styleContext.get(), context->platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
+#if !GTK_CHECK_VERSION(3, 19, 2)
gtk_style_context_restore(styleContext);
+#endif
}
} // namespace WebCore