-background_size_compute (GtkCssStyleProperty *property,
- GtkStyleContext *context,
- GtkCssValue *specified)
-{
- const GtkCssBackgroundSize *ssize = _gtk_css_value_get_background_size (specified);
- GtkCssBackgroundSize csize;
- gboolean changed;
-
- csize.cover = ssize->cover;
- csize.contain = ssize->contain;
- changed = _gtk_css_number_compute (&csize.width,
- &ssize->width,
- context);
- changed |= _gtk_css_number_compute (&csize.height,
- &ssize->height,
- context);
- if (changed)
- return _gtk_css_value_new_from_background_size (&csize);
- return _gtk_css_value_ref (specified);
-}
-
-static gboolean
-background_position_parse (GtkCssStyleProperty *property,
- GValue *value,
- GtkCssParser *parser,
- GFile *base)
-{
- static const struct {
- const char *name;
- guint percentage;
- gboolean horizontal;
- gboolean vertical;
- } names[] = {
- { "left", 0, TRUE, FALSE },
- { "right", 100, TRUE, FALSE },
- { "center", 50, TRUE, TRUE },
- { "top", 0, FALSE, TRUE },
- { "bottom", 100, FALSE, TRUE },
- { NULL , 0, TRUE, FALSE }, /* used for numbers */
- { NULL , 50, TRUE, TRUE } /* used for no value */
- };
- GtkCssBackgroundPosition pos;
- GtkCssNumber *missing;
- guint first, second;
-
- for (first = 0; names[first].name != NULL; first++)
- {
- if (_gtk_css_parser_try (parser, names[first].name, TRUE))
- {
- if (names[first].horizontal)
- {
- _gtk_css_number_init (&pos.x, names[first].percentage, GTK_CSS_PERCENT);
- missing = &pos.y;
- }
- else
- {
- _gtk_css_number_init (&pos.y, names[first].percentage, GTK_CSS_PERCENT);
- missing = &pos.x;
- }
- break;
- }
- }
- if (names[first].name == NULL)
- {
- missing = &pos.y;
- if (!_gtk_css_parser_read_number (parser,
- &pos.x,
- GTK_CSS_PARSE_PERCENT
- | GTK_CSS_PARSE_LENGTH))
- return FALSE;
- }