[gtk/fix-current-color] css: Fix computation of currentcolor



commit e78572f59251ffd35ac60708cea544f79eb6e2f2
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Apr 15 17:03:01 2020 -0400

    css: Fix computation of currentcolor
    
    We must always store NULL for currentcolor in
    our values structs, since that is resolved to
    the color of the style at use time, it can't
    be fixed at compute time, since values structs
    are shared between styles.

 gtk/gtkcssstaticstyle.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index fee5c01e56..bd77af01f4 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -1085,7 +1085,27 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
     }
   else
     {
-      value = _gtk_css_initial_value_new_compute (id, provider, (GtkCssStyle *)style, parent_style);
+      /* We store currentcolor as NULL in the values structs,
+       * this gets resolved to the value of color in the style
+       * using the values struct - it needs to be resolved late
+       * since values structs are shared between styles.
+       */
+      switch (id)
+        {
+        case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
+        case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
+        case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
+        case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
+        case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
+        case GTK_CSS_PROPERTY_OUTLINE_COLOR:
+        case GTK_CSS_PROPERTY_CARET_COLOR:
+        case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
+          value = NULL;
+          break;
+        default:
+          value = _gtk_css_initial_value_new_compute (id, provider, (GtkCssStyle *)style, parent_style);
+          break;
+        }
     }
 
   gtk_css_static_style_set_value (style, id, value, section);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]