gtkcssshorthandpropertyimpl.c 46.3 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
{
  guint i;

  for (i = 0; i < 4; i++)
    {
71
      if (!gtk_css_number_value_can_parse (parser))
72 73
        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_number_value_can_parse (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
    }

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

  if (_gtk_css_parser_try (parser, "/", TRUE))
    {
166
      for (i = 0; i < 4; i++)
167
        {
168
          if (!gtk_css_number_value_can_parse (parser))
169
            break;
170 171 172 173 174 175 176
          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;
177 178 179 180 181
        }

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

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

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

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

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;
210 211
}

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

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

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

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

  return TRUE;
}

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

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

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

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

  return TRUE;
}

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

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

285 286 287 288 289 290 291 292 293
          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)
        {
294 295 296 297 298 299 300
          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)
301
            return FALSE;
302

303 304
          if (_gtk_css_parser_try (parser, "/", TRUE))
            {
305 306 307 308 309 310 311 312
              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)
313 314 315 316 317 318 319
                return FALSE;
            }
        }
      else
        {
          /* We parsed everything and there's still stuff left?
           * Pretend we didn't notice and let the normal code produce
Matthias Clasen's avatar
Matthias Clasen committed
320 321
           * a 'junk at end of value' error
           */
322 323 324 325
          break;
        }
    }
  while (!value_is_done_parsing (parser));
326

327
  return TRUE;
328 329
}

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

  return TRUE;
}

372
static gboolean
373 374
parse_border (GtkCssShorthandProperty  *shorthand,
              GtkCssValue             **values,
375
              GtkCssParser             *parser)
376 377 378
{
  do
  {
379
    if (values[0] == NULL &&
380
        gtk_css_number_value_can_parse (parser))
381
      {
382 383 384 385 386
        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)
387
          return FALSE;
388 389 390
        values[1] = _gtk_css_value_ref (values[0]);
        values[2] = _gtk_css_value_ref (values[0]);
        values[3] = _gtk_css_value_ref (values[0]);
391
      }
392
    else if (values[4] == NULL &&
393
             (values[4] = _gtk_css_border_style_value_try_parse (parser)))
394
      {
395 396 397
        values[5] = _gtk_css_value_ref (values[4]);
        values[6] = _gtk_css_value_ref (values[4]);
        values[7] = _gtk_css_value_ref (values[4]);
398 399 400
      }
    else if (!G_IS_VALUE (&values[8]))
      {
401
        values[8] = _gtk_css_color_value_parse (parser);
402
        if (values[8] == NULL)
403 404
          return FALSE;

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

  /* Note that border-image values are not set: according to the spec
Matthias Clasen's avatar
Matthias Clasen committed
421 422
   * they just need to be reset when using the border shorthand
   */
423 424 425 426

  return TRUE;
}

427
static gboolean
428 429
parse_font (GtkCssShorthandProperty  *shorthand,
            GtkCssValue             **values,
430
            GtkCssParser             *parser)
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
{
  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)
    {
447
      values[0] = _gtk_css_array_value_new (_gtk_css_string_value_new (pango_font_description_get_family (desc)));
448 449 450
    }
  if (mask & PANGO_FONT_MASK_STYLE)
    {
451
      values[1] = _gtk_css_font_style_value_new (pango_font_description_get_style (desc));
452 453 454
    }
  if (mask & PANGO_FONT_MASK_VARIANT)
    {
455
      values[2] = _gtk_css_font_variant_value_new (pango_font_description_get_variant (desc));
456 457 458
    }
  if (mask & PANGO_FONT_MASK_WEIGHT)
    {
459
      values[3] = _gtk_css_font_weight_value_new (pango_font_description_get_weight (desc));
460
    }
461 462 463 464
  if (mask & PANGO_FONT_MASK_STRETCH)
    {
      values[4] = _gtk_css_font_stretch_value_new (pango_font_description_get_stretch (desc));
    }
465 466
  if (mask & PANGO_FONT_MASK_SIZE)
    {
467
      values[5] = _gtk_css_number_value_new ((double) pango_font_description_get_size (desc) / PANGO_SCALE, GTK_CSS_PX);
468 469 470 471 472 473 474
    }

  pango_font_description_free (desc);

  return TRUE;
}

475
static gboolean
476 477 478
parse_one_background (GtkCssShorthandProperty  *shorthand,
                      GtkCssValue             **values,
                      GtkCssParser             *parser)
479
{
480
  GtkCssValue *value = NULL;
481

482 483 484
  do
    {
      /* the image part */
485
      if (values[0] == NULL &&
486 487 488 489 490 491 492 493 494
          (_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
            {
495
              image = _gtk_css_image_new_parse (parser);
496 497 498 499
              if (image == NULL)
                return FALSE;
            }

500 501 502
          values[0] = _gtk_css_image_value_new (image);
        }
      else if (values[1] == NULL &&
Matthias Clasen's avatar
Matthias Clasen committed
503
               (value = _gtk_css_position_value_try_parse (parser)))
504 505 506 507 508 509 510 511 512 513
        {
          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;
            }
514
        }
515
      else if (values[3] == NULL &&
516
               (value = _gtk_css_background_repeat_value_try_parse (parser)))
517
        {
518
          values[3] = value;
519
          value = NULL;
520
        }
521
      else if ((values[4] == NULL || values[5] == NULL) &&
522
               (value = _gtk_css_area_value_try_parse (parser)))
523
        {
524
          values[4] = value;
525

526
          if (values[5] == NULL)
527
            {
528 529
              values[5] = values[4];
              values[4] = NULL;
530
            }
531
          value = NULL;
532
        }
533
      else if (values[6] == NULL)
534
        {
535
          value = _gtk_css_color_value_parse (parser);
536
          if (value == NULL)
537 538 539 540
            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;
541

542 543
          value = NULL;
        }
544 545 546 547
      else
        {
          /* We parsed everything and there's still stuff left?
           * Pretend we didn't notice and let the normal code produce
Matthias Clasen's avatar
Matthias Clasen committed
548 549
           * a 'junk at end of value' error
           */
550 551 552 553 554
          break;
        }
    }
  while (!value_is_done_parsing (parser));

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 580 581 582 583 584 585
  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]);
          }
586
        return FALSE;
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
      }

      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];

611 612 613
  return TRUE;
}

614 615 616
static gboolean
parse_one_transition (GtkCssShorthandProperty  *shorthand,
                      GtkCssValue             **values,
617
                      GtkCssParser             *parser)
618 619 620 621 622
{
  do
    {
      /* the image part */
      if (values[2] == NULL &&
623
          gtk_css_number_value_can_parse (parser) && !_gtk_css_parser_begins_with (parser, '-'))
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
        {
          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
Matthias Clasen's avatar
Matthias Clasen committed
657 658
           * a 'junk at end of value' error
           */
659 660 661 662 663 664 665 666 667 668 669
          break;
        }
    }
  while (!value_is_done_parsing (parser));

  return TRUE;
}

static gboolean
parse_transition (GtkCssShorthandProperty  *shorthand,
                  GtkCssValue             **values,
670
                  GtkCssParser             *parser)
671 672 673 674 675 676 677 678 679 680 681 682
{
  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 {
683
    if (!parse_one_transition (shorthand, step_values, parser))
684 685 686 687 688 689
      {
        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]);
          }
690
        return FALSE;
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
      }

      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;
}

716 717 718 719 720 721 722 723 724 725 726 727
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) &&
728
               gtk_css_number_value_can_parse (parser))
729 730 731 732 733 734 735
        {
          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));
736 737 738
          if (value == NULL)
            return FALSE;

739
          if (gtk_css_number_value_get_dimension (value) == GTK_CSS_DIMENSION_NUMBER)
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 783 784 785 786 787 788 789
            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];
790
  GPtrArray *arrays[7];
791 792
  guint i;

793
  for (i = 0; i < 7; i++)
794 795 796 797 798 799 800 801
    {
      arrays[i] = g_ptr_array_new ();
      step_values[i] = NULL;
    }
  
  do {
    if (!parse_one_animation (shorthand, step_values, parser))
      {
802
        for (i = 0; i < 7; i++)
803 804 805 806
          {
            g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
            g_ptr_array_unref (arrays[i]);
          }
807
        return FALSE;
808 809
      }

810
      for (i = 0; i < 7; i++)
811 812 813 814 815 816 817 818 819 820 821 822 823
        {
          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));

824
  for (i = 0; i < 7; i++)
825 826 827 828 829 830 831 832
    {
      values[i] = _gtk_css_array_value_new_from_array ((GtkCssValue **) arrays[i]->pdata, arrays[i]->len);
      g_ptr_array_unref (arrays[i]);
    }

  return TRUE;
}

833 834 835 836 837 838 839 840 841 842 843 844 845
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;
      }
846 847
    else if (values[1] == NULL &&
        (values[1] = _gtk_css_text_decoration_style_value_try_parse (parser)))
848 849 850 851
      {
        if (values[1] == NULL)
          return FALSE;
      }
852 853 854 855 856 857
    else if (values[2] == NULL)
      {
        values[2] = _gtk_css_color_value_parse (parser);
        if (values[2] == NULL)
          return FALSE;
      }
858 859 860 861 862 863 864 865 866 867 868 869 870
    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;
}

871 872 873 874 875 876 877 878 879
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;
}

880 881
/*** PACKING ***/

882
static void
883
unpack_border (GtkCssShorthandProperty *shorthand,
884 885 886
               GtkStyleProperties      *props,
               GtkStateFlags            state,
               const GValue            *value)
887
{
888
  GValue v = G_VALUE_INIT;
889 890
  GtkBorder *border = g_value_get_boxed (value);

891 892 893 894 895 896 897 898 899 900 901 902
  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);
903 904
}

905
static void
906
pack_border (GtkCssShorthandProperty *shorthand,
907
             GValue                  *value,
908 909
             GtkStyleQueryFunc        query_func,
             gpointer                 query_data)
910
{
911
  GtkCssStyleProperty *prop;
912
  GtkBorder border;
913
  GValue v;
914 915

  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
916 917 918 919
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
  border.top = g_value_get_int (&v);
  g_value_unset (&v);

920
  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 1);
921 922 923 924
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
  border.right = g_value_get_int (&v);
  g_value_unset (&v);

925
  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 2);
926 927 928 929
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
  border.bottom = g_value_get_int (&v);
  g_value_unset (&v);

930
  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 3);
931 932 933
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
  border.left = g_value_get_int (&v);
  g_value_unset (&v);
934

935 936
  g_value_init (value, GTK_TYPE_BORDER);
  g_value_set_boxed (value, &border);
937 938
}

939
static void
940
unpack_border_radius (GtkCssShorthandProperty *shorthand,
941 942 943
                      GtkStyleProperties      *props,
                      GtkStateFlags            state,
                      const GValue            *value)
944
{
945
  GtkCssValue *css_value;
946
  guint i;
947
  
948 949
  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));
950

951
  for (i = 0; i < 4; i++)
952 953 954 955
    _gtk_style_properties_set_property_by_property (props,
                                                    _gtk_css_shorthand_property_get_subproperty (shorthand, i),
                                                    state,
                                                    css_value);
956

957
  _gtk_css_value_unref (css_value);
958 959
}

960
static void
961
pack_border_radius (GtkCssShorthandProperty *shorthand,
962
                    GValue                  *value,
963 964
                    GtkStyleQueryFunc        query_func,
                    gpointer                 query_data)
965
{
966
  GtkCssStyleProperty *prop;
967
  GtkCssValue *v;
968
  int i = 0;
969

970 971 972
  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)
973
    i = _gtk_css_corner_value_get_x (v, 100);
974

975 976
  g_value_init (value, G_TYPE_INT);
  g_value_set_int (value, i);
977 978
}

979
static void
980
unpack_font_description (GtkCssShorthandProperty *shorthand,
981 982 983
                         GtkStyleProperties      *props,
                         GtkStateFlags            state,
                         const GValue            *value)
984
{
985
  GtkStyleProperty *prop;
986 987
  PangoFontDescription *description;
  PangoFontMask mask;
988
  GValue v = G_VALUE_INIT;
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
  
  /* 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);
1010 1011 1012 1013 1014 1015
      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);
1016 1017 1018 1019
    }

  if (mask & PANGO_FONT_MASK_STYLE)
    {
1020 1021 1022 1023 1024 1025
      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);
1026 1027 1028 1029
    }

  if (mask & PANGO_FONT_MASK_VARIANT)
    {
1030 1031 1032 1033 1034 1035
      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);
1036 1037 1038 1039
    }

  if (mask & PANGO_FONT_MASK_WEIGHT)
    {
1040 1041 1042 1043 1044 1045
      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);
1046 1047
    }

1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
  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);
    }

1058 1059
  if (mask & PANGO_FONT_MASK_SIZE)
    {
1060 1061
      g_value_init (&v, G_TYPE_DOUBLE);
      g_value_set_double (&v, (double) pango_font_description_get_size (description) / PANGO_SCALE);
1062

1063 1064 1065 1066
      prop = _gtk_style_property_lookup ("font-size");
      _gtk_style_property_assign (prop, props, state, &v);
      g_value_unset (&v);
    }
1067 1068
}

1069
static void
1070
pack_font_description (GtkCssShorthandProperty *shorthand,
1071
                       GValue                  *value,
1072 1073
                       GtkStyleQueryFunc        query_func,
                       gpointer                 query_data)
1074 1075
{
  PangoFontDescription *description;
1076
  GtkCssValue *v;
1077
  double dpi;
1078 1079 1080

  description = pango_font_description_new ();

1081 1082 1083 1084
  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? */
1085
      pango_font_description_set_family (description, _gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, 0)));
1086 1087
    }

1088 1089
  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("-gtk-dpi"))), query_data);
  dpi = _gtk_css_number_value_get (v, 96);
1090 1091
  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-size"))), query_data);
  if (v)
1092
    pango_font_description_set_size (description, round (_gtk_css_number_value_get (v, 100) * PANGO_SCALE * 72 / dpi));
1093 1094 1095

  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-style"))), query_data);
  if (v)
1096
    pango_font_description_set_style (description, _gtk_css_font_style_value_get (v));
1097 1098 1099

  v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-variant"))), query_data);
  if (v)
1100
    pango_font_description_set_variant (description, _gtk_css_font_variant_value_get (v));
1101 1102 1103

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

1106 1107 1108 1109
  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));

1110 1111
  g_value_init (value, PANGO_TYPE_FONT_DESCRIPTION);
  g_value_take_boxed (value, description);
1112 1113
}

1114
static void
1115
unpack_to_everything (GtkCssShorthandProperty *shorthand,
1116 1117 1118
                      GtkStyleProperties      *props,
                      GtkStateFlags            state,
                      const GValue            *value)
1119
{
1120 1121
  GtkCssStyleProperty *prop;
  guint i, n;
1122
  
1123
  n = _gtk_css_shorthand_property_get_n_subproperties (shorthand);
1124

1125 1126 1127
  for (i = 0; i < n; i++)
    {
      prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
1128
      _gtk_style_property_assign (GTK_STYLE_PROPERTY (prop), props, state, value);
1129
    }
1130 1131
}

1132
static void
1133
pack_first_element (GtkCssShorthandProperty *shorthand,
1134
                    GValue                  *value,
1135 1136
                    GtkStyleQueryFunc        query_func,
                    gpointer                 query_data)
1137
{
1138 1139 1140 1141 1142 1143
  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 
1144
   * real properties instead. */
1145 1146 1147 1148 1149
  prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
  _gtk_style_property_query (GTK_STYLE_PROPERTY (prop),
                             value,
                             query_func,
                             query_data);
1150 1151
}

1152
static void
1153 1154 1155 1156
_gtk_css_shorthand_property_register (const char                        *name,
                                      GType                              value_type,
                                      const char                       **subproperties,
                                      GtkCssShorthandPropertyParseFunc   parse_func,
1157 1158
                                      GtkCssShorthandPropertyAssignFunc  assign_func,
                                      GtkCssShorthandPropertyQueryFunc   query_func)
1159
{
1160
  GtkCssShorthandProperty *node;
1161 1162

  node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
1163 1164
                       "name", name,
                       "value-type", value_type,
1165
                       "subproperties", subproperties,
1166 1167
                       NULL);

1168 1169 1170
  node->parse = parse_func;
  node->assign = assign_func;
  node->query = query_func;
1171 1172
}

1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191
/* 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;
}

1192 1193 1194
void
_gtk_css_shorthand_property_init_properties (void)
{
1195
  /* The order is important here, be careful when changing it */
1196
  const char *font_subproperties[] = { "font-family", "font-style", "font-variant", "font-weight", "font-stretch", "font-size", NULL };
1197 1198 1199 1200 1201 1202
  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 };
1203
  const char *border_style_subproperties[] = { "border-top-style", "border-right-style", "border-bottom-style", "border-left-style", NULL };
1204
  const char *border_image_subproperties[] = { "border-image-source", "border-image-slice", "border-image-width", "border-image-repeat", NULL };
1205 1206 1207 1208
  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 };
1209 1210 1211 1212
  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 };
1213
  const char *outline_subproperties[] = { "outline-width", "outline-style", "outline-color", NULL };
1214 1215
  const char *outline_radius_subproperties[] = { "outline-top-left-radius", "outline-top-right-radius",
                                                 "outline-bottom-right-radius", "outline-bottom-left-radius", NULL };
1216
  const char *background_subproperties[] = { "background-image", "background-position", "background-size", "background-repeat", "background-clip", "background-origin",
1217
                                             "background-color", NULL };
1218
  const char *transition_subproperties[] = { "transition-property", "transition-duration", "transition-delay", "transition-timing-function", NULL };
1219 1220
  const char *animation_subproperties[] = { "animation-name", "animation-iteration-count", "animation-duration", "animation-delay", 
                                            "animation-timing-function", "animation-direction", "animation-fill-mode", NULL };
1221
  const char *text_decoration_subproperties[] = { "text-decoration-line", "text-decoration-style", "text-decoration-color", NULL };
1222

1223 1224
  const char **all_subproperties;

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

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