summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/properties/border_color.c14
-rw-r--r--src/parse/properties/css_property_parser_gen.c13
-rw-r--r--src/parse/properties/properties.gen4
-rw-r--r--src/parse/properties/utils.c33
-rw-r--r--src/parse/properties/utils.h2
-rw-r--r--src/parse/propstrings.c1
-rw-r--r--src/parse/propstrings.h2
7 files changed, 30 insertions, 39 deletions
diff --git a/src/parse/properties/border_color.c b/src/parse/properties/border_color.c
index 074b457..7495ffc 100644
--- a/src/parse/properties/border_color.c
+++ b/src/parse/properties/border_color.c
@@ -37,7 +37,6 @@ css_error css__parse_border_color(css_language *c,
uint16_t side_val[4];
uint32_t side_color[4];
uint32_t side_count = 0;
- bool match;
css_error error;
/* Firstly, handle inherit */
@@ -74,18 +73,7 @@ css_error css__parse_border_color(css_language *c,
return CSS_INVALID;
}
- if ((token->type == CSS_TOKEN_IDENT) &&
- (lwc_string_caseless_isequal(token->idata,
- c->strings[TRANSPARENT],
- &match) == lwc_error_ok && match)) {
- side_val[side_count] = BORDER_COLOR_TRANSPARENT;
- parserutils_vector_iterate(vector, ctx);
- error = CSS_OK;
- } else {
- side_val[side_count] = BORDER_COLOR_SET;
- error = css__parse_colour_specifier(c, vector, ctx, &side_color[side_count]);
- }
-
+ error = css__parse_colour_specifier(c, vector, ctx, &side_val[side_count], &side_color[side_count]);
if (error == CSS_OK) {
side_count++;
diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c
index ae1fa04..dec4745 100644
--- a/src/parse/properties/css_property_parser_gen.c
+++ b/src/parse/properties/css_property_parser_gen.c
@@ -268,27 +268,26 @@ void output_number(FILE *outputf, struct keyval *parseid, struct keyval_list *kv
void output_color(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist)
{
- struct keyval *ckv = kvlist->item[0];
-
fprintf(outputf,
"{\n"
+ "\t\tuint16_t value = 0;\n"
"\t\tuint32_t color = 0;\n"
"\t\t*ctx = orig_ctx;\n\n"
- "\t\terror = css__parse_colour_specifier(c, vector, ctx, &color);\n"
+ "\t\terror = css__parse_colour_specifier(c, vector, ctx, &value, &color);\n"
"\t\tif (error != CSS_OK) {\n"
"\t\t\t*ctx = orig_ctx;\n"
"\t\t\treturn error;\n"
"\t\t}\n\n"
- "\t\terror = css__stylesheet_style_appendOPV(result, %s, 0, %s);\n"
+ "\t\terror = css__stylesheet_style_appendOPV(result, %s, 0, value);\n"
"\t\tif (error != CSS_OK) {\n"
"\t\t\t*ctx = orig_ctx;\n"
"\t\t\treturn error;\n"
"\t\t}\n"
"\n"
- "\t\terror = css__stylesheet_style_append(result, color);\n"
+ "\t\tif (value == COLOR_SET)\n"
+ "\t\t\terror = css__stylesheet_style_append(result, color);\n"
"\t}\n\n",
- parseid->val,
- ckv->val);
+ parseid->val);
}
void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist)
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index b0e84b8..016d7a0 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -93,7 +93,7 @@ border_left_style:CSS_PROP_BORDER_LEFT_STYLE WRAP:css__parse_border_side_style
border_right_style:CSS_PROP_BORDER_RIGHT_STYLE WRAP:css__parse_border_side_style
#generic for border_{top, bottom, left, right}_color.c
-border_side_color:op GENERIC: IDENT:( INHERIT: TRANSPARENT:0,BORDER_COLOR_TRANSPARENT IDENT:) COLOR:BORDER_COLOR_SET
+border_side_color:op GENERIC: IDENT:( INHERIT: IDENT:) COLOR:BORDER_COLOR_SET
border_top_color:CSS_PROP_BORDER_TOP_COLOR WRAP:css__parse_border_side_color
border_bottom_color:CSS_PROP_BORDER_BOTTOM_COLOR WRAP:css__parse_border_side_color
@@ -108,7 +108,7 @@ counter_reset:CSS_PROP_COUNTER_RESET IDENT:( INHERIT: NONE:0,COUNTER_RESET_NONE
background_attachment:CSS_PROP_BACKGROUND_ATTACHMENT IDENT:( INHERIT: FIXED:0,BACKGROUND_ATTACHMENT_FIXED SCROLL:0,BACKGROUND_ATTACHMENT_SCROLL IDENT:)
-background_color:CSS_PROP_BACKGROUND_COLOR IDENT:( INHERIT: TRANSPARENT:0,BACKGROUND_COLOR_TRANSPARENT IDENT:) COLOR:BACKGROUND_COLOR_SET
+background_color:CSS_PROP_BACKGROUND_COLOR IDENT:( INHERIT: IDENT:) COLOR:BACKGROUND_COLOR_SET
caption_side:CSS_PROP_CAPTION_SIDE IDENT:( INHERIT: TOP:0,CAPTION_SIDE_TOP BOTTOM:0,CAPTION_SIDE_BOTTOM IDENT:)
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 860712d..934b3f6 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -342,6 +342,7 @@ static void HSL_to_RGB(css_fixed hue, css_fixed sat, css_fixed lit, uint8_t *r,
* \param c Parsing context
* \param vector Vector of tokens to process
* \param ctx Pointer to vector iteration context
+ * \param value Pointer to location to receive value
* \param result Pointer to location to receive result (AARRGGBB)
* \return CSS_OK on success,
* CSS_INVALID if the input is invalid
@@ -351,11 +352,10 @@ static void HSL_to_RGB(css_fixed hue, css_fixed sat, css_fixed lit, uint8_t *r,
*/
css_error css__parse_colour_specifier(css_language *c,
const parserutils_vector *vector, int *ctx,
- uint32_t *result)
+ uint16_t *value, uint32_t *result)
{
int orig_ctx = *ctx;
const css_token *token;
- uint8_t r = 0, g = 0, b = 0, a = 0xff;
bool match;
css_error error;
@@ -386,9 +386,17 @@ css_error css__parse_colour_specifier(css_language *c,
if ((lwc_string_caseless_isequal(
token->idata, c->strings[TRANSPARENT],
&match) == lwc_error_ok && match)) {
+ *value = COLOR_TRANSPARENT;
*result = 0; /* black transparent */
return CSS_OK;
+ } else if ((lwc_string_caseless_isequal(
+ token->idata, c->strings[CURRENTCOLOR],
+ &match) == lwc_error_ok && match)) {
+ *value = COLOR_CURRENT_COLOR;
+ *result = 0;
+ return CSS_OK;
}
+
error = css__parse_named_colour(c, token->idata, result);
if (error != CSS_OK && c->sheet->quirks_allowed) {
error = css__parse_hash_colour(token->idata, result);
@@ -397,34 +405,27 @@ css_error css__parse_colour_specifier(css_language *c,
}
if (error != CSS_OK)
- *ctx = orig_ctx;
-
- return error;
+ goto invalid;
} else if (token->type == CSS_TOKEN_HASH) {
error = css__parse_hash_colour(token->idata, result);
if (error != CSS_OK)
- *ctx = orig_ctx;
-
- return error;
+ goto invalid;
} else if (c->sheet->quirks_allowed &&
token->type == CSS_TOKEN_NUMBER) {
error = css__parse_hash_colour(token->idata, result);
if (error == CSS_OK)
c->sheet->quirks_used = true;
else
- *ctx = orig_ctx;
-
- return error;
+ goto invalid;
} else if (c->sheet->quirks_allowed &&
token->type == CSS_TOKEN_DIMENSION) {
error = css__parse_hash_colour(token->idata, result);
if (error == CSS_OK)
c->sheet->quirks_used = true;
else
- *ctx = orig_ctx;
-
- return error;
+ goto invalid;
} else if (token->type == CSS_TOKEN_FUNCTION) {
+ uint8_t r = 0, g = 0, b = 0, a = 0xff;
int colour_channels = 0;
if ((lwc_string_caseless_isequal(
@@ -641,9 +642,11 @@ css_error css__parse_colour_specifier(css_language *c,
} else {
goto invalid;
}
+
+ *result = (a << 24) | (r << 16) | (g << 8) | b;
}
- *result = (a << 24) | (r << 16) | (g << 8) | b;
+ *value = COLOR_SET;
return CSS_OK;
diff --git a/src/parse/properties/utils.h b/src/parse/properties/utils.h
index e5315bb..ab045bd 100644
--- a/src/parse/properties/utils.h
+++ b/src/parse/properties/utils.h
@@ -166,7 +166,7 @@ css_error css__parse_list_style_type_value(css_language *c,
css_error css__parse_colour_specifier(css_language *c,
const parserutils_vector *vector, int *ctx,
- uint32_t *result);
+ uint16_t *value, uint32_t *result);
css_error css__parse_named_colour(css_language *c, lwc_string *data,
uint32_t *result);
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index 354c794..9e81300 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -336,6 +336,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "-libcss-left", SLEN("-libcss-left") },
{ "-libcss-center", SLEN("-libcss-center") },
{ "-libcss-right", SLEN("-libcss-right") },
+ { "currentColor", SLEN("currentColor") },
{ "aliceblue", SLEN("aliceblue") },
{ "antiquewhite", SLEN("antiquewhite") },
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index d3b7208..5a1662d 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -85,7 +85,7 @@ enum {
W_RESIZE, LIBCSS_TEXT, WAIT, HELP, PROGRESS, SERIF, SANS_SERIF, CURSIVE,
FANTASY, MONOSPACE, MALE, FEMALE, CHILD, MIX, UNDERLINE, OVERLINE,
LINE_THROUGH, BLINK, RGB, RGBA, HSL, HSLA, LIBCSS_LEFT, LIBCSS_CENTER,
- LIBCSS_RIGHT,
+ LIBCSS_RIGHT, CURRENTCOLOR,
/* Named colours */
FIRST_COLOUR,