gtkcssshorthandpropertyimpl.c 46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * Copyright © 2011 Red Hat Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21 22 23 24 25 26
 *
 * Authors: Benjamin Otte <otte@gnome.org>
 */

#include "config.h"

#include "gtkcssshorthandpropertyprivate.h"

#include <cairo-gobject.h>
#include <math.h>

27
#include "gtkcssarrayvalueprivate.h"
28
#include "gtkcssbgsizevalueprivate.h"
29
#include "gtkcssbordervalueprivate.h"
30
#include "gtkcsscolorvalueprivate.h"
31
#include "gtkcsscornervalueprivate.h"
32
#include "gtkcsseasevalueprivate.h"
33
#include "gtkcssenumvalueprivate.h"
34
#include "gtkcssimageprivate.h"
35
#include "gtkcssimagevalueprivate.h"
36
#include "gtkcssnumbervalueprivate.h"
37
#include "gtkcsspositionvalueprivate.h"
38
#include "gtkcssrepeatvalueprivate.h"
39
#include "gtkcssstringvalueprivate.h"
40
#include "gtkcssstylefuncsprivate.h"
41
#include "gtkcssvalueprivate.h"
Matthias Clasen's avatar
Matthias Clasen committed
42
#include "deprecated/gtkstylepropertiesprivate.h"
43
#include "gtktypebuiltins.h"
44 45 46 47 48 49 50 51

/* this is in case round() is not provided by the compiler, 
 * such as in the case of C89 compilers, like MSVC
 */
#include "fallback-c89.c"

/*** PARSING ***/

52 53 54 55
static gboolean
value_is_done_parsing (GtkCssParser *parser)
{
  return _gtk_css_parser_is_eof (parser) ||
56
         _gtk_css_parser_begins_with (parser, ',') ||
57 58 59 60
         _gtk_css_parser_begins_with (parser, ';') ||
         _gtk_css_parser_begins_with (parser, '}');
}

61
static gboolean
62 63 64 65
parse_four_numbers (GtkCssShorthandProperty  *shorthand,
                    GtkCssValue             **values,
                    GtkCssParser             *parser,
                    GtkCssNumberParseFlags    flags)
66 67 68 69 70 71 72 73
{
  guint i;

  for (i = 0; i < 4; i++)
    {
      if (!_gtk_css_parser_has_number (parser))
        break;

74 75
      values[i] = _gtk_css_number_value_parse (parser, flags);
      if (values[i] == NULL)
76 77 78 79 80 81 82 83 84 85 86
        return FALSE;
    }

  if (i == 0)
    {
      _gtk_css_parser_error (parser, "Expected a length");
      return FALSE;
    }

  for (; i < 4; i++)
    {
87
      values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
88 89 90 91 92
    }

  return TRUE;
}

93
static gboolean
94 95
parse_margin (GtkCssShorthandProperty  *shorthand,
              GtkCssValue             **values,
96
              GtkCssParser             *parser)
97 98 99 100 101 102 103 104 105
{
  return parse_four_numbers (shorthand,
                             values,
                             parser,
                             GTK_CSS_NUMBER_AS_PIXELS
                             | GTK_CSS_PARSE_LENGTH);
}

static gboolean
106 107
parse_padding (GtkCssShorthandProperty  *shorthand,
               GtkCssValue             **values,
108
               GtkCssParser             *parser)
109 110 111 112 113 114 115 116 117 118
{
  return parse_four_numbers (shorthand,
                             values,
                             parser,
                             GTK_CSS_POSITIVE_ONLY
                             | GTK_CSS_NUMBER_AS_PIXELS
                             | GTK_CSS_PARSE_LENGTH);
}

static gboolean
119 120
parse_border_width (GtkCssShorthandProperty  *shorthand,
                    GtkCssValue             **values,
121
                    GtkCssParser             *parser)
122 123 124 125 126 127 128 129 130
{
  return parse_four_numbers (shorthand,
                             values,
                             parser,
                             GTK_CSS_POSITIVE_ONLY
                             | GTK_CSS_NUMBER_AS_PIXELS
                             | GTK_CSS_PARSE_LENGTH);
}

131
static gboolean 
132 133
parse_border_radius (GtkCssShorthandProperty  *shorthand,
                     GtkCssValue             **values,
134
                     GtkCssParser             *parser)
135
{
136
  GtkCssValue *x[4] = { NULL, }, *y[4] = { NULL, };
137 138
  guint i;

139
  for (i = 0; i < 4; i++)
140
    {
141
      if (!_gtk_css_parser_has_number (parser))
142
        break;
143 144 145 146 147 148 149
      x[i] = _gtk_css_number_value_parse (parser,
                                          GTK_CSS_POSITIVE_ONLY
                                          | GTK_CSS_PARSE_PERCENT
                                          | GTK_CSS_NUMBER_AS_PIXELS
                                          | GTK_CSS_PARSE_LENGTH);
      if (x[i] == NULL)
        goto fail;
150 151 152 153 154
    }

  if (i == 0)
    {
      _gtk_css_parser_error (parser, "Expected a number");
155
      goto fail;
156 157 158 159
    }

  /* The magic (i - 1) >> 1 below makes it take the correct value
   * according to spec. Feel free to check the 4 cases */
160 161
  for (; i < 4; i++)
    x[i] = _gtk_css_value_ref (x[(i - 1) >> 1]);
162 163 164

  if (_gtk_css_parser_try (parser, "/", TRUE))
    {
165
      for (i = 0; i < 4; i++)
166
        {
167
          if (!_gtk_css_parser_has_number (parser))
168
            break;
169 170 171 172 173 174 175
          y[i] = _gtk_css_number_value_parse (parser,
                                              GTK_CSS_POSITIVE_ONLY
                                              | GTK_CSS_PARSE_PERCENT
                                              | GTK_CSS_NUMBER_AS_PIXELS
                                              | GTK_CSS_PARSE_LENGTH);
          if (y[i] == NULL)
            goto fail;
176 177 178 179 180
        }

      if (i == 0)
        {
          _gtk_css_parser_error (parser, "Expected a number");
181
          goto fail;
182 183
        }

184 185
      for (; i < 4; i++)
        y[i] = _gtk_css_value_ref (y[(i - 1) >> 1]);
186 187 188
    }
  else
    {
189 190
      for (i = 0; i < 4; i++)
        y[i] = _gtk_css_value_ref (x[i]);
191 192
    }

193
  for (i = 0; i < 4; i++)
194
    {
195
      values[i] = _gtk_css_corner_value_new (x[i], y[i]);
196 197 198
    }

  return TRUE;
199 200 201 202 203 204 205 206 207 208

fail:
  for (i = 0; i < 4; i++)
    {
      if (x[i])
        _gtk_css_value_unref (x[i]);
      if (y[i])
        _gtk_css_value_unref (y[i]);
    }
  return FALSE;
209 210
}

211
static gboolean 
212 213
parse_border_color (GtkCssShorthandProperty  *shorthand,
                    GtkCssValue             **values,
214
                    GtkCssParser             *parser)
215 216 217 218 219
{
  guint i;

  for (i = 0; i < 4; i++)
    {
220
      values[i] = _gtk_css_color_value_parse (parser);
221
      if (values[i] == NULL)
222
        return FALSE;
223

224
      if (value_is_done_parsing (parser))
225 226 227 228 229
        break;
    }

  for (i++; i < 4; i++)
    {
230
      values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
231 232 233 234 235
    }

  return TRUE;
}

236
static gboolean
237 238
parse_border_style (GtkCssShorthandProperty  *shorthand,
                    GtkCssValue             **values,
239
                    GtkCssParser             *parser)
240 241 242 243 244
{
  guint i;

  for (i = 0; i < 4; i++)
    {
245 246
      values[i] = _gtk_css_border_style_value_try_parse (parser);
      if (values[i] == NULL)
247 248 249 250 251 252 253 254 255
        break;
    }

  if (i == 0)
    {
      _gtk_css_parser_error (parser, "Expected a border style");
      return FALSE;
    }

256 257
  for (; i < 4; i++)
    values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
258 259 260 261

  return TRUE;
}

262
static gboolean
263 264
parse_border_image (GtkCssShorthandProperty  *shorthand,
                    GtkCssValue             **values,
265
                    GtkCssParser             *parser)
266
{
267
  do
268
    {
269 270 271 272 273
      if (values[0] == NULL &&
          (_gtk_css_parser_has_prefix (parser, "none") ||
           _gtk_css_image_can_parse (parser)))
        {
          GtkCssImage *image;
274

275 276 277 278
          if (_gtk_css_parser_try (parser, "none", TRUE))
            image = NULL;
          else
            {
279
              image = _gtk_css_image_new_parse (parser);
280 281 282
              if (image == NULL)
                return FALSE;
            }
283

284 285 286 287 288 289 290 291 292
          values[0] = _gtk_css_image_value_new (image);
        }
      else if (values[3] == NULL &&
               (values[3] = _gtk_css_border_repeat_value_try_parse (parser)))
        {
          /* please move along */
        }
      else if (values[1] == NULL)
        {
293 294 295 296 297 298 299
          values[1] = _gtk_css_border_value_parse (parser,
                                                   GTK_CSS_PARSE_PERCENT
                                                   | GTK_CSS_PARSE_NUMBER
                                                   | GTK_CSS_POSITIVE_ONLY,
                                                   FALSE,
                                                   TRUE);
          if (values[1] == NULL)
300
            return FALSE;
301

302 303
          if (_gtk_css_parser_try (parser, "/", TRUE))
            {
304 305 306 307 308 309 310 311
              values[2] = _gtk_css_border_value_parse (parser,
                                                       GTK_CSS_PARSE_PERCENT
                                                       | GTK_CSS_PARSE_LENGTH
                                                       | GTK_CSS_PARSE_NUMBER
                                                       | GTK_CSS_POSITIVE_ONLY,
                                                       TRUE,
                                                       FALSE);
              if (values[2] == NULL)
312 313 314 315 316 317 318 319 320 321 322 323
                return FALSE;
            }
        }
      else
        {
          /* We parsed everything and there's still stuff left?
           * Pretend we didn't notice and let the normal code produce
           * a 'junk at end of value' error */
          break;
        }
    }
  while (!value_is_done_parsing (parser));
324

325
  return TRUE;
326 327
}

328
static gboolean
329 330
parse_border_side (GtkCssShorthandProperty  *shorthand,
                   GtkCssValue             **values,
331
                   GtkCssParser             *parser)
332 333 334
{
  do
  {
335
    if (values[0] == NULL &&
336
         _gtk_css_parser_has_number (parser))
337
      {
338 339 340 341 342
        values[0] = _gtk_css_number_value_parse (parser,
                                                 GTK_CSS_POSITIVE_ONLY
                                                 | GTK_CSS_NUMBER_AS_PIXELS
                                                 | GTK_CSS_PARSE_LENGTH);
        if (values[0] == NULL)
343
          return FALSE;
344
      }
345
    else if (values[1] == NULL &&
346
             (values[1] = _gtk_css_border_style_value_try_parse (parser)))
347
      {
348
        /* Nothing to do */
349
      }
350
    else if (values[2] == NULL)
351
      {
352
        values[2] = _gtk_css_color_value_parse (parser);
353
        if (values[2] == NULL)
354 355
          return FALSE;
      }
356 357 358 359 360 361 362
    else
      {
        /* We parsed and there's still stuff left?
         * Pretend we didn't notice and let the normal code produce
         * a 'junk at end of value' error */
        break;
      }
363 364 365 366 367 368
  }
  while (!value_is_done_parsing (parser));

  return TRUE;
}

369
static gboolean
370 371
parse_border (GtkCssShorthandProperty  *shorthand,
              GtkCssValue             **values,
372
              GtkCssParser             *parser)
373 374 375
{
  do
  {
376
    if (values[0] == NULL &&
377
         _gtk_css_parser_has_number (parser))
378
      {
379 380 381 382 383
        values[0] = _gtk_css_number_value_parse (parser,
                                                 GTK_CSS_POSITIVE_ONLY
                                                 | GTK_CSS_NUMBER_AS_PIXELS
                                                 | GTK_CSS_PARSE_LENGTH);
        if (values[0] == NULL)
384
          return FALSE;
385 386 387
        values[1] = _gtk_css_value_ref (values[0]);
        values[2] = _gtk_css_value_ref (values[0]);
        values[3] = _gtk_css_value_ref (values[0]);
388
      }
389
    else if (values[4] == NULL &&
390
             (values[4] = _gtk_css_border_style_value_try_parse (parser)))
391
      {
392 393 394
        values[5] = _gtk_css_value_ref (values[4]);
        values[6] = _gtk_css_value_ref (values[4]);
        values[7] = _gtk_css_value_ref (values[4]);
395 396 397
      }
    else if (!G_IS_VALUE (&values[8]))
      {
398
        values[8] = _gtk_css_color_value_parse (parser);
399
        if (values[8] == NULL)
400 401
          return FALSE;

402 403 404
        values[9] = _gtk_css_value_ref (values[8]);
        values[10] = _gtk_css_value_ref (values[8]);
        values[11] = _gtk_css_value_ref (values[8]);
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
      }
    else
      {
        /* We parsed everything and there's still stuff left?
         * Pretend we didn't notice and let the normal code produce
         * a 'junk at end of value' error */
        break;
      }
  }
  while (!value_is_done_parsing (parser));

  /* Note that border-image values are not set: according to the spec
     they just need to be reset when using the border shorthand */

  return TRUE;
}

422
static gboolean
423 424
parse_font (GtkCssShorthandProperty  *shorthand,
            GtkCssValue             **values,
425
            GtkCssParser             *parser)
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
{
  PangoFontDescription *desc;
  guint mask;
  char *str;

  str = _gtk_css_parser_read_value (parser);
  if (str == NULL)
    return FALSE;

  desc = pango_font_description_from_string (str);
  g_free (str);

  mask = pango_font_description_get_set_fields (desc);

  if (mask & PANGO_FONT_MASK_FAMILY)
    {
442
      values[0] = _gtk_css_array_value_new (_gtk_css_string_value_new (pango_font_description_get_family (desc)));
443 444 445
    }
  if (mask & PANGO_FONT_MASK_STYLE)
    {
446
      values[1] = _gtk_css_font_style_value_new (pango_font_description_get_style (desc));
447 448 449
    }
  if (mask & PANGO_FONT_MASK_VARIANT)
    {
450
      values[2] = _gtk_css_font_variant_value_new (pango_font_description_get_variant (desc));
451 452 453
    }
  if (mask & PANGO_FONT_MASK_WEIGHT)
    {
454
      values[3] = _gtk_css_font_weight_value_new (pango_font_description_get_weight (desc));
455
    }
456 457 458 459
  if (mask & PANGO_FONT_MASK_STRETCH)
    {
      values[4] = _gtk_css_font_stretch_value_new (pango_font_description_get_stretch (desc));
    }
460 461
  if (mask & PANGO_FONT_MASK_SIZE)
    {
462
      values[5] = _gtk_css_number_value_new ((double) pango_font_description_get_size (desc) / PANGO_SCALE, GTK_CSS_PX);
463 464 465 466 467 468 469
    }

  pango_font_description_free (desc);

  return TRUE;
}

470
static gboolean
471 472 473
parse_one_background (GtkCssShorthandProperty  *shorthand,
                      GtkCssValue             **values,
                      GtkCssParser             *parser)
474
{
475
  GtkCssValue *value = NULL;
476

477 478 479
  do
    {
      /* the image part */
480
      if (values[0] == NULL &&
481 482 483 484 485 486 487 488 489
          (_gtk_css_parser_has_prefix (parser, "none") ||
           _gtk_css_image_can_parse (parser)))
        {
          GtkCssImage *image;

          if (_gtk_css_parser_try (parser, "none", TRUE))
            image = NULL;
          else
            {
490
              image = _gtk_css_image_new_parse (parser);
491 492 493 494
              if (image == NULL)
                return FALSE;
            }

495 496 497
          values[0] = _gtk_css_image_value_new (image);
        }
      else if (values[1] == NULL &&
Matthias Clasen's avatar
Matthias Clasen committed
498
               (value = _gtk_css_position_value_try_parse (parser)))
499 500 501 502 503 504 505 506 507 508
        {
          values[1] = value;
          value = NULL;

          if (_gtk_css_parser_try (parser, "/", TRUE) &&
              (value = _gtk_css_bg_size_value_parse (parser)))
            {
              values[2] = value;
              value = NULL;
            }
509
        }
510
      else if (values[3] == NULL &&
511
               (value = _gtk_css_background_repeat_value_try_parse (parser)))
512
        {
513
          values[3] = value;
514
          value = NULL;
515
        }
516
      else if ((values[4] == NULL || values[5] == NULL) &&
517
               (value = _gtk_css_area_value_try_parse (parser)))
518
        {
519
          values[4] = value;
520

521
          if (values[5] == NULL)
522
            {
523 524
              values[5] = values[4];
              values[4] = NULL;
525
            }
526
          value = NULL;
527
        }
528
      else if (values[6] == NULL)
529
        {
530
          value = _gtk_css_color_value_parse (parser);
531
          if (value == NULL)
532 533 534 535
            values[6] = _gtk_css_value_ref (_gtk_css_style_property_get_initial_value 
                                            (_gtk_css_shorthand_property_get_subproperty (shorthand, 6)));
          else
            values[6] = value;
536

537 538
          value = NULL;
        }
539 540 541 542 543 544 545 546 547 548
      else
        {
          /* We parsed everything and there's still stuff left?
           * Pretend we didn't notice and let the normal code produce
           * a 'junk at end of value' error */
          break;
        }
    }
  while (!value_is_done_parsing (parser));

549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
  if (values[5] != NULL && values[4] == NULL)
    values[4] = _gtk_css_value_ref (values[5]);

  return TRUE;
}

static gboolean
parse_background (GtkCssShorthandProperty  *shorthand,
                  GtkCssValue             **values,
                  GtkCssParser             *parser)
{
  GtkCssValue *step_values[7];
  GPtrArray *arrays[6];
  guint i;

  for (i = 0; i < 6; i++)
    {
      arrays[i] = g_ptr_array_new ();
      step_values[i] = NULL;
    }
  
  step_values[6] = NULL;

  do {
    if (!parse_one_background (shorthand, step_values, parser))
      {
        for (i = 0; i < 6; i++)
          {
            g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
            g_ptr_array_unref (arrays[i]);
          }
580
        return FALSE;
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
      }

      for (i = 0; i < 6; i++)
        {
          if (step_values[i] == NULL)
            {
              GtkCssValue *initial = _gtk_css_style_property_get_initial_value (
                                         _gtk_css_shorthand_property_get_subproperty (shorthand, i));
              step_values[i] = _gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
            }

          g_ptr_array_add (arrays[i], step_values[i]);
          step_values[i] = NULL;
        }
  } while (_gtk_css_parser_try (parser, ",", TRUE));

  for (i = 0; i < 6; i++)
    {
      values[i] = _gtk_css_array_value_new_from_array ((GtkCssValue **) arrays[i]->pdata, arrays[i]->len);
      g_ptr_array_unref (arrays[i]);
    }

  values[6] = step_values[6];

605 606 607
  return TRUE;
}

608 609 610
static gboolean
parse_one_transition (GtkCssShorthandProperty  *shorthand,
                      GtkCssValue             **values,
611
                      GtkCssParser             *parser)
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
{
  do
    {
      /* the image part */
      if (values[2] == NULL &&
          _gtk_css_parser_has_number (parser) && !_gtk_css_parser_begins_with (parser, '-'))
        {
          GtkCssValue *number = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_TIME);

          if (number == NULL)
            return FALSE;

          if (values[1] == NULL)
            values[1] = number;
          else
            values[2] = number;
        }
      else if (values[3] == NULL &&
               _gtk_css_ease_value_can_parse (parser))
        {
          values[3] = _gtk_css_ease_value_parse (parser);

          if (values[3] == NULL)
            return FALSE;
        }
      else if (values[0] == NULL)
        {
          values[0] = _gtk_css_ident_value_try_parse (parser);
          if (values[0] == NULL)
            {
              _gtk_css_parser_error (parser, "Unknown value for property");
              return FALSE;
            }

        }
      else
        {
          /* We parsed everything and there's still stuff left?
           * Pretend we didn't notice and let the normal code produce
           * a 'junk at end of value' error */
          break;
        }
    }
  while (!value_is_done_parsing (parser));

  return TRUE;
}

static gboolean
parse_transition (GtkCssShorthandProperty  *shorthand,
                  GtkCssValue             **values,
663
                  GtkCssParser             *parser)
664 665 666 667 668 669 670 671 672 673 674 675
{
  GtkCssValue *step_values[4];
  GPtrArray *arrays[4];
  guint i;

  for (i = 0; i < 4; i++)
    {
      arrays[i] = g_ptr_array_new ();
      step_values[i] = NULL;
    }

  do {
676
    if (!parse_one_transition (shorthand, step_values, parser))
677 678 679 680 681 682
      {
        for (i = 0; i < 4; i++)
          {
            g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
            g_ptr_array_unref (arrays[i]);
          }
683
        return FALSE;
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
      }

      for (i = 0; i < 4; i++)
        {
          if (step_values[i] == NULL)
            {
              GtkCssValue *initial = _gtk_css_style_property_get_initial_value (
                                         _gtk_css_shorthand_property_get_subproperty (shorthand, i));
              step_values[i] = _gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
            }

          g_ptr_array_add (arrays[i], step_values[i]);
          step_values[i] = NULL;
        }
  } while (_gtk_css_parser_try (parser, ",", TRUE));

  for (i = 0; i < 4; i++)
    {
      values[i] = _gtk_css_array_value_new_from_array ((GtkCssValue **) arrays[i]->pdata, arrays[i]->len);
      g_ptr_array_unref (arrays[i]);
    }

  return TRUE;
}

709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
static gboolean
parse_one_animation (GtkCssShorthandProperty  *shorthand,
                     GtkCssValue             **values,
                     GtkCssParser             *parser)
{
  do
    {
      if (values[1] == NULL && _gtk_css_parser_try (parser, "infinite", TRUE))
        {
          values[1] = _gtk_css_number_value_new (HUGE_VAL, GTK_CSS_NUMBER);
        }
      else if ((values[1] == NULL || values[3] == NULL) &&
          _gtk_css_parser_has_number (parser))
        {
          GtkCssValue *value;
          
          value = _gtk_css_number_value_parse (parser,
                                               GTK_CSS_POSITIVE_ONLY
                                               | (values[1] == NULL ? GTK_CSS_PARSE_NUMBER : 0)
                                               | (values[3] == NULL ? GTK_CSS_PARSE_TIME : 0));
729 730 731
          if (value == NULL)
            return FALSE;

732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782
          if (_gtk_css_number_value_get_unit (value) == GTK_CSS_NUMBER)
            values[1] = value;
          else if (values[2] == NULL)
            values[2] = value;
          else
            values[3] = value;
        }
      else if (values[4] == NULL &&
               _gtk_css_ease_value_can_parse (parser))
        {
          values[4] = _gtk_css_ease_value_parse (parser);

          if (values[4] == NULL)
            return FALSE;
        }
      else if (values[5] == NULL &&
               (values[5] = _gtk_css_direction_value_try_parse (parser)))
        {
          /* nothing to do */
        }
      else if (values[6] == NULL &&
               (values[6] = _gtk_css_fill_mode_value_try_parse (parser)))
        {
          /* nothing to do */
        }
      else if (values[0] == NULL &&
               (values[0] = _gtk_css_ident_value_try_parse (parser)))
        {
          /* nothing to do */
          /* keep in mind though that this needs to come last as fill modes, directions
           * etc are valid idents */
        }
      else
        {
          /* We parsed everything and there's still stuff left?
           * Pretend we didn't notice and let the normal code produce
           * a 'junk at end of value' error */
          break;
        }
    }
  while (!value_is_done_parsing (parser));

  return TRUE;
}

static gboolean
parse_animation (GtkCssShorthandProperty  *shorthand,
                 GtkCssValue             **values,
                 GtkCssParser             *parser)
{
  GtkCssValue *step_values[7];
783
  GPtrArray *arrays[7];
784 785
  guint i;

786
  for (i = 0; i < 7; i++)
787 788 789 790 791 792 793 794
    {
      arrays[i] = g_ptr_array_new ();
      step_values[i] = NULL;
    }
  
  do {
    if (!parse_one_animation (shorthand, step_values, parser))
      {
795
        for (i = 0; i < 7; i++)
796 797 798 799
          {
            g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
            g_ptr_array_unref (arrays[i]);
          }
800
        return FALSE;
801 802
      }

803
      for (i = 0; i < 7; i++)
804 805 806 807 808 809 810 811 812 813 814 815 816
        {
          if (step_values[i] == NULL)
            {
              GtkCssValue *initial = _gtk_css_style_property_get_initial_value (
                                         _gtk_css_shorthand_property_get_subproperty (shorthand, i));
              step_values[i] = _gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
            }

          g_ptr_array_add (arrays[i], step_values[i]);
          step_values[i] = NULL;
        }
  } while (_gtk_css_parser_try (parser, ",", TRUE));

817
  for (i = 0; i < 7; i++)
818 819 820 821 822 823 824 825
    {
      values[i] = _gtk_css_array_value_new_from_array ((GtkCssValue **) arrays[i]->pdata, arrays[i]->len);
      g_ptr_array_unref (arrays[i]);
    }

  return TRUE;
}

826 827 828 829 830 831 832 833 834 835 836 837 838
static gboolean
parse_text_decoration (GtkCssShorthandProperty  *shorthand,
                       GtkCssValue             **values,
                       GtkCssParser             *parser)
{
  do
  {
    if (values[0] == NULL &&
        (values[0] = _gtk_css_text_decoration_line_value_try_parse (parser)))
      {
        if (values[0] == NULL)
          return FALSE;
      }
839 840
    else if (values[1] == NULL &&
        (values[1] = _gtk_css_text_decoration_style_value_try_parse (parser)))
841 842 843 844
      {
        if (values[1] == NULL)
          return FALSE;
      }
845 846 847 848 849 850
    else if (values[2] == NULL)
      {
        values[2] = _gtk_css_color_value_parse (parser);
        if (values[2] == NULL)
          return FALSE;
      }
851 852 853 854 855 856 857 858 859 860 861 862 863
    else
      {
        /* We parsed and there's still stuff left?
         * Pretend we didn't notice and let the normal code produce
         * a 'junk at end of value' error */
        break;
      }
  }
  while (!value_is_done_parsing (parser));

  return TRUE;
}

864 865 866 867 868 869 870 871 872
static gboolean
parse_all (GtkCssShorthandProperty  *shorthand,
           GtkCssValue             **values,
           GtkCssParser             *parser)
{
  _gtk_css_parser_error (parser, "The 'all' property can only be set to 'initial', 'inherit' or 'unset'");
  return FALSE;
}

873 874
/*** PACKING ***/

875
static void
876
unpack_border (GtkCssShorthandProperty *shorthand,
877 878 879
               GtkStyleProperties      *props,
               GtkStateFlags            state,
               const GValue            *value)
880
{
881
  GValue v = G_VALUE_INIT;
882 883
  GtkBorder *border = g_value_get_boxed (value);

884 885 886 887 888 889 890 891 892 893 894 895
  g_value_init (&v, G_TYPE_INT);

  g_value_set_int (&v, border->top);
  _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 0)), props, state, &v);
  g_value_set_int (&v, border->right);
  _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 1)), props, state, &v);
  g_value_set_int (&v, border->bottom);
  _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 2)), props, state, &v);
  g_value_set_int (&v, border->left);
  _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 3)), props, state, &v);

  g_value_unset (&v);
896 897
}

898
static void
899
pack_border (GtkCssShorthandProperty *shorthand,
900
             GValue                  *value,
901 902
             GtkStyleQueryFunc        query_func,
             gpointer                 query_data)
903
{
904
  GtkCssStyleProperty *prop;
905
  GtkBorder border;
906
  GValue v;
907 908

  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
909 910 911 912
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
  border.top = g_value_get_int (&v);
  g_value_unset (&v);

913
  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 1);
914 915 916 917
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
  border.right = g_value_get_int (&v);
  g_value_unset (&v);

918
  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 2);
919 920 921 922
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
  border.bottom = g_value_get_int (&v);
  g_value_unset (&v);

923
  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 3);
924 925 926
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
  border.left = g_value_get_int (&v);
  g_value_unset (&v);
927

928 929
  g_value_init (value, GTK_TYPE_BORDER);
  g_value_set_boxed (value, &border);
930 931
}

932
static void
933
unpack_border_radius (GtkCssShorthandProperty *shorthand,
934 935 936
                      GtkStyleProperties      *props,
                      GtkStateFlags            state,
                      const GValue            *value)
937
{
938
  GtkCssValue *css_value;
939
  guint i;
940
  
941 942
  css_value = _gtk_css_corner_value_new (_gtk_css_number_value_new (g_value_get_int (value), GTK_CSS_PX),
                                         _gtk_css_number_value_new (g_value_get_int (value), GTK_CSS_PX));
943

944
  for (i = 0; i < 4; i++)
945 946 947 948
    _gtk_style_properties_set_property_by_property (props,
                                                    _gtk_css_shorthand_property_get_subproperty (shorthand, i),
                                                    state,
                                                    css_value);
949

950
  _gtk_css_value_unref (css_value);
951 952
}

953
static void
954
pack_border_radius (GtkCssShorthandProperty *shorthand,
955
                    GValue                  *value,
956 957
                    GtkStyleQueryFunc        query_func,
                    gpointer                 query_data)
958
{
959
  GtkCssStyleProperty *prop;
960
  GtkCssValue *v;
961
  int i = 0;
962

963 964 965
  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)
966
    i = _gtk_css_corner_value_get_x (v, 100);
967

968 969
  g_value_init (value, G_TYPE_INT);
  g_value_set_int (value, i);
970 971
}

972
static void
973
unpack_font_description (GtkCssShorthandProperty *shorthand,
974 975 976
                         GtkStyleProperties      *props,
                         GtkStateFlags            state,
                         const GValue            *value)
977
{
978
  GtkStyleProperty *prop;
979 980
  PangoFontDescription *description;
  PangoFontMask mask;
981
  GValue v = G_VALUE_INIT;
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
  
  /* For backwards compat, we only unpack values that are indeed set.
   * For strict CSS conformance we need to unpack all of them.
   * Note that we do set all of them in the parse function, so it
   * will not have effects when parsing CSS files. It will though
   * for custom style providers.
   */

  description = g_value_get_boxed (value);

  if (description)
    mask = pango_font_description_get_set_fields (description);
  else
    mask = 0;

  if (mask & PANGO_FONT_MASK_FAMILY)
    {
      GPtrArray *strv = g_ptr_array_new ();

      g_ptr_array_add (strv, g_strdup (pango_font_description_get_family (description)));
      g_ptr_array_add (strv, NULL);
1003 1004 1005 1006 1007 1008
      g_value_init (&v, G_TYPE_STRV);
      g_value_take_boxed (&v, g_ptr_array_free (strv, FALSE));

      prop = _gtk_style_property_lookup ("font-family");
      _gtk_style_property_assign (prop, props, state, &v);
      g_value_unset (&v);
1009 1010 1011 1012
    }

  if (mask & PANGO_FONT_MASK_STYLE)
    {
1013 1014 1015 1016 1017 1018
      g_value_init (&v, PANGO_TYPE_STYLE);
      g_value_set_enum (&v, pango_font_description_get_style (description));

      prop = _gtk_style_property_lookup ("font-style");
      _gtk_style_property_assign (prop, props, state, &v);
      g_value_unset (&v);
1019 1020 1021 1022
    }

  if (mask & PANGO_FONT_MASK_VARIANT)
    {
1023 1024 1025 1026 1027 1028
      g_value_init (&v, PANGO_TYPE_VARIANT);
      g_value_set_enum (&v, pango_font_description_get_variant (description));

      prop = _gtk_style_property_lookup ("font-variant");
      _gtk_style_property_assign (prop, props, state, &v);
      g_value_unset (&v);
1029 1030 1031 1032
    }

  if (mask & PANGO_FONT_MASK_WEIGHT)
    {
1033 1034 1035 1036 1037 1038
      g_value_init (&v, PANGO_TYPE_WEIGHT);
      g_value_set_enum (&v, pango_font_description_get_weight (description));

      prop = _gtk_style_property_lookup ("font-weight");
      _gtk_style_property_assign (prop, props, state, &v);
      g_value_unset (&v);
1039 1040
    }

1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
  if (mask & PANGO_FONT_MASK_STRETCH)
    {
      g_value_init (&v, PANGO_TYPE_STRETCH);
      g_value_set_enum (&v, pango_font_description_get_stretch (description));

      prop = _gtk_style_property_lookup ("font-stretch");
      _gtk_style_property_assign (prop, props, state, &v);
      g_value_unset (&v);
    }

1051 1052
  if (mask & PANGO_FONT_MASK_SIZE)
    {
1053 1054
      g_value_init (&v, G_TYPE_DOUBLE);
      g_value_set_double (&v, (double) pango_font_description_get_size (description) / PANGO_SCALE);
1055

1056 1057 1058 1059
      prop = _gtk_style_property_lookup ("font-size");
      _gtk_style_property_assign (prop, props, state, &v);
      g_value_unset (&v);
    }
1060 1061
}

1062
static void
1063
pack_font_description (GtkCssShorthandProperty *shorthand,
1064
                       GValue                  *value,
1065 1066
                       GtkStyleQueryFunc        query_func,
                       gpointer                 query_data)
1067 1068
{
  PangoFontDescription *description;
1069
  GtkCssValue *v;
1070 1071 1072

  description = pango_font_description_new ();

1073 1074 1075 1076
  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-family"))), query_data);
  if (v)
    {
      /* xxx: Can we set all the families here somehow? */
1077
      pango_font_description_set_family (description, _gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, 0)));
1078 1079 1080 1081
    }

  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-size"))), query_data);
  if (v)
1082
    pango_font_description_set_size (description, round (_gtk_css_number_value_get (v, 100) * PANGO_SCALE));
1083 1084 1085

  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-style"))), query_data);
  if (v)
1086
    pango_font_description_set_style (description, _gtk_css_font_style_value_get (v));
1087 1088 1089

  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-variant"))), query_data);
  if (v)
1090
    pango_font_description_set_variant (description, _gtk_css_font_variant_value_get (v));
1091 1092 1093

  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-weight"))), query_data);
  if (v)
1094
    pango_font_description_set_weight (description, _gtk_css_font_weight_value_get (v));
1095

1096 1097 1098 1099
  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-stretch"))), query_data);
  if (v)
    pango_font_description_set_stretch (description, _gtk_css_font_stretch_value_get (v));

1100 1101
  g_value_init (value, PANGO_TYPE_FONT_DESCRIPTION);
  g_value_take_boxed (value, description);
1102 1103
}

1104
static void
1105
unpack_to_everything (GtkCssShorthandProperty *shorthand,
1106 1107 1108
                      GtkStyleProperties      *props,
                      GtkStateFlags            state,
                      const GValue            *value)
1109
{
1110 1111
  GtkCssStyleProperty *prop;
  guint i, n;
1112
  
1113
  n = _gtk_css_shorthand_property_get_n_subproperties (shorthand);
1114

1115 1116 1117
  for (i = 0; i < n; i++)
    {
      prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
1118
      _gtk_style_property_assign (GTK_STYLE_PROPERTY (prop), props, state, value);
1119
    }
1120 1121
}

1122
static void
1123
pack_first_element (GtkCssShorthandProperty *shorthand,
1124
                    GValue                  *value,
1125 1126
                    GtkStyleQueryFunc        query_func,
                    gpointer                 query_data)
1127
{
1128 1129 1130 1131 1132 1133
  GtkCssStyleProperty *prop;

  /* NB: This is a fallback for properties that originally were
   * not used as shorthand. We just pick the first subproperty
   * as a representative.
   * Lesson learned: Don't query the shorthand, query the 
1134
   * real properties instead. */
1135 1136 1137 1138 1139
  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop),
                             value,
                             query_func,
                             query_data);
1140 1141
}

1142
static void
1143 1144 1145 1146
_gtk_css_shorthand_property_register (const char                        *name,
                                      GType                              value_type,
                                      const char                       **subproperties,
                                      GtkCssShorthandPropertyParseFunc   parse_func,
1147 1148
                                      GtkCssShorthandPropertyAssignFunc  assign_func,
                                      GtkCssShorthandPropertyQueryFunc   query_func)
1149
{
1150
  GtkCssShorthandProperty *node;
1151 1152

  node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
1153 1154
                       "name", name,
                       "value-type", value_type,
1155
                       "subproperties", subproperties,
1156 1157
                       NULL);

1158 1159 1160
  node->parse = parse_func;
  node->assign = assign_func;
  node->query = query_func;
1161 1162
}

1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181
/* NB: return value is transfer: container */
static const char **
get_all_subproperties (void)
{
  const char **properties;
  guint i, n;

  n = _gtk_css_style_property_get_n_properties ();
  properties = g_new (const char *, n + 1);
  properties[n] = NULL;

  for (i = 0; i < n; i++)
    {
      properties[i] = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (i)));
    }

  return properties;
}

1182 1183 1184
void
_gtk_css_shorthand_property_init_properties (void)
{
1185
  /* The order is important here, be careful when changing it */
1186
  const char *font_subproperties[] = { "font-family", "font-style", "font-variant", "font-weight", "font-stretch", "font-size", NULL };
1187 1188 1189 1190 1191 1192
  const char *margin_subproperties[] = { "margin-top", "margin-right", "margin-bottom", "margin-left", NULL };
  const char *padding_subproperties[] = { "padding-top", "padding-right", "padding-bottom", "padding-left", NULL };
  const char *border_width_subproperties[] = { "border-top-width", "border-right-width", "border-bottom-width", "border-left-width", NULL };
  const char *border_radius_subproperties[] = { "border-top-left-radius", "border-top-right-radius",
                                                "border-bottom-right-radius", "border-bottom-left-radius", NULL };
  const char *border_color_subproperties[] = { "border-top-color", "border-right-color", "border-bottom-color", "border-left-color", NULL };
1193
  const char *border_style_subproperties[] = { "border-top-style", "border-right-style", "border-bottom-style", "border-left-style", NULL };
1194
  const char *border_image_subproperties[] = { "border-image-source", "border-image-slice", "border-image-width", "border-image-repeat", NULL };
1195 1196 1197 1198
  const char *border_top_subproperties[] = { "border-top-width", "border-top-style", "border-top-color", NULL };
  const char *border_right_subproperties[] = { "border-right-width", "border-right-style", "border-right-color", NULL };
  const char *border_bottom_subproperties[] = { "border-bottom-width", "border-bottom-style", "border-bottom-color", NULL };
  const char *border_left_subproperties[] = { "border-left-width", "border-left-style", "border-left-color", NULL };
1199 1200 1201 1202
  const char *border_subproperties[] = { "border-top-width", "border-right-width", "border-bottom-width", "border-left-width",
                                         "border-top-style", "border-right-style", "border-bottom-style", "border-left-style",
                                         "border-top-color", "border-right-color", "border-bottom-color", "border-left-color",
                                         "border-image-source", "border-image-slice", "border-image-width", "border-image-repeat", NULL };
1203
  const char *outline_subproperties[] = { "outline-width", "outline-style", "outline-color", NULL };
1204 1205
  const char *outline_radius_subproperties[] = { "outline-top-left-radius", "outline-top-right-radius",
                                                 "outline-bottom-right-radius", "outline-bottom-left-radius", NULL };
1206
  const char *background_subproperties[] = { "background-image", "background-position", "background-size", "background-repeat", "background-clip", "background-origin",
1207
                                             "background-color", NULL };
1208
  const char *transition_subproperties[] = { "transition-property", "transition-duration", "transition-delay", "transition-timing-function", NULL };
1209 1210
  const char *animation_subproperties[] = { "animation-name", "animation-iteration-count", "animation-duration", "animation-delay", 
                                            "animation-timing-function", "animation-direction", "animation-fill-mode", NULL };
1211
  const char *text_decoration_subproperties[] = { "text-decoration-line", "text-decoration-style", "text-decoration-color", NULL };
1212

1213 1214
  const char **all_subproperties;

1215 1216
  _gtk_css_shorthand_property_register   ("font",
                                          PANGO_TYPE_FONT_DESCRIPTION,
1217
                                          font_subproperties,
1218
                                          parse_font,
1219
                                          unpack_font_description,
1220
                                          pack_font_description);
1221 1222
  _gtk_css_shorthand_property_register   ("margin",
                                          GTK_TYPE_BORDER,
1223
                                          margin_subproperties,
1224
                                          parse_margin,
1225
                                          unpack_border,
1226
                                          pack_border);
1227 1228
  _gtk_css_shorthand_property_register   ("padding",
                                          GTK_TYPE_BORDER,
1229
                                          padding_subproperties,
1230
                                          parse_padding,
1231
                                          unpack_border,
1232
                                          pack_border);
1233 1234
  _gtk_css_shorthand_property_register   ("border-width",
                                          GTK_TYPE_BORDER,
1235
                                          border_width_subproperties,
1236
                                          parse_border_width,
1237
                                          unpack_border,
1238
                                          pack_border);
1239 1240
  _gtk_css_shorthand_property_register   ("border-radius",
                                          G_TYPE_INT,
1241
                                          border_radius_subproperties,
1242
                                          parse_border_radius,
1243
                                          unpack_border_radius,
1244
                                          pack_border_radius);
1245 1246
  _gtk_css_shorthand_property_register   ("border-color",
                                          GDK_TYPE_RGBA,
1247
                                          border_color_subproperties,
1248
                                          parse_border_color,
1249
                                          unpack_to_everything,
1250
                                          pack_first_element);
1251 1252 1253 1254
  _gtk_css_shorthand_property_register   ("border-style",
                                          GTK_TYPE_BORDER_STYLE,
                                          border_style_subproperties,
                                          parse_border_style,
1255
                                          unpack_to_everything,
1256
                                          pack_first_element);
1257
  _gtk_css_shorthand_property_register   ("border-image",
1258
                                          G_TYPE_NONE,
1259
                                          border_image_subproperties,
1260
                                          parse_border_image,
1261 1262
                                          NULL,
                                          NULL);
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
  _gtk_css_shorthand_property_register   ("border-top",
                                          G_TYPE_NONE,
                                          border_top_subproperties,
                                          parse_border_side,
                                          NULL,
                                          NULL);
  _gtk_css_shorthand_property_register   ("border-right",
                                          G_TYPE_NONE,
                                          border_right_subproperties,
                                          parse_border_side,
                                          NULL,
                                          NULL);
  _gtk_css_shorthand_property_register   ("border-bottom",
                                          G_TYPE_NONE,
                                          border_bottom_subproperties,
                                          parse_border_side,
                                          NULL,
                                          NULL);
  _gtk_css_shorthand_property_register   ("border-left",
                                          G_TYPE_NONE,
                                          border_left_subproperties,
                                          parse_border_side,
                                          NULL,
                                          NULL);
1287 1288 1289 1290 1291 1292
  _gtk_css_shorthand_property_register   ("border",
                                          G_TYPE_NONE,
                                          border_subproperties,
                                          parse_border,
                                          NULL,
                                          NULL);
1293 1294 1295 1296 1297 1298
  _gtk_css_shorthand_property_register   ("outline-radius",
                                          G_TYPE_INT,
                                          outline_radius_subproperties,
                                          parse_border_radius,
                                          unpack_border_radius,
                                          pack_border_radius);
1299 1300 1301 1302 1303 1304
  _gtk_css_shorthand_property_register   ("outline",
                                          G_TYPE_NONE,
                                          outline_subproperties,
                                          parse_border_side,
                                          NULL,
                                          NULL);
1305 1306 1307 1308 1309 1310
  _gtk_css_shorthand_property_register   ("background",
                                          G_TYPE_NONE,
                                          background_subproperties,
                                          parse_background,
                                          NULL,
                                          NULL);
1311 1312 1313 1314 1315 1316
  _gtk_css_shorthand_property_register   ("transition",
                                          G_TYPE_NONE,
                                          transition_subproperties,
                                          parse_transition,
                                          NULL,
                                          NULL);
1317 1318 1319 1320 1321 1322
  _gtk_css_shorthand_property_register   ("animation",
                                          G_TYPE_NONE,
                                          animation_subproperties,
                                          parse_animation,
                                          NULL,
                                          NULL);
1323 1324 1325 1326 1327 1328
  _gtk_css_shorthand_property_register   ("text-decoration",
                                          G_TYPE_NONE,
                                          text_decoration_subproperties,
                                          parse_text_decoration,
                                          NULL,
                                          NULL);
1329 1330 1331 1332 1333 1334 1335 1336 1337

  all_subproperties = get_all_subproperties ();
  _gtk_css_shorthand_property_register   ("all",
                                          G_TYPE_NONE,
                                          all_subproperties,
                                          parse_all,
                                          NULL,
                                          NULL);
  g_free (all_subproperties);
1338
}