cssstaticstyle: Compute initial/inherit values directly

This commit is contained in:
Timm Bäder 2019-08-22 19:25:22 +02:00
parent 629f528f6d
commit 8d6c5ba90e
3 changed files with 26 additions and 9 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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 ();
else
specified = _gtk_css_initial_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
{
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);
}
gtk_css_static_style_set_value (style, id, value, section);
}