diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-25 22:43:48 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-25 22:43:48 +0000 |
commit | 28fad14fb8cd1b210cfcdab7873198644156b807 (patch) | |
tree | 12b2677a2d644b0df8557560e3e24a9aba935894 /src | |
parent | fe455db71a80f6bd07e30c94b0cfb1ebb3533672 (diff) | |
download | libcss-28fad14fb8cd1b210cfcdab7873198644156b807.tar.gz libcss-28fad14fb8cd1b210cfcdab7873198644156b807.tar.bz2 |
stress
svn path=/trunk/libcss/; revision=5792
Diffstat (limited to 'src')
-rw-r--r-- | src/parse/css21props.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/src/parse/css21props.c b/src/parse/css21props.c index ea60652..2579479 100644 --- a/src/parse/css21props.c +++ b/src/parse/css21props.c @@ -3514,10 +3514,54 @@ css_error parse_stress(css_css21 *c, const parserutils_vector *vector, int *ctx, css_style **result) { - UNUSED(c); - UNUSED(vector); - UNUSED(ctx); - UNUSED(result); + css_error error; + const css_token *token; + uint8_t flags = 0; + uint16_t value = 0; + uint32_t opv; + fixed num = 0; + uint32_t required_size; + + /* number | IDENT (inherit) */ + token = parserutils_vector_iterate(vector, ctx); + if (token == NULL || (token->type != CSS_TOKEN_IDENT && + token->type != CSS_TOKEN_NUMBER)) + return CSS_INVALID; + + error = parse_important(c, vector, ctx, &flags); + if (error != CSS_OK) + return error; + + if (token->lower.ptr == c->strings[INHERIT]) { + flags |= FLAG_INHERIT; + } else if (token->type == CSS_TOKEN_NUMBER) { + size_t consumed = 0; + num = number_from_css_string(&token->lower, &consumed); + /* Invalid if there are trailing characters */ + if (consumed != token->lower.len) + return CSS_INVALID; + + value = STRESS_SET; + } else + return CSS_INVALID; + + opv = buildOPV(OP_STRESS, flags, value); + + required_size = sizeof(opv); + if ((flags & FLAG_INHERIT) == false && value == STRESS_SET) + required_size += sizeof(num); + + /* Allocate result */ + error = css_stylesheet_style_create(c->sheet, required_size, result); + if (error != CSS_OK) + return error; + + /* Copy the bytecode to it */ + memcpy((*result)->bytecode, &opv, sizeof(opv)); + if ((flags & FLAG_INHERIT) == false && value == STRESS_SET) { + memcpy(((uint8_t *) (*result)->bytecode) + sizeof(opv), + &num, sizeof(num)); + } return CSS_OK; } |