diff options
author | Benjamin Otte <otte@redhat.com> | 2012-07-17 14:01:52 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-08-28 15:40:57 +0200 |
commit | 9e7e65ca6e01246cf9eea156f0153014b58e4d36 (patch) | |
tree | 6c4ba6560e23d854fa232a3e9af9b73b3a64972a /gtk/gtkcsscomputedvalues.c | |
parent | 6dc3113edc484d9ac1bb1ca248177e279658d31e (diff) | |
download | gtk+-9e7e65ca6e01246cf9eea156f0153014b58e4d36.tar.gz |
css: Move computing of initial and inherit values
... to the compute vfunc. Simplifies code quite a bit. But makes the
code no longer a simple step-by-step implementation of the spec.
Diffstat (limited to 'gtk/gtkcsscomputedvalues.c')
-rw-r--r-- | gtk/gtkcsscomputedvalues.c | 67 |
1 files changed, 9 insertions, 58 deletions
diff --git a/gtk/gtkcsscomputedvalues.c b/gtk/gtkcsscomputedvalues.c index caa2251d1b..7aa121f023 100644 --- a/gtk/gtkcsscomputedvalues.c +++ b/gtk/gtkcsscomputedvalues.c @@ -90,15 +90,10 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values, GtkCssValue *specified, GtkCssSection *section) { - GtkCssStyleProperty *prop; - GtkStyleContext *parent; g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values)); g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); - prop = _gtk_css_style_property_lookup_by_id (id); - parent = gtk_style_context_get_parent (context); - gtk_css_computed_values_ensure_array (values, id + 1); /* http://www.w3.org/TR/css3-cascade/#cascade @@ -106,65 +101,19 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values, * by following this pseudo-algorithm: * 1) Identify all declarations that apply to the element */ - if (specified != NULL) - { - if (_gtk_css_value_is_inherit (specified)) - { - /* 3) if the value of the winning declaration is ‘inherit’, - * the inherited value (see below) becomes the specified value. - */ - specified = NULL; - } - else if (_gtk_css_value_is_initial (specified)) - { - /* if the value of the winning declaration is ‘initial’, - * the initial value (see below) becomes the specified value. - */ - specified = _gtk_css_style_property_get_initial_value (prop); - } - - /* 2) If the cascading process (described below) yields a winning - * declaration and the value of the winning declaration is not - * ‘initial’ or ‘inherit’, the value of the winning declaration - * becomes the specified value. - */ - } - else + if (specified == NULL) { + GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (id); + if (_gtk_css_style_property_is_inherit (prop)) - { - /* 4) if the property is inherited, the inherited value becomes - * the specified value. - */ - specified = NULL; - } + specified = _gtk_css_inherit_value_new (); else - { - /* 5) Otherwise, the initial value becomes the specified value. - */ - specified = _gtk_css_style_property_get_initial_value (prop); - } - } - - if (specified == NULL && parent == NULL) - { - /* If the ‘inherit’ value is set on the root element, the property is - * assigned its initial value. */ - specified = _gtk_css_style_property_get_initial_value (prop); - } - - if (specified) - { - g_ptr_array_index (values->values, id) = _gtk_css_value_compute (specified, id, context); + specified = _gtk_css_initial_value_new (); } else - { - GtkCssValue *parent_value; - /* Set NULL here and do the inheritance upon lookup? */ - parent_value = _gtk_style_context_peek_property (parent, id); + _gtk_css_value_ref (specified); - g_ptr_array_index (values->values, id) = _gtk_css_value_ref (parent_value); - } + g_ptr_array_index (values->values, id) = _gtk_css_value_compute (specified, id, context); if (section) { @@ -175,6 +124,8 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values, g_ptr_array_index (values->sections, id) = gtk_css_section_ref (section); } + + _gtk_css_value_unref (specified); } void |