summaryrefslogtreecommitdiff
path: root/src/parse/css21props.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-20 23:45:34 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-20 23:45:34 +0000
commit5bd64c6ae682e8e063de7550e6987e0b18a3b27e (patch)
tree1986eafcc1250ecb08d7b53f2f6c80d79b7011e0 /src/parse/css21props.c
parentc3a51e6ebf2d1edcc871d6eb8bb2113172078d4a (diff)
downloadlibcss-5bd64c6ae682e8e063de7550e6987e0b18a3b27e.tar.gz
libcss-5bd64c6ae682e8e063de7550e6987e0b18a3b27e.tar.bz2
letter-spacing
svn path=/trunk/libcss/; revision=5760
Diffstat (limited to 'src/parse/css21props.c')
-rw-r--r--src/parse/css21props.c61
1 files changed, 57 insertions, 4 deletions
diff --git a/src/parse/css21props.c b/src/parse/css21props.c
index 809a2bb..5f3b54e 100644
--- a/src/parse/css21props.c
+++ b/src/parse/css21props.c
@@ -1855,10 +1855,63 @@ css_error parse_letter_spacing(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;
+
+ /* length | IDENT(normal, 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[NORMAL]) {
+ parserutils_vector_iterate(vector, ctx);
+ value = LETTER_SPACING_NORMAL;
+ } else {
+ error = parse_unit_specifier(c, vector, ctx, &length, &unit);
+ if (error != CSS_OK)
+ return error;
+
+ if (unit & UNIT_ANGLE || unit & UNIT_TIME || unit & UNIT_FREQ ||
+ unit & UNIT_PCT)
+ return CSS_INVALID;
+
+ value = LETTER_SPACING_SET;
+ }
+
+ error = parse_important(c, vector, ctx, &flags);
+ if (error != CSS_OK)
+ return error;
+
+ opv = buildOPV(OP_LETTER_SPACING, flags, value);
+
+ required_size = sizeof(opv);
+ if (value == LETTER_SPACING_SET)
+ required_size += sizeof(length) + sizeof(unit);
+
+ /* 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 (value == LETTER_SPACING_SET) {
+ 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;
}