diff --git a/gtk/gtkcsscomputedvalues.c b/gtk/gtkcsscomputedvalues.c index dea23bdf5e..eb2210dc39 100644 --- a/gtk/gtkcsscomputedvalues.c +++ b/gtk/gtkcsscomputedvalues.c @@ -137,7 +137,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values, if (_gtk_css_style_property_is_inherit (prop)) specified = _gtk_css_inherit_value_new (); else - specified = _gtk_css_initial_value_new (); + specified = _gtk_css_initial_value_new (prop); } else _gtk_css_value_ref (specified); diff --git a/gtk/gtkcssinheritvalue.c b/gtk/gtkcssinheritvalue.c index e2c3f16330..4699c8476c 100644 --- a/gtk/gtkcssinheritvalue.c +++ b/gtk/gtkcssinheritvalue.c @@ -48,7 +48,7 @@ gtk_css_value_inherit_compute (GtkCssValue *value, } else { - return _gtk_css_value_compute (_gtk_css_initial_value_get (), + return _gtk_css_value_compute (_gtk_css_initial_value_get (_gtk_css_style_property_lookup_by_id (property_id)), property_id, provider, values, diff --git a/gtk/gtkcssinitialvalue.c b/gtk/gtkcssinitialvalue.c index 427044d574..4db1bb4372 100644 --- a/gtk/gtkcssinitialvalue.c +++ b/gtk/gtkcssinitialvalue.c @@ -27,6 +27,7 @@ struct _GtkCssValue { GTK_CSS_VALUE_BASE + GtkCssStyleProperty *property; }; static void @@ -77,7 +78,7 @@ gtk_css_value_initial_compute (GtkCssValue *value, break; } - return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)), + return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (value->property), property_id, provider, values, @@ -119,13 +120,19 @@ static const GtkCssValueClass GTK_CSS_VALUE_INITIAL = { static GtkCssValue initial = { >K_CSS_VALUE_INITIAL, 1 }; GtkCssValue * -_gtk_css_initial_value_new (void) +_gtk_css_initial_value_new (GtkCssStyleProperty *property) { - return _gtk_css_value_ref (&initial); + return _gtk_css_value_ref (_gtk_css_initial_value_get (property)); } GtkCssValue * -_gtk_css_initial_value_get (void) +_gtk_css_initial_value_get (GtkCssStyleProperty *property) { - return &initial; + if (property->css_initial_value == NULL) + { + property->css_initial_value = g_new0 (GtkCssValue, 1); + *property->css_initial_value = initial; + property->css_initial_value->property = property; + } + return property->css_initial_value; } diff --git a/gtk/gtkcssinitialvalueprivate.h b/gtk/gtkcssinitialvalueprivate.h index 185e1be177..6fa30eac24 100644 --- a/gtk/gtkcssinitialvalueprivate.h +++ b/gtk/gtkcssinitialvalueprivate.h @@ -21,11 +21,11 @@ #define __GTK_CSS_INITIAL_VALUE_PRIVATE_H__ #include "gtkcssvalueprivate.h" - +#include "gtkcssstylepropertyprivate.h" G_BEGIN_DECLS -GtkCssValue * _gtk_css_initial_value_new (void); -GtkCssValue * _gtk_css_initial_value_get (void); +GtkCssValue * _gtk_css_initial_value_new (GtkCssStyleProperty *property); +GtkCssValue * _gtk_css_initial_value_get (GtkCssStyleProperty *property); G_END_DECLS diff --git a/gtk/gtkcssshorthandproperty.c b/gtk/gtkcssshorthandproperty.c index c6ca614689..752d877839 100644 --- a/gtk/gtkcssshorthandproperty.c +++ b/gtk/gtkcssshorthandproperty.c @@ -102,7 +102,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property, */ for (i = 0; i < shorthand->subproperties->len; i++) { - data[i] = _gtk_css_initial_value_new (); + data[i] = _gtk_css_initial_value_new (shorthand->subproperties->pdata[i]); } } else if (_gtk_css_parser_try (parser, "inherit", TRUE)) @@ -135,7 +135,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property, for (i = 0; i < shorthand->subproperties->len; i++) { if (data[i] == NULL) - data[i] = _gtk_css_initial_value_new (); + data[i] = _gtk_css_initial_value_new (shorthand->subproperties->pdata[i]); } result = _gtk_css_array_value_new_from_array (data, shorthand->subproperties->len); diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c index bd7d5a06cb..5f53f5b566 100644 --- a/gtk/gtkcssstyleproperty.c +++ b/gtk/gtkcssstyleproperty.c @@ -230,7 +230,7 @@ gtk_css_style_property_parse_value (GtkStyleProperty *property, /* the initial value can be explicitly specified with the * ‘initial’ keyword which all properties accept. */ - return _gtk_css_initial_value_new (); + return _gtk_css_initial_value_new (style_property); } else if (_gtk_css_parser_try (parser, "inherit", TRUE)) { diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c index 3d8eb213c6..4ed1779bbc 100644 --- a/gtk/gtkcssstylepropertyimpl.c +++ b/gtk/gtkcssstylepropertyimpl.c @@ -162,7 +162,7 @@ assign_border (GtkCssStyleProperty *property, const GtkBorder *border = g_value_get_boxed (value); if (border == NULL) - return _gtk_css_initial_value_new (); + return _gtk_css_initial_value_new (property); else return _gtk_css_border_value_new (_gtk_css_number_value_new (border->top, GTK_CSS_PX), _gtk_css_number_value_new (border->right, GTK_CSS_PX), diff --git a/gtk/gtkcssstylepropertyprivate.h b/gtk/gtkcssstylepropertyprivate.h index 00d8437a8b..8a88bb4380 100644 --- a/gtk/gtkcssstylepropertyprivate.h +++ b/gtk/gtkcssstylepropertyprivate.h @@ -51,6 +51,8 @@ struct _GtkCssStyleProperty guint animated :1; guint affects_size :1; + GtkCssValue *css_initial_value; /* Used to quickly find the GCssInitialValue for a property */ + GtkCssStylePropertyParseFunc parse_value; GtkCssStylePropertyQueryFunc query_value; GtkCssStylePropertyAssignFunc assign_value;