summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-25 22:19:00 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-25 22:19:00 +0000
commit68bc37815cf700de1b7074a87a964d4803893492 (patch)
tree3df7842860fb14d489e2ff6ca44200dcd7af1c9e /src/parse
parentea62ade8dd519f3feec1c8dab1176c9486916f91 (diff)
downloadlibcss-68bc37815cf700de1b7074a87a964d4803893492.tar.gz
libcss-68bc37815cf700de1b7074a87a964d4803893492.tar.bz2
richness
svn path=/trunk/libcss/; revision=5785
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/css21props.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/src/parse/css21props.c b/src/parse/css21props.c
index 9fbdfc5..c386a62 100644
--- a/src/parse/css21props.c
+++ b/src/parse/css21props.c
@@ -3134,6 +3134,8 @@ css_error parse_quotes(css_css21 *c,
const parserutils_vector *vector, int *ctx,
css_style **result)
{
+ /** \todo quotes */
+
UNUSED(c);
UNUSED(vector);
UNUSED(ctx);
@@ -3146,10 +3148,54 @@ css_error parse_richness(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 = RICHNESS_SET;
+ } else
+ return CSS_INVALID;
+
+ opv = buildOPV(OP_RICHNESS, flags, value);
+
+ required_size = sizeof(opv);
+ if ((flags & FLAG_INHERIT) == false && value == RICHNESS_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 == RICHNESS_SET) {
+ memcpy(((uint8_t *) (*result)->bytecode) + sizeof(opv),
+ &num, sizeof(num));
+ }
return CSS_OK;
}