[gtk+/wip/cssvalue: 150/164] computedvalues: Split out a function
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 150/164] computedvalues: Split out a function
- Date: Wed, 11 Apr 2012 14:52:31 +0000 (UTC)
commit 376c3081d07a68f2f2668d42b84e0e21aca3b26d
Author: Benjamin Otte <otte redhat com>
Date: Tue Apr 10 13:25:56 2012 +0200
computedvalues: Split out a function
gtk/gtkcsscomputedvalues.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkcsscomputedvalues.c b/gtk/gtkcsscomputedvalues.c
index ac2718f..6f99667 100644
--- a/gtk/gtkcsscomputedvalues.c
+++ b/gtk/gtkcsscomputedvalues.c
@@ -73,6 +73,16 @@ maybe_unref_section (gpointer section)
gtk_css_section_unref (section);
}
+static void
+gtk_css_computed_values_ensure_array (GtkCssComputedValues *values,
+ guint at_least_size)
+{
+ if (values->values == NULL)
+ values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
+ if (at_least_size > values->values->len)
+ g_ptr_array_set_size (values->values, at_least_size);
+}
+
void
_gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkStyleContext *context,
@@ -89,10 +99,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
prop = _gtk_css_style_property_lookup_by_id (id);
parent = gtk_style_context_get_parent (context);
- if (values->values == NULL)
- values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
- if (id <= values->values->len)
- g_ptr_array_set_size (values->values, id + 1);
+ 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
@@ -181,10 +188,7 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
{
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
- if (values->values == NULL)
- values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
- if (id >= values->values->len)
- g_ptr_array_set_size (values->values, id + 1);
+ gtk_css_computed_values_ensure_array (values, id + 1);
if (g_ptr_array_index (values->values, id))
_gtk_css_value_unref (g_ptr_array_index (values->values, id));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]