From 8b823d7e13d8cb923db5f2e093645588ad3da9c9 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 17 Dec 2014 05:52:13 +0100 Subject: [PATCH] cssstaticstyle: Move function We want the new() return values to be immutable, so we have to move the code that modifes them. --- gtk/gtkcssstaticstyle.c | 29 +++++++++++++++++++++++++++-- gtk/gtkcssstaticstyleprivate.h | 7 ++++++- gtk/gtkstylecontext.c | 26 +++++++++++--------------- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c index 82066cf1f0..2819fdb6e1 100644 --- a/gtk/gtkcssstaticstyle.c +++ b/gtk/gtkcssstaticstyle.c @@ -177,9 +177,34 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *style, } GtkCssStyle * -gtk_css_static_style_new (void) +gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher, + int scale, + GtkCssStyle *parent, + GtkCssChange *out_change) { - return g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL); + GtkCssStaticStyle *result; + GtkCssLookup *lookup; + + lookup = _gtk_css_lookup_new (NULL); + + if (matcher) + _gtk_style_provider_private_lookup (provider, + matcher, + lookup, + out_change); + + result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL); + + _gtk_css_lookup_resolve (lookup, + provider, + scale, + result, + parent); + + _gtk_css_lookup_free (lookup); + + return GTK_CSS_STYLE (result); } GtkCssStyle * diff --git a/gtk/gtkcssstaticstyleprivate.h b/gtk/gtkcssstaticstyleprivate.h index a18127bc22..09e28189c8 100644 --- a/gtk/gtkcssstaticstyleprivate.h +++ b/gtk/gtkcssstaticstyleprivate.h @@ -20,6 +20,7 @@ #ifndef __GTK_CSS_STATIC_STYLE_PRIVATE_H__ #define __GTK_CSS_STATIC_STYLE_PRIVATE_H__ +#include "gtk/gtkcssmatcherprivate.h" #include "gtk/gtkcssstyleprivate.h" G_BEGIN_DECLS @@ -54,7 +55,11 @@ struct _GtkCssStaticStyleClass GType gtk_css_static_style_get_type (void) G_GNUC_CONST; -GtkCssStyle * gtk_css_static_style_new (void); +GtkCssStyle * gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher, + int scale, + GtkCssStyle *parent, + GtkCssChange *out_change); GtkCssStyle * gtk_css_static_style_copy (GtkCssStaticStyle *original, const GtkBitmask *properties_to_not_copy); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 69722a21a8..ba62c1b581 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -734,29 +734,25 @@ build_properties (GtkStyleContext *context, GtkStyleContextPrivate *priv; GtkCssMatcher matcher; GtkWidgetPath *path; - GtkCssLookup *lookup; GtkCssStyle *style; priv = context->priv; - style = gtk_css_static_style_new (); - path = create_query_path (context, decl); - lookup = _gtk_css_lookup_new (NULL); if (_gtk_css_matcher_init (&matcher, path)) - _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade), - &matcher, - lookup, - out_change); + style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade), + &matcher, + priv->scale, + priv->parent ? style_values_lookup (priv->parent) : NULL, + out_change); + else + style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade), + NULL, + priv->scale, + priv->parent ? style_values_lookup (priv->parent) : NULL, + out_change); - _gtk_css_lookup_resolve (lookup, - GTK_STYLE_PROVIDER_PRIVATE (priv->cascade), - priv->scale, - GTK_CSS_STATIC_STYLE (style), - priv->parent ? style_values_lookup (priv->parent) : NULL); - - _gtk_css_lookup_free (lookup); gtk_widget_path_free (path); return style;