diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-26 23:56:24 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-26 23:56:24 +0000 |
commit | d1ab23e5fffd2a458974b6a6b27b9adfd876496a (patch) | |
tree | d6fc9e6b82b8728cf26e65dba91c64796b2f74c7 /src | |
parent | 156ddc7310d42809dad42e27181d5372be62caaa (diff) | |
download | libcss-d1ab23e5fffd2a458974b6a6b27b9adfd876496a.tar.gz libcss-d1ab23e5fffd2a458974b6a6b27b9adfd876496a.tar.bz2 |
z-index
svn path=/trunk/libcss/; revision=5805
Diffstat (limited to 'src')
-rw-r--r-- | src/parse/css21props.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/parse/css21props.c b/src/parse/css21props.c index 142e349..fe0c405 100644 --- a/src/parse/css21props.c +++ b/src/parse/css21props.c @@ -4362,10 +4362,59 @@ css_error parse_z_index(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; + + /* <integer> | IDENT (auto, 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->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[INHERIT]) { + flags |= FLAG_INHERIT; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[AUTO]) { + value = Z_INDEX_AUTO; + } else if (token->type == CSS_TOKEN_NUMBER) { + size_t consumed = 0; + num = number_from_css_string(&token->lower, &consumed); + int32_t intpart = FIXTOINT(num); + /* Invalid if there are trailing characters or it was a float */ + if (consumed != token->lower.len || num != intpart) + return CSS_INVALID; + + value = Z_INDEX_SET; + } else + return CSS_INVALID; + + opv = buildOPV(OP_Z_INDEX, flags, value); + + required_size = sizeof(opv); + if ((flags & FLAG_INHERIT) == false && value == Z_INDEX_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 == Z_INDEX_SET) { + memcpy(((uint8_t *) (*result)->bytecode) + sizeof(opv), + &num, sizeof(num)); + } return CSS_OK; } |