summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-10-26 15:22:27 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-10-26 15:22:27 +0000
commitff9495d56006405324e4404089f158d61b944c57 (patch)
tree384b14c3b329e87022fd4e6437f904d7af1e2bad /src
parent415e877957b09e0d1e03a079306d1d64202cd386 (diff)
downloadlibcss-ff9495d56006405324e4404089f158d61b944c57.tar.gz
libcss-ff9495d56006405324e4404089f158d61b944c57.tar.bz2
cue-{after,before}
svn path=/trunk/libcss/; revision=5637
Diffstat (limited to 'src')
-rw-r--r--src/parse/css21props.c107
1 files changed, 99 insertions, 8 deletions
diff --git a/src/parse/css21props.c b/src/parse/css21props.c
index 31f52e2..273abb3 100644
--- a/src/parse/css21props.c
+++ b/src/parse/css21props.c
@@ -1027,6 +1027,7 @@ css_error parse_content(css_css21 *c,
const parserutils_vector *vector, int *ctx,
css_style **result)
{
+ /** \todo content */
UNUSED(c);
UNUSED(vector);
UNUSED(ctx);
@@ -1039,6 +1040,7 @@ css_error parse_counter_increment(css_css21 *c,
const parserutils_vector *vector, int *ctx,
css_style **result)
{
+ /** \todo counter-increment */
UNUSED(c);
UNUSED(vector);
UNUSED(ctx);
@@ -1051,6 +1053,7 @@ css_error parse_counter_reset(css_css21 *c,
const parserutils_vector *vector, int *ctx,
css_style **result)
{
+ /** \todo counter-reset */
UNUSED(c);
UNUSED(vector);
UNUSED(ctx);
@@ -1063,10 +1066,54 @@ css_error parse_cue_after(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 required_size;
+
+ /* URI | IDENT (none, inherit) */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL || (token->type != CSS_TOKEN_IDENT &&
+ token->type != CSS_TOKEN_URI))
+ 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[NONE]) {
+ value = CUE_AFTER_NONE;
+ } else if (token->type == CSS_TOKEN_URI) {
+ value = CUE_AFTER_URI;
+ } else
+ return CSS_INVALID;
+
+ opv = buildOPV(OP_CUE_AFTER, flags, value);
+
+ required_size = sizeof(opv);
+ if (value == CUE_AFTER_URI)
+ required_size += sizeof(uint8_t *) + sizeof(size_t);
+
+ /* 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 == CUE_AFTER_URI) {
+ memcpy((uint8_t *) (*result)->bytecode + sizeof(opv),
+ &token->data.ptr, sizeof(uint8_t *));
+ memcpy((uint8_t *) (*result)->bytecode + sizeof(opv) +
+ sizeof(uint8_t *),
+ &token->data.len, sizeof(size_t));
+ }
return CSS_OK;
}
@@ -1075,10 +1122,54 @@ css_error parse_cue_before(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 required_size;
+
+ /* URI | IDENT (none, inherit) */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL || (token->type != CSS_TOKEN_IDENT &&
+ token->type != CSS_TOKEN_URI))
+ 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[NONE]) {
+ value = CUE_BEFORE_NONE;
+ } else if (token->type == CSS_TOKEN_URI) {
+ value = CUE_BEFORE_URI;
+ } else
+ return CSS_INVALID;
+
+ opv = buildOPV(OP_CUE_BEFORE, flags, value);
+
+ required_size = sizeof(opv);
+ if (value == CUE_BEFORE_URI)
+ required_size += sizeof(uint8_t *) + sizeof(size_t);
+
+ /* 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 == CUE_BEFORE_URI) {
+ memcpy((uint8_t *) (*result)->bytecode + sizeof(opv),
+ &token->data.ptr, sizeof(uint8_t *));
+ memcpy((uint8_t *) (*result)->bytecode + sizeof(opv) +
+ sizeof(uint8_t *),
+ &token->data.len, sizeof(size_t));
+ }
return CSS_OK;
}