[gtk/wip/otte/for-master: 1/2] css: Split dimension token
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-master: 1/2] css: Split dimension token
- Date: Wed, 20 Oct 2021 22:16:49 +0000 (UTC)
commit c11bd57422a1d84a2e507b020461f4afd74f0726
Author: Benjamin Otte <otte redhat com>
Date: Thu Oct 21 00:05:19 2021 +0200
css: Split dimension token
Add a signed and an unsigned version.
This will become useful real soon.
gtk/css/gtkcsstokenizer.c | 17 +++++++++++------
gtk/css/gtkcsstokenizerprivate.h | 3 ++-
gtk/gtkcssdimensionvalue.c | 3 ++-
gtk/gtkcssnumbervalue.c | 3 ++-
4 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/gtk/css/gtkcsstokenizer.c b/gtk/css/gtkcsstokenizer.c
index 05fca8ed01..a6d14abc21 100644
--- a/gtk/css/gtkcsstokenizer.c
+++ b/gtk/css/gtkcsstokenizer.c
@@ -55,7 +55,8 @@ gtk_css_token_clear (GtkCssToken *token)
case GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION:
case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
- case GTK_CSS_TOKEN_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNED_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNLESS_DIMENSION:
g_free (token->dimension.dimension);
break;
@@ -206,7 +207,8 @@ gtk_css_token_is_finite (const GtkCssToken *token)
case GTK_CSS_TOKEN_BAD_URL:
case GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION:
case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
- case GTK_CSS_TOKEN_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNED_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNLESS_DIMENSION:
return FALSE;
}
}
@@ -281,7 +283,8 @@ gtk_css_token_is_preserved (const GtkCssToken *token,
case GTK_CSS_TOKEN_BAD_URL:
case GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION:
case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
- case GTK_CSS_TOKEN_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNED_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNLESS_DIMENSION:
if (out_closing)
*out_closing = GTK_CSS_TOKEN_EOF;
return TRUE;
@@ -372,11 +375,12 @@ gtk_css_token_print (const GtkCssToken *token,
break;
case GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNED_DIMENSION:
if (token->dimension.value >= 0)
g_string_append_c (string, '+');
G_GNUC_FALLTHROUGH;
case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
- case GTK_CSS_TOKEN_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNLESS_DIMENSION:
g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, token->dimension.value);
g_string_append (string, buf);
append_ident (string, token->dimension.dimension);
@@ -549,7 +553,8 @@ gtk_css_token_init_dimension (GtkCssToken *token,
{
case GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION:
case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
- case GTK_CSS_TOKEN_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNED_DIMENSION:
+ case GTK_CSS_TOKEN_SIGNLESS_DIMENSION:
token->dimension.value = value;
token->dimension.dimension = dimension;
break;
@@ -1122,7 +1127,7 @@ gtk_css_tokenizer_read_numeric (GtkCssTokenizer *tokenizer,
if (is_int)
type = has_sign ? GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION : GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION;
else
- type = GTK_CSS_TOKEN_DIMENSION;
+ type = has_sign ? GTK_CSS_TOKEN_SIGNED_DIMENSION : GTK_CSS_TOKEN_SIGNLESS_DIMENSION;
gtk_css_token_init_dimension (token, type, value, gtk_css_tokenizer_read_name (tokenizer));
}
diff --git a/gtk/css/gtkcsstokenizerprivate.h b/gtk/css/gtkcsstokenizerprivate.h
index 40447b0b89..6211ef722f 100644
--- a/gtk/css/gtkcsstokenizerprivate.h
+++ b/gtk/css/gtkcsstokenizerprivate.h
@@ -67,7 +67,8 @@ typedef enum {
/* dimension */
GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION,
GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION,
- GTK_CSS_TOKEN_DIMENSION
+ GTK_CSS_TOKEN_SIGNED_DIMENSION,
+ GTK_CSS_TOKEN_SIGNLESS_DIMENSION
} GtkCssTokenType;
typedef union _GtkCssToken GtkCssToken;
diff --git a/gtk/gtkcssdimensionvalue.c b/gtk/gtkcssdimensionvalue.c
index 84a1d0e780..4bc0c32a6a 100644
--- a/gtk/gtkcssdimensionvalue.c
+++ b/gtk/gtkcssdimensionvalue.c
@@ -93,7 +93,8 @@ gtk_css_dimension_value_parse (GtkCssParser *parser,
}
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION) ||
- gtk_css_token_is (token, GTK_CSS_TOKEN_DIMENSION))
+ gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNED_DIMENSION) ||
+ gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNLESS_DIMENSION))
{
guint i;
diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index dacf9c4476..7b2dbeacc9 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -704,7 +704,8 @@ gtk_css_number_value_can_parse (GtkCssParser *parser)
|| gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_PERCENTAGE)
|| gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION)
|| gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION)
- || gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_DIMENSION)
+ || gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNED_DIMENSION)
+ || gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNLESS_DIMENSION)
|| gtk_css_parser_has_function (parser, "calc");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]