1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 #include "gtkcssstylefuncsprivate.h"
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28 #include <cairo-gobject.h>
30 #include "gtkcsscolorvalueprivate.h"
31 #include "gtkcssimagegradientprivate.h"
32 #include "gtkcssprovider.h"
33 #include "gtkcssrgbavalueprivate.h"
34 #include "gtkcsstypedvalueprivate.h"
35 #include "gtkcsstypesprivate.h"
36 #include "gtkgradient.h"
37 #include "gtkgradientprivate.h"
38 #include "gtkprivatetypebuiltins.h"
39 #include "gtkstylecontextprivate.h"
40 #include "gtksymboliccolorprivate.h"
41 #include "gtkthemingengine.h"
42 #include "gtktypebuiltins.h"
43 #include "gtkwin32themeprivate.h"
45 /* this is in case round() is not provided by the compiler,
46 * such as in the case of C89 compilers, like MSVC
48 #include "fallback-c89.c"
50 static GHashTable *parse_funcs = NULL;
51 static GHashTable *print_funcs = NULL;
52 static GHashTable *compute_funcs = NULL;
54 typedef gboolean (* GtkStyleParseFunc) (GtkCssParser *parser,
56 typedef void (* GtkStylePrintFunc) (const GValue *value,
58 typedef GtkCssValue * (* GtkStyleComputeFunc) (GtkStyleProviderPrivate *provider,
59 GtkCssComputedValues *values,
60 GtkCssComputedValues *parent_values,
61 GtkCssValue *specified,
62 GtkCssDependencies *dependencies);
65 register_conversion_function (GType type,
66 GtkStyleParseFunc parse,
67 GtkStylePrintFunc print,
68 GtkStyleComputeFunc compute)
71 g_hash_table_insert (parse_funcs, GSIZE_TO_POINTER (type), parse);
73 g_hash_table_insert (print_funcs, GSIZE_TO_POINTER (type), print);
75 g_hash_table_insert (compute_funcs, GSIZE_TO_POINTER (type), compute);
79 string_append_double (GString *string,
82 char buf[G_ASCII_DTOSTR_BUF_SIZE];
84 g_ascii_dtostr (buf, sizeof (buf), d);
85 g_string_append (string, buf);
89 string_append_string (GString *str,
94 g_string_append_c (str, '"');
97 len = strcspn (string, "\"\n\r\f");
98 g_string_append (str, string);
105 g_string_append (str, "\\A ");
108 g_string_append (str, "\\D ");
111 g_string_append (str, "\\C ");
114 g_string_append (str, "\\\"");
117 g_assert_not_reached ();
122 g_string_append_c (str, '"');
125 /*** IMPLEMENTATIONS ***/
128 enum_parse (GtkCssParser *parser,
134 if (_gtk_css_parser_try_enum (parser, type, res))
137 str = _gtk_css_parser_try_ident (parser, TRUE);
140 _gtk_css_parser_error (parser, "Expected an identifier");
144 _gtk_css_parser_error (parser,
145 "Unknown value '%s' for enum type '%s'",
146 str, g_type_name (type));
153 enum_print (int value,
157 GEnumClass *enum_class;
158 GEnumValue *enum_value;
160 enum_class = g_type_class_ref (type);
161 enum_value = g_enum_get_value (enum_class, value);
163 g_string_append (string, enum_value->value_nick);
165 g_type_class_unref (enum_class);
169 rgba_value_parse (GtkCssParser *parser,
172 GtkSymbolicColor *symbolic;
175 symbolic = _gtk_css_symbolic_value_new (parser);
176 if (symbolic == NULL)
179 if (gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
181 g_value_set_boxed (value, &rgba);
182 gtk_symbolic_color_unref (symbolic);
186 g_value_unset (value);
187 g_value_init (value, GTK_TYPE_SYMBOLIC_COLOR);
188 g_value_take_boxed (value, symbolic);
195 rgba_value_print (const GValue *value,
198 const GdkRGBA *rgba = g_value_get_boxed (value);
201 g_string_append (string, "none");
204 char *s = gdk_rgba_to_string (rgba);
205 g_string_append (string, s);
211 rgba_value_compute (GtkStyleProviderPrivate *provider,
212 GtkCssComputedValues *values,
213 GtkCssComputedValues *parent_values,
214 GtkCssValue *specified,
215 GtkCssDependencies *dependencies)
217 GdkRGBA white = { 1, 1, 1, 1 };
220 value = _gtk_css_typed_value_get (specified);
222 if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR))
224 GtkSymbolicColor *symbolic = g_value_get_boxed (value);
226 GValue new_value = G_VALUE_INIT;
229 val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (symbolic),
231 _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
232 GTK_CSS_DEPENDS_ON_COLOR,
236 rgba = *_gtk_css_rgba_value_get_rgba (val);
237 _gtk_css_value_unref (val);
242 g_value_init (&new_value, GDK_TYPE_RGBA);
243 g_value_set_boxed (&new_value, &rgba);
244 return _gtk_css_typed_value_new_take (&new_value);
247 return _gtk_css_value_ref (specified);
251 color_value_parse (GtkCssParser *parser,
254 GtkSymbolicColor *symbolic;
257 symbolic = _gtk_css_symbolic_value_new (parser);
258 if (symbolic == NULL)
261 if (gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
265 color.red = rgba.red * 65535. + 0.5;
266 color.green = rgba.green * 65535. + 0.5;
267 color.blue = rgba.blue * 65535. + 0.5;
269 g_value_set_boxed (value, &color);
273 g_value_unset (value);
274 g_value_init (value, GTK_TYPE_SYMBOLIC_COLOR);
275 g_value_take_boxed (value, symbolic);
282 color_value_print (const GValue *value,
285 const GdkColor *color = g_value_get_boxed (value);
288 g_string_append (string, "none");
291 char *s = gdk_color_to_string (color);
292 g_string_append (string, s);
298 color_value_compute (GtkStyleProviderPrivate *provider,
299 GtkCssComputedValues *values,
300 GtkCssComputedValues *parent_values,
301 GtkCssValue *specified,
302 GtkCssDependencies *dependencies)
304 GdkColor color = { 0, 65535, 65535, 65535 };
307 value = _gtk_css_typed_value_get (specified);
309 if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR))
311 GValue new_value = G_VALUE_INIT;
314 val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (g_value_get_boxed (value)),
316 _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
317 GTK_CSS_DEPENDS_ON_COLOR,
321 const GdkRGBA *rgba = _gtk_css_rgba_value_get_rgba (val);
322 color.red = rgba->red * 65535. + 0.5;
323 color.green = rgba->green * 65535. + 0.5;
324 color.blue = rgba->blue * 65535. + 0.5;
325 _gtk_css_value_unref (val);
328 g_value_init (&new_value, GDK_TYPE_COLOR);
329 g_value_set_boxed (&new_value, &color);
330 return _gtk_css_typed_value_new_take (&new_value);
333 return _gtk_css_value_ref (specified);
337 symbolic_color_value_parse (GtkCssParser *parser,
340 GtkSymbolicColor *symbolic;
342 symbolic = _gtk_css_symbolic_value_new (parser);
343 if (symbolic == NULL)
346 g_value_take_boxed (value, symbolic);
351 symbolic_color_value_print (const GValue *value,
354 GtkSymbolicColor *symbolic = g_value_get_boxed (value);
356 if (symbolic == NULL)
357 g_string_append (string, "none");
360 char *s = gtk_symbolic_color_to_string (symbolic);
361 g_string_append (string, s);
367 font_description_value_parse (GtkCssParser *parser,
370 PangoFontDescription *font_desc;
374 str = _gtk_css_parser_read_value (parser);
378 font_desc = pango_font_description_from_string (str);
379 mask = pango_font_description_get_set_fields (font_desc);
380 /* These values are not really correct,
381 * but the fields must be set, so we set them to something */
382 if ((mask & PANGO_FONT_MASK_FAMILY) == 0)
383 pango_font_description_set_family_static (font_desc, "Sans");
384 if ((mask & PANGO_FONT_MASK_SIZE) == 0)
385 pango_font_description_set_size (font_desc, 10 * PANGO_SCALE);
387 g_value_take_boxed (value, font_desc);
392 font_description_value_print (const GValue *value,
395 const PangoFontDescription *desc = g_value_get_boxed (value);
398 g_string_append (string, "none");
401 char *s = pango_font_description_to_string (desc);
402 g_string_append (string, s);
408 boolean_value_parse (GtkCssParser *parser,
411 if (_gtk_css_parser_try (parser, "true", TRUE) ||
412 _gtk_css_parser_try (parser, "1", TRUE))
414 g_value_set_boolean (value, TRUE);
417 else if (_gtk_css_parser_try (parser, "false", TRUE) ||
418 _gtk_css_parser_try (parser, "0", TRUE))
420 g_value_set_boolean (value, FALSE);
425 _gtk_css_parser_error (parser, "Expected a boolean value");
431 boolean_value_print (const GValue *value,
434 if (g_value_get_boolean (value))
435 g_string_append (string, "true");
437 g_string_append (string, "false");
441 int_value_parse (GtkCssParser *parser,
446 if (_gtk_css_parser_begins_with (parser, '-'))
448 int res = _gtk_win32_theme_int_parse (parser, &i);
451 g_value_set_int (value, i);
454 /* < 0 => continue */
457 if (!_gtk_css_parser_try_int (parser, &i))
459 _gtk_css_parser_error (parser, "Expected a valid integer value");
463 g_value_set_int (value, i);
468 int_value_print (const GValue *value,
471 g_string_append_printf (string, "%d", g_value_get_int (value));
475 uint_value_parse (GtkCssParser *parser,
480 if (!_gtk_css_parser_try_uint (parser, &u))
482 _gtk_css_parser_error (parser, "Expected a valid unsigned value");
486 g_value_set_uint (value, u);
491 uint_value_print (const GValue *value,
494 g_string_append_printf (string, "%u", g_value_get_uint (value));
498 double_value_parse (GtkCssParser *parser,
503 if (!_gtk_css_parser_try_double (parser, &d))
505 _gtk_css_parser_error (parser, "Expected a number");
509 g_value_set_double (value, d);
514 double_value_print (const GValue *value,
517 string_append_double (string, g_value_get_double (value));
521 float_value_parse (GtkCssParser *parser,
526 if (!_gtk_css_parser_try_double (parser, &d))
528 _gtk_css_parser_error (parser, "Expected a number");
532 g_value_set_float (value, d);
537 float_value_print (const GValue *value,
540 string_append_double (string, g_value_get_float (value));
544 string_value_parse (GtkCssParser *parser,
547 char *str = _gtk_css_parser_read_string (parser);
552 g_value_take_string (value, str);
557 string_value_print (const GValue *value,
560 string_append_string (str, g_value_get_string (value));
564 theming_engine_value_parse (GtkCssParser *parser,
567 GtkThemingEngine *engine;
570 if (_gtk_css_parser_try (parser, "none", TRUE))
572 g_value_set_object (value, gtk_theming_engine_load (NULL));
576 str = _gtk_css_parser_try_ident (parser, TRUE);
579 _gtk_css_parser_error (parser, "Expected a valid theme name");
583 engine = gtk_theming_engine_load (str);
587 _gtk_css_parser_error (parser, "Theming engine '%s' not found", str);
592 g_value_set_object (value, engine);
598 theming_engine_value_print (const GValue *value,
601 GtkThemingEngine *engine;
604 engine = g_value_get_object (value);
606 g_string_append (string, "none");
609 /* XXX: gtk_theming_engine_get_name()? */
610 g_object_get (engine, "name", &name, NULL);
611 g_string_append (string, name ? name : "none");
617 border_value_parse (GtkCssParser *parser,
620 GtkBorder border = { 0, };
624 for (i = 0; i < G_N_ELEMENTS (numbers); i++)
626 if (_gtk_css_parser_begins_with (parser, '-'))
628 /* These are strictly speaking signed, but we want to be able to use them
629 for unsigned types too, as the actual ranges of values make this safe */
630 int res = _gtk_win32_theme_int_parse (parser, &numbers[i]);
632 if (res == 0) /* Parse error, report */
635 if (res < 0) /* Nothing known to expand */
640 if (!_gtk_css_parser_try_length (parser, &numbers[i]))
647 _gtk_css_parser_error (parser, "Expected valid border");
651 border.top = numbers[0];
653 border.right = numbers[1];
655 border.right = border.top;
657 border.bottom = numbers[2];
659 border.bottom = border.top;
661 border.left = numbers[3];
663 border.left = border.right;
665 g_value_set_boxed (value, &border);
670 border_value_print (const GValue *value, GString *string)
672 const GtkBorder *border = g_value_get_boxed (value);
675 g_string_append (string, "none");
676 else if (border->left != border->right)
677 g_string_append_printf (string, "%d %d %d %d", border->top, border->right, border->bottom, border->left);
678 else if (border->top != border->bottom)
679 g_string_append_printf (string, "%d %d %d", border->top, border->right, border->bottom);
680 else if (border->top != border->left)
681 g_string_append_printf (string, "%d %d", border->top, border->right);
683 g_string_append_printf (string, "%d", border->top);
687 gradient_value_parse (GtkCssParser *parser,
690 GtkGradient *gradient;
692 gradient = _gtk_gradient_parse (parser);
693 if (gradient == NULL)
696 g_value_take_boxed (value, gradient);
701 gradient_value_print (const GValue *value,
704 GtkGradient *gradient = g_value_get_boxed (value);
706 if (gradient == NULL)
707 g_string_append (string, "none");
710 char *s = gtk_gradient_to_string (gradient);
711 g_string_append (string, s);
717 pattern_value_parse (GtkCssParser *parser,
720 if (_gtk_css_parser_try (parser, "none", TRUE))
722 /* nothing to do here */
724 else if (_gtk_css_parser_begins_with (parser, '-'))
726 g_value_unset (value);
727 g_value_init (value, GTK_TYPE_GRADIENT);
728 return gradient_value_parse (parser, value);
732 GError *error = NULL;
736 cairo_surface_t *surface;
737 cairo_pattern_t *pattern;
739 cairo_matrix_t matrix;
741 file = _gtk_css_parser_read_url (parser);
745 path = g_file_get_path (file);
746 g_object_unref (file);
748 pixbuf = gdk_pixbuf_new_from_file (path, &error);
752 _gtk_css_parser_take_error (parser, error);
756 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
757 gdk_pixbuf_get_width (pixbuf),
758 gdk_pixbuf_get_height (pixbuf));
759 cr = cairo_create (surface);
760 gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
762 pattern = cairo_pattern_create_for_surface (surface);
764 cairo_matrix_init_scale (&matrix,
765 gdk_pixbuf_get_width (pixbuf),
766 gdk_pixbuf_get_height (pixbuf));
767 cairo_pattern_set_matrix (pattern, &matrix);
769 cairo_surface_destroy (surface);
771 g_object_unref (pixbuf);
773 g_value_take_boxed (value, pattern);
779 static cairo_status_t
780 surface_write (void *closure,
781 const unsigned char *data,
784 g_byte_array_append (closure, data, length);
786 return CAIRO_STATUS_SUCCESS;
790 surface_print (cairo_surface_t *surface,
793 #if CAIRO_HAS_PNG_FUNCTIONS
797 array = g_byte_array_new ();
798 cairo_surface_write_to_png_stream (surface, surface_write, array);
799 base64 = g_base64_encode (array->data, array->len);
800 g_byte_array_free (array, TRUE);
802 g_string_append (string, "url(\"data:image/png;base64,");
803 g_string_append (string, base64);
804 g_string_append (string, "\")");
808 g_string_append (string, "none /* you need cairo png functions enabled to make this work */");
813 pattern_value_print (const GValue *value,
816 cairo_pattern_t *pattern;
817 cairo_surface_t *surface;
819 pattern = g_value_get_boxed (value);
823 g_string_append (string, "none");
827 switch (cairo_pattern_get_type (pattern))
829 case CAIRO_PATTERN_TYPE_SURFACE:
830 if (cairo_pattern_get_surface (pattern, &surface) != CAIRO_STATUS_SUCCESS)
832 g_assert_not_reached ();
834 surface_print (surface, string);
836 case CAIRO_PATTERN_TYPE_LINEAR:
837 case CAIRO_PATTERN_TYPE_RADIAL:
838 g_string_append (string, "none /* FIXME: add support for printing gradients */");
840 case CAIRO_PATTERN_TYPE_SOLID:
842 g_assert_not_reached ();
848 pattern_value_compute (GtkStyleProviderPrivate *provider,
849 GtkCssComputedValues *values,
850 GtkCssComputedValues *parent_values,
851 GtkCssValue *specified,
852 GtkCssDependencies *dependencies)
854 const GValue *value = _gtk_css_typed_value_get (specified);
856 if (G_VALUE_HOLDS (value, GTK_TYPE_GRADIENT))
858 GValue new_value = G_VALUE_INIT;
859 cairo_pattern_t *gradient;
861 gradient = _gtk_gradient_resolve_full (g_value_get_boxed (value), provider, values, parent_values, dependencies);
863 g_value_init (&new_value, CAIRO_GOBJECT_TYPE_PATTERN);
864 g_value_take_boxed (&new_value, gradient);
865 return _gtk_css_typed_value_new_take (&new_value);
868 return _gtk_css_value_ref (specified);
872 enum_value_parse (GtkCssParser *parser,
877 if (enum_parse (parser, G_VALUE_TYPE (value), &v))
879 g_value_set_enum (value, v);
887 enum_value_print (const GValue *value,
890 enum_print (g_value_get_enum (value), G_VALUE_TYPE (value), string);
894 flags_value_parse (GtkCssParser *parser,
897 GFlagsClass *flags_class;
898 GFlagsValue *flag_value;
902 flags_class = g_type_class_ref (G_VALUE_TYPE (value));
905 str = _gtk_css_parser_try_ident (parser, TRUE);
908 _gtk_css_parser_error (parser, "Expected an identifier");
909 g_type_class_unref (flags_class);
913 flag_value = g_flags_get_value_by_nick (flags_class, str);
916 _gtk_css_parser_error (parser,
917 "Unknown flag value '%s' for type '%s'",
918 str, g_type_name (G_VALUE_TYPE (value)));
919 /* XXX Do we want to return FALSE here? We can get
920 * forward-compatibility for new values this way
923 g_type_class_unref (flags_class);
929 while (_gtk_css_parser_try (parser, ",", FALSE));
931 g_type_class_unref (flags_class);
933 g_value_set_enum (value, flags);
939 flags_value_print (const GValue *value,
942 GFlagsClass *flags_class;
945 flags_class = g_type_class_ref (G_VALUE_TYPE (value));
946 flags = g_value_get_flags (value);
948 for (i = 0; i < flags_class->n_values; i++)
950 GFlagsValue *flags_value = &flags_class->values[i];
952 if (flags & flags_value->value)
954 if (string->len != 0)
955 g_string_append (string, ", ");
957 g_string_append (string, flags_value->value_nick);
961 g_type_class_unref (flags_class);
967 gtk_css_style_funcs_init (void)
969 if (G_LIKELY (parse_funcs != NULL))
972 parse_funcs = g_hash_table_new (NULL, NULL);
973 print_funcs = g_hash_table_new (NULL, NULL);
974 compute_funcs = g_hash_table_new (NULL, NULL);
976 register_conversion_function (GDK_TYPE_RGBA,
980 register_conversion_function (GDK_TYPE_COLOR,
983 color_value_compute);
984 register_conversion_function (GTK_TYPE_SYMBOLIC_COLOR,
985 symbolic_color_value_parse,
986 symbolic_color_value_print,
988 register_conversion_function (PANGO_TYPE_FONT_DESCRIPTION,
989 font_description_value_parse,
990 font_description_value_print,
992 register_conversion_function (G_TYPE_BOOLEAN,
996 register_conversion_function (G_TYPE_INT,
1000 register_conversion_function (G_TYPE_UINT,
1004 register_conversion_function (G_TYPE_DOUBLE,
1008 register_conversion_function (G_TYPE_FLOAT,
1012 register_conversion_function (G_TYPE_STRING,
1016 register_conversion_function (GTK_TYPE_THEMING_ENGINE,
1017 theming_engine_value_parse,
1018 theming_engine_value_print,
1020 register_conversion_function (GTK_TYPE_BORDER,
1024 register_conversion_function (GTK_TYPE_GRADIENT,
1025 gradient_value_parse,
1026 gradient_value_print,
1028 register_conversion_function (CAIRO_GOBJECT_TYPE_PATTERN,
1029 pattern_value_parse,
1030 pattern_value_print,
1031 pattern_value_compute);
1032 register_conversion_function (G_TYPE_ENUM,
1036 register_conversion_function (G_TYPE_FLAGS,
1043 * _gtk_css_style_parse_value:
1044 * @value: the value to parse into. Must be a valid initialized #GValue
1045 * @parser: the parser to parse from
1047 * This is the generic parsing function used for CSS values. If the
1048 * function fails to parse a value, it will emit an error on @parser,
1049 * return %FALSE and not touch @value.
1051 * Returns: %TRUE if parsing succeeded.
1054 _gtk_css_style_parse_value (GValue *value,
1055 GtkCssParser *parser)
1057 GtkStyleParseFunc func;
1059 g_return_val_if_fail (value != NULL, FALSE);
1060 g_return_val_if_fail (parser != NULL, FALSE);
1062 gtk_css_style_funcs_init ();
1064 func = g_hash_table_lookup (parse_funcs,
1065 GSIZE_TO_POINTER (G_VALUE_TYPE (value)));
1067 func = g_hash_table_lookup (parse_funcs,
1068 GSIZE_TO_POINTER (g_type_fundamental (G_VALUE_TYPE (value))));
1072 _gtk_css_parser_error (parser,
1073 "Cannot convert to type '%s'",
1074 g_type_name (G_VALUE_TYPE (value)));
1078 return (*func) (parser, value);
1082 * _gtk_css_style_print_value:
1083 * @value: an initialized GValue returned from _gtk_css_style_parse()
1084 * @string: the string to print into
1086 * Prints @value into @string as a CSS value. If @value is not a
1087 * valid value, a random string will be printed instead.
1090 _gtk_css_style_print_value (const GValue *value,
1093 GtkStylePrintFunc func;
1095 gtk_css_style_funcs_init ();
1097 func = g_hash_table_lookup (print_funcs,
1098 GSIZE_TO_POINTER (G_VALUE_TYPE (value)));
1100 func = g_hash_table_lookup (print_funcs,
1101 GSIZE_TO_POINTER (g_type_fundamental (G_VALUE_TYPE (value))));
1105 char *s = g_strdup_value_contents (value);
1106 g_string_append (string, s);
1111 func (value, string);
1115 * _gtk_css_style_compute_value:
1116 * @provider: Style provider to look up information from
1117 * @values: The values to compute for
1118 * @parent_values: Values to look up inherited values from
1119 * @target_type: Type the resulting value should have
1120 * @specified: the value to use for the computation
1121 * @dependencies: (out): Value initialized with 0 to take the dependencies
1122 * of the returned value
1124 * Converts the @specified value into the @computed value using the
1125 * information in @context. The values must have matching types, ie
1126 * @specified must be a result of a call to
1127 * _gtk_css_style_parse_value() with the same type as @computed.
1129 * Returns: the resulting value
1132 _gtk_css_style_compute_value (GtkStyleProviderPrivate *provider,
1133 GtkCssComputedValues *values,
1134 GtkCssComputedValues *parent_values,
1136 GtkCssValue *specified,
1137 GtkCssDependencies *dependencies)
1139 GtkStyleComputeFunc func;
1141 g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
1142 g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
1143 g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
1144 g_return_val_if_fail (*dependencies == 0, NULL);
1146 gtk_css_style_funcs_init ();
1148 func = g_hash_table_lookup (compute_funcs,
1149 GSIZE_TO_POINTER (target_type));
1151 func = g_hash_table_lookup (compute_funcs,
1152 GSIZE_TO_POINTER (g_type_fundamental (target_type)));
1155 return func (provider, values, parent_values, specified, dependencies);
1157 return _gtk_css_value_ref (specified);