From b327b6652ac1757816f079bddea6fb87ec1c60c9 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 25 Nov 2008 21:41:37 +0000 Subject: pitch svn path=/trunk/libcss/; revision=5783 --- src/parse/css21.c | 6 ++++- src/parse/css21props.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/parse/css21.c b/src/parse/css21.c index f4277a6..2300475 100644 --- a/src/parse/css21.c +++ b/src/parse/css21.c @@ -62,7 +62,7 @@ enum { LIGHTER, INSIDE, OUTSIDE, DISC, CIRCLE, SQUARE, DECIMAL, DECIMAL_LEADING_ZERO, LOWER_ROMAN, UPPER_ROMAN, LOWER_GREEK, LOWER_LATIN, UPPER_LATIN, ARMENIAN, GEORGIAN, LOWER_ALPHA, UPPER_ALPHA, - INVERT, VISIBLE, ALWAYS, AVOID, + INVERT, VISIBLE, ALWAYS, AVOID, X_LOW, LOW, HIGH, X_HIGH, LAST_KNOWN }; @@ -262,6 +262,10 @@ static struct { { "visible", SLEN("visible") }, { "always", SLEN("always") }, { "avoid", SLEN("avoid") }, + { "x-low", SLEN("x-low") }, + { "low", SLEN("low") }, + { "high", SLEN("high") }, + { "x-high", SLEN("x-high") }, }; typedef struct context_entry { diff --git a/src/parse/css21props.c b/src/parse/css21props.c index 56d5b77..c3510cc 100644 --- a/src/parse/css21props.c +++ b/src/parse/css21props.c @@ -3000,10 +3000,73 @@ css_error parse_pitch(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 length = 0; + uint32_t unit = 0; + uint32_t required_size; + + /* frequency | IDENT(x-low, low, medium, high, x-high, 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[X_LOW]) { + value = PITCH_X_LOW; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[LOW]) { + value = PITCH_LOW; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[MEDIUM]) { + value = PITCH_MEDIUM; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[HIGH]) { + value = PITCH_HIGH; + } else if (token->type == CSS_TOKEN_IDENT && + token->lower.ptr == c->strings[X_HIGH]) { + value = PITCH_X_HIGH; + } else { + error = parse_unit_specifier(c, vector, ctx, &length, &unit); + if (error != CSS_OK) + return error; + + if ((unit & UNIT_FREQ) == false) + return CSS_INVALID; + + value = PITCH_FREQUENCY; + } + + error = parse_important(c, vector, ctx, &flags); + if (error != CSS_OK) + return error; + + opv = buildOPV(OP_PITCH, flags, value); + + required_size = sizeof(opv); + if ((flags & FLAG_INHERIT) == false && value == PITCH_FREQUENCY) + 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 ((flags & FLAG_INHERIT) == false && value == PITCH_FREQUENCY) { + 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; } -- cgit v1.2.3