computedvalues: Pass dependencies to set_value()

This simplifies the code.
This commit is contained in:
Benjamin Otte 2012-08-24 17:00:02 +02:00
parent 8874a06ba0
commit 6fbd8b0003
5 changed files with 19 additions and 22 deletions

View File

@ -251,6 +251,7 @@ _gtk_css_animated_values_new (GtkCssComputedValues *computed,
_gtk_css_computed_values_set_value (GTK_CSS_COMPUTED_VALUES (values),
i,
value,
0,
_gtk_css_computed_values_get_section (computed, i));
}

View File

@ -108,12 +108,11 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkCssSection *section)
{
GtkCssDependencies dependencies;
GtkCssValue *value;
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
gtk_css_computed_values_ensure_array (values, id + 1);
/* http://www.w3.org/TR/css3-cascade/#cascade
* Then, for every element, the value for each property can be found
* by following this pseudo-algorithm:
@ -131,27 +130,11 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
else
_gtk_css_value_ref (specified);
g_ptr_array_index (values->values, id) = _gtk_css_value_compute (specified, id, context, &dependencies);
value = _gtk_css_value_compute (specified, id, context, &dependencies);
if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
values->depends_on_parent = _gtk_bitmask_set (values->depends_on_parent, id, TRUE);
if (dependencies & (GTK_CSS_EQUALS_PARENT))
values->equals_parent = _gtk_bitmask_set (values->equals_parent, id, TRUE);
if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
values->depends_on_color = _gtk_bitmask_set (values->depends_on_color, id, TRUE);
if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
values->depends_on_font_size = _gtk_bitmask_set (values->depends_on_font_size, id, TRUE);
_gtk_css_computed_values_set_value (values, id, value, dependencies, section);
if (section)
{
if (values->sections == NULL)
values->sections = g_ptr_array_new_with_free_func (maybe_unref_section);
if (values->sections->len <= id)
g_ptr_array_set_size (values->sections, id + 1);
g_ptr_array_index (values->sections, id) = gtk_css_section_ref (section);
}
_gtk_css_value_unref (value);
_gtk_css_value_unref (specified);
}
@ -159,6 +142,7 @@ void
_gtk_css_computed_values_set_value (GtkCssComputedValues *values,
guint id,
GtkCssValue *value,
GtkCssDependencies dependencies,
GtkCssSection *section)
{
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
@ -169,6 +153,15 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
_gtk_css_value_unref (g_ptr_array_index (values->values, id));
g_ptr_array_index (values->values, id) = _gtk_css_value_ref (value);
if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
values->depends_on_parent = _gtk_bitmask_set (values->depends_on_parent, id, TRUE);
if (dependencies & (GTK_CSS_EQUALS_PARENT))
values->equals_parent = _gtk_bitmask_set (values->equals_parent, id, TRUE);
if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
values->depends_on_color = _gtk_bitmask_set (values->depends_on_color, id, TRUE);
if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
values->depends_on_font_size = _gtk_bitmask_set (values->depends_on_font_size, id, TRUE);
if (section)
{
if (values->sections == NULL)

View File

@ -68,6 +68,7 @@ void _gtk_css_computed_values_compute_value (GtkCssCom
void _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
guint id,
GtkCssValue *value,
GtkCssDependencies dependencies,
GtkCssSection *section);
GtkCssValue * _gtk_css_computed_values_get_value (GtkCssComputedValues *values,

View File

@ -167,6 +167,7 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
_gtk_css_computed_values_set_value (values,
i,
lookup->values[i].computed,
0,
lookup->values[i].section);
else
_gtk_css_computed_values_compute_value (values,

View File

@ -51,7 +51,8 @@ gtk_css_transition_set_values (GtkStyleAnimation *animation,
value = _gtk_css_value_ref (transition->end);
}
_gtk_css_computed_values_set_value (values, transition->property, value, NULL);
/* XXX: Is using 0 correct here? */
_gtk_css_computed_values_set_value (values, transition->property, value, 0, NULL);
_gtk_css_value_unref (value);
return _gtk_bitmask_set (changed, transition->property, TRUE);