Commit 7603e6e4 authored by Alexander Larsson's avatar Alexander Larsson

css: Use GtkCssValues instead of GValue in the css machinery

Also, in places where we're computing a new CssValue based on an
old one, make sure that if nothing changes we're returning a reference
to the old one, rather than creating a new identical instance.
parent 0ece7a5d
......@@ -39,12 +39,12 @@ _gtk_border_image_init (GtkBorderImage *image,
{
GtkBorder *width;
image->source = g_value_get_object (_gtk_theming_engine_peek_property (engine, "border-image-source"));
image->source = _gtk_css_value_get_object (_gtk_theming_engine_peek_property (engine, "border-image-source"));
if (image->source == NULL)
return FALSE;
image->slice = *(GtkBorder *) g_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-slice"));
width = g_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-width"));
image->slice = *(GtkBorder *) _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-slice"));
width = _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-width"));
if (width)
{
image->width = *width;
......@@ -53,8 +53,7 @@ _gtk_border_image_init (GtkBorderImage *image,
else
image->has_width = FALSE;
image->repeat = *(GtkCssBorderImageRepeat *) g_value_get_boxed (
_gtk_theming_engine_peek_property (engine, "border-image-repeat"));
image->repeat = *_gtk_css_value_get_border_image_repeat (_gtk_theming_engine_peek_property (engine, "border-image-repeat"));
return TRUE;
}
......
......@@ -34,7 +34,7 @@ gtk_css_computed_values_dispose (GObject *object)
if (values->values)
{
g_array_free (values->values, TRUE);
g_ptr_array_unref (values->values);
values->values = NULL;
}
if (values->sections)
......@@ -77,7 +77,7 @@ void
_gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkStyleContext *context,
guint id,
const GValue *specified,
GtkCssValue *specified,
GtkCssSection *section)
{
GtkCssStyleProperty *prop;
......@@ -85,18 +85,14 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (specified == NULL || G_IS_VALUE (specified));
prop = _gtk_css_style_property_lookup_by_id (id);
parent = gtk_style_context_get_parent (context);
if (values->values == NULL)
{
values->values = g_array_new (FALSE, TRUE, sizeof (GValue));
g_array_set_clear_func (values->values, (GDestroyNotify) g_value_unset);
}
values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
if (id <= values->values->len)
g_array_set_size (values->values, id + 1);
g_ptr_array_set_size (values->values, id + 1);
/* http://www.w3.org/TR/css3-cascade/#cascade
* Then, for every element, the value for each property can be found
......@@ -105,9 +101,9 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
*/
if (specified != NULL)
{
if (G_VALUE_HOLDS (specified, GTK_TYPE_CSS_SPECIAL_VALUE))
if (_gtk_css_value_is_special (specified))
{
switch (g_value_get_enum (specified))
switch (_gtk_css_value_get_special_kind (specified))
{
case GTK_CSS_INHERIT:
/* 3) if the value of the winning declaration is ‘inherit’,
......@@ -159,20 +155,19 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
if (specified)
{
_gtk_css_style_property_compute_value (prop,
&g_array_index (values->values, GValue, id),
context,
specified);
g_ptr_array_index (values->values, id) =
_gtk_css_style_property_compute_value (prop,
context,
specified);
}
else
{
const GValue *parent_value;
GValue *value = &g_array_index (values->values, GValue, id);
GtkCssValue *parent_value;
/* Set NULL here and do the inheritance upon lookup? */
parent_value = _gtk_style_context_peek_property (parent,
_gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)));
g_value_init (value, G_VALUE_TYPE (parent_value));
g_value_copy (parent_value, value);
g_ptr_array_index (values->values, id) = _gtk_css_value_ref (parent_value);
}
if (section)
......@@ -189,26 +184,17 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
void
_gtk_css_computed_values_set_value (GtkCssComputedValues *values,
guint id,
const GValue *value,
GtkCssValue *value,
GtkCssSection *section)
{
GValue *set;
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (value == NULL || G_IS_VALUE (value));
if (values->values == NULL)
{
values->values = g_array_new (FALSE, TRUE, sizeof (GValue));
g_array_set_clear_func (values->values, (GDestroyNotify) g_value_unset);
}
values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
if (id <= values->values->len)
g_array_set_size (values->values, id + 1);
g_ptr_array_set_size (values->values, id + 1);
set = &g_array_index (values->values, GValue, id);
g_value_init (set, G_VALUE_TYPE (value));
g_value_copy (value, set);
g_ptr_array_index (values->values, id) = _gtk_css_value_ref (value);
if (section)
{
......@@ -221,26 +207,20 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
}
}
const GValue *
GtkCssValue *
_gtk_css_computed_values_get_value (GtkCssComputedValues *values,
guint id)
{
const GValue *v;
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->values == NULL ||
id >= values->values->len)
return NULL;
v = &g_array_index (values->values, GValue, id);
if (!G_IS_VALUE (v))
return NULL;
return v;
return g_ptr_array_index (values->values, id);
}
const GValue *
GtkCssValue *
_gtk_css_computed_values_get_value_by_name (GtkCssComputedValues *values,
const char *name)
{
......
......@@ -24,6 +24,7 @@
#include "gtk/gtkcsssection.h"
#include "gtk/gtkstylecontext.h"
#include "gtk/gtkcssvalueprivate.h"
G_BEGIN_DECLS
......@@ -41,7 +42,7 @@ struct _GtkCssComputedValues
{
GObject parent;
GArray *values;
GPtrArray *values;
GPtrArray *sections;
};
......@@ -57,16 +58,16 @@ GtkCssComputedValues * _gtk_css_computed_values_new (void);
void _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkStyleContext *context,
guint id,
const GValue *specified,
GtkCssValue *specified,
GtkCssSection *section);
void _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
guint id,
const GValue *value,
GtkCssValue *value,
GtkCssSection *section);
const GValue * _gtk_css_computed_values_get_value (GtkCssComputedValues *values,
GtkCssValue * _gtk_css_computed_values_get_value (GtkCssComputedValues *values,
guint id);
const GValue * _gtk_css_computed_values_get_value_by_name (GtkCssComputedValues *values,
GtkCssValue * _gtk_css_computed_values_get_value_by_name (GtkCssComputedValues *values,
const char *name);
GtkCssSection * _gtk_css_computed_values_get_section (GtkCssComputedValues *values,
guint id);
......
......@@ -91,29 +91,32 @@ gtk_css_custom_property_get_specified_type (GParamSpec *pspec)
return pspec->value_type;
}
static void
gtk_css_custom_property_create_initial_value (GParamSpec *pspec,
GValue *value)
static GtkCssValue *
gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
{
g_value_init (value, gtk_css_custom_property_get_specified_type (pspec));
GValue value = G_VALUE_INIT;
g_value_init (&value, gtk_css_custom_property_get_specified_type (pspec));
if (pspec->value_type == GTK_TYPE_THEMING_ENGINE)
g_value_set_object (value, gtk_theming_engine_load (NULL));
g_value_set_object (&value, gtk_theming_engine_load (NULL));
else if (pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
g_value_take_boxed (value, pango_font_description_from_string ("Sans 10"));
g_value_take_boxed (&value, pango_font_description_from_string ("Sans 10"));
else if (pspec->value_type == GDK_TYPE_RGBA ||
pspec->value_type == GDK_TYPE_COLOR)
{
GdkRGBA color;
gdk_rgba_parse (&color, "pink");
g_value_take_boxed (value, gtk_symbolic_color_new_literal (&color));
g_value_take_boxed (&value, gtk_symbolic_color_new_literal (&color));
}
else if (pspec->value_type == GTK_TYPE_BORDER)
{
g_value_take_boxed (value, gtk_border_new ());
g_value_take_boxed (&value, gtk_border_new ());
}
else
g_param_value_set_default (pspec, value);
g_param_value_set_default (pspec, &value);
return _gtk_css_value_new_take_gvalue (&value);
}
/* Property registration functions */
......@@ -164,7 +167,7 @@ gtk_theming_engine_register_property (const gchar *name_space,
GParamSpec *pspec)
{
GtkCssCustomProperty *node;
GValue initial = { 0, };
GtkCssValue *initial;
gchar *name;
g_return_if_fail (name_space != NULL);
......@@ -172,10 +175,10 @@ gtk_theming_engine_register_property (const gchar *name_space,
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
name = g_strdup_printf ("-%s-%s", name_space, pspec->name);
gtk_css_custom_property_create_initial_value (pspec, &initial);
initial = gtk_css_custom_property_create_initial_value (pspec);
node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
"initial-value", &initial,
"initial-value", initial,
"name", name,
"computed-type", pspec->value_type,
"value-type", pspec->value_type,
......@@ -183,7 +186,7 @@ gtk_theming_engine_register_property (const gchar *name_space,
node->pspec = pspec;
node->property_parse_func = parse_func;
g_value_unset (&initial);
_gtk_css_value_unref (initial);
g_free (name);
}
......@@ -204,14 +207,14 @@ gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
GParamSpec *pspec)
{
GtkCssCustomProperty *node;
GValue initial = { 0, };
GtkCssValue *initial;
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
gtk_css_custom_property_create_initial_value (pspec, &initial);
initial = gtk_css_custom_property_create_initial_value (pspec);
node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
"initial-value", &initial,
"initial-value", initial,
"name", pspec->name,
"computed-type", pspec->value_type,
"value-type", pspec->value_type,
......@@ -219,7 +222,7 @@ gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
node->pspec = pspec;
node->property_parse_func = parse_func;
g_value_unset (&initial);
_gtk_css_value_unref (initial);
}
/**
......
......@@ -26,8 +26,8 @@
typedef struct {
GtkCssSection *section;
const GValue *value;
const GValue *computed;
GtkCssValue *value;
GtkCssValue *computed;
} GtkCssLookupValue;
struct _GtkCssLookup {
......@@ -91,7 +91,7 @@ void
_gtk_css_lookup_set (GtkCssLookup *lookup,
guint id,
GtkCssSection *section,
const GValue *value)
GtkCssValue *value)
{
g_return_if_fail (lookup != NULL);
g_return_if_fail (_gtk_bitmask_get (lookup->missing, id));
......@@ -125,7 +125,7 @@ void
_gtk_css_lookup_set_computed (GtkCssLookup *lookup,
guint id,
GtkCssSection *section,
const GValue *value)
GtkCssValue *value)
{
g_return_if_fail (lookup != NULL);
g_return_if_fail (_gtk_bitmask_get (lookup->missing, id));
......
......@@ -38,11 +38,11 @@ gboolean _gtk_css_lookup_is_missing (const GtkCssLoo
void _gtk_css_lookup_set (GtkCssLookup *lookup,
guint id,
GtkCssSection *section,
const GValue *value);
GtkCssValue *value);
void _gtk_css_lookup_set_computed (GtkCssLookup *lookup,
guint id,
GtkCssSection *section,
const GValue *value);
GtkCssValue *value);
void _gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleContext *context,
GtkCssComputedValues *values);
......
......@@ -969,14 +969,14 @@ typedef enum ParserSymbol ParserSymbol;
struct _PropertyValue {
GtkCssStyleProperty *property;
GValue value;
GtkCssValue *value;
GtkCssSection *section;
};
struct _WidgetPropertyValue {
char *name;
WidgetPropertyValue *next;
GValue value;
GtkCssValue *value;
GtkCssSection *section;
};
......@@ -1156,7 +1156,8 @@ gtk_css_ruleset_clear (GtkCssRuleset *ruleset)
for (i = 0; i < ruleset->n_styles; i++)
{
g_value_unset (&ruleset->styles[i].value);
_gtk_css_value_unref (ruleset->styles[i].value);
ruleset->styles[i].value = NULL;
gtk_css_section_unref (ruleset->styles[i].section);
}
g_free (ruleset->styles);
......@@ -1187,9 +1188,7 @@ widget_property_value_new (char *name, GtkCssSection *section)
static void
widget_property_value_free (WidgetPropertyValue *value)
{
if (G_IS_VALUE (&value->value))
g_value_unset (&value->value);
_gtk_css_value_unref (value->value);
g_free (value->name);
gtk_css_section_unref (value->section);
......@@ -1263,7 +1262,8 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
{
if (ruleset->styles[i].property == property)
{
g_value_unset (&ruleset->styles[i].value);
_gtk_css_value_unref (ruleset->styles[i].value);
ruleset->styles[i].value = NULL;
gtk_css_section_unref (ruleset->styles[i].section);
break;
}
......@@ -1272,12 +1272,11 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
{
ruleset->n_styles++;
ruleset->styles = g_realloc (ruleset->styles, ruleset->n_styles * sizeof (PropertyValue));
memset (&ruleset->styles[i].value, 0, sizeof (GValue));
ruleset->styles[i].value = NULL;
ruleset->styles[i].property = property;
}
g_value_init (&ruleset->styles[i].value, G_VALUE_TYPE (value));
g_value_copy (value, &ruleset->styles[i].value);
ruleset->styles[i].value = _gtk_css_value_new_from_gvalue (value);
ruleset->styles[i].section = gtk_css_section_ref (section);
}
......@@ -1485,7 +1484,7 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
_gtk_style_properties_set_property_by_property (props,
GTK_CSS_STYLE_PROPERTY (ruleset->styles[i].property),
_gtk_css_selector_get_state_flags (ruleset->selector),
&ruleset->styles[i].value);
ruleset->styles[i].value);
}
return props;
......@@ -1531,7 +1530,7 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
NULL,
val->section,
gtk_css_section_get_file (val->section),
g_value_get_string (&val->value));
_gtk_css_value_get_string (val->value));
found = _gtk_css_style_parse_value (value,
scanner->parser,
......@@ -1609,7 +1608,7 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
_gtk_css_lookup_set (lookup,
id,
ruleset->styles[j].section,
&ruleset->styles[j].value);
ruleset->styles[j].value);
}
}
}
......@@ -2215,8 +2214,7 @@ parse_declaration (GtkCssScanner *scanner,
WidgetPropertyValue *val;
val = widget_property_value_new (name, scanner->section);
g_value_init (&val->value, G_TYPE_STRING);
g_value_take_string (&val->value, value_str);
val->value = _gtk_css_value_new_take_string (value_str);
gtk_css_ruleset_add_style (ruleset, name, val);
}
......@@ -2799,7 +2797,7 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
g_string_append (str, " ");
g_string_append (str, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop->property)));
g_string_append (str, ": ");
_gtk_css_style_property_print_value (prop->property, &prop->value, str);
_gtk_css_style_property_print_value (prop->property, prop->value, str);
g_string_append (str, ";\n");
}
......@@ -2822,7 +2820,7 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
g_string_append (str, " ");
g_string_append (str, widget_value->name);
g_string_append (str, ": ");
g_string_append (str, g_value_get_string (&widget_value->value));
g_string_append (str, _gtk_css_value_get_string (widget_value->value));
g_string_append (str, ";\n");
}
......
......@@ -72,15 +72,14 @@ _gtk_css_shorthand_property_assign (GtkStyleProperty *property,
shorthand->assign (shorthand, props, state, value);
}
static void
static GtkCssValue *
_gtk_css_shorthand_property_query (GtkStyleProperty *property,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
shorthand->query (shorthand, value, query_func, query_data);
return shorthand->query (shorthand, query_func, query_data);
}
static void
......
......@@ -31,6 +31,7 @@
#include "gtkstylepropertiesprivate.h"
#include "gtksymboliccolorprivate.h"
#include "gtktypebuiltins.h"
#include "gtkcssvalueprivate.h"
/* this is in case round() is not provided by the compiler,
* such as in the case of C89 compilers, like MSVC
......@@ -608,34 +609,33 @@ unpack_border (GtkCssShorthandProperty *shorthand,
g_value_unset (&v);
}
static void
static GtkCssValue *
pack_border (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssStyleProperty *prop;
GtkBorder border;
const GValue *v;
GtkCssValue *v;
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
border.top = g_value_get_int (v);
border.top = _gtk_css_value_get_int (v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 1);
v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
border.right = g_value_get_int (v);
border.right = _gtk_css_value_get_int (v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 2);
v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
border.bottom = g_value_get_int (v);
border.bottom = _gtk_css_value_get_int (v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 3);
v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
border.left = g_value_get_int (v);
border.left = _gtk_css_value_get_int (v);
g_value_set_boxed (value, &border);
return _gtk_css_value_new_from_border (&border);
}
static void
......@@ -659,24 +659,26 @@ unpack_border_radius (GtkCssShorthandProperty *shorthand,
g_value_unset (&v);
}
static void
static GtkCssValue *
pack_border_radius (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssBorderCornerRadius *top_left;
GtkCssStyleProperty *prop;
const GValue *v;
GtkCssValue *v;
int value = 0;
prop = GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("border-top-left-radius"));
v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
{
top_left = g_value_get_boxed (v);
top_left = _gtk_css_value_get_border_corner_radius (v);
if (top_left)
g_value_set_int (value, top_left->horizontal.value);
value = top_left->horizontal.value;
}
return _gtk_css_value_new_from_int (value);
}
static void
......@@ -759,21 +761,20 @@ unpack_font_description (GtkCssShorthandProperty *shorthand,
}
}
static void
static GtkCssValue *
pack_font_description (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
PangoFontDescription *description;
const GValue *v;
GtkCssValue *v;
description = pango_font_description_new ();
v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-family"))), query_data);
if (v)
{
const char **families = g_value_get_boxed (v);
const char **families = _gtk_css_value_get_strv (v);
/* xxx: Can we set all the families here somehow? */
if (families)
pango_font_description_set_family (description, families[0]);
......@@ -781,21 +782,21 @@ pack_font_description (GtkCssShorthandProperty *shorthand,
v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-size"))), query_data);
if (v)
pango_font_description_set_size (description, round (g_value_get_double (v) * PANGO_SCALE));
pango_font_description_set_size (description, round (_gtk_css_value_get_double (v) * PANGO_SCALE));
v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-style"))), query_data);
if (v)
pango_font_description_set_style (description, g_value_get_enum (v));
pango_font_description_set_style (description, _gtk_css_value_get_pango_style (v));
v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-variant"))), query_data);
if (v)
pango_font_description_set_variant (description, g_value_get_enum (v));
pango_font_description_set_variant (description, _gtk_css_value_get_pango_variant (v));
v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-weight"))), query_data);
if (v)
pango_font_description_set_weight (description, g_value_get_enum (v));
pango_font_description_set_weight (description, _gtk_css_value_get_pango_weight (v));
g_value_take_boxed (value, description);
return _gtk_css_value_new_take_font_description (description);
}
static void
......@@ -816,14 +817,13 @@ unpack_to_everything (GtkCssShorthandProperty *shorthand,
}
}
static void
static GtkCssValue *
pack_first_element (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssStyleProperty *prop;
const GValue *v;
GtkCssValue *v;
guint i;
/* NB: This is a fallback for properties that originally were
......@@ -837,10 +837,10 @@ pack_first_element (GtkCssShorthandProperty *shorthand,
v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
{
g_value_copy (v, value);
return;
return _gtk_css_value_ref (v);
}
}
return NULL;
}
static void
......
......@@ -46,8 +46,7 @@ typedef void (* GtkCssShorthandPropertyAssignFunc) (GtkCssS
GtkStyleProperties *props,
GtkStateFlags state,
const GValue *value);
typedef void (* GtkCssShorthandPropertyQueryFunc) (GtkCssShorthandProperty *shorthand,
GValue *value,
typedef GtkCssValue * (* GtkCssShorthandPropertyQueryFunc) (GtkCssShorthandProperty *shorthand,
GtkStyleQueryFunc query_func,
gpointer query_data);
......
......@@ -54,9 +54,8 @@ typedef gboolean (* GtkStyleParseFunc) (GtkCssParser
GValue *value);
typedef void (* GtkStylePrintFunc) (const GValue *value,
GString *string);
typedef void (* GtkStyleComputeFunc) (GValue *computed,
GtkStyleContext *context,
const GValue *specified);
typedef GtkCssValue * (* GtkStyleComputeFunc) (GtkStyleContext *context,
GtkCssValue *specified);
static void
register_conversion_function (GType type,
......@@ -212,31 +211,31 @@ rgba_value_print (const GValue *value,
}
}
static void
rgba_value_compute (GValue *computed,
GtkStyleContext *context,
const GValue *specified)
static GtkCssValue *
rgba_value_compute (GtkStyleContext *context,
GtkCssValue *specified)
{
GdkRGBA rgba, white = { 1, 1, 1, 1 };
if (G_VALUE_HOLDS (specified, GTK_TYPE_CSS_SPECIAL_VALUE))
if (_gtk_css_value_holds (specified, GTK_TYPE_CSS_SPECIAL_VALUE))
{
return _gtk_css_value_new_from_rgba (NULL);
}
else if (G_VALUE_HOLDS (specified, GTK_TYPE_SYMBOLIC_COLOR))
else if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR))
{
GtkSymbolicColor *symbolic = g_value_get_boxed (specified);
GtkSymbolicColor *symbolic = _gtk_css_value_get_symbolic_color (specified);
if (symbolic == _gtk_symbolic_color_get_current_color ())
g_value_copy (_gtk_style_context_peek_property (context, "color"), computed);
return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color"));
else if (_gtk_style_context_resolve_color (context,
symbolic,
&rgba))
g_value_set_boxed (computed, &rgba);
return _gtk_css_value_new_from_rgba (&rgba);
else
g_value_set_boxed (computed, &white);
return _gtk_css_value_new_from_rgba (&white);
}
else
g_value_copy (specified, computed);
return _gtk_css_value_ref (specified);
}
static gboolean
......@@ -287,18 +286,17 @@ color_value_print (const GValue *value,
}
}
static void
color_value_compute (GValue *computed,
GtkStyleContext *context,
const GValue *specified)
static GtkCssValue *
color_value_compute (GtkStyleContext *context,
GtkCssValue *specified)
{
GdkRGBA rgba;
GdkColor color = { 0, 65535, 65535, 65535 };
if (G_VALUE_HOLDS (specified, GTK_TYPE_SYMBOLIC_COLOR))