[gtk/wip/baedert/for-master: 18/20] cssstaticstyle: Compute initial/inherit values directly



commit 7de79af50a7b753fef922f130e6c4643a0bf0ea0
Author: Timm Bäder <mail baedert org>
Date:   Thu Aug 22 19:25:22 2019 +0200

    cssstaticstyle: Compute initial/inherit values directly

 gtk/gtkcssinitialvalue.c        | 14 +++++++++++++-
 gtk/gtkcssinitialvalueprivate.h |  4 +---
 gtk/gtkcssstaticstyle.c         | 17 ++++++++++++-----
 3 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcssinitialvalue.c b/gtk/gtkcssinitialvalue.c
index db479cfabc..258d9f604d 100644
--- a/gtk/gtkcssinitialvalue.c
+++ b/gtk/gtkcssinitialvalue.c
@@ -37,7 +37,7 @@ gtk_css_value_initial_free (GtkCssValue *value)
   g_assert_not_reached ();
 }
 
-GtkCssValue *
+static GtkCssValue *
 gtk_css_value_initial_compute (GtkCssValue      *value,
                                guint             property_id,
                                GtkStyleProvider *provider,
@@ -124,3 +124,15 @@ _gtk_css_initial_value_get (void)
 {
   return &initial;
 }
+GtkCssValue *
+_gtk_css_initial_value_new_compute (guint             property_id,
+                                    GtkStyleProvider *provider,
+                                    GtkCssStyle      *style,
+                                    GtkCssStyle      *parent_style)
+{
+  return gtk_css_value_initial_compute (NULL,
+                                        property_id,
+                                        provider,
+                                        style,
+                                        parent_style);
+}
diff --git a/gtk/gtkcssinitialvalueprivate.h b/gtk/gtkcssinitialvalueprivate.h
index 08e501f20f..7bec6bd5a0 100644
--- a/gtk/gtkcssinitialvalueprivate.h
+++ b/gtk/gtkcssinitialvalueprivate.h
@@ -26,9 +26,7 @@ G_BEGIN_DECLS
 
 GtkCssValue *   _gtk_css_initial_value_new            (void);
 GtkCssValue *   _gtk_css_initial_value_get            (void);
-
-GtkCssValue *   gtk_css_value_initial_compute         (GtkCssValue      *value,
-                                                       guint             property_id,
+GtkCssValue *   _gtk_css_initial_value_new_compute    (guint             property_id,
                                                        GtkStyleProvider *provider,
                                                        GtkCssStyle      *style,
                                                        GtkCssStyle      *parent_style);
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index 840281e24e..6cb835d6e2 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -218,13 +218,20 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
     {
       GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (id);
 
-      if (_gtk_css_style_property_is_inherit (prop))
-        specified = _gtk_css_inherit_value_get ();
+      if (parent_style && _gtk_css_style_property_is_inherit (prop))
+        {
+          /* Just take the style from the parent */
+          value = _gtk_css_value_ref (gtk_css_style_get_value (parent_style, id));
+        }
       else
-        specified = _gtk_css_initial_value_get ();
+        {
+          value = _gtk_css_initial_value_new_compute (id, provider, (GtkCssStyle *)style, parent_style);
+        }
+    }
+  else
+    {
+      value = _gtk_css_value_compute (specified, id, provider, (GtkCssStyle *)style, parent_style);
     }
-
-  value = _gtk_css_value_compute (specified, id, provider, (GtkCssStyle *)style, parent_style);
 
   gtk_css_static_style_set_value (style, id, value, section);
 }


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