calc: Allow subterms with '(' ')' bracketing

Some more tests included.
This commit is contained in:
Benjamin Otte 2016-02-13 04:12:45 +01:00
parent 63d1f80742
commit 0cda3ba3e8
5 changed files with 71 additions and 0 deletions

View File

@ -316,6 +316,9 @@ gtk_css_calc_value_new_sum (GtkCssValue *value1,
return gtk_css_value_new_from_array (array); return gtk_css_value_new_from_array (array);
} }
GtkCssValue * gtk_css_calc_value_parse_sum (GtkCssParser *parser,
GtkCssNumberParseFlags flags);
GtkCssValue * GtkCssValue *
gtk_css_calc_value_parse_value (GtkCssParser *parser, gtk_css_calc_value_parse_value (GtkCssParser *parser,
GtkCssNumberParseFlags flags) GtkCssNumberParseFlags flags)
@ -326,6 +329,22 @@ gtk_css_calc_value_parse_value (GtkCssParser *parser,
return NULL; return NULL;
} }
if (_gtk_css_parser_try (parser, "(", TRUE))
{
GtkCssValue *result = gtk_css_calc_value_parse_sum (parser, flags);
if (result == NULL)
return NULL;
if (!_gtk_css_parser_try (parser, ")", TRUE))
{
_gtk_css_parser_error (parser, "Missing closing ')' in calc() subterm");
_gtk_css_value_unref (result);
return NULL;
}
return result;
}
return _gtk_css_number_value_parse (parser, flags); return _gtk_css_number_value_parse (parser, flags);
} }

View File

@ -57,3 +57,19 @@ n {
o { o {
margin-left: calc(1px / error); margin-left: calc(1px / error);
} }
p {
margin-left: calc((((((1px))));
}
q {
margin-left: calc((((((1px)))))))));
}
r {
margin-left: calc(1px + (1));
}
s {
margin-left: calc(1px + (error));
}

View File

@ -13,3 +13,7 @@ calc-errors.css:46: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
calc-errors.css:50: error: GTK_CSS_PROVIDER_ERROR_SYNTAX calc-errors.css:50: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
calc-errors.css:54: error: GTK_CSS_PROVIDER_ERROR_SYNTAX calc-errors.css:54: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
calc-errors.css:58: error: GTK_CSS_PROVIDER_ERROR_SYNTAX calc-errors.css:58: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
calc-errors.css:62: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
calc-errors.css:66: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
calc-errors.css:70: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
calc-errors.css:74: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -21,3 +21,19 @@ e {
f { f {
background-size: calc(2 * 3px + 4px * 5 - 6px / 3); background-size: calc(2 * 3px + 4px * 5 - 6px / 3);
} }
g {
background-size: calc((((((1px))))));
}
h {
background-size: calc(3 * ((4px + ((4 * (6px + 3em)) / 3)) + 5em));
}
i {
border-top-left-radius: calc(1px * (3 + 2)) calc(1px / ( 3 / (2 * 1.5)));
}
j {
border-bottom-right-radius: calc((1 + 1 + (1 + 1) + 1) * 1px) calc((1 / 1) * 1px);
}

View File

@ -21,3 +21,19 @@ e {
f { f {
background-size: 24px; background-size: 24px;
} }
g {
background-size: 1px;
}
h {
background-size: calc(27em + 36px);
}
i {
border-top-left-radius: 5px 1px;
}
j {
border-bottom-right-radius: 5px 1px;
}