diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-25 21:34:10 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-25 21:34:10 +0000 |
commit | fa2912246c90edacf403ecc9df956ee0a0ee8b3e (patch) | |
tree | d20cd35450fb721664a7e8f888146aec4f1634bb /src | |
parent | 4ee27e0e7fe22f8934d4f91cb344ba477e67f91d (diff) | |
download | libcss-fa2912246c90edacf403ecc9df956ee0a0ee8b3e.tar.gz libcss-fa2912246c90edacf403ecc9df956ee0a0ee8b3e.tar.bz2 |
pitch-range
svn path=/trunk/libcss/; revision=5782
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 4972089..56d5b77 100644 --- a/src/parse/css21props.c +++ b/src/parse/css21props.c @@ -2944,10 +2944,54 @@ css_error parse_pitch_range(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 = PITCH_RANGE_SET; + } else + return CSS_INVALID; + + opv = buildOPV(OP_PITCH_RANGE, flags, value); + + required_size = sizeof(opv); + if ((flags & FLAG_INHERIT) == false && value == PITCH_RANGE_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 == PITCH_RANGE_SET) { + memcpy(((uint8_t *) (*result)->bytecode) + sizeof(opv), + &num, sizeof(num)); + } return CSS_OK; } |