Title: [175033] releases/WebKitGTK/webkit-2.4/Source/WebCore
Revision
175033
Author
[email protected]
Date
2014-10-22 02:59:37 -0700 (Wed, 22 Oct 2014)

Log Message

Merge r174929 - [GTK] Several labels are white instead of black
https://bugs.webkit.org/show_bug.cgi?id=137803

Reviewed by Martin Robinson.

Recent GTK+ versions require to explicitly set the state before
getting a color.

* rendering/RenderThemeGtk.cpp:
(WebCore::styleColor): Helper function to get a color from a
GtkStylecontext that explicitly sets the state before getting the color.
(WebCore::RenderThemeGtk::platformActiveSelectionBackgroundColor): Use styleColor().
(WebCore::RenderThemeGtk::platformInactiveSelectionBackgroundColor): Ditto.
(WebCore::RenderThemeGtk::platformActiveSelectionForegroundColor): Ditto.
(WebCore::RenderThemeGtk::platformInactiveSelectionForegroundColor): Ditto.
(WebCore::RenderThemeGtk::platformActiveListBoxSelectionBackgroundColor): Ditto.
(WebCore::RenderThemeGtk::platformInactiveListBoxSelectionBackgroundColor): Ditto.
(WebCore::RenderThemeGtk::platformActiveListBoxSelectionForegroundColor): Ditto.
(WebCore::RenderThemeGtk::platformInactiveListBoxSelectionForegroundColor): Ditto.
(WebCore::RenderThemeGtk::systemColor): Ditto.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (175032 => 175033)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2014-10-22 09:50:58 UTC (rev 175032)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2014-10-22 09:59:37 UTC (rev 175033)
@@ -1,3 +1,26 @@
+2014-10-21  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Several labels are white instead of black
+        https://bugs.webkit.org/show_bug.cgi?id=137803
+
+        Reviewed by Martin Robinson.
+
+        Recent GTK+ versions require to explicitly set the state before
+        getting a color.
+
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::styleColor): Helper function to get a color from a
+        GtkStylecontext that explicitly sets the state before getting the color.
+        (WebCore::RenderThemeGtk::platformActiveSelectionBackgroundColor): Use styleColor().
+        (WebCore::RenderThemeGtk::platformInactiveSelectionBackgroundColor): Ditto.
+        (WebCore::RenderThemeGtk::platformActiveSelectionForegroundColor): Ditto.
+        (WebCore::RenderThemeGtk::platformInactiveSelectionForegroundColor): Ditto.
+        (WebCore::RenderThemeGtk::platformActiveListBoxSelectionBackgroundColor): Ditto.
+        (WebCore::RenderThemeGtk::platformInactiveListBoxSelectionBackgroundColor): Ditto.
+        (WebCore::RenderThemeGtk::platformActiveListBoxSelectionForegroundColor): Ditto.
+        (WebCore::RenderThemeGtk::platformInactiveListBoxSelectionForegroundColor): Ditto.
+        (WebCore::RenderThemeGtk::systemColor): Ditto.
+
 2014-10-09  Philip Chimento  <[email protected]>
 
         [GTK] Netscape plugin API symbol used outside feature guards

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp (175032 => 175033)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp	2014-10-22 09:50:58 UTC (rev 175032)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp	2014-10-22 09:59:37 UTC (rev 175033)
@@ -932,73 +932,69 @@
     return adoptGRef(icon);
 }
 
-Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const
+enum StyleColorType { StyleColorBackground, StyleColorForeground };
+
+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_set_state(context, state);
+
     GdkRGBA gdkRGBAColor;
-    gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
+    if (colorType == StyleColorBackground)
+        gtk_style_context_get_background_color(context, state, &gdkRGBAColor);
+    else
+        gtk_style_context_get_color(context, state, &gdkRGBAColor);
     return gdkRGBAColor;
 }
 
+Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const
+{
+    return styleColor(GTK_TYPE_ENTRY, static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), StyleColorBackground);
+}
+
 Color RenderThemeGtk::platformInactiveSelectionBackgroundColor() const
 {
-    GdkRGBA gdkRGBAColor;
-    gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_ENTRY), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
-    return gdkRGBAColor;
+    return styleColor(GTK_TYPE_ENTRY, GTK_STATE_FLAG_SELECTED, StyleColorBackground);
 }
 
 Color RenderThemeGtk::platformActiveSelectionForegroundColor() const
 {
-    GdkRGBA gdkRGBAColor;
-    gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
-    return gdkRGBAColor;
+    return styleColor(GTK_TYPE_ENTRY, static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), StyleColorForeground);
 }
 
 Color RenderThemeGtk::platformInactiveSelectionForegroundColor() const
 {
-    GdkRGBA gdkRGBAColor;
-    gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
-    return gdkRGBAColor;
+    return styleColor(GTK_TYPE_ENTRY, GTK_STATE_FLAG_SELECTED, StyleColorForeground);
 }
 
 Color RenderThemeGtk::activeListBoxSelectionBackgroundColor() const
 {
-    GdkRGBA gdkRGBAColor;
-    gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_TREE_VIEW), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
-    return gdkRGBAColor;
+    return styleColor(GTK_TYPE_TREE_VIEW, static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), StyleColorBackground);
 }
 
 Color RenderThemeGtk::inactiveListBoxSelectionBackgroundColor() const
 {
-    GdkRGBA gdkRGBAColor;
-    gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_TREE_VIEW), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
-    return gdkRGBAColor;
+    return styleColor(GTK_TYPE_TREE_VIEW, GTK_STATE_FLAG_SELECTED, StyleColorBackground);
 }
 
 Color RenderThemeGtk::activeListBoxSelectionForegroundColor() const
 {
-    GdkRGBA gdkRGBAColor;
-    gtk_style_context_get_color(getStyleContext(GTK_TYPE_TREE_VIEW), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
-    return gdkRGBAColor;
+    return styleColor(GTK_TYPE_TREE_VIEW, static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), StyleColorForeground);
 }
 
 Color RenderThemeGtk::inactiveListBoxSelectionForegroundColor() const
 {
-    GdkRGBA gdkRGBAColor;
-    gtk_style_context_get_color(getStyleContext(GTK_TYPE_TREE_VIEW), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
-    return gdkRGBAColor;
+    return styleColor(GTK_TYPE_TREE_VIEW, GTK_STATE_FLAG_SELECTED, StyleColorForeground);
 }
 
 Color RenderThemeGtk::systemColor(CSSValueID cssValueId) const
 {
-    GdkRGBA gdkRGBAColor;
-
     switch (cssValueId) {
     case CSSValueButtontext:
-        gtk_style_context_get_color(getStyleContext(GTK_TYPE_BUTTON), GTK_STATE_FLAG_ACTIVE, &gdkRGBAColor);
-        return gdkRGBAColor;
+        return styleColor(GTK_TYPE_BUTTON, GTK_STATE_FLAG_ACTIVE, StyleColorForeground);
     case CSSValueCaptiontext:
-        gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(0), &gdkRGBAColor);
-        return gdkRGBAColor;
+        return styleColor(GTK_TYPE_ENTRY, GTK_STATE_FLAG_ACTIVE, StyleColorForeground);
     default:
         return RenderTheme::systemColor(cssValueId);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to