css: Add gtk_css_token_source_consume_integer()
And make sure the integer parsing functions call it.
This commit is contained in:
@@ -1109,16 +1109,8 @@ gtk_css_color_value_token_parse (GtkCssTokenSource *source)
|
||||
}
|
||||
gtk_css_token_source_consume_token (source);
|
||||
}
|
||||
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNED_INTEGER) ||
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNLESS_INTEGER))
|
||||
else if (!gtk_css_token_source_consume_integer (source, &id))
|
||||
{
|
||||
id = token->number.number;
|
||||
gtk_css_token_source_consume_token (source);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_token_source_error (source, "Expected a valid integer value");
|
||||
gtk_css_token_source_consume_all (source);
|
||||
gtk_win32_theme_unref (theme);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ struct _GtkCssValue {
|
||||
double y2;
|
||||
} cubic;
|
||||
struct {
|
||||
guint steps;
|
||||
int steps;
|
||||
gboolean start;
|
||||
} steps;
|
||||
} u;
|
||||
@@ -125,7 +125,7 @@ gtk_css_value_ease_print (const GtkCssValue *ease,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_append_printf (string, "steps(%u%s)", ease->u.steps.steps, ease->u.steps.start ? ",start" : "");
|
||||
g_string_append_printf (string, "steps(%d%s)", ease->u.steps.steps, ease->u.steps.start ? ",start" : "");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -167,7 +167,7 @@ _gtk_css_ease_value_new_cubic_bezier (double x1,
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
_gtk_css_ease_value_new_steps (guint n_steps,
|
||||
_gtk_css_ease_value_new_steps (gint n_steps,
|
||||
gboolean start)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
@@ -359,20 +359,15 @@ token_parse_steps (GtkCssTokenSource *source,
|
||||
token = gtk_css_token_source_get_token (source);
|
||||
if (nth_argument == 0)
|
||||
{
|
||||
if (!gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNLESS_INTEGER))
|
||||
{
|
||||
gtk_css_token_source_error (source, "Expected a positive integer for number of steps");
|
||||
gtk_css_token_source_consume_all (source);
|
||||
return 0;
|
||||
}
|
||||
else if (token->number.number <= 0)
|
||||
if (!gtk_css_token_source_consume_integer (source, &value->u.steps.steps))
|
||||
return 0;
|
||||
|
||||
if (value->u.steps.steps <= 0)
|
||||
{
|
||||
gtk_css_token_source_error (source, "Number of steps must be greater than 0");
|
||||
gtk_css_token_source_consume_all (source);
|
||||
return 0;
|
||||
}
|
||||
value->u.steps.steps = token->number.number;
|
||||
gtk_css_token_source_consume_token (source);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -438,6 +438,27 @@ gtk_css_token_source_consume_number (GtkCssTokenSource *source,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_token_source_consume_integer (GtkCssTokenSource *source,
|
||||
int *number)
|
||||
{
|
||||
const GtkCssToken *token;
|
||||
|
||||
token = gtk_css_token_source_get_token (source);
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNED_INTEGER) ||
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_SIGNLESS_INTEGER))
|
||||
{
|
||||
*number = token->number.number;
|
||||
gtk_css_token_source_consume_token (source);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* XXX: parse calc() */
|
||||
gtk_css_token_source_error (source, "Expected an integer");
|
||||
gtk_css_token_source_consume_all (source);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GFile *
|
||||
gtk_css_token_source_resolve_url (GtkCssTokenSource *source,
|
||||
const char *url)
|
||||
|
||||
@@ -74,6 +74,8 @@ gboolean gtk_css_token_source_consume_function (GtkCssTokenSour
|
||||
gpointer data);
|
||||
gboolean gtk_css_token_source_consume_number (GtkCssTokenSource *source,
|
||||
double *number);
|
||||
gboolean gtk_css_token_source_consume_integer (GtkCssTokenSource *source,
|
||||
int *number);
|
||||
GFile * gtk_css_token_source_resolve_url (GtkCssTokenSource *source,
|
||||
const char *url);
|
||||
GFile * gtk_css_token_source_consume_url (GtkCssTokenSource *source);
|
||||
|
||||
Reference in New Issue
Block a user