summaryrefslogtreecommitdiff
path: root/src/parse/properties
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2021-02-09 23:38:11 +0000
committerVincent Sanders <vince@kyllikki.org>2021-02-09 23:38:11 +0000
commitdd74dbf4b1a8d27cb49855f067f65b722d65bd42 (patch)
treeaede14fcd9c91f869aa68e8347b62c9e08c0b12e /src/parse/properties
parent3ccff93d3a494b9303a1cc55c4075ef0c59eaf4f (diff)
downloadlibcss-dd74dbf4b1a8d27cb49855f067f65b722d65bd42.tar.gz
libcss-dd74dbf4b1a8d27cb49855f067f65b722d65bd42.tar.bz2
implement the firt half of the css 3.1 simple predefined counter styles
Diffstat (limited to 'src/parse/properties')
-rw-r--r--src/parse/properties/utils.c116
1 files changed, 49 insertions, 67 deletions
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 0e49853..a71e22d 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -29,77 +29,60 @@
css_error css__parse_list_style_type_value(css_language *c, const css_token *ident,
uint16_t *value)
{
- bool match;
-
/* IDENT (disc, circle, square, decimal, decimal-leading-zero,
* lower-roman, upper-roman, lower-greek, lower-latin,
* upper-latin, armenian, georgian, lower-alpha, upper-alpha,
* none)
*/
- if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[DISC],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_DISC;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[CIRCLE],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_CIRCLE;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[SQUARE],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_SQUARE;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[DECIMAL],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_DECIMAL;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[DECIMAL_LEADING_ZERO],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[LOWER_ROMAN],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_LOWER_ROMAN;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[UPPER_ROMAN],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_UPPER_ROMAN;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[LOWER_GREEK],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_LOWER_GREEK;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[LOWER_LATIN],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_LOWER_LATIN;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[UPPER_LATIN],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_UPPER_LATIN;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[ARMENIAN],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_ARMENIAN;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[GEORGIAN],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_GEORGIAN;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[LOWER_ALPHA],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_LOWER_ALPHA;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[UPPER_ALPHA],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_UPPER_ALPHA;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[NONE],
- &match) == lwc_error_ok && match)) {
- *value = LIST_STYLE_TYPE_NONE;
- } else
- return CSS_INVALID;
+ #define MAP_ENTRIES 29
+ bool match;
+ int midx;
+ const struct {
+ int stringid;
+ int value;
+ } mapping[MAP_ENTRIES] = {
+ { DISC, LIST_STYLE_TYPE_DISC },
+ { CIRCLE, LIST_STYLE_TYPE_CIRCLE },
+ { SQUARE, LIST_STYLE_TYPE_SQUARE },
+ { DECIMAL, LIST_STYLE_TYPE_DECIMAL },
+ { DECIMAL_LEADING_ZERO, LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO },
+ { LOWER_ROMAN, LIST_STYLE_TYPE_LOWER_ROMAN },
+ { UPPER_ROMAN, LIST_STYLE_TYPE_UPPER_ROMAN },
+ { LOWER_GREEK, LIST_STYLE_TYPE_LOWER_GREEK },
+ { LOWER_LATIN, LIST_STYLE_TYPE_LOWER_LATIN },
+ { UPPER_LATIN, LIST_STYLE_TYPE_UPPER_LATIN },
+ { ARMENIAN, LIST_STYLE_TYPE_ARMENIAN },
+ { GEORGIAN, LIST_STYLE_TYPE_GEORGIAN },
+ { LOWER_ALPHA, LIST_STYLE_TYPE_LOWER_ALPHA },
+ { UPPER_ALPHA, LIST_STYLE_TYPE_UPPER_ALPHA },
+ { NONE, LIST_STYLE_TYPE_NONE },
+ { BINARY, LIST_STYLE_TYPE_BINARY },
+ { OCTAL, LIST_STYLE_TYPE_OCTAL},
+ { LOWER_HEXADECIMAL, LIST_STYLE_TYPE_LOWER_HEXADECIMAL },
+ { UPPER_HEXADECIMAL, LIST_STYLE_TYPE_UPPER_HEXADECIMAL },
+ { ARABIC_INDIC, LIST_STYLE_TYPE_ARABIC_INDIC },
+ { LOWER_ARMENIAN, LIST_STYLE_TYPE_LOWER_ARMENIAN },
+ { UPPER_ARMENIAN, LIST_STYLE_TYPE_UPPER_ARMENIAN },
+ { BENGALI, LIST_STYLE_TYPE_BENGALI },
+ { CAMBODIAN, LIST_STYLE_TYPE_CAMBODIAN },
+ { KHMER, LIST_STYLE_TYPE_KHMER },
+ { CJK_DECIMAL, LIST_STYLE_TYPE_CJK_DECIMAL },
+ { DEVANAGARI, LIST_STYLE_TYPE_DEVANAGARI },
+ { GUJARATI, LIST_STYLE_TYPE_GUJARATI },
+ { GURMUKHI, LIST_STYLE_TYPE_GURMUKHI }
+ };
- return CSS_OK;
+ for (midx = 0; midx < MAP_ENTRIES; midx++) {
+ if ((lwc_string_caseless_isequal(
+ ident->idata,
+ c->strings[mapping[midx].stringid],
+ &match) == lwc_error_ok && match)) {
+ *value = mapping[midx].value;
+ return CSS_OK;
+ }
+ }
+
+ return CSS_INVALID;
}
@@ -1117,7 +1100,7 @@ css_error css__ident_list_or_string_to_string(css_language *c,
token = parserutils_vector_iterate(vector, ctx);
*result = lwc_string_ref(token->idata);
return CSS_OK;
- } else if(token->type == CSS_TOKEN_IDENT) {
+ } else if(token->type == CSS_TOKEN_IDENT) {
return css__ident_list_to_string(c, vector, ctx, reserved,
result);
}
@@ -1333,4 +1316,3 @@ cleanup:
return error;
}
-