From 6a50bef84ae6a0a67e03ac1356f8d85d15fe09d6 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 19 Jan 2011 23:12:37 +0000 Subject: Merge parser autogeneration and string handling refactor branch r=jmb,kinnison,vince svn path=/trunk/libcss/; revision=11408 --- src/parse/properties/text_decoration.c | 62 +++++++++++++++------------------- 1 file changed, 27 insertions(+), 35 deletions(-) (limited to 'src/parse/properties/text_decoration.c') diff --git a/src/parse/properties/text_decoration.c b/src/parse/properties/text_decoration.c index 0c63c39..c9a91d1 100644 --- a/src/parse/properties/text_decoration.c +++ b/src/parse/properties/text_decoration.c @@ -29,36 +29,35 @@ */ css_error parse_text_decoration(css_language *c, const parserutils_vector *vector, int *ctx, - css_style **result) + css_style *result) { int orig_ctx = *ctx; - css_error error; - const css_token *ident; - uint8_t flags = 0; - uint16_t value = 0; - uint32_t opv; + css_error error = CSS_INVALID; + const css_token *token; bool match; /* IDENT([ underline || overline || line-through || blink ]) * | IDENT (none, inherit) */ - ident = parserutils_vector_iterate(vector, ctx); - if (ident == NULL || ident->type != CSS_TOKEN_IDENT) { + token = parserutils_vector_iterate(vector, ctx); + if ((token == NULL) || (token->type != CSS_TOKEN_IDENT) ) { *ctx = orig_ctx; return CSS_INVALID; } - if ((lwc_string_caseless_isequal( - ident->idata, c->strings[INHERIT], - &match) == lwc_error_ok && match)) { - flags |= FLAG_INHERIT; - } else if ((lwc_string_caseless_isequal( - ident->idata, c->strings[NONE], - &match) == lwc_error_ok && match)) { - value = TEXT_DECORATION_NONE; + if (lwc_string_caseless_isequal(token->idata, + c->strings[INHERIT], + &match) == lwc_error_ok && match) { + error = css_stylesheet_style_inherit(result, CSS_PROP_TEXT_DECORATION); + } else if (lwc_string_caseless_isequal(token->idata, + c->strings[NONE], + &match) == lwc_error_ok && match) { + error = css_stylesheet_style_appendOPV(result, + CSS_PROP_TEXT_DECORATION, 0, TEXT_DECORATION_NONE); } else { - while (ident != NULL) { + uint16_t value = 0; + while (token != NULL) { if ((lwc_string_caseless_isequal( - ident->idata, c->strings[UNDERLINE], + token->idata, c->strings[UNDERLINE], &match) == lwc_error_ok && match)) { if ((value & TEXT_DECORATION_UNDERLINE) == 0) value |= TEXT_DECORATION_UNDERLINE; @@ -67,7 +66,7 @@ css_error parse_text_decoration(css_language *c, return CSS_INVALID; } } else if ((lwc_string_caseless_isequal( - ident->idata, c->strings[OVERLINE], + token->idata, c->strings[OVERLINE], &match) == lwc_error_ok && match)) { if ((value & TEXT_DECORATION_OVERLINE) == 0) value |= TEXT_DECORATION_OVERLINE; @@ -76,7 +75,7 @@ css_error parse_text_decoration(css_language *c, return CSS_INVALID; } } else if ((lwc_string_caseless_isequal( - ident->idata, c->strings[LINE_THROUGH], + token->idata, c->strings[LINE_THROUGH], &match) == lwc_error_ok && match)) { if ((value & TEXT_DECORATION_LINE_THROUGH) == 0) value |= TEXT_DECORATION_LINE_THROUGH; @@ -85,7 +84,7 @@ css_error parse_text_decoration(css_language *c, return CSS_INVALID; } } else if ((lwc_string_caseless_isequal( - ident->idata, c->strings[BLINK], + token->idata, c->strings[BLINK], &match) == lwc_error_ok && match)) { if ((value & TEXT_DECORATION_BLINK) == 0) value |= TEXT_DECORATION_BLINK; @@ -100,24 +99,17 @@ css_error parse_text_decoration(css_language *c, consumeWhitespace(vector, ctx); - ident = parserutils_vector_peek(vector, *ctx); - if (ident != NULL && ident->type != CSS_TOKEN_IDENT) + token = parserutils_vector_peek(vector, *ctx); + if (token != NULL && token->type != CSS_TOKEN_IDENT) break; - ident = parserutils_vector_iterate(vector, ctx); + token = parserutils_vector_iterate(vector, ctx); } + error = css_stylesheet_style_appendOPV(result, + CSS_PROP_TEXT_DECORATION, 0, value); } - opv = buildOPV(CSS_PROP_TEXT_DECORATION, flags, value); - - /* Allocate result */ - error = css_stylesheet_style_create(c->sheet, sizeof(opv), result); - if (error != CSS_OK) { + if (error != CSS_OK) *ctx = orig_ctx; - return error; - } - - /* Copy the bytecode to it */ - memcpy((*result)->bytecode, &opv, sizeof(opv)); - return CSS_OK; + return error; } -- cgit v1.2.3