diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-10-26 21:04:41 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-10-26 21:04:41 +0000 |
commit | 61a53f6413dee94df35f07e4968693c69b863262 (patch) | |
tree | 3f4cbe7213449f4857d9db71d230432ab6b2b1ff /src | |
parent | 3de4a3051a59a2b6bfe7029c63ba6af035f437a7 (diff) | |
download | libcss-61a53f6413dee94df35f07e4968693c69b863262.tar.gz libcss-61a53f6413dee94df35f07e4968693c69b863262.tar.bz2 |
elevation
svn path=/trunk/libcss/; revision=5639
Diffstat (limited to 'src')
-rw-r--r-- | src/parse/css21.c | 7 | ||||
-rw-r--r-- | src/parse/css21props.c | 76 |
2 files changed, 78 insertions, 5 deletions
diff --git a/src/parse/css21.c b/src/parse/css21.c index 4a341bf..63da4e3 100644 --- a/src/parse/css21.c +++ b/src/parse/css21.c @@ -56,7 +56,7 @@ enum { COLLAPSE, SEPARATE, AUTO, LTR, RTL, INLINE, BLOCK, LIST_ITEM, RUN_IN, INLINE_BLOCK, TABLE, INLINE_TABLE, TABLE_ROW_GROUP, TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW, TABLE_COLUMN_GROUP, TABLE_COLUMN, - TABLE_CELL, TABLE_CAPTION, + TABLE_CELL, TABLE_CAPTION, BELOW, LEVEL, ABOVE, HIGHER, LOWER, LAST_KNOWN }; @@ -214,6 +214,11 @@ static struct { { "table-column", SLEN("table-column") }, { "table-cell", SLEN("table-cell") }, { "table-caption", SLEN("table-caption") }, + { "below", SLEN("below") }, + { "level", SLEN("level") }, + { "above", SLEN("above") }, + { "higher", SLEN("higher") }, + { "lower", SLEN("lower") }, }; typedef struct context_entry { diff --git a/src/parse/css21props.c b/src/parse/css21props.c index 47bee38..1cfacc0 100644 --- a/src/parse/css21props.c +++ b/src/parse/css21props.c @@ -1304,10 +1304,78 @@ css_error parse_elevation(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; + uint32_t length = 0; + uint32_t unit = 0; + uint32_t required_size; + + /* angle | IDENT(below, level, above, higher, lower, inherit) */ + token = parserutils_vector_peek(vector, *ctx); + if (token == NULL) + return CSS_INVALID; + + if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[INHERIT]) { + parserutils_vector_iterate(vector, ctx); + flags = FLAG_INHERIT; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[BELOW]) { + parserutils_vector_iterate(vector, ctx); + value = ELEVATION_BELOW; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[LEVEL]) { + parserutils_vector_iterate(vector, ctx); + value = ELEVATION_LEVEL; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[ABOVE]) { + parserutils_vector_iterate(vector, ctx); + value = ELEVATION_ABOVE; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[HIGHER]) { + parserutils_vector_iterate(vector, ctx); + value = ELEVATION_HIGHER; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[LOWER]) { + parserutils_vector_iterate(vector, ctx); + value = ELEVATION_LOWER; + } else { + error = parse_unit_specifier(c, vector, ctx, &length, &unit); + if (error != CSS_OK) + return error; + + if ((unit & UNIT_ANGLE) == false) + return CSS_INVALID; + + value = ELEVATION_ANGLE; + } + + error = parse_important(c, vector, ctx, &flags); + if (error != CSS_OK) + return error; + + opv = buildOPV(OP_ELEVATION, flags, value); + + required_size = sizeof(opv); + if (value == ELEVATION_ANGLE) + required_size += sizeof(length) + sizeof(unit); + + /* Allocate result */ + *result = css_stylesheet_style_create(c->sheet, required_size); + if (*result == NULL) + return CSS_NOMEM; + + /* Copy the bytecode to it */ + memcpy((*result)->bytecode, &opv, sizeof(opv)); + if (value == ELEVATION_ANGLE) { + memcpy(((uint8_t *) (*result)->bytecode) + sizeof(opv), + &length, sizeof(length)); + memcpy(((uint8_t *) (*result)->bytecode) + sizeof(opv) + + sizeof(length), &unit, sizeof(unit)); + } return CSS_OK; } |