2011-12-31 14:05:09 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2011-12-31 14:05:09 +00:00
|
|
|
*
|
|
|
|
* Authors: Benjamin Otte <otte@gnome.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gtkcssshorthandpropertyprivate.h"
|
|
|
|
|
|
|
|
#include <cairo-gobject.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2012-03-30 01:09:26 +00:00
|
|
|
#include "gtkcssarrayvalueprivate.h"
|
2012-05-11 20:33:13 +00:00
|
|
|
#include "gtkcssbgsizevalueprivate.h"
|
2012-04-04 14:15:41 +00:00
|
|
|
#include "gtkcssbordervalueprivate.h"
|
2012-11-08 16:22:56 +00:00
|
|
|
#include "gtkcsscolorvalueprivate.h"
|
2012-04-03 16:39:01 +00:00
|
|
|
#include "gtkcsscornervalueprivate.h"
|
2012-04-04 20:33:27 +00:00
|
|
|
#include "gtkcsseasevalueprivate.h"
|
2012-03-28 06:19:53 +00:00
|
|
|
#include "gtkcssenumvalueprivate.h"
|
2012-01-04 03:04:59 +00:00
|
|
|
#include "gtkcssimageprivate.h"
|
2012-03-29 00:58:32 +00:00
|
|
|
#include "gtkcssimagevalueprivate.h"
|
2012-03-27 22:04:29 +00:00
|
|
|
#include "gtkcssnumbervalueprivate.h"
|
2012-05-11 20:33:13 +00:00
|
|
|
#include "gtkcsspositionvalueprivate.h"
|
2012-04-04 09:44:57 +00:00
|
|
|
#include "gtkcssrepeatvalueprivate.h"
|
2012-03-30 01:09:26 +00:00
|
|
|
#include "gtkcssstringvalueprivate.h"
|
2012-03-27 22:04:29 +00:00
|
|
|
#include "gtkcssvalueprivate.h"
|
2012-01-05 15:53:43 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
2011-12-31 14:05:09 +00:00
|
|
|
|
|
|
|
/* 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 ***/
|
|
|
|
|
2012-01-02 03:12:41 +00:00
|
|
|
static gboolean
|
|
|
|
value_is_done_parsing (GtkCssParser *parser)
|
|
|
|
{
|
2019-03-31 21:22:18 +00:00
|
|
|
return gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF) ||
|
2019-03-24 02:56:31 +00:00
|
|
|
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA) ||
|
|
|
|
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SEMICOLON) ||
|
|
|
|
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY);
|
2012-01-02 03:12:41 +00:00
|
|
|
}
|
|
|
|
|
2012-01-15 01:53:39 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_four_numbers (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
|
|
|
GtkCssParser *parser,
|
|
|
|
GtkCssNumberParseFlags flags)
|
2012-01-15 01:53:39 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2016-02-12 05:45:06 +00:00
|
|
|
if (!gtk_css_number_value_can_parse (parser))
|
2012-01-15 01:53:39 +00:00
|
|
|
break;
|
|
|
|
|
2012-03-27 22:04:29 +00:00
|
|
|
values[i] = _gtk_css_number_value_parse (parser, flags);
|
|
|
|
if (values[i] == NULL)
|
2012-01-15 01:53:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_syntax (parser, "Expected a length");
|
2012-01-15 01:53:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; i < 4; i++)
|
|
|
|
{
|
2012-03-27 22:04:29 +00:00
|
|
|
values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
|
2012-01-15 01:53:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-01-17 15:41:14 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_margin (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-17 15:41:14 +00:00
|
|
|
{
|
|
|
|
return parse_four_numbers (shorthand,
|
|
|
|
values,
|
|
|
|
parser,
|
2017-01-18 03:12:15 +00:00
|
|
|
GTK_CSS_PARSE_LENGTH);
|
2012-01-17 15:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_padding (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-24 16:49:29 +00:00
|
|
|
{
|
|
|
|
return parse_four_numbers (shorthand,
|
|
|
|
values,
|
|
|
|
parser,
|
|
|
|
GTK_CSS_POSITIVE_ONLY
|
|
|
|
| GTK_CSS_PARSE_LENGTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_border_width (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-17 15:41:14 +00:00
|
|
|
{
|
|
|
|
return parse_four_numbers (shorthand,
|
|
|
|
values,
|
|
|
|
parser,
|
|
|
|
GTK_CSS_POSITIVE_ONLY
|
|
|
|
| GTK_CSS_PARSE_LENGTH);
|
|
|
|
}
|
|
|
|
|
2012-01-02 02:05:49 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_border_radius (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-02 02:05:49 +00:00
|
|
|
{
|
2012-04-03 16:39:01 +00:00
|
|
|
GtkCssValue *x[4] = { NULL, }, *y[4] = { NULL, };
|
2012-01-02 02:05:49 +00:00
|
|
|
guint i;
|
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2012-01-02 02:05:49 +00:00
|
|
|
{
|
2016-02-12 05:45:06 +00:00
|
|
|
if (!gtk_css_number_value_can_parse (parser))
|
2012-01-02 02:05:49 +00:00
|
|
|
break;
|
2012-04-03 16:39:01 +00:00
|
|
|
x[i] = _gtk_css_number_value_parse (parser,
|
|
|
|
GTK_CSS_POSITIVE_ONLY
|
|
|
|
| GTK_CSS_PARSE_PERCENT
|
|
|
|
| GTK_CSS_PARSE_LENGTH);
|
|
|
|
if (x[i] == NULL)
|
|
|
|
goto fail;
|
2012-01-02 02:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_syntax (parser, "Expected a number");
|
2012-04-03 16:39:01 +00:00
|
|
|
goto fail;
|
2012-01-02 02:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The magic (i - 1) >> 1 below makes it take the correct value
|
2015-12-23 02:19:11 +00:00
|
|
|
* according to spec. Feel free to check the 4 cases
|
|
|
|
*/
|
2012-04-03 16:39:01 +00:00
|
|
|
for (; i < 4; i++)
|
|
|
|
x[i] = _gtk_css_value_ref (x[(i - 1) >> 1]);
|
2012-01-02 02:05:49 +00:00
|
|
|
|
2019-04-05 00:57:14 +00:00
|
|
|
if (gtk_css_parser_try_delim (parser, '/'))
|
2012-01-02 02:05:49 +00:00
|
|
|
{
|
2012-04-03 16:39:01 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2012-01-02 02:05:49 +00:00
|
|
|
{
|
2016-02-12 05:45:06 +00:00
|
|
|
if (!gtk_css_number_value_can_parse (parser))
|
2012-01-02 02:05:49 +00:00
|
|
|
break;
|
2012-04-03 16:39:01 +00:00
|
|
|
y[i] = _gtk_css_number_value_parse (parser,
|
|
|
|
GTK_CSS_POSITIVE_ONLY
|
|
|
|
| GTK_CSS_PARSE_PERCENT
|
|
|
|
| GTK_CSS_PARSE_LENGTH);
|
|
|
|
if (y[i] == NULL)
|
|
|
|
goto fail;
|
2012-01-02 02:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_syntax (parser, "Expected a number");
|
2012-04-03 16:39:01 +00:00
|
|
|
goto fail;
|
2012-01-02 02:05:49 +00:00
|
|
|
}
|
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
for (; i < 4; i++)
|
|
|
|
y[i] = _gtk_css_value_ref (y[(i - 1) >> 1]);
|
2012-01-02 02:05:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-03 16:39:01 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
y[i] = _gtk_css_value_ref (x[i]);
|
2012-01-02 02:05:49 +00:00
|
|
|
}
|
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2012-01-02 02:05:49 +00:00
|
|
|
{
|
2012-04-03 16:39:01 +00:00
|
|
|
values[i] = _gtk_css_corner_value_new (x[i], y[i]);
|
2012-01-02 02:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2012-04-03 16:39:01 +00:00
|
|
|
|
|
|
|
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;
|
2012-01-02 02:05:49 +00:00
|
|
|
}
|
|
|
|
|
2012-01-02 02:43:48 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_border_color (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-02 02:43:48 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2012-11-08 16:22:56 +00:00
|
|
|
values[i] = _gtk_css_color_value_parse (parser);
|
2012-04-07 04:18:03 +00:00
|
|
|
if (values[i] == NULL)
|
2012-04-05 20:22:52 +00:00
|
|
|
return FALSE;
|
2012-01-02 02:43:48 +00:00
|
|
|
|
2012-01-02 03:12:41 +00:00
|
|
|
if (value_is_done_parsing (parser))
|
2012-01-02 02:43:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i++; i < 4; i++)
|
|
|
|
{
|
2012-03-26 15:24:02 +00:00
|
|
|
values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
|
2012-01-02 02:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-01-05 15:53:43 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_border_style (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-05 15:53:43 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2012-03-28 06:19:53 +00:00
|
|
|
values[i] = _gtk_css_border_style_value_try_parse (parser);
|
|
|
|
if (values[i] == NULL)
|
2012-01-05 15:53:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_syntax (parser, "Expected a border style");
|
2012-01-05 15:53:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-03-28 06:19:53 +00:00
|
|
|
for (; i < 4; i++)
|
|
|
|
values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
|
2012-01-05 15:53:43 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-12-31 14:05:09 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_border_image (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2011-12-31 14:05:09 +00:00
|
|
|
{
|
2012-04-04 09:44:57 +00:00
|
|
|
do
|
2011-12-21 16:43:31 +00:00
|
|
|
{
|
2012-04-04 09:44:57 +00:00
|
|
|
if (values[0] == NULL &&
|
2019-04-01 09:47:53 +00:00
|
|
|
(gtk_css_parser_has_ident (parser, "none") ||
|
2012-04-04 09:44:57 +00:00
|
|
|
_gtk_css_image_can_parse (parser)))
|
|
|
|
{
|
|
|
|
GtkCssImage *image;
|
2011-12-31 14:05:09 +00:00
|
|
|
|
2019-03-24 13:03:52 +00:00
|
|
|
if (gtk_css_parser_try_ident (parser, "none"))
|
2012-04-04 09:44:57 +00:00
|
|
|
image = NULL;
|
|
|
|
else
|
|
|
|
{
|
2012-04-18 19:44:08 +00:00
|
|
|
image = _gtk_css_image_new_parse (parser);
|
2012-04-04 09:44:57 +00:00
|
|
|
if (image == NULL)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-12-31 14:05:09 +00:00
|
|
|
|
2012-04-04 09:44:57 +00:00
|
|
|
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)
|
|
|
|
{
|
2012-04-04 14:15:41 +00:00
|
|
|
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)
|
2012-04-04 09:44:57 +00:00
|
|
|
return FALSE;
|
2011-12-31 14:05:09 +00:00
|
|
|
|
2019-04-05 00:57:14 +00:00
|
|
|
if (gtk_css_parser_try_delim (parser, '/'))
|
2012-04-04 09:44:57 +00:00
|
|
|
{
|
2012-04-04 15:42:45 +00:00
|
|
|
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)
|
2012-04-04 09:44:57 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We parsed everything and there's still stuff left?
|
|
|
|
* Pretend we didn't notice and let the normal code produce
|
2015-12-23 02:19:11 +00:00
|
|
|
* a 'junk at end of value' error
|
|
|
|
*/
|
2012-04-04 09:44:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!value_is_done_parsing (parser));
|
2011-12-31 14:05:09 +00:00
|
|
|
|
2012-01-02 03:12:41 +00:00
|
|
|
return TRUE;
|
2011-12-31 14:05:09 +00:00
|
|
|
}
|
|
|
|
|
2012-01-07 02:04:10 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_border_side (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-07 02:04:10 +00:00
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2012-03-26 15:24:02 +00:00
|
|
|
if (values[0] == NULL &&
|
2016-02-12 05:45:06 +00:00
|
|
|
gtk_css_number_value_can_parse (parser))
|
2012-01-07 02:04:10 +00:00
|
|
|
{
|
2012-03-27 22:04:29 +00:00
|
|
|
values[0] = _gtk_css_number_value_parse (parser,
|
|
|
|
GTK_CSS_POSITIVE_ONLY
|
|
|
|
| GTK_CSS_PARSE_LENGTH);
|
|
|
|
if (values[0] == NULL)
|
2012-01-15 01:53:39 +00:00
|
|
|
return FALSE;
|
2012-01-07 02:04:10 +00:00
|
|
|
}
|
2012-03-26 15:24:02 +00:00
|
|
|
else if (values[1] == NULL &&
|
2012-03-28 06:19:53 +00:00
|
|
|
(values[1] = _gtk_css_border_style_value_try_parse (parser)))
|
2012-01-07 02:04:10 +00:00
|
|
|
{
|
2012-03-28 06:19:53 +00:00
|
|
|
/* Nothing to do */
|
2012-01-07 02:04:10 +00:00
|
|
|
}
|
2012-03-26 15:24:02 +00:00
|
|
|
else if (values[2] == NULL)
|
2012-01-07 02:04:10 +00:00
|
|
|
{
|
2012-11-08 16:22:56 +00:00
|
|
|
values[2] = _gtk_css_color_value_parse (parser);
|
2012-04-07 04:18:03 +00:00
|
|
|
if (values[2] == NULL)
|
2012-01-07 02:04:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-07-30 16:23:20 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We parsed and there's still stuff left?
|
|
|
|
* Pretend we didn't notice and let the normal code produce
|
2015-12-23 02:19:11 +00:00
|
|
|
* a 'junk at end of value' error
|
|
|
|
*/
|
2014-07-30 16:23:20 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-01-07 02:04:10 +00:00
|
|
|
}
|
|
|
|
while (!value_is_done_parsing (parser));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-01-04 23:04:12 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_border (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-04 23:04:12 +00:00
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2012-03-26 15:24:02 +00:00
|
|
|
if (values[0] == NULL &&
|
2016-02-12 05:45:06 +00:00
|
|
|
gtk_css_number_value_can_parse (parser))
|
2012-01-04 23:04:12 +00:00
|
|
|
{
|
2012-03-27 22:04:29 +00:00
|
|
|
values[0] = _gtk_css_number_value_parse (parser,
|
|
|
|
GTK_CSS_POSITIVE_ONLY
|
|
|
|
| GTK_CSS_PARSE_LENGTH);
|
|
|
|
if (values[0] == NULL)
|
2012-01-15 01:53:39 +00:00
|
|
|
return FALSE;
|
2012-03-26 15:24:02 +00:00
|
|
|
values[1] = _gtk_css_value_ref (values[0]);
|
|
|
|
values[2] = _gtk_css_value_ref (values[0]);
|
|
|
|
values[3] = _gtk_css_value_ref (values[0]);
|
2012-01-04 23:04:12 +00:00
|
|
|
}
|
2012-03-26 15:24:02 +00:00
|
|
|
else if (values[4] == NULL &&
|
2012-03-28 06:19:53 +00:00
|
|
|
(values[4] = _gtk_css_border_style_value_try_parse (parser)))
|
2012-01-04 23:04:12 +00:00
|
|
|
{
|
2012-03-26 15:24:02 +00:00
|
|
|
values[5] = _gtk_css_value_ref (values[4]);
|
|
|
|
values[6] = _gtk_css_value_ref (values[4]);
|
|
|
|
values[7] = _gtk_css_value_ref (values[4]);
|
2012-01-04 23:04:12 +00:00
|
|
|
}
|
2019-11-21 19:26:22 +00:00
|
|
|
else if (values[8] == NULL)
|
2012-01-04 23:04:12 +00:00
|
|
|
{
|
2012-11-08 16:22:56 +00:00
|
|
|
values[8] = _gtk_css_color_value_parse (parser);
|
2012-04-07 04:18:03 +00:00
|
|
|
if (values[8] == NULL)
|
2012-01-04 23:04:12 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-03-26 15:24:02 +00:00
|
|
|
values[9] = _gtk_css_value_ref (values[8]);
|
|
|
|
values[10] = _gtk_css_value_ref (values[8]);
|
|
|
|
values[11] = _gtk_css_value_ref (values[8]);
|
2012-01-04 23:04:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We parsed everything and there's still stuff left?
|
|
|
|
* Pretend we didn't notice and let the normal code produce
|
2015-12-23 02:19:11 +00:00
|
|
|
* a 'junk at end of value' error
|
|
|
|
*/
|
2012-01-04 23:04:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!value_is_done_parsing (parser));
|
|
|
|
|
|
|
|
/* Note that border-image values are not set: according to the spec
|
2015-12-23 02:19:11 +00:00
|
|
|
* they just need to be reset when using the border shorthand
|
|
|
|
*/
|
2012-01-04 23:04:12 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-09-18 15:28:05 +00:00
|
|
|
static GtkCssValue *
|
|
|
|
_gtk_css_font_variant_value_try_parse (GtkCssParser *parser)
|
|
|
|
{
|
2019-03-24 13:03:52 +00:00
|
|
|
if (gtk_css_parser_try_ident (parser, "normal"))
|
2017-09-18 15:28:05 +00:00
|
|
|
return _gtk_css_ident_value_new ("normal");
|
2019-03-24 13:03:52 +00:00
|
|
|
else if (gtk_css_parser_try_ident (parser, "small-caps"))
|
2017-09-18 15:28:05 +00:00
|
|
|
return _gtk_css_ident_value_new ("small-caps");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-01-02 08:19:27 +00:00
|
|
|
static gboolean
|
2012-03-26 15:24:02 +00:00
|
|
|
parse_font (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-01-02 08:19:27 +00:00
|
|
|
{
|
2016-04-18 15:43:29 +00:00
|
|
|
gboolean parsed_one;
|
2012-01-02 08:19:27 +00:00
|
|
|
|
2016-04-18 15:43:29 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
parsed_one = FALSE;
|
2012-01-02 08:19:27 +00:00
|
|
|
|
2016-04-18 15:43:29 +00:00
|
|
|
if (values[1] == NULL)
|
|
|
|
{
|
|
|
|
values[1] = _gtk_css_font_style_value_try_parse (parser);
|
|
|
|
parsed_one = parsed_one || values[1] != NULL;
|
|
|
|
}
|
2012-01-02 08:19:27 +00:00
|
|
|
|
2016-04-18 15:43:29 +00:00
|
|
|
if (values[2] == NULL)
|
|
|
|
{
|
|
|
|
values[2] = _gtk_css_font_variant_value_try_parse (parser);
|
|
|
|
parsed_one = parsed_one || values[2] != NULL;
|
|
|
|
}
|
2012-01-02 08:19:27 +00:00
|
|
|
|
2016-04-18 15:43:29 +00:00
|
|
|
if (values[3] == NULL)
|
|
|
|
{
|
2019-03-31 18:05:12 +00:00
|
|
|
values[3] = gtk_css_font_weight_value_try_parse (parser);
|
|
|
|
if (values[3] == NULL && gtk_css_number_value_can_parse (parser))
|
|
|
|
{
|
|
|
|
/* This needs to check for font-size, too */
|
|
|
|
GtkCssValue *num = _gtk_css_number_value_parse (parser,
|
|
|
|
GTK_CSS_PARSE_NUMBER |
|
|
|
|
GTK_CSS_PARSE_LENGTH |
|
|
|
|
GTK_CSS_PARSE_PERCENT |
|
|
|
|
GTK_CSS_POSITIVE_ONLY);
|
|
|
|
if (num == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (gtk_css_number_value_get_dimension (num) != GTK_CSS_DIMENSION_NUMBER)
|
|
|
|
{
|
|
|
|
values[5] = num;
|
|
|
|
goto have_font_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
values[3] = num;
|
|
|
|
if (_gtk_css_number_value_get (values[3], 100) < 1 ||
|
|
|
|
_gtk_css_number_value_get (values[3], 100) > 1000)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Font weight values must be between 1 and 1000");
|
2019-03-31 18:05:12 +00:00
|
|
|
g_clear_pointer (&values[3], gtk_css_value_unref);
|
2019-04-09 03:40:50 +00:00
|
|
|
return FALSE;
|
2019-03-31 18:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:43:29 +00:00
|
|
|
parsed_one = parsed_one || values[3] != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (values[4] == NULL)
|
|
|
|
{
|
2016-04-18 18:38:12 +00:00
|
|
|
values[4] = _gtk_css_font_stretch_value_try_parse (parser);
|
2016-04-18 15:43:29 +00:00
|
|
|
parsed_one = parsed_one || values[4] != NULL;
|
|
|
|
}
|
2012-01-02 08:19:27 +00:00
|
|
|
}
|
2016-04-18 15:43:29 +00:00
|
|
|
while (parsed_one && !value_is_done_parsing (parser));
|
2012-01-02 08:19:27 +00:00
|
|
|
|
2016-04-18 15:43:29 +00:00
|
|
|
values[5] = gtk_css_font_size_value_parse (parser);
|
2019-04-09 03:40:50 +00:00
|
|
|
if (values[5] == NULL)
|
|
|
|
return FALSE;
|
2016-04-18 18:09:41 +00:00
|
|
|
|
2019-03-31 18:05:12 +00:00
|
|
|
have_font_size:
|
2016-04-18 15:43:29 +00:00
|
|
|
values[0] = gtk_css_font_family_value_parse (parser);
|
2019-04-09 03:40:50 +00:00
|
|
|
if (values[0] == NULL)
|
|
|
|
return FALSE;
|
2012-01-02 08:19:27 +00:00
|
|
|
|
2019-04-09 03:40:50 +00:00
|
|
|
return TRUE;
|
2012-01-02 08:19:27 +00:00
|
|
|
}
|
|
|
|
|
2012-01-04 18:15:00 +00:00
|
|
|
static gboolean
|
2012-05-12 00:38:36 +00:00
|
|
|
parse_one_background (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
|
|
|
GtkCssParser *parser)
|
2012-01-04 18:15:00 +00:00
|
|
|
{
|
2012-05-12 00:38:36 +00:00
|
|
|
GtkCssValue *value = NULL;
|
2012-05-11 18:30:07 +00:00
|
|
|
|
2012-01-04 18:15:00 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
/* the image part */
|
2012-03-26 15:24:02 +00:00
|
|
|
if (values[0] == NULL &&
|
2019-04-01 09:47:53 +00:00
|
|
|
(gtk_css_parser_has_ident (parser, "none") ||
|
2012-01-04 18:15:00 +00:00
|
|
|
_gtk_css_image_can_parse (parser)))
|
|
|
|
{
|
|
|
|
GtkCssImage *image;
|
|
|
|
|
2019-03-24 13:03:52 +00:00
|
|
|
if (gtk_css_parser_try_ident (parser, "none"))
|
2012-01-04 18:15:00 +00:00
|
|
|
image = NULL;
|
|
|
|
else
|
|
|
|
{
|
2012-04-18 19:44:08 +00:00
|
|
|
image = _gtk_css_image_new_parse (parser);
|
2012-01-04 18:15:00 +00:00
|
|
|
if (image == NULL)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-05-12 00:38:36 +00:00
|
|
|
values[0] = _gtk_css_image_value_new (image);
|
|
|
|
}
|
|
|
|
else if (values[1] == NULL &&
|
2012-10-16 10:00:40 +00:00
|
|
|
(value = _gtk_css_position_value_try_parse (parser)))
|
2012-05-12 00:38:36 +00:00
|
|
|
{
|
|
|
|
values[1] = value;
|
|
|
|
value = NULL;
|
|
|
|
|
2019-04-05 00:57:14 +00:00
|
|
|
if (gtk_css_parser_try_delim (parser, '/') &&
|
2012-05-12 00:38:36 +00:00
|
|
|
(value = _gtk_css_bg_size_value_parse (parser)))
|
|
|
|
{
|
|
|
|
values[2] = value;
|
|
|
|
value = NULL;
|
|
|
|
}
|
2012-01-04 18:15:00 +00:00
|
|
|
}
|
2012-05-11 20:33:13 +00:00
|
|
|
else if (values[3] == NULL &&
|
2012-05-11 18:30:07 +00:00
|
|
|
(value = _gtk_css_background_repeat_value_try_parse (parser)))
|
2012-01-04 18:15:00 +00:00
|
|
|
{
|
2012-05-12 00:38:36 +00:00
|
|
|
values[3] = value;
|
2012-05-11 18:30:07 +00:00
|
|
|
value = NULL;
|
2012-01-04 18:15:00 +00:00
|
|
|
}
|
2012-05-11 20:33:13 +00:00
|
|
|
else if ((values[4] == NULL || values[5] == NULL) &&
|
2012-05-11 18:30:07 +00:00
|
|
|
(value = _gtk_css_area_value_try_parse (parser)))
|
2012-01-04 18:15:00 +00:00
|
|
|
{
|
2012-05-12 00:38:36 +00:00
|
|
|
values[4] = value;
|
2012-05-11 18:30:07 +00:00
|
|
|
|
2012-05-12 00:38:36 +00:00
|
|
|
if (values[5] == NULL)
|
2012-03-30 00:19:39 +00:00
|
|
|
{
|
2012-05-12 00:38:36 +00:00
|
|
|
values[5] = values[4];
|
|
|
|
values[4] = NULL;
|
2012-03-30 00:19:39 +00:00
|
|
|
}
|
2012-05-11 18:30:07 +00:00
|
|
|
value = NULL;
|
2012-01-04 18:15:00 +00:00
|
|
|
}
|
2012-05-11 20:33:13 +00:00
|
|
|
else if (values[6] == NULL)
|
2012-01-04 18:15:00 +00:00
|
|
|
{
|
2012-11-08 16:22:56 +00:00
|
|
|
value = _gtk_css_color_value_parse (parser);
|
2012-05-11 18:30:07 +00:00
|
|
|
if (value == NULL)
|
2012-05-12 00:38:36 +00:00
|
|
|
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;
|
2012-05-11 18:30:07 +00:00
|
|
|
|
2012-05-11 20:33:13 +00:00
|
|
|
value = NULL;
|
|
|
|
}
|
2012-01-04 18:15:00 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We parsed everything and there's still stuff left?
|
|
|
|
* Pretend we didn't notice and let the normal code produce
|
2015-12-23 02:19:11 +00:00
|
|
|
* a 'junk at end of value' error
|
|
|
|
*/
|
2012-01-04 18:15:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!value_is_done_parsing (parser));
|
|
|
|
|
2012-05-12 00:38:36 +00:00
|
|
|
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]);
|
|
|
|
}
|
2012-11-30 04:05:07 +00:00
|
|
|
return FALSE;
|
2012-05-12 00:38:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2019-03-24 13:36:55 +00:00
|
|
|
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
2012-05-12 00:38:36 +00:00
|
|
|
|
|
|
|
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];
|
|
|
|
|
2012-01-04 18:15:00 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-04-04 20:33:27 +00:00
|
|
|
static gboolean
|
2019-04-09 22:08:57 +00:00
|
|
|
has_transition_property (GtkCssParser *parser,
|
|
|
|
gpointer option_data,
|
|
|
|
gpointer user_data)
|
2012-04-04 20:33:27 +00:00
|
|
|
{
|
2019-04-09 22:08:57 +00:00
|
|
|
return gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_IDENT);
|
|
|
|
}
|
2012-04-04 20:33:27 +00:00
|
|
|
|
2019-04-09 22:08:57 +00:00
|
|
|
static gboolean
|
|
|
|
parse_transition_property (GtkCssParser *parser,
|
|
|
|
gpointer option_data,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkCssValue **value = option_data;
|
2012-04-04 20:33:27 +00:00
|
|
|
|
2019-04-09 22:08:57 +00:00
|
|
|
*value = _gtk_css_ident_value_try_parse (parser);
|
|
|
|
g_assert (*value);
|
2012-04-04 20:33:27 +00:00
|
|
|
|
2019-04-09 22:08:57 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2012-04-04 20:33:27 +00:00
|
|
|
|
2019-04-09 22:08:57 +00:00
|
|
|
static gboolean
|
|
|
|
parse_transition_time (GtkCssParser *parser,
|
|
|
|
gpointer option_data,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkCssValue **value = option_data;
|
2012-04-04 20:33:27 +00:00
|
|
|
|
2019-04-09 22:08:57 +00:00
|
|
|
*value = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_TIME);
|
|
|
|
|
|
|
|
return *value != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_transition_timing_function (GtkCssParser *parser,
|
|
|
|
gpointer option_data,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkCssValue **value = option_data;
|
|
|
|
|
|
|
|
*value = _gtk_css_ease_value_parse (parser);
|
|
|
|
|
|
|
|
return *value != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_one_transition (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
|
|
|
GtkCssParser *parser)
|
|
|
|
{
|
|
|
|
const GtkCssParseOption options[] = {
|
|
|
|
{ (void *) _gtk_css_ease_value_can_parse, parse_transition_timing_function, &values[3] },
|
|
|
|
{ (void *) gtk_css_number_value_can_parse, parse_transition_time, &values[1] },
|
|
|
|
{ (void *) gtk_css_number_value_can_parse, parse_transition_time, &values[2] },
|
|
|
|
{ (void *) has_transition_property, parse_transition_property, &values[0] },
|
|
|
|
};
|
|
|
|
|
|
|
|
return gtk_css_parser_consume_any (parser, options, G_N_ELEMENTS (options), NULL);
|
2012-04-04 20:33:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_transition (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
2012-04-18 19:48:05 +00:00
|
|
|
GtkCssParser *parser)
|
2012-04-04 20:33:27 +00:00
|
|
|
{
|
|
|
|
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 {
|
2012-04-18 19:48:05 +00:00
|
|
|
if (!parse_one_transition (shorthand, step_values, parser))
|
2012-04-04 20:33:27 +00:00
|
|
|
{
|
|
|
|
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]);
|
|
|
|
}
|
2012-11-30 04:05:07 +00:00
|
|
|
return FALSE;
|
2012-04-04 20:33:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2019-03-24 13:36:55 +00:00
|
|
|
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
2012-04-04 20:33:27 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-09-10 10:15:44 +00:00
|
|
|
static gboolean
|
|
|
|
parse_one_animation (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
|
|
|
GtkCssParser *parser)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2019-03-24 13:03:52 +00:00
|
|
|
if (values[1] == NULL && gtk_css_parser_try_ident (parser, "infinite"))
|
2012-09-10 10:15:44 +00:00
|
|
|
{
|
|
|
|
values[1] = _gtk_css_number_value_new (HUGE_VAL, GTK_CSS_NUMBER);
|
|
|
|
}
|
|
|
|
else if ((values[1] == NULL || values[3] == NULL) &&
|
2016-02-12 05:45:06 +00:00
|
|
|
gtk_css_number_value_can_parse (parser))
|
2012-09-10 10:15:44 +00:00
|
|
|
{
|
|
|
|
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));
|
2014-07-30 16:45:15 +00:00
|
|
|
if (value == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-02-12 03:40:35 +00:00
|
|
|
if (gtk_css_number_value_get_dimension (value) == GTK_CSS_DIMENSION_NUMBER)
|
2012-09-10 10:15:44 +00:00
|
|
|
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];
|
2014-07-07 11:09:30 +00:00
|
|
|
GPtrArray *arrays[7];
|
2012-09-10 10:15:44 +00:00
|
|
|
guint i;
|
|
|
|
|
2014-07-07 11:09:30 +00:00
|
|
|
for (i = 0; i < 7; i++)
|
2012-09-10 10:15:44 +00:00
|
|
|
{
|
|
|
|
arrays[i] = g_ptr_array_new ();
|
|
|
|
step_values[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (!parse_one_animation (shorthand, step_values, parser))
|
|
|
|
{
|
2014-07-07 11:09:30 +00:00
|
|
|
for (i = 0; i < 7; i++)
|
2012-09-10 10:15:44 +00:00
|
|
|
{
|
|
|
|
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
|
|
|
|
g_ptr_array_unref (arrays[i]);
|
|
|
|
}
|
2012-11-30 04:05:07 +00:00
|
|
|
return FALSE;
|
2012-09-10 10:15:44 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 11:09:30 +00:00
|
|
|
for (i = 0; i < 7; i++)
|
2012-09-10 10:15:44 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2019-03-24 13:36:55 +00:00
|
|
|
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
2012-09-10 10:15:44 +00:00
|
|
|
|
2014-07-07 11:09:30 +00:00
|
|
|
for (i = 0; i < 7; i++)
|
2012-09-10 10:15:44 +00:00
|
|
|
{
|
|
|
|
values[i] = _gtk_css_array_value_new_from_array ((GtkCssValue **) arrays[i]->pdata, arrays[i]->len);
|
|
|
|
g_ptr_array_unref (arrays[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-07-05 21:24:49 +00:00
|
|
|
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;
|
|
|
|
}
|
2015-07-06 18:03:54 +00:00
|
|
|
else if (values[1] == NULL &&
|
|
|
|
(values[1] = _gtk_css_text_decoration_style_value_try_parse (parser)))
|
2015-07-05 21:24:49 +00:00
|
|
|
{
|
|
|
|
if (values[1] == NULL)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-07-06 18:03:54 +00:00
|
|
|
else if (values[2] == NULL)
|
|
|
|
{
|
|
|
|
values[2] = _gtk_css_color_value_parse (parser);
|
|
|
|
if (values[2] == NULL)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-07-05 21:24:49 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-09-18 15:28:05 +00:00
|
|
|
static gboolean
|
|
|
|
parse_font_variant (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
|
|
|
GtkCssParser *parser)
|
|
|
|
{
|
2019-03-24 13:03:52 +00:00
|
|
|
if (gtk_css_parser_try_ident (parser, "normal"))
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
|
|
|
/* all initial values */
|
|
|
|
}
|
2019-03-24 13:03:52 +00:00
|
|
|
else if (gtk_css_parser_try_ident (parser, "none"))
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
|
|
|
/* all initial values, except for font-variant-ligatures */
|
2017-09-18 22:38:16 +00:00
|
|
|
values[0] = _gtk_css_font_variant_ligature_value_new (GTK_CSS_FONT_VARIANT_LIGATURE_NONE);
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
GtkCssFontVariantLigature ligatures;
|
|
|
|
GtkCssFontVariantNumeric numeric;
|
|
|
|
GtkCssFontVariantEastAsian east_asian;
|
2017-09-18 15:28:05 +00:00
|
|
|
|
2017-09-18 22:38:16 +00:00
|
|
|
ligatures = 0;
|
|
|
|
numeric = 0;
|
|
|
|
east_asian = 0;
|
2017-09-18 15:28:05 +00:00
|
|
|
do {
|
2017-09-18 22:38:16 +00:00
|
|
|
GtkCssFontVariantLigature parsed_ligature;
|
|
|
|
GtkCssFontVariantNumeric parsed_numeric;
|
|
|
|
GtkCssFontVariantEastAsian parsed_east_asian;
|
|
|
|
|
|
|
|
parsed_ligature = _gtk_css_font_variant_ligature_try_parse_one (parser, ligatures);
|
|
|
|
if (parsed_ligature == 0 && ligatures != 0)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Invalid combination of ligature values");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
if (parsed_ligature == GTK_CSS_FONT_VARIANT_LIGATURE_NORMAL ||
|
|
|
|
parsed_ligature == GTK_CSS_FONT_VARIANT_LIGATURE_NONE)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Unexpected ligature value");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
if (parsed_ligature != ligatures)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
ligatures = parsed_ligature;
|
|
|
|
goto found;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
|
|
|
|
2017-09-18 22:38:16 +00:00
|
|
|
parsed_numeric = _gtk_css_font_variant_numeric_try_parse_one (parser, numeric);
|
|
|
|
if (parsed_numeric == 0 && numeric != 0)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Invalid combination of numeric values");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
if (parsed_numeric == GTK_CSS_FONT_VARIANT_NUMERIC_NORMAL)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Unexpected numeric value");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
if (parsed_numeric != numeric)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
numeric = parsed_numeric;
|
|
|
|
goto found;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
|
|
|
|
parsed_east_asian = _gtk_css_font_variant_east_asian_try_parse_one (parser, east_asian);
|
|
|
|
if (parsed_east_asian == 0 && east_asian != 0)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Invalid combination of east asian values");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
if (parsed_east_asian == GTK_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Unexpected east asian value");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
if (parsed_east_asian != east_asian)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
east_asian = parsed_east_asian;
|
|
|
|
goto found;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (values[1] == NULL)
|
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
values[1] = _gtk_css_font_variant_position_value_try_parse (parser);
|
2017-09-18 15:28:05 +00:00
|
|
|
if (values[1])
|
2017-09-18 22:38:16 +00:00
|
|
|
{
|
|
|
|
if (_gtk_css_font_variant_position_value_get (values[1]) == GTK_CSS_FONT_VARIANT_POSITION_NORMAL)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Unexpected position value");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
goto found;
|
|
|
|
}
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
|
|
|
if (values[2] == NULL)
|
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
values[2] = _gtk_css_font_variant_caps_value_try_parse (parser);
|
2017-09-18 15:28:05 +00:00
|
|
|
if (values[2])
|
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
if (_gtk_css_font_variant_caps_value_get (values[2]) == GTK_CSS_FONT_VARIANT_CAPS_NORMAL)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Unexpected caps value");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
goto found;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (values[4] == NULL)
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
values[4] = _gtk_css_font_variant_alternate_value_try_parse (parser);
|
|
|
|
if (values[4])
|
2017-09-18 15:28:05 +00:00
|
|
|
{
|
2017-09-18 22:38:16 +00:00
|
|
|
if (_gtk_css_font_variant_alternate_value_get (values[4]) == GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Unexpected alternate value");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
goto found;
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
2017-09-18 22:38:16 +00:00
|
|
|
}
|
2017-09-18 15:28:05 +00:00
|
|
|
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Unknown value for property");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
2017-09-18 15:28:05 +00:00
|
|
|
|
2017-09-18 22:38:16 +00:00
|
|
|
found:
|
|
|
|
if (value_is_done_parsing (parser))
|
|
|
|
break;
|
2017-09-18 15:28:05 +00:00
|
|
|
|
2017-09-18 22:38:16 +00:00
|
|
|
} while (1);
|
2017-09-18 15:28:05 +00:00
|
|
|
|
2017-09-18 22:38:16 +00:00
|
|
|
if (ligatures != 0)
|
|
|
|
{
|
|
|
|
values[0] = _gtk_css_font_variant_ligature_value_new (ligatures);
|
|
|
|
if (values[0] == NULL)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Invalid combination of ligature values");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2017-09-18 15:28:05 +00:00
|
|
|
|
2017-09-18 22:38:16 +00:00
|
|
|
if (numeric != 0)
|
|
|
|
{
|
|
|
|
values[3] = _gtk_css_font_variant_numeric_value_new (numeric);
|
|
|
|
if (values[3] == NULL)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Invalid combination of numeric values");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2017-09-18 15:28:05 +00:00
|
|
|
|
2017-09-18 22:38:16 +00:00
|
|
|
if (east_asian != 0)
|
|
|
|
{
|
|
|
|
values[5] = _gtk_css_font_variant_east_asian_value_new (east_asian);
|
|
|
|
if (values[5] == NULL)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_value (parser, "Invalid combination of east asian values");
|
2017-09-18 22:38:16 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2017-09-18 15:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-11 01:22:06 +00:00
|
|
|
static gboolean
|
|
|
|
parse_all (GtkCssShorthandProperty *shorthand,
|
|
|
|
GtkCssValue **values,
|
|
|
|
GtkCssParser *parser)
|
|
|
|
{
|
2019-04-09 03:40:50 +00:00
|
|
|
gtk_css_parser_error_syntax (parser, "The 'all' property can only be set to 'initial', 'inherit' or 'unset'");
|
2014-05-11 01:22:06 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-31 14:05:09 +00:00
|
|
|
/*** PACKING ***/
|
|
|
|
|
2012-03-26 05:08:24 +00:00
|
|
|
static void
|
2012-01-10 22:36:10 +00:00
|
|
|
pack_border (GtkCssShorthandProperty *shorthand,
|
2012-03-26 05:08:24 +00:00
|
|
|
GValue *value,
|
2012-01-11 01:43:16 +00:00
|
|
|
GtkStyleQueryFunc query_func,
|
|
|
|
gpointer query_data)
|
2011-12-31 14:05:09 +00:00
|
|
|
{
|
2012-01-10 22:36:10 +00:00
|
|
|
GtkCssStyleProperty *prop;
|
2011-12-31 14:05:09 +00:00
|
|
|
GtkBorder border;
|
2012-04-07 05:38:35 +00:00
|
|
|
GValue v;
|
2012-01-10 22:36:10 +00:00
|
|
|
|
|
|
|
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
|
2012-04-07 05:38:35 +00:00
|
|
|
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
|
|
|
|
border.top = g_value_get_int (&v);
|
|
|
|
g_value_unset (&v);
|
|
|
|
|
2012-01-10 22:36:10 +00:00
|
|
|
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 1);
|
2012-04-07 05:38:35 +00:00
|
|
|
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
|
|
|
|
border.right = g_value_get_int (&v);
|
|
|
|
g_value_unset (&v);
|
|
|
|
|
2012-01-10 22:36:10 +00:00
|
|
|
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 2);
|
2012-04-07 05:38:35 +00:00
|
|
|
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
|
|
|
|
border.bottom = g_value_get_int (&v);
|
|
|
|
g_value_unset (&v);
|
|
|
|
|
2012-01-10 22:36:10 +00:00
|
|
|
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 3);
|
2012-04-07 05:38:35 +00:00
|
|
|
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
|
|
|
|
border.left = g_value_get_int (&v);
|
|
|
|
g_value_unset (&v);
|
2011-12-31 14:05:09 +00:00
|
|
|
|
2012-03-26 05:08:24 +00:00
|
|
|
g_value_init (value, GTK_TYPE_BORDER);
|
|
|
|
g_value_set_boxed (value, &border);
|
2011-12-31 14:05:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 05:08:24 +00:00
|
|
|
static void
|
2012-01-10 18:02:42 +00:00
|
|
|
pack_border_radius (GtkCssShorthandProperty *shorthand,
|
2012-03-26 05:08:24 +00:00
|
|
|
GValue *value,
|
2012-01-11 01:43:16 +00:00
|
|
|
GtkStyleQueryFunc query_func,
|
|
|
|
gpointer query_data)
|
2011-12-31 14:05:09 +00:00
|
|
|
{
|
2012-03-06 13:16:32 +00:00
|
|
|
GtkCssValue *v;
|
2012-03-26 05:08:24 +00:00
|
|
|
int i = 0;
|
2011-12-31 14:05:09 +00:00
|
|
|
|
2018-07-03 21:23:36 +00:00
|
|
|
v = (* query_func) (GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS, query_data);
|
2012-01-11 01:43:16 +00:00
|
|
|
if (v)
|
2012-04-03 16:39:01 +00:00
|
|
|
i = _gtk_css_corner_value_get_x (v, 100);
|
2012-03-06 13:16:32 +00:00
|
|
|
|
2012-03-26 05:08:24 +00:00
|
|
|
g_value_init (value, G_TYPE_INT);
|
|
|
|
g_value_set_int (value, i);
|
2011-12-31 14:05:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 05:08:24 +00:00
|
|
|
static void
|
2012-01-10 18:02:42 +00:00
|
|
|
pack_font_description (GtkCssShorthandProperty *shorthand,
|
2012-03-26 05:08:24 +00:00
|
|
|
GValue *value,
|
2012-01-11 01:43:16 +00:00
|
|
|
GtkStyleQueryFunc query_func,
|
|
|
|
gpointer query_data)
|
2011-12-31 14:05:09 +00:00
|
|
|
{
|
|
|
|
PangoFontDescription *description;
|
2012-03-06 13:16:32 +00:00
|
|
|
GtkCssValue *v;
|
2011-12-31 14:05:09 +00:00
|
|
|
|
|
|
|
description = pango_font_description_new ();
|
|
|
|
|
2018-07-03 21:23:36 +00:00
|
|
|
v = (* query_func) (GTK_CSS_PROPERTY_FONT_FAMILY, query_data);
|
2012-01-11 01:43:16 +00:00
|
|
|
if (v)
|
|
|
|
{
|
2019-05-03 01:18:42 +00:00
|
|
|
int i;
|
|
|
|
GString *s = g_string_new ("");
|
|
|
|
|
|
|
|
for (i = 0; i < _gtk_css_array_value_get_n_values (v); i++)
|
|
|
|
{
|
|
|
|
if (i > 0)
|
|
|
|
g_string_append (s, ",");
|
|
|
|
g_string_append (s, _gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
pango_font_description_set_family (description, s->str);
|
|
|
|
g_string_free (s, TRUE);
|
2012-01-11 01:43:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 21:23:36 +00:00
|
|
|
v = (* query_func) (GTK_CSS_PROPERTY_FONT_SIZE, query_data);
|
2012-01-11 01:43:16 +00:00
|
|
|
if (v)
|
2018-07-03 21:17:41 +00:00
|
|
|
pango_font_description_set_absolute_size (description, round (_gtk_css_number_value_get (v, 100) * PANGO_SCALE));
|
2012-01-11 01:43:16 +00:00
|
|
|
|
2018-07-03 21:23:36 +00:00
|
|
|
v = (* query_func) (GTK_CSS_PROPERTY_FONT_STYLE, query_data);
|
2012-01-11 01:43:16 +00:00
|
|
|
if (v)
|
2012-03-28 07:04:54 +00:00
|
|
|
pango_font_description_set_style (description, _gtk_css_font_style_value_get (v));
|
2012-01-11 01:43:16 +00:00
|
|
|
|
2018-07-03 21:23:36 +00:00
|
|
|
v = (* query_func) (GTK_CSS_PROPERTY_FONT_WEIGHT, query_data);
|
2012-01-11 01:43:16 +00:00
|
|
|
if (v)
|
2019-03-31 18:05:12 +00:00
|
|
|
pango_font_description_set_weight (description, _gtk_css_number_value_get (v, 100));
|
2011-12-31 14:05:09 +00:00
|
|
|
|
2018-07-03 21:23:36 +00:00
|
|
|
v = (* query_func) (GTK_CSS_PROPERTY_FONT_STRETCH, query_data);
|
2014-08-28 11:50:49 +00:00
|
|
|
if (v)
|
|
|
|
pango_font_description_set_stretch (description, _gtk_css_font_stretch_value_get (v));
|
|
|
|
|
2012-03-26 05:08:24 +00:00
|
|
|
g_value_init (value, PANGO_TYPE_FONT_DESCRIPTION);
|
|
|
|
g_value_take_boxed (value, description);
|
2011-12-31 14:05:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 05:08:24 +00:00
|
|
|
static void
|
2012-01-10 22:49:21 +00:00
|
|
|
pack_first_element (GtkCssShorthandProperty *shorthand,
|
2012-03-26 05:08:24 +00:00
|
|
|
GValue *value,
|
2012-01-11 01:43:16 +00:00
|
|
|
GtkStyleQueryFunc query_func,
|
|
|
|
gpointer query_data)
|
2011-12-31 14:05:09 +00:00
|
|
|
{
|
2012-01-10 22:49:21 +00:00
|
|
|
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
|
2011-12-31 14:05:09 +00:00
|
|
|
* real properties instead. */
|
2012-03-26 05:08:24 +00:00
|
|
|
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
|
|
|
|
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop),
|
|
|
|
value,
|
|
|
|
query_func,
|
|
|
|
query_data);
|
2011-12-31 14:05:09 +00:00
|
|
|
}
|
|
|
|
|
2011-12-31 14:43:13 +00:00
|
|
|
static void
|
2012-01-02 01:23:54 +00:00
|
|
|
_gtk_css_shorthand_property_register (const char *name,
|
|
|
|
GType value_type,
|
|
|
|
const char **subproperties,
|
|
|
|
GtkCssShorthandPropertyParseFunc parse_func,
|
2012-01-10 18:02:42 +00:00
|
|
|
GtkCssShorthandPropertyQueryFunc query_func)
|
2011-12-31 14:43:13 +00:00
|
|
|
{
|
2012-01-10 18:02:42 +00:00
|
|
|
GtkCssShorthandProperty *node;
|
2011-12-31 14:43:13 +00:00
|
|
|
|
|
|
|
node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
|
2012-01-01 22:16:35 +00:00
|
|
|
"name", name,
|
|
|
|
"value-type", value_type,
|
2011-12-31 15:31:25 +00:00
|
|
|
"subproperties", subproperties,
|
2011-12-31 14:43:13 +00:00
|
|
|
NULL);
|
|
|
|
|
2012-01-10 18:02:42 +00:00
|
|
|
node->parse = parse_func;
|
|
|
|
node->query = query_func;
|
2011-12-31 14:43:13 +00:00
|
|
|
}
|
|
|
|
|
2014-05-11 01:22:06 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2011-12-31 14:05:09 +00:00
|
|
|
void
|
|
|
|
_gtk_css_shorthand_property_init_properties (void)
|
|
|
|
{
|
2012-01-02 01:33:56 +00:00
|
|
|
/* The order is important here, be careful when changing it */
|
2017-09-18 15:28:05 +00:00
|
|
|
const char *font_subproperties[] = { "font-family", "font-style", "font-variant-caps", "font-weight", "font-stretch", "font-size", NULL };
|
2011-12-31 15:31:25 +00:00
|
|
|
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 };
|
2012-01-05 15:53:43 +00:00
|
|
|
const char *border_style_subproperties[] = { "border-top-style", "border-right-style", "border-bottom-style", "border-left-style", NULL };
|
2011-12-31 15:31:25 +00:00
|
|
|
const char *border_image_subproperties[] = { "border-image-source", "border-image-slice", "border-image-width", "border-image-repeat", NULL };
|
2012-01-07 02:04:10 +00:00
|
|
|
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 };
|
2012-01-04 23:04:12 +00:00
|
|
|
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 };
|
2012-01-08 01:10:35 +00:00
|
|
|
const char *outline_subproperties[] = { "outline-width", "outline-style", "outline-color", NULL };
|
2017-09-18 01:17:30 +00:00
|
|
|
const char *outline_radius_subproperties[] = { "-gtk-outline-top-left-radius", "-gtk-outline-top-right-radius",
|
|
|
|
"-gtk-outline-bottom-right-radius", "-gtk-outline-bottom-left-radius", NULL };
|
2012-05-11 20:33:13 +00:00
|
|
|
const char *background_subproperties[] = { "background-image", "background-position", "background-size", "background-repeat", "background-clip", "background-origin",
|
2012-01-04 18:15:00 +00:00
|
|
|
"background-color", NULL };
|
2012-04-04 20:33:27 +00:00
|
|
|
const char *transition_subproperties[] = { "transition-property", "transition-duration", "transition-delay", "transition-timing-function", NULL };
|
2012-09-10 10:15:44 +00:00
|
|
|
const char *animation_subproperties[] = { "animation-name", "animation-iteration-count", "animation-duration", "animation-delay",
|
|
|
|
"animation-timing-function", "animation-direction", "animation-fill-mode", NULL };
|
2015-07-06 18:03:54 +00:00
|
|
|
const char *text_decoration_subproperties[] = { "text-decoration-line", "text-decoration-style", "text-decoration-color", NULL };
|
2017-09-18 22:10:08 +00:00
|
|
|
const char *font_variant_subproperties[] = { "font-variant-ligatures", "font-variant-position", "font-variant-caps", "font-variant-numeric", "font-variant-alternates", "font-variant-east-asian", NULL };
|
2011-12-31 15:31:25 +00:00
|
|
|
|
2014-05-11 01:22:06 +00:00
|
|
|
const char **all_subproperties;
|
|
|
|
|
2012-01-01 22:16:35 +00:00
|
|
|
_gtk_css_shorthand_property_register ("font",
|
|
|
|
PANGO_TYPE_FONT_DESCRIPTION,
|
2011-12-31 15:31:25 +00:00
|
|
|
font_subproperties,
|
2012-01-02 08:19:27 +00:00
|
|
|
parse_font,
|
2012-01-02 08:22:35 +00:00
|
|
|
pack_font_description);
|
2012-01-01 22:16:35 +00:00
|
|
|
_gtk_css_shorthand_property_register ("margin",
|
|
|
|
GTK_TYPE_BORDER,
|
2011-12-31 15:31:25 +00:00
|
|
|
margin_subproperties,
|
2012-01-17 15:41:14 +00:00
|
|
|
parse_margin,
|
2012-01-10 22:36:10 +00:00
|
|
|
pack_border);
|
2012-01-01 22:16:35 +00:00
|
|
|
_gtk_css_shorthand_property_register ("padding",
|
|
|
|
GTK_TYPE_BORDER,
|
2011-12-31 15:31:25 +00:00
|
|
|
padding_subproperties,
|
2012-01-24 16:49:29 +00:00
|
|
|
parse_padding,
|
2012-01-10 22:36:10 +00:00
|
|
|
pack_border);
|
2012-01-01 22:16:35 +00:00
|
|
|
_gtk_css_shorthand_property_register ("border-width",
|
|
|
|
GTK_TYPE_BORDER,
|
2011-12-31 15:31:25 +00:00
|
|
|
border_width_subproperties,
|
2012-01-24 16:49:29 +00:00
|
|
|
parse_border_width,
|
2012-01-10 22:36:10 +00:00
|
|
|
pack_border);
|
2012-01-01 22:16:35 +00:00
|
|
|
_gtk_css_shorthand_property_register ("border-radius",
|
|
|
|
G_TYPE_INT,
|
2011-12-31 15:31:25 +00:00
|
|
|
border_radius_subproperties,
|
2012-01-02 02:05:49 +00:00
|
|
|
parse_border_radius,
|
2012-01-02 08:22:35 +00:00
|
|
|
pack_border_radius);
|
2012-01-01 22:16:35 +00:00
|
|
|
_gtk_css_shorthand_property_register ("border-color",
|
|
|
|
GDK_TYPE_RGBA,
|
2011-12-31 15:31:25 +00:00
|
|
|
border_color_subproperties,
|
2012-01-02 02:43:48 +00:00
|
|
|
parse_border_color,
|
2012-01-10 22:49:21 +00:00
|
|
|
pack_first_element);
|
2012-01-05 15:53:43 +00:00
|
|
|
_gtk_css_shorthand_property_register ("border-style",
|
|
|
|
GTK_TYPE_BORDER_STYLE,
|
|
|
|
border_style_subproperties,
|
|
|
|
parse_border_style,
|
2012-01-10 22:49:21 +00:00
|
|
|
pack_first_element);
|
2012-01-01 22:16:35 +00:00
|
|
|
_gtk_css_shorthand_property_register ("border-image",
|
2012-01-04 03:04:59 +00:00
|
|
|
G_TYPE_NONE,
|
2011-12-31 15:31:25 +00:00
|
|
|
border_image_subproperties,
|
2012-01-02 03:12:41 +00:00
|
|
|
parse_border_image,
|
2012-01-04 03:04:59 +00:00
|
|
|
NULL);
|
2012-01-07 02:04:10 +00:00
|
|
|
_gtk_css_shorthand_property_register ("border-top",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
border_top_subproperties,
|
|
|
|
parse_border_side,
|
|
|
|
NULL);
|
|
|
|
_gtk_css_shorthand_property_register ("border-right",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
border_right_subproperties,
|
|
|
|
parse_border_side,
|
|
|
|
NULL);
|
|
|
|
_gtk_css_shorthand_property_register ("border-bottom",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
border_bottom_subproperties,
|
|
|
|
parse_border_side,
|
|
|
|
NULL);
|
|
|
|
_gtk_css_shorthand_property_register ("border-left",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
border_left_subproperties,
|
|
|
|
parse_border_side,
|
|
|
|
NULL);
|
2012-01-04 23:04:12 +00:00
|
|
|
_gtk_css_shorthand_property_register ("border",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
border_subproperties,
|
|
|
|
parse_border,
|
|
|
|
NULL);
|
2015-12-22 21:18:10 +00:00
|
|
|
_gtk_css_shorthand_property_register ("-gtk-outline-radius",
|
2014-05-01 16:11:23 +00:00
|
|
|
G_TYPE_INT,
|
|
|
|
outline_radius_subproperties,
|
|
|
|
parse_border_radius,
|
|
|
|
pack_border_radius);
|
2012-01-08 01:10:35 +00:00
|
|
|
_gtk_css_shorthand_property_register ("outline",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
outline_subproperties,
|
|
|
|
parse_border_side,
|
|
|
|
NULL);
|
2012-01-04 18:15:00 +00:00
|
|
|
_gtk_css_shorthand_property_register ("background",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
background_subproperties,
|
|
|
|
parse_background,
|
|
|
|
NULL);
|
2012-04-04 20:33:27 +00:00
|
|
|
_gtk_css_shorthand_property_register ("transition",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
transition_subproperties,
|
|
|
|
parse_transition,
|
|
|
|
NULL);
|
2012-09-10 10:15:44 +00:00
|
|
|
_gtk_css_shorthand_property_register ("animation",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
animation_subproperties,
|
|
|
|
parse_animation,
|
|
|
|
NULL);
|
2015-07-05 21:24:49 +00:00
|
|
|
_gtk_css_shorthand_property_register ("text-decoration",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
text_decoration_subproperties,
|
|
|
|
parse_text_decoration,
|
|
|
|
NULL);
|
2017-09-18 15:28:05 +00:00
|
|
|
_gtk_css_shorthand_property_register ("font-variant",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
font_variant_subproperties,
|
|
|
|
parse_font_variant,
|
|
|
|
NULL);
|
2014-05-11 01:22:06 +00:00
|
|
|
|
|
|
|
all_subproperties = get_all_subproperties ();
|
|
|
|
_gtk_css_shorthand_property_register ("all",
|
|
|
|
G_TYPE_NONE,
|
|
|
|
all_subproperties,
|
|
|
|
parse_all,
|
|
|
|
NULL);
|
|
|
|
g_free (all_subproperties);
|
2011-12-31 14:05:09 +00:00
|
|
|
}
|