Changeset 194370 in webkit


Ignore:
Timestamp:
Dec 22, 2015, 12:37:33 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

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

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r194369 r194370  
     12015-12-22  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r194362.
     4        https://bugs.webkit.org/show_bug.cgi?id=152508
     5
     6        crashes release bot (Requested by mcatanzaro on #webkit).
     7
     8        Reverted changeset:
     9
     10        "[GTK] Everything broken in GTK+ 3.19"
     11        https://bugs.webkit.org/show_bug.cgi?id=150550
     12        http://trac.webkit.org/changeset/194362
     13
    1142015-12-22  Keith Miller  <keith_miller@apple.com>
    215
  • trunk/Source/WebCore/platform/gtk/GRefPtrGtk.cpp

    r194362 r194370  
    7373        gdk_cursor_unref(ptr);
    7474}
    75 
    76 #else
    77 
    78 template <> GtkWidgetPath* refGPtr(GtkWidgetPath* ptr)
    79 {
    80     if (ptr)
    81         gtk_widget_path_ref(ptr);
    82     return ptr;
    83 }
    84 
    85 template <> void derefGPtr(GtkWidgetPath* ptr)
    86 {
    87     if (ptr)
    88         gtk_widget_path_unref(ptr);
    89 }
    90 
    9175#endif
    9276
  • trunk/Source/WebCore/platform/gtk/GRefPtrGtk.h

    r194362 r194370  
    2424#include <wtf/glib/GRefPtr.h>
    2525
    26 typedef struct _GtkWidgetPath GtkWidgetPath;
    2726typedef struct _SecretValue SecretValue;
    2827
     
    4039template <> GdkCursor* refGPtr(GdkCursor* ptr);
    4140template <> void derefGPtr(GdkCursor* ptr);
    42 #else
    43 template <> GtkWidgetPath* refGPtr(GtkWidgetPath* ptr);
    44 template <> void derefGPtr(GtkWidgetPath* ptr);
    4541#endif
    4642
  • trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp

    r194362 r194370  
    164164
    165165#ifndef GTK_API_VERSION_2
    166 
    167 #if !GTK_CHECK_VERSION(3, 19, 2)
    168 // Currently we use a static GtkStyleContext for GTK+ < 3.19, and a bunch of unique
    169 // GtkStyleContexts for GTK+ >= 3.19. This is crazy and definitely should not be necessary, but I
    170 // couldn't find any other way to not break one version or the other. Ideally one of the two
    171 // people on the planet who really understand GTK+ styles would fix this.
    172166class ScrollbarStyleContext {
    173167    WTF_MAKE_NONCOPYABLE(ScrollbarStyleContext); WTF_MAKE_FAST_ALLOCATED;
     
    198192    return styleContext.get().context();
    199193}
    200 #endif
    201194
    202195ScrollbarThemeGtk::ScrollbarThemeGtk()
     
    207200void ScrollbarThemeGtk::themeChanged()
    208201{
    209 #if !GTK_CHECK_VERSION(3, 19, 2)
    210202    gtk_style_context_invalidate(gtkScrollbarStyleContext());
    211 #endif
    212203    updateThemeProperties();
    213204}
     
    215206void ScrollbarThemeGtk::updateThemeProperties()
    216207{
    217 #if GTK_CHECK_VERSION(3, 19, 2)
    218     GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
    219     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    220 
    221     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    222     gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
    223 
    224     gtk_style_context_set_path(styleContext.get(), path.get());
    225 #else
    226     GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
    227 #endif
    228 
    229208    gtk_style_context_get_style(
    230         styleContext.get(),
     209        gtkScrollbarStyleContext(),
    231210        "min-slider-length", &m_minThumbLength,
    232211        "slider-width", &m_thumbFatness,
     
    294273}
    295274
    296 
    297 static const char* orientationStyleClass(ScrollbarOrientation orientation)
    298 {
    299     return orientation == VerticalScrollbar ? "vertical" : "horizontal";
    300 }
    301 
    302 #if !GTK_CHECK_VERSION(3, 19, 2)
    303275static void applyScrollbarStyleContextClasses(GtkStyleContext* context, ScrollbarOrientation orientation)
    304276{
    305277    gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCROLLBAR);
    306     gtk_style_context_add_class(context, orientationStyleClass(orientation));
    307 }
    308 #endif
     278    gtk_style_context_add_class(context, orientation == VerticalScrollbar ?  GTK_STYLE_CLASS_VERTICAL : GTK_STYLE_CLASS_HORIZONTAL);
     279}
    309280
    310281static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect)
     
    326297        fullScrollbarRect = IntRect(scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height());
    327298
    328 #if GTK_CHECK_VERSION(3, 19, 2)
    329     GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
    330     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    331 
    332     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    333     gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
    334     gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation()));
    335 
    336     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    337     gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
    338 
    339     gtk_style_context_set_path(styleContext.get(), path.get());
    340 #else
    341     GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
    342     gtk_style_context_save(styleContext.get());
    343 
    344     applyScrollbarStyleContextClasses(styleContext.get(), scrollbar.orientation());
    345     gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_TROUGH);
    346 #endif
    347 
    348     adjustRectAccordingToMargin(styleContext.get(), static_cast<GtkStateFlags>(0), fullScrollbarRect);
    349     gtk_render_background(styleContext.get(), context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
    350     gtk_render_frame(styleContext.get(), context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
    351 
    352 #if !GTK_CHECK_VERSION(3, 19, 2)
    353     gtk_style_context_restore(styleContext.get());
    354 #endif
     299    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
     300    gtk_style_context_save(styleContext);
     301
     302    applyScrollbarStyleContextClasses(styleContext, scrollbar.orientation());
     303    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_TROUGH);
     304
     305    adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(0), fullScrollbarRect);
     306    gtk_render_background(styleContext, context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
     307    gtk_render_frame(styleContext, context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
     308
     309    gtk_style_context_restore(styleContext);
    355310}
    356311
    357312void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext& context, Scrollbar& scrollbar)
    358313{
    359 #if GTK_CHECK_VERSION(3, 19, 2)
    360     GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
    361     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    362 
    363     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    364     gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
    365     gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation()));
    366 
    367     gtk_style_context_set_path(styleContext.get(), path.get());
    368 #else
    369     GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
    370     gtk_style_context_save(styleContext.get());
    371 
    372     applyScrollbarStyleContextClasses(styleContext.get(), scrollbar.orientation());
    373     gtk_style_context_add_class(styleContext.get(), "scrolled-window");
    374 #endif
    375 
    376     gtk_render_frame(styleContext.get(), context.platformContext()->cr(), scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height());
    377 
    378 #if !GTK_CHECK_VERSION(3, 19, 2)
    379     gtk_style_context_restore(styleContext.get());
    380 #endif
     314    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
     315    gtk_style_context_save(styleContext);
     316
     317    applyScrollbarStyleContextClasses(styleContext, scrollbar.orientation());
     318    gtk_style_context_add_class(styleContext, "scrolled-window");
     319    gtk_render_frame(styleContext, context.platformContext()->cr(), scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height());
     320
     321    gtk_style_context_restore(styleContext);
    381322}
    382323
    383324void ScrollbarThemeGtk::paintThumb(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect)
    384325{
    385 #if GTK_CHECK_VERSION(3, 19, 2)
    386     GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
    387     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    388 
    389     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    390     gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
    391     gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation()));
    392 
    393     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    394     gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
    395 
    396     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    397     gtk_widget_path_iter_set_object_name(path.get(), 2, "slider");
    398 
    399     gtk_style_context_set_path(styleContext.get(), path.get());
    400 #else
    401     GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
    402     gtk_style_context_save(styleContext.get());
    403 #endif
     326    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
     327    gtk_style_context_save(styleContext);
    404328
    405329    ScrollbarOrientation orientation = scrollbar.orientation();
    406 #if !GTK_CHECK_VERSION(3, 19, 2)
    407     applyScrollbarStyleContextClasses(styleContext.get(), orientation);
    408     gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_SLIDER);
    409 #endif
     330    applyScrollbarStyleContextClasses(styleContext, orientation);
     331    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_SLIDER);
    410332
    411333    guint flags = 0;
     
    414336    if (scrollbar.hoveredPart() == ThumbPart)
    415337        flags |= GTK_STATE_FLAG_PRELIGHT;
    416     gtk_style_context_set_state(styleContext.get(), static_cast<GtkStateFlags>(flags));
     338    gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags));
    417339
    418340    IntRect thumbRect(rect);
    419     adjustRectAccordingToMargin(styleContext.get(), static_cast<GtkStateFlags>(flags), thumbRect);
    420     gtk_render_slider(styleContext.get(), context.platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),
     341    adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(flags), thumbRect);
     342    gtk_render_slider(styleContext, context.platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),
    421343        orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
    422344
    423 #if !GTK_CHECK_VERSION(3, 19, 2)
    424     gtk_style_context_restore(styleContext.get());
    425 #endif
     345    gtk_style_context_restore(styleContext);
    426346}
    427347
    428348void ScrollbarThemeGtk::paintButton(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect, ScrollbarPart part)
    429349{
    430 #if GTK_CHECK_VERSION(3, 19, 2)
    431     GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());
    432     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    433 
    434     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    435     gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");
    436     gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation()));
    437 
    438     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);
    439     gtk_widget_path_iter_set_object_name(path.get(), 1, "button");
    440 
    441     gtk_style_context_set_path(styleContext.get(), path.get());
    442 #else
    443     GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();
    444     gtk_style_context_save(styleContext.get());
    445 #endif
     350    GtkStyleContext* styleContext = gtkScrollbarStyleContext();
     351    gtk_style_context_save(styleContext);
    446352
    447353    ScrollbarOrientation orientation = scrollbar.orientation();
    448 #if !GTK_CHECK_VERSION(3, 19, 2)
    449     applyScrollbarStyleContextClasses(styleContext.get(), orientation);
    450 #endif
     354    applyScrollbarStyleContextClasses(styleContext, orientation);
    451355
    452356    guint flags = 0;
     
    461365    } else
    462366        flags |= GTK_STATE_FLAG_INSENSITIVE;
    463     gtk_style_context_set_state(styleContext.get(), static_cast<GtkStateFlags>(flags));
    464 
    465 #if !GTK_CHECK_VERSION(3, 19, 2)
    466     gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_BUTTON);
    467 #endif
    468 
    469     gtk_render_background(styleContext.get(), context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
    470     gtk_render_frame(styleContext.get(), context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
     367    gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags));
     368
     369    gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_BUTTON);
     370    gtk_render_background(styleContext, context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
     371    gtk_render_frame(styleContext, context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
    471372
    472373    gfloat arrowScaling;
    473     gtk_style_context_get_style(styleContext.get(), "arrow-scaling", &arrowScaling, nullptr);
     374    gtk_style_context_get_style(styleContext, "arrow-scaling", &arrowScaling, nullptr);
    474375
    475376    double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling;
     
    480381    if (flags & GTK_STATE_FLAG_ACTIVE) {
    481382        gint arrowDisplacementX, arrowDisplacementY;
    482         gtk_style_context_get_style(styleContext.get(), "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);
     383        gtk_style_context_get_style(styleContext, "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);
    483384        arrowPoint.move(arrowDisplacementX, arrowDisplacementY);
    484385    }
     
    490391        angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2);
    491392
    492     gtk_render_arrow(styleContext.get(), context.platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
    493 
    494 #if !GTK_CHECK_VERSION(3, 19, 2)
    495     gtk_style_context_restore(styleContext.get());
    496 #endif
     393    gtk_render_arrow(styleContext, context.platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
     394
     395    gtk_style_context_restore(styleContext);
    497396}
    498397
  • trunk/Source/WebCore/rendering/RenderThemeGtk.cpp

    r194362 r194370  
    153153    }
    154154
    155     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    156     gtk_widget_path_append_type(path.get(), widgetType);
    157 
    158 #if GTK_CHECK_VERSION(3, 19, 2)
    159     // Pick a good default object path for the style context based on the widget type. This will
    160     // usually need to be overridden manually, but it doesn't hurt to have a good default.
     155    GtkWidgetPath* path = gtk_widget_path_new();
     156    gtk_widget_path_append_type(path, widgetType);
     157
    161158    if (widgetType == GTK_TYPE_ENTRY)
    162         gtk_widget_path_iter_set_object_name(path.get(), 0, "entry");
     159        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_ENTRY);
    163160    else if (widgetType == GTK_TYPE_ARROW)
    164         gtk_widget_path_iter_set_object_name(path.get(), 0, "button"); // Note: not a typo.
     161        gtk_widget_path_iter_add_class(path, 0, "arrow");
    165162    else if (widgetType == GTK_TYPE_BUTTON) {
    166         gtk_widget_path_iter_set_object_name(path.get(), 0, "button");
    167         gtk_widget_path_iter_add_class(path.get(), 0, "text-button");
     163        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON);
     164        gtk_widget_path_iter_add_class(path, 0, "text-button");
    168165    } else if (widgetType == GTK_TYPE_SCALE)
    169         gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");
     166        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCALE);
    170167    else if (widgetType == GTK_TYPE_SEPARATOR)
    171         gtk_widget_path_iter_set_object_name(path.get(), 0, "separator");
     168        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SEPARATOR);
    172169    else if (widgetType == GTK_TYPE_PROGRESS_BAR)
    173         gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");
     170        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_PROGRESSBAR);
    174171    else if (widgetType == GTK_TYPE_SPIN_BUTTON)
    175         gtk_widget_path_iter_set_object_name(path.get(), 0, "spinbutton");
    176     else if (widgetType == GTK_TYPE_TREE_VIEW) {
    177         gtk_widget_path_iter_set_object_name(path.get(), 0, "treeview");
    178         gtk_widget_path_iter_add_class(path.get(), 0, "view");
    179     } else if (widgetType == GTK_TYPE_CHECK_BUTTON)
    180         gtk_widget_path_iter_set_object_name(path.get(), 0, "checkbutton");
     172        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SPINBUTTON);
     173    else if (widgetType == GTK_TYPE_TREE_VIEW)
     174        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_VIEW);
     175    else if (widgetType == GTK_TYPE_CHECK_BUTTON)
     176        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_CHECK);
    181177    else if (widgetType == GTK_TYPE_RADIO_BUTTON)
    182         gtk_widget_path_iter_set_object_name(path.get(), 0, "radiobutton");
    183     else if (widgetType == GTK_TYPE_COMBO_BOX)
    184         gtk_widget_path_iter_set_object_name(path.get(), 0, "combobox");
    185 #else
    186     if (widgetType == GTK_TYPE_ENTRY)
    187         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_ENTRY);
    188     else if (widgetType == GTK_TYPE_ARROW)
    189         gtk_widget_path_iter_add_class(path.get(), 0, "arrow");
    190     else if (widgetType == GTK_TYPE_BUTTON) {
    191         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_BUTTON);
    192         gtk_widget_path_iter_add_class(path.get(), 0, "text-button");
    193     } else if (widgetType == GTK_TYPE_SCALE)
    194         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SCALE);
    195     else if (widgetType == GTK_TYPE_SEPARATOR)
    196         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SEPARATOR);
    197     else if (widgetType == GTK_TYPE_PROGRESS_BAR)
    198         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_PROGRESSBAR);
    199     else if (widgetType == GTK_TYPE_SPIN_BUTTON)
    200         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SPINBUTTON);
    201     else if (widgetType == GTK_TYPE_TREE_VIEW)
    202         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_VIEW);
    203     else if (widgetType == GTK_TYPE_CHECK_BUTTON)
    204         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_CHECK);
    205     else if (widgetType == GTK_TYPE_RADIO_BUTTON)
    206         gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_RADIO);
    207 #endif
     178        gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_RADIO);
    208179
    209180    GRefPtr<GtkStyleContext> context = adoptGRef(gtk_style_context_new());
    210     gtk_style_context_set_path(context.get(), path.get());
     181    gtk_style_context_set_path(context.get(), path);
     182    gtk_widget_path_free(path);
    211183
    212184    return context;
     
    481453        return;
    482454
    483     // Other ports hard-code this to 13. GTK+ users tend to demand the native look.
     455    // Other ports hard-code this to 13 which is also the default value defined by GTK+.
     456    // GTK+ users tend to demand the native look.
     457    // It could be made a configuration option values other than 13 actually break site compatibility.
    484458    gint indicatorSize;
    485459    gtk_style_context_get_style(context.get(), "indicator-size", &indicatorSize, nullptr);
     
    495469{
    496470    GRefPtr<GtkStyleContext> context = createStyleContext(widgetType);
    497 #if GTK_CHECK_VERSION(3, 19, 2)
    498     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    499 
    500     if (widgetType == GTK_TYPE_CHECK_BUTTON) {
    501         if (theme->isChecked(renderObject) || theme->isIndeterminate(renderObject)) {
    502             gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);
    503             gtk_widget_path_iter_set_object_name(path.get(), 0, "checkbutton");
    504         } else {
    505             gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);
    506             gtk_widget_path_iter_set_object_name(path.get(), 0, "button");
    507             gtk_widget_path_iter_add_class(path.get(), 0, "check");
    508         }
    509 
    510         gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);
    511         gtk_widget_path_iter_set_object_name(path.get(), 1, "check");
    512     } else if (widgetType == GTK_TYPE_RADIO_BUTTON) {
    513         if (theme->isChecked(renderObject) || theme->isIndeterminate(renderObject)) {
    514             gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);
    515             gtk_widget_path_iter_set_object_name(path.get(), 0, "radiobutton");
    516         } else {
    517             gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);
    518             gtk_widget_path_iter_set_object_name(path.get(), 0, "button");
    519             gtk_widget_path_iter_add_class(path.get(), 0, "radio");
    520         }
    521 
    522         gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);
    523         gtk_widget_path_iter_set_object_name(path.get(), 1, "radio");
    524     }
    525 
    526     gtk_style_context_set_path(context.get(), path.get());
    527 #endif
    528471
    529472    // Some themes do not render large toggle buttons properly, so we simply
     
    545488
    546489    gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
    547 
    548 #if GTK_CHECK_VERSION(3, 19, 2)
    549     gtk_style_context_add_class(context.get(), "toggle");
    550 #else
    551490    gtk_style_context_add_class(context.get(), widgetType == GTK_TYPE_CHECK_BUTTON ? GTK_STYLE_CLASS_CHECK : GTK_STYLE_CLASS_RADIO);
    552 #endif
    553491
    554492    guint flags = 0;
     
    677615
    678616    gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
    679 #if !GTK_CHECK_VERSION(3, 19, 2)
    680617    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON);
    681 #endif
    682618
    683619    renderButton(this, context.get(), renderObject, paintInfo, rect);
     
    708644
    709645    GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_COMBO_BOX);
    710 #if GTK_CHECK_VERSION(3, 19, 2)
    711     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    712 
    713     gtk_widget_path_append_type(path.get(), GTK_TYPE_COMBO_BOX);
    714     gtk_widget_path_iter_set_object_name(path.get(), 0, "combobox");
    715 
    716     gtk_widget_path_append_type(path.get(), GTK_TYPE_COMBO_BOX);
    717     gtk_widget_path_iter_set_object_name(path.get(), 1, "button");
    718     gtk_widget_path_iter_add_class(path.get(), 1, "combo");
    719 
    720     gtk_style_context_set_path(context.get(), path.get());
    721 #else
     646
    722647    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON);
    723 #endif
    724648    gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(style.direction())));
    725649
     
    736660    GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(style.direction()));
    737661    gtk_style_context_set_direction(context.get(), direction);
    738 #if !GTK_CHECK_VERSION(3, 19, 2)
    739662    gtk_style_context_add_class(context.get(), "separator");
    740 #endif
    741663
    742664    gboolean wideSeparators;
     
    800722    GRefPtr<GtkStyleContext> buttonStyleContext = createStyleContext(GTK_TYPE_BUTTON);
    801723    gtk_style_context_set_direction(buttonStyleContext.get(), direction);
    802 #if !GTK_CHECK_VERSION(3, 19, 2)
    803724    gtk_style_context_add_class(buttonStyleContext.get(), GTK_STYLE_CLASS_BUTTON);
    804 #endif
    805725    renderButton(this, buttonStyleContext.get(), renderObject, paintInfo, rect);
    806726
     
    839759
    840760    gtk_style_context_set_direction(arrowStyleContext.get(), direction);
    841 #if !GTK_CHECK_VERSION(3, 19, 2)
    842761    gtk_style_context_add_class(arrowStyleContext.get(), "arrow");
    843762    gtk_style_context_add_class(arrowStyleContext.get(), GTK_STYLE_CLASS_BUTTON);
    844 #endif
    845763
    846764    gfloat arrowScaling;
     
    862780    // Paint the separator if needed.
    863781    GRefPtr<GtkStyleContext> separatorStyleContext = createStyleContext(GTK_TYPE_COMBO_BOX);
    864 #if GTK_CHECK_VERSION(3, 19, 2)
    865     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    866 
    867     gtk_widget_path_append_type(path.get(), GTK_TYPE_SEPARATOR);
    868     gtk_widget_path_iter_set_object_name(path.get(), 0, "separator");
    869 
    870     gtk_style_context_set_path(separatorStyleContext.get(), path.get());
    871 #else
     782
     783    gtk_style_context_set_direction(separatorStyleContext.get(), direction);
    872784    gtk_style_context_add_class(separatorStyleContext.get(), "separator");
    873 #endif
    874 
    875     gtk_style_context_set_direction(separatorStyleContext.get(), direction);
    876785
    877786    gboolean wideSeparators;
     
    923832
    924833    gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
    925 #if !GTK_CHECK_VERSION(3, 19, 2)
    926834    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_ENTRY);
    927 #endif
    928835
    929836    guint flags = 0;
     
    11351042static void applySliderStyleContextClasses(GtkStyleContext* context, ControlPart part)
    11361043{
    1137 #if !GTK_CHECK_VERSION(3, 19, 2)
    11381044    gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCALE);
    1139 #endif
    11401045    if (part == SliderHorizontalPart || part == SliderThumbHorizontalPart)
    11411046        gtk_style_context_add_class(context, GTK_STYLE_CLASS_HORIZONTAL);
     
    11501055
    11511056    GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_SCALE);
    1152 #if GTK_CHECK_VERSION(3, 19, 2)
    1153     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    1154 
    1155     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
    1156     gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");
    1157 
    1158     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
    1159     gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
    1160 
    1161     gtk_style_context_set_path(context.get(), path.get());
    1162 #endif
    11631057
    11641058    gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject.style().direction()));
    11651059    applySliderStyleContextClasses(context.get(), part);
    1166 #if !GTK_CHECK_VERSION(3, 19, 2)
    11671060    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH);
    1168 #endif
    11691061
    11701062    if (!isEnabled(renderObject))
     
    11911083
    11921084    GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_SCALE);
    1193 #if GTK_CHECK_VERSION(3, 19, 2)
    1194     // FIXME: The entire slider is too wide, stretching the thumb into an oval rather than a circle.
    1195     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    1196 
    1197     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
    1198     gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");
    1199 
    1200     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
    1201     gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
    1202 
    1203     gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);
    1204     gtk_widget_path_iter_set_object_name(path.get(), 2, "slider");
    1205 
    1206     gtk_style_context_set_path(context.get(), path.get());
    1207 #endif
    12081085
    12091086    gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject.style().direction()));
    12101087    applySliderStyleContextClasses(context.get(), part);
     1088    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_SLIDER);
    12111089
    12121090    guint flags = 0;
     
    12501128
    12511129    GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_PROGRESS_BAR);
    1252 #if GTK_CHECK_VERSION(3, 19, 2)
    1253     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    1254 
    1255     gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
    1256     gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");
    1257 
    1258     gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
    1259     gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
    1260 
    1261     gtk_style_context_set_path(context.get(), path.get());
    1262 #else
    12631130    gtk_style_context_save(context.get());
     1131
    12641132    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH);
    1265 #endif
    12661133
    12671134    gtk_render_background(context.get(), paintInfo.context().platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
    12681135    gtk_render_frame(context.get(), paintInfo.context().platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
    12691136
    1270 #if GTK_CHECK_VERSION(3, 19, 2)
    1271     path = adoptGRef(gtk_widget_path_new());
    1272 
    1273     gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
    1274     gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");
    1275 
    1276     gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
    1277     gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");
    1278 
    1279     gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);
    1280     gtk_widget_path_iter_set_object_name(path.get(), 2, "progress");
    1281 
    1282     gtk_style_context_set_path(context.get(), path.get());
    1283 #else
    12841137    gtk_style_context_restore(context.get());
     1138
    12851139    gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_PROGRESSBAR);
    1286 #endif
    1287 
    12881140    gtk_style_context_set_state(context.get(), static_cast<GtkStateFlags>(0));
    12891141
     
    13371189
    13381190    gtk_style_context_save(context);
    1339 
    1340 #if GTK_CHECK_VERSION(3, 19, 2)
    1341     GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    1342 
    1343     gtk_widget_path_append_type(path.get(), GTK_TYPE_SPIN_BUTTON);
    1344     gtk_widget_path_iter_set_object_name(path.get(), 0, "spinbutton");
    1345 
    1346     gtk_widget_path_append_type(path.get(), GTK_TYPE_SPIN_BUTTON);
    1347     gtk_widget_path_iter_set_object_name(path.get(), 1, "button");
    1348     gtk_widget_path_iter_add_class(path.get(), 1, arrowType == GTK_ARROW_UP ? "up" : "down");
    1349 
    1350     gtk_style_context_set_path(context, path.get());
    1351 #else
    13521191    gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
    1353 #endif
    13541192
    13551193    GtkTextDirection direction = gtk_style_context_get_direction(context);
     
    14521290static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType colorType)
    14531291{
     1292
    14541293    GRefPtr<GtkStyleContext> context = createStyleContext(widgetType);
    1455 #if GTK_CHECK_VERSION(3, 19, 2)
    1456     if (widgetType == GTK_TYPE_ENTRY) {
    1457         GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());
    1458 
    1459         gtk_widget_path_append_type(path.get(), GTK_TYPE_ENTRY);
    1460         gtk_widget_path_iter_set_object_name(path.get(), 0, "entry");
    1461 
    1462         gtk_widget_path_append_type(path.get(), GTK_TYPE_ENTRY);
    1463         gtk_widget_path_iter_set_object_name(path.get(), 1, "selection");
    1464 
    1465         gtk_style_context_set_path(context.get(), path.get());
    1466     }
    1467 #endif
    1468 
     1294    // Recent GTK+ versions (> 3.14) require to explicitly set the state before getting the color.
    14691295    gtk_style_context_set_state(context.get(), state);
    14701296
    14711297    GdkRGBA gdkRGBAColor;
    14721298    if (colorType == StyleColorBackground)
    1473         gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor);
     1299        gtk_style_context_get_background_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor);
    14741300    else
    1475         gtk_style_context_get_color(context.get(), state, &gdkRGBAColor);
     1301        gtk_style_context_get_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor);
    14761302    return gdkRGBAColor;
    14771303}
Note: See TracChangeset for help on using the changeset viewer.