Changeset 192727 in webkit


Ignore:
Timestamp:
Nov 22, 2015 12:50:40 AM (8 years ago)
Author:
Michael Catanzaro
Message:

[GTK] RenderThemeGtk::platformActiveSelectionBackgroundColor, et. al. should not clobber state of cached GtkStyleContexts
https://bugs.webkit.org/show_bug.cgi?id=151533

Reviewed by Carlos Garcia Campos.

platformActiveSelectionBackgroundColor(), platformInactiveSelectionBackgroundColor(), etc.
are const functions intended only to return a color used for painting, but since r174929
they also change the state of the cached style contexts we use for GTK_TYPE_ENTRY and
GTK_TYPE_TREE_VIEW. That's wrong; those style contexts should not have any state set. This
could cause theme colors returned by those GtkStyleContexts to change unexpectedly,
depending on whether the state is explicitly set before each use, or whether the theme
actually uses the states.

This didn't cause any regression only because every place using these style contexts
explicitly sets the state of the style contexts before use. In fact, the GtkTreeView style
context is not used anywhere else, and the GtkEntry style context is only used in
paintTextField, which does set the state before use (and then reverts it using
save/restore), so this cannot have broken anything in practice. But it's a landmine waiting
for the next programmer to trip it.

Fix this with a gtk_style_context_save()/gtk_style_context_restore() pair.

  • rendering/RenderThemeGtk.cpp:

(WebCore::styleColor):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r192726 r192727  
     12015-11-22  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [GTK] RenderThemeGtk::platformActiveSelectionBackgroundColor, et. al. should not clobber state of cached GtkStyleContexts
     4        https://bugs.webkit.org/show_bug.cgi?id=151533
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        platformActiveSelectionBackgroundColor(), platformInactiveSelectionBackgroundColor(), etc.
     9        are const functions intended only to return a color used for painting, but since r174929
     10        they also change the state of the cached style contexts we use for GTK_TYPE_ENTRY and
     11        GTK_TYPE_TREE_VIEW. That's wrong; those style contexts should not have any state set. This
     12        could cause theme colors returned by those GtkStyleContexts to change unexpectedly,
     13        depending on whether the state is explicitly set before each use, or whether the theme
     14        actually uses the states.
     15
     16        This didn't cause any regression only because every place using these style contexts
     17        explicitly sets the state of the style contexts before use. In fact, the GtkTreeView style
     18        context is not used anywhere else, and the GtkEntry style context is only used in
     19        paintTextField, which does set the state before use (and then reverts it using
     20        save/restore), so this cannot have broken anything in practice. But it's a landmine waiting
     21        for the next programmer to trip it.
     22
     23        Fix this with a gtk_style_context_save()/gtk_style_context_restore() pair.
     24
     25        * rendering/RenderThemeGtk.cpp:
     26        (WebCore::styleColor):
     27
    1282015-11-21  Myles C. Maxfield  <mmaxfield@apple.com>
    229
  • trunk/Source/WebCore/rendering/RenderThemeGtk.cpp

    r192724 r192727  
    13491349static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType colorType)
    13501350{
    1351 
    13521351    GtkStyleContext* context = getStyleContext(widgetType);
    1353     // Recent GTK+ versions (> 3.14) require to explicitly set the state before getting the color.
     1352    gtk_style_context_save(context);
    13541353    gtk_style_context_set_state(context, state);
    13551354
     
    13591358    else
    13601359        gtk_style_context_get_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
     1360
     1361    gtk_style_context_restore(context);
    13611362    return gdkRGBAColor;
    13621363}
Note: See TracChangeset for help on using the changeset viewer.