2 * Copyright © 2011 Red Hat Inc.
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.1 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, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Benjamin Otte <otte@gnome.org>
23 #include "gtkcssshorthandpropertyprivate.h"
25 #include <cairo-gobject.h>
28 #include "gtkcssimageprivate.h"
29 #include "gtkcssstylefuncsprivate.h"
30 #include "gtkcsstypesprivate.h"
31 #include "gtkprivatetypebuiltins.h"
32 #include "gtkstylepropertiesprivate.h"
33 #include "gtksymboliccolorprivate.h"
34 #include "gtktypebuiltins.h"
36 /* this is in case round() is not provided by the compiler,
37 * such as in the case of C89 compilers, like MSVC
39 #include "fallback-c89.c"
44 value_is_done_parsing (GtkCssParser *parser)
46 return _gtk_css_parser_is_eof (parser) ||
47 _gtk_css_parser_begins_with (parser, ';') ||
48 _gtk_css_parser_begins_with (parser, '}');
52 parse_border_width (GtkCssShorthandProperty *shorthand,
57 GValue temp = G_VALUE_INIT;
60 g_value_init (&temp, GTK_TYPE_BORDER);
61 if (!_gtk_css_style_parse_value (&temp, parser, base))
63 g_value_unset (&temp);
67 border = g_value_get_boxed (&temp);
69 g_value_init (&values[0], G_TYPE_INT);
70 g_value_init (&values[1], G_TYPE_INT);
71 g_value_init (&values[2], G_TYPE_INT);
72 g_value_init (&values[3], G_TYPE_INT);
73 g_value_set_int (&values[0], border->top);
74 g_value_set_int (&values[1], border->right);
75 g_value_set_int (&values[2], border->bottom);
76 g_value_set_int (&values[3], border->left);
78 g_value_unset (&temp);
84 parse_border_width_really (GtkCssShorthandProperty *shorthand,
89 GtkCssNumber numbers[4];
92 for (i = 0; i < 4; i++)
94 if (!_gtk_css_parser_has_number (parser))
97 if (!_gtk_css_parser_read_number (parser,
100 | GTK_CSS_NUMBER_AS_PIXELS
101 | GTK_CSS_PARSE_LENGTH))
107 _gtk_css_parser_error (parser, "Expected a length");
113 numbers[i] = numbers[(i - 1) >> 1];
116 for (i = 0; i < 4; i++)
118 g_value_init (&values[i], GTK_TYPE_CSS_NUMBER);
119 g_value_set_boxed (&values[i], &numbers[i]);
126 parse_border_radius (GtkCssShorthandProperty *shorthand,
128 GtkCssParser *parser,
131 GtkCssBorderCornerRadius borders[4];
134 for (i = 0; i < G_N_ELEMENTS (borders); i++)
136 if (!_gtk_css_parser_has_number (parser))
138 if (!_gtk_css_parser_read_number (parser,
139 &borders[i].horizontal,
140 GTK_CSS_POSITIVE_ONLY
141 | GTK_CSS_PARSE_PERCENT
142 | GTK_CSS_NUMBER_AS_PIXELS
143 | GTK_CSS_PARSE_LENGTH))
149 _gtk_css_parser_error (parser, "Expected a number");
153 /* The magic (i - 1) >> 1 below makes it take the correct value
154 * according to spec. Feel free to check the 4 cases */
155 for (; i < G_N_ELEMENTS (borders); i++)
156 borders[i].horizontal = borders[(i - 1) >> 1].horizontal;
158 if (_gtk_css_parser_try (parser, "/", TRUE))
160 for (i = 0; i < G_N_ELEMENTS (borders); i++)
162 if (!_gtk_css_parser_has_number (parser))
164 if (!_gtk_css_parser_read_number (parser,
165 &borders[i].vertical,
166 GTK_CSS_POSITIVE_ONLY
167 | GTK_CSS_PARSE_PERCENT
168 | GTK_CSS_NUMBER_AS_PIXELS
169 | GTK_CSS_PARSE_LENGTH))
175 _gtk_css_parser_error (parser, "Expected a number");
179 for (; i < G_N_ELEMENTS (borders); i++)
180 borders[i].vertical = borders[(i - 1) >> 1].vertical;
185 for (i = 0; i < G_N_ELEMENTS (borders); i++)
186 borders[i].vertical = borders[i].horizontal;
189 for (i = 0; i < G_N_ELEMENTS (borders); i++)
191 g_value_init (&values[i], GTK_TYPE_CSS_BORDER_CORNER_RADIUS);
192 g_value_set_boxed (&values[i], &borders[i]);
199 parse_border_color (GtkCssShorthandProperty *shorthand,
201 GtkCssParser *parser,
204 GtkSymbolicColor *symbolic;
207 for (i = 0; i < 4; i++)
209 if (_gtk_css_parser_try (parser, "currentcolor", TRUE))
211 symbolic = gtk_symbolic_color_ref (_gtk_symbolic_color_get_current_color ());
215 symbolic = _gtk_css_parser_read_symbolic_color (parser);
216 if (symbolic == NULL)
220 g_value_init (&values[i], GTK_TYPE_SYMBOLIC_COLOR);
221 g_value_set_boxed (&values[i], symbolic);
223 if (value_is_done_parsing (parser))
227 for (i++; i < 4; i++)
229 g_value_init (&values[i], G_VALUE_TYPE (&values[(i - 1) >> 1]));
230 g_value_copy (&values[(i - 1) >> 1], &values[i]);
237 parse_border_style (GtkCssShorthandProperty *shorthand,
239 GtkCssParser *parser,
242 GtkBorderStyle styles[4];
245 for (i = 0; i < 4; i++)
247 if (!_gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, (int *)&styles[i]))
253 _gtk_css_parser_error (parser, "Expected a border style");
257 for (; i < G_N_ELEMENTS (styles); i++)
258 styles[i] = styles[(i - 1) >> 1];
260 for (i = 0; i < G_N_ELEMENTS (styles); i++)
262 g_value_init (&values[i], GTK_TYPE_BORDER_STYLE);
263 g_value_set_enum (&values[i], styles[i]);
270 parse_border_image (GtkCssShorthandProperty *shorthand,
272 GtkCssParser *parser,
277 if (_gtk_css_parser_try (parser, "none", TRUE))
281 image = _gtk_css_image_new_parse (parser, base);
285 g_value_init (&values[0], GTK_TYPE_CSS_IMAGE);
286 g_value_set_object (&values[0], image);
288 if (value_is_done_parsing (parser))
291 g_value_init (&values[1], GTK_TYPE_BORDER);
292 if (!_gtk_css_style_parse_value (&values[1], parser, base))
295 if (_gtk_css_parser_try (parser, "/", TRUE))
297 g_value_init (&values[2], GTK_TYPE_BORDER);
298 if (!_gtk_css_style_parse_value (&values[2], parser, base))
302 if (value_is_done_parsing (parser))
305 g_value_init (&values[3], GTK_TYPE_CSS_BORDER_IMAGE_REPEAT);
306 if (!_gtk_css_style_parse_value (&values[3], parser, base))
313 parse_border_side (GtkCssShorthandProperty *shorthand,
315 GtkCssParser *parser,
322 if (!G_IS_VALUE (&values[0]) &&
323 _gtk_css_parser_has_number (parser))
326 if (!_gtk_css_parser_read_number (parser,
328 GTK_CSS_POSITIVE_ONLY
329 | GTK_CSS_NUMBER_AS_PIXELS
330 | GTK_CSS_PARSE_LENGTH))
333 g_value_init (&values[0], GTK_TYPE_CSS_NUMBER);
334 g_value_set_boxed (&values[0], &number);
336 else if (!G_IS_VALUE (&values[1]) &&
337 _gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, &style))
339 g_value_init (&values[1], GTK_TYPE_BORDER_STYLE);
340 g_value_set_enum (&values[1], style);
342 else if (!G_IS_VALUE (&values[2]))
344 GtkSymbolicColor *symbolic;
346 symbolic = _gtk_css_parser_read_symbolic_color (parser);
347 if (symbolic == NULL)
350 g_value_init (&values[2], GTK_TYPE_SYMBOLIC_COLOR);
351 g_value_take_boxed (&values[2], symbolic);
355 /* We parsed everything and there's still stuff left?
356 * Pretend we didn't notice and let the normal code produce
357 * a 'junk at end of value' error */
361 while (!value_is_done_parsing (parser));
367 parse_border (GtkCssShorthandProperty *shorthand,
369 GtkCssParser *parser,
376 if (!G_IS_VALUE (&values[0]) &&
377 _gtk_css_parser_has_number (parser))
380 if (!_gtk_css_parser_read_number (parser,
382 GTK_CSS_POSITIVE_ONLY
383 | GTK_CSS_NUMBER_AS_PIXELS
384 | GTK_CSS_PARSE_LENGTH))
387 g_value_init (&values[0], GTK_TYPE_CSS_NUMBER);
388 g_value_init (&values[1], GTK_TYPE_CSS_NUMBER);
389 g_value_init (&values[2], GTK_TYPE_CSS_NUMBER);
390 g_value_init (&values[3], GTK_TYPE_CSS_NUMBER);
391 g_value_set_boxed (&values[0], &number);
392 g_value_set_boxed (&values[1], &number);
393 g_value_set_boxed (&values[2], &number);
394 g_value_set_boxed (&values[3], &number);
396 else if (!G_IS_VALUE (&values[4]) &&
397 _gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, &style))
399 g_value_init (&values[4], GTK_TYPE_BORDER_STYLE);
400 g_value_init (&values[5], GTK_TYPE_BORDER_STYLE);
401 g_value_init (&values[6], GTK_TYPE_BORDER_STYLE);
402 g_value_init (&values[7], GTK_TYPE_BORDER_STYLE);
403 g_value_set_enum (&values[4], style);
404 g_value_set_enum (&values[5], style);
405 g_value_set_enum (&values[6], style);
406 g_value_set_enum (&values[7], style);
408 else if (!G_IS_VALUE (&values[8]))
410 GtkSymbolicColor *symbolic;
412 symbolic = _gtk_css_parser_read_symbolic_color (parser);
413 if (symbolic == NULL)
416 g_value_init (&values[8], GTK_TYPE_SYMBOLIC_COLOR);
417 g_value_init (&values[9], GTK_TYPE_SYMBOLIC_COLOR);
418 g_value_init (&values[10], GTK_TYPE_SYMBOLIC_COLOR);
419 g_value_init (&values[11], GTK_TYPE_SYMBOLIC_COLOR);
420 g_value_set_boxed (&values[8], symbolic);
421 g_value_set_boxed (&values[9], symbolic);
422 g_value_set_boxed (&values[10], symbolic);
423 g_value_take_boxed (&values[11], symbolic);
427 /* We parsed everything and there's still stuff left?
428 * Pretend we didn't notice and let the normal code produce
429 * a 'junk at end of value' error */
433 while (!value_is_done_parsing (parser));
435 /* Note that border-image values are not set: according to the spec
436 they just need to be reset when using the border shorthand */
442 parse_font (GtkCssShorthandProperty *shorthand,
444 GtkCssParser *parser,
447 PangoFontDescription *desc;
451 str = _gtk_css_parser_read_value (parser);
455 desc = pango_font_description_from_string (str);
458 mask = pango_font_description_get_set_fields (desc);
460 if (mask & PANGO_FONT_MASK_FAMILY)
462 GPtrArray *strv = g_ptr_array_new ();
464 g_ptr_array_add (strv, g_strdup (pango_font_description_get_family (desc)));
465 g_ptr_array_add (strv, NULL);
466 g_value_init (&values[0], G_TYPE_STRV);
467 g_value_take_boxed (&values[0], g_ptr_array_free (strv, FALSE));
469 if (mask & PANGO_FONT_MASK_STYLE)
471 g_value_init (&values[1], PANGO_TYPE_STYLE);
472 g_value_set_enum (&values[1], pango_font_description_get_style (desc));
474 if (mask & PANGO_FONT_MASK_VARIANT)
476 g_value_init (&values[2], PANGO_TYPE_VARIANT);
477 g_value_set_enum (&values[2], pango_font_description_get_variant (desc));
479 if (mask & PANGO_FONT_MASK_WEIGHT)
481 g_value_init (&values[3], PANGO_TYPE_WEIGHT);
482 g_value_set_enum (&values[3], pango_font_description_get_weight (desc));
484 if (mask & PANGO_FONT_MASK_SIZE)
486 g_value_init (&values[4], G_TYPE_DOUBLE);
487 g_value_set_double (&values[4],
488 (double) pango_font_description_get_size (desc) / PANGO_SCALE);
491 pango_font_description_free (desc);
497 parse_background (GtkCssShorthandProperty *shorthand,
499 GtkCssParser *parser,
507 if (!G_IS_VALUE (&values[0]) &&
508 (_gtk_css_parser_has_prefix (parser, "none") ||
509 _gtk_css_image_can_parse (parser)))
513 if (_gtk_css_parser_try (parser, "none", TRUE))
517 image = _gtk_css_image_new_parse (parser, base);
522 g_value_init (&values[0], GTK_TYPE_CSS_IMAGE);
523 g_value_take_object (&values[0], image);
525 else if (!G_IS_VALUE (&values[1]) &&
526 _gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_BACKGROUND_REPEAT, &enum_value))
528 if (enum_value <= GTK_CSS_BACKGROUND_REPEAT_MASK)
532 if (_gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_BACKGROUND_REPEAT, &vertical))
534 if (vertical >= GTK_CSS_BACKGROUND_REPEAT_MASK)
536 _gtk_css_parser_error (parser, "Not a valid 2nd value for border-repeat");
540 enum_value |= vertical << GTK_CSS_BACKGROUND_REPEAT_SHIFT;
543 enum_value |= enum_value << GTK_CSS_BACKGROUND_REPEAT_SHIFT;
546 g_value_init (&values[1], GTK_TYPE_CSS_BACKGROUND_REPEAT);
547 g_value_set_enum (&values[1], enum_value);
549 else if ((!G_IS_VALUE (&values[2]) || !G_IS_VALUE (&values[3])) &&
550 _gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_AREA, &enum_value))
552 guint idx = !G_IS_VALUE (&values[2]) ? 2 : 3;
553 g_value_init (&values[idx], GTK_TYPE_CSS_AREA);
554 g_value_set_enum (&values[idx], enum_value);
556 else if (!G_IS_VALUE (&values[4]))
558 GtkSymbolicColor *symbolic;
560 symbolic = _gtk_css_parser_read_symbolic_color (parser);
561 if (symbolic == NULL)
564 g_value_init (&values[4], GTK_TYPE_SYMBOLIC_COLOR);
565 g_value_take_boxed (&values[4], symbolic);
569 /* We parsed everything and there's still stuff left?
570 * Pretend we didn't notice and let the normal code produce
571 * a 'junk at end of value' error */
575 while (!value_is_done_parsing (parser));
583 unpack_border (GtkCssShorthandProperty *shorthand,
584 GtkStyleProperties *props,
588 GValue v = G_VALUE_INIT;
589 GtkBorder *border = g_value_get_boxed (value);
591 g_value_init (&v, G_TYPE_INT);
593 g_value_set_int (&v, border->top);
594 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 0)), props, state, &v);
595 g_value_set_int (&v, border->right);
596 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 1)), props, state, &v);
597 g_value_set_int (&v, border->bottom);
598 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 2)), props, state, &v);
599 g_value_set_int (&v, border->left);
600 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 3)), props, state, &v);
606 pack_border (GtkCssShorthandProperty *shorthand,
608 GtkStyleQueryFunc query_func,
611 GtkCssStyleProperty *prop;
615 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
616 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
618 border.top = g_value_get_int (v);
619 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 1);
620 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
622 border.right = g_value_get_int (v);
623 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 2);
624 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
626 border.bottom = g_value_get_int (v);
627 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 3);
628 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
630 border.left = g_value_get_int (v);
632 g_value_set_boxed (value, &border);
636 unpack_border_radius (GtkCssShorthandProperty *shorthand,
637 GtkStyleProperties *props,
641 GtkCssBorderCornerRadius border;
642 GValue v = G_VALUE_INIT;
645 _gtk_css_number_init (&border.horizontal, g_value_get_int (value), GTK_CSS_PX);
646 border.vertical = border.horizontal;
647 g_value_init (&v, GTK_TYPE_CSS_BORDER_CORNER_RADIUS);
648 g_value_set_boxed (&v, &border);
650 for (i = 0; i < 4; i++)
651 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, i)), props, state, &v);
657 pack_border_radius (GtkCssShorthandProperty *shorthand,
659 GtkStyleQueryFunc query_func,
662 GtkCssBorderCornerRadius *top_left;
663 GtkCssStyleProperty *prop;
666 prop = GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("border-top-left-radius"));
667 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
670 top_left = g_value_get_boxed (v);
672 g_value_set_int (value, top_left->horizontal.value);
677 unpack_font_description (GtkCssShorthandProperty *shorthand,
678 GtkStyleProperties *props,
682 GtkStyleProperty *prop;
683 PangoFontDescription *description;
685 GValue v = G_VALUE_INIT;
687 /* For backwards compat, we only unpack values that are indeed set.
688 * For strict CSS conformance we need to unpack all of them.
689 * Note that we do set all of them in the parse function, so it
690 * will not have effects when parsing CSS files. It will though
691 * for custom style providers.
694 description = g_value_get_boxed (value);
697 mask = pango_font_description_get_set_fields (description);
701 if (mask & PANGO_FONT_MASK_FAMILY)
703 GPtrArray *strv = g_ptr_array_new ();
705 g_ptr_array_add (strv, g_strdup (pango_font_description_get_family (description)));
706 g_ptr_array_add (strv, NULL);
707 g_value_init (&v, G_TYPE_STRV);
708 g_value_take_boxed (&v, g_ptr_array_free (strv, FALSE));
710 prop = _gtk_style_property_lookup ("font-family");
711 _gtk_style_property_assign (prop, props, state, &v);
715 if (mask & PANGO_FONT_MASK_STYLE)
717 g_value_init (&v, PANGO_TYPE_STYLE);
718 g_value_set_enum (&v, pango_font_description_get_style (description));
720 prop = _gtk_style_property_lookup ("font-style");
721 _gtk_style_property_assign (prop, props, state, &v);
725 if (mask & PANGO_FONT_MASK_VARIANT)
727 g_value_init (&v, PANGO_TYPE_VARIANT);
728 g_value_set_enum (&v, pango_font_description_get_variant (description));
730 prop = _gtk_style_property_lookup ("font-variant");
731 _gtk_style_property_assign (prop, props, state, &v);
735 if (mask & PANGO_FONT_MASK_WEIGHT)
737 g_value_init (&v, PANGO_TYPE_WEIGHT);
738 g_value_set_enum (&v, pango_font_description_get_weight (description));
740 prop = _gtk_style_property_lookup ("font-weight");
741 _gtk_style_property_assign (prop, props, state, &v);
745 if (mask & PANGO_FONT_MASK_SIZE)
747 g_value_init (&v, G_TYPE_DOUBLE);
748 g_value_set_double (&v, (double) pango_font_description_get_size (description) / PANGO_SCALE);
750 prop = _gtk_style_property_lookup ("font-size");
751 _gtk_style_property_assign (prop, props, state, &v);
757 pack_font_description (GtkCssShorthandProperty *shorthand,
759 GtkStyleQueryFunc query_func,
762 PangoFontDescription *description;
765 description = pango_font_description_new ();
767 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-family"))), query_data);
770 const char **families = g_value_get_boxed (v);
771 /* xxx: Can we set all the families here somehow? */
773 pango_font_description_set_family (description, families[0]);
776 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-size"))), query_data);
778 pango_font_description_set_size (description, round (g_value_get_double (v) * PANGO_SCALE));
780 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-style"))), query_data);
782 pango_font_description_set_style (description, g_value_get_enum (v));
784 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-variant"))), query_data);
786 pango_font_description_set_variant (description, g_value_get_enum (v));
788 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-weight"))), query_data);
790 pango_font_description_set_weight (description, g_value_get_enum (v));
792 g_value_take_boxed (value, description);
796 unpack_to_everything (GtkCssShorthandProperty *shorthand,
797 GtkStyleProperties *props,
801 GtkCssStyleProperty *prop;
804 n = _gtk_css_shorthand_property_get_n_subproperties (shorthand);
806 for (i = 0; i < n; i++)
808 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
809 _gtk_style_property_assign (GTK_STYLE_PROPERTY (prop), props, state, value);
814 pack_first_element (GtkCssShorthandProperty *shorthand,
816 GtkStyleQueryFunc query_func,
819 GtkCssStyleProperty *prop;
823 /* NB: This is a fallback for properties that originally were
824 * not used as shorthand. We just pick the first subproperty
825 * as a representative.
826 * Lesson learned: Don't query the shorthand, query the
827 * real properties instead. */
828 for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
830 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
831 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
834 g_value_copy (v, value);
841 _gtk_css_shorthand_property_register (const char *name,
843 const char **subproperties,
844 GtkCssShorthandPropertyParseFunc parse_func,
845 GtkCssShorthandPropertyAssignFunc assign_func,
846 GtkCssShorthandPropertyQueryFunc query_func)
848 GtkCssShorthandProperty *node;
850 node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
852 "value-type", value_type,
853 "subproperties", subproperties,
856 node->parse = parse_func;
857 node->assign = assign_func;
858 node->query = query_func;
862 _gtk_css_shorthand_property_init_properties (void)
864 /* The order is important here, be careful when changing it */
865 const char *font_subproperties[] = { "font-family", "font-style", "font-variant", "font-weight", "font-size", NULL };
866 const char *margin_subproperties[] = { "margin-top", "margin-right", "margin-bottom", "margin-left", NULL };
867 const char *padding_subproperties[] = { "padding-top", "padding-right", "padding-bottom", "padding-left", NULL };
868 const char *border_width_subproperties[] = { "border-top-width", "border-right-width", "border-bottom-width", "border-left-width", NULL };
869 const char *border_radius_subproperties[] = { "border-top-left-radius", "border-top-right-radius",
870 "border-bottom-right-radius", "border-bottom-left-radius", NULL };
871 const char *border_color_subproperties[] = { "border-top-color", "border-right-color", "border-bottom-color", "border-left-color", NULL };
872 const char *border_style_subproperties[] = { "border-top-style", "border-right-style", "border-bottom-style", "border-left-style", NULL };
873 const char *border_image_subproperties[] = { "border-image-source", "border-image-slice", "border-image-width", "border-image-repeat", NULL };
874 const char *border_top_subproperties[] = { "border-top-width", "border-top-style", "border-top-color", NULL };
875 const char *border_right_subproperties[] = { "border-right-width", "border-right-style", "border-right-color", NULL };
876 const char *border_bottom_subproperties[] = { "border-bottom-width", "border-bottom-style", "border-bottom-color", NULL };
877 const char *border_left_subproperties[] = { "border-left-width", "border-left-style", "border-left-color", NULL };
878 const char *border_subproperties[] = { "border-top-width", "border-right-width", "border-bottom-width", "border-left-width",
879 "border-top-style", "border-right-style", "border-bottom-style", "border-left-style",
880 "border-top-color", "border-right-color", "border-bottom-color", "border-left-color",
881 "border-image-source", "border-image-slice", "border-image-width", "border-image-repeat", NULL };
882 const char *outline_subproperties[] = { "outline-width", "outline-style", "outline-color", NULL };
883 const char *background_subproperties[] = { "background-image", "background-repeat", "background-clip", "background-origin",
884 "background-color", NULL };
886 _gtk_css_shorthand_property_register ("font",
887 PANGO_TYPE_FONT_DESCRIPTION,
890 unpack_font_description,
891 pack_font_description);
892 _gtk_css_shorthand_property_register ("margin",
894 margin_subproperties,
898 _gtk_css_shorthand_property_register ("padding",
900 padding_subproperties,
904 _gtk_css_shorthand_property_register ("border-width",
906 border_width_subproperties,
907 parse_border_width_really,
910 _gtk_css_shorthand_property_register ("border-radius",
912 border_radius_subproperties,
914 unpack_border_radius,
916 _gtk_css_shorthand_property_register ("border-color",
918 border_color_subproperties,
920 unpack_to_everything,
922 _gtk_css_shorthand_property_register ("border-style",
923 GTK_TYPE_BORDER_STYLE,
924 border_style_subproperties,
926 unpack_to_everything,
928 _gtk_css_shorthand_property_register ("border-image",
930 border_image_subproperties,
934 _gtk_css_shorthand_property_register ("border-top",
936 border_top_subproperties,
940 _gtk_css_shorthand_property_register ("border-right",
942 border_right_subproperties,
946 _gtk_css_shorthand_property_register ("border-bottom",
948 border_bottom_subproperties,
952 _gtk_css_shorthand_property_register ("border-left",
954 border_left_subproperties,
958 _gtk_css_shorthand_property_register ("border",
960 border_subproperties,
964 _gtk_css_shorthand_property_register ("outline",
966 outline_subproperties,
970 _gtk_css_shorthand_property_register ("background",
972 background_subproperties,