Title: [192727] trunk/Source/WebCore
Revision
192727
Author
mcatanz...@igalia.com
Date
2015-11-22 00:50:40 -0800 (Sun, 22 Nov 2015)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (192726 => 192727)


--- trunk/Source/WebCore/ChangeLog	2015-11-21 23:06:46 UTC (rev 192726)
+++ trunk/Source/WebCore/ChangeLog	2015-11-22 08:50:40 UTC (rev 192727)
@@ -1,3 +1,30 @@
+2015-11-22  Michael Catanzaro  <mcatanz...@igalia.com>
+
+        [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):
+
 2015-11-21  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Tiny cleanup in ComplexTextController::collectComplexTextRuns()

Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.cpp (192726 => 192727)


--- trunk/Source/WebCore/rendering/RenderThemeGtk.cpp	2015-11-21 23:06:46 UTC (rev 192726)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.cpp	2015-11-22 08:50:40 UTC (rev 192727)
@@ -1348,9 +1348,8 @@
 
 static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType colorType)
 {
-
     GtkStyleContext* context = getStyleContext(widgetType);
-    // Recent GTK+ versions (> 3.14) require to explicitly set the state before getting the color.
+    gtk_style_context_save(context);
     gtk_style_context_set_state(context, state);
 
     GdkRGBA gdkRGBAColor;
@@ -1358,6 +1357,8 @@
         gtk_style_context_get_background_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
     else
         gtk_style_context_get_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
+
+    gtk_style_context_restore(context);
     return gdkRGBAColor;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to