summaryrefslogtreecommitdiff
path: root/src/parse/properties/generated_list.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-05-27 00:16:03 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-05-27 00:16:03 +0000
commitbbe40f6f982426cd6ab40b30dd0d413ab5249aed (patch)
tree993dd64d68f962465ba940f3d998dd581d2953f2 /src/parse/properties/generated_list.c
parent5f47593e78ab1fb0d0adf24c6cfa1fbae0a36e1a (diff)
downloadlibcss-bbe40f6f982426cd6ab40b30dd0d413ab5249aed.tar.gz
libcss-bbe40f6f982426cd6ab40b30dd0d413ab5249aed.tar.bz2
Quotes property is also generated content, so move to appropriate file
svn path=/trunk/libcss/; revision=7565
Diffstat (limited to 'src/parse/properties/generated_list.c')
-rw-r--r--src/parse/properties/generated_list.c176
1 files changed, 170 insertions, 6 deletions
diff --git a/src/parse/properties/generated_list.c b/src/parse/properties/generated_list.c
index bebb5c5..4adfdbc 100644
--- a/src/parse/properties/generated_list.c
+++ b/src/parse/properties/generated_list.c
@@ -585,6 +585,164 @@ css_error parse_list_style_type(css_language *c,
return CSS_OK;
}
+css_error parse_quotes(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style **result)
+{
+ css_error error;
+ const css_token *token;
+ uint8_t flags = 0;
+ uint16_t value = 0;
+ uint32_t opv;
+ uint32_t required_size = sizeof(opv);
+ int temp_ctx = *ctx;
+ uint8_t *ptr;
+
+ /* [ STRING STRING ]+ | IDENT(none,inherit) */
+
+ /* Pass 1: validate input and calculate bytecode size */
+ token = parserutils_vector_iterate(vector, &temp_ctx);
+ if (token == NULL || (token->type != CSS_TOKEN_IDENT &&
+ token->type != CSS_TOKEN_STRING))
+ return CSS_INVALID;
+
+ if (token->type == CSS_TOKEN_IDENT) {
+ if (token->ilower == c->strings[INHERIT]) {
+ flags = FLAG_INHERIT;
+ } else if (token->ilower == c->strings[NONE]) {
+ value = QUOTES_NONE;
+ } else
+ return CSS_INVALID;
+ } else {
+ bool first = true;
+
+ /* [ STRING STRING ] + */
+ while (token != NULL && token->type == CSS_TOKEN_STRING) {
+ lwc_string *open = token->idata;
+ lwc_string *close;
+
+ consumeWhitespace(vector, &temp_ctx);
+
+ token = parserutils_vector_peek(vector, temp_ctx);
+ if (token == NULL || token->type != CSS_TOKEN_STRING)
+ return CSS_INVALID;
+
+ close = token->idata;
+
+ token = parserutils_vector_iterate(vector, &temp_ctx);
+
+ consumeWhitespace(vector, &temp_ctx);
+
+ if (first == false) {
+ required_size += sizeof(opv);
+ } else {
+ value = QUOTES_STRING;
+ }
+ required_size += sizeof(open) + sizeof(close);
+
+ first = false;
+
+ token = parserutils_vector_peek(vector, temp_ctx);
+ if (token == NULL || token->type != CSS_TOKEN_STRING)
+ break;
+ token = parserutils_vector_iterate(vector, &temp_ctx);
+ }
+
+ consumeWhitespace(vector, &temp_ctx);
+
+ token = parserutils_vector_peek(vector, temp_ctx);
+ if (token != NULL && tokenIsChar(token, '!') == false)
+ return CSS_INVALID;
+
+ /* Terminator */
+ required_size += sizeof(opv);
+ }
+
+ error = parse_important(c, vector, &temp_ctx, &flags);
+ if (error != CSS_OK)
+ return error;
+
+ opv = buildOPV(CSS_PROP_QUOTES, flags, value);
+
+ /* Allocate result */
+ error = css_stylesheet_style_create(c->sheet, required_size, result);
+ if (error != CSS_OK)
+ return error;
+
+ /* Copy OPV to bytecode */
+ ptr = (*result)->bytecode;
+ memcpy(ptr, &opv, sizeof(opv));
+ ptr += sizeof(opv);
+
+ /* Pass 2: construct bytecode */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL || (token->type != CSS_TOKEN_IDENT &&
+ token->type != CSS_TOKEN_STRING))
+ return CSS_INVALID;
+
+ if (token->type == CSS_TOKEN_IDENT) {
+ /* Nothing to do */
+ } else {
+ bool first = true;
+
+ /* [ STRING STRING ]+ */
+ while (token != NULL && token->type == CSS_TOKEN_STRING) {
+ lwc_string *open = token->idata;
+ lwc_string *close;
+
+ consumeWhitespace(vector, ctx);
+
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token == NULL || token->type != CSS_TOKEN_STRING)
+ return CSS_INVALID;
+
+ close = token->idata;
+
+ token = parserutils_vector_iterate(vector, ctx);
+
+ consumeWhitespace(vector, ctx);
+
+ if (first == false) {
+ opv = QUOTES_STRING;
+ memcpy(ptr, &opv, sizeof(opv));
+ ptr += sizeof(opv);
+ }
+
+ lwc_context_string_ref(c->sheet->dictionary, open);
+ memcpy(ptr, &open, sizeof(open));
+ ptr += sizeof(open);
+
+ lwc_context_string_ref(c->sheet->dictionary, close);
+ memcpy(ptr, &close, sizeof(close));
+ ptr += sizeof(close);
+
+ first = false;
+
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token == NULL || token->type != CSS_TOKEN_STRING)
+ break;
+ token = parserutils_vector_iterate(vector, ctx);
+ }
+
+ consumeWhitespace(vector, ctx);
+
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token != NULL && tokenIsChar(token, '!') == false)
+ return CSS_INVALID;
+
+ /* Terminator */
+ opv = QUOTES_NONE;
+ memcpy(ptr, &opv, sizeof(opv));
+ ptr += sizeof(opv);
+ }
+
+ error = parse_important(c, vector, ctx, &flags);
+ if (error != CSS_OK)
+ return error;
+
+ return CSS_OK;
+}
+
css_error parse_list_style_type_value(css_language *c, const css_token *ident,
uint16_t *value)
{
@@ -713,7 +871,8 @@ css_error parse_content_list(css_language *c,
}
if (buffer != NULL) {
- lwc_context_string_ref(c->sheet->dictionary, token->idata);
+ lwc_context_string_ref(c->sheet->dictionary,
+ token->idata);
memcpy(buffer + offset, &token->idata,
sizeof(token->idata));
}
@@ -732,7 +891,8 @@ css_error parse_content_list(css_language *c,
}
if (buffer != NULL) {
- lwc_context_string_ref(c->sheet->dictionary, token->idata);
+ lwc_context_string_ref(c->sheet->dictionary,
+ token->idata);
memcpy(buffer + offset, &token->idata,
sizeof(token->idata));
}
@@ -759,7 +919,8 @@ css_error parse_content_list(css_language *c,
return CSS_INVALID;
if (buffer != NULL) {
- lwc_context_string_ref(c->sheet->dictionary, token->idata);
+ lwc_context_string_ref(c->sheet->dictionary,
+ token->idata);
memcpy(buffer + offset, &token->idata,
sizeof(token->idata));
}
@@ -839,7 +1000,8 @@ css_error parse_content_list(css_language *c,
}
if (buffer != NULL) {
- lwc_context_string_ref(c->sheet->dictionary, name);
+ lwc_context_string_ref(c->sheet->dictionary,
+ name);
memcpy(buffer + offset, &name, sizeof(name));
}
@@ -928,14 +1090,16 @@ css_error parse_content_list(css_language *c,
}
if (buffer != NULL) {
- lwc_context_string_ref(c->sheet->dictionary, name);
+ lwc_context_string_ref(c->sheet->dictionary,
+ name);
memcpy(buffer + offset, &name, sizeof(name));
}
offset += sizeof(name);
if (buffer != NULL) {
- lwc_context_string_ref(c->sheet->dictionary, sep);
+ lwc_context_string_ref(c->sheet->dictionary,
+ sep);
memcpy(buffer + offset, &sep, sizeof(sep));
}