summaryrefslogtreecommitdiff
path: root/src/parse/properties/properties.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-05-26 23:33:03 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-05-26 23:33:03 +0000
commitd31b85e586b137610978725871c8f57eaa29d241 (patch)
tree65a8489498c3ca560f14d8d1d358a93da3c7b9ea /src/parse/properties/properties.c
parent81777be0325e2434911f697f0d9a284e50ee63ef (diff)
downloadlibcss-d31b85e586b137610978725871c8f57eaa29d241.tar.gz
libcss-d31b85e586b137610978725871c8f57eaa29d241.tar.bz2
Split out background property parsers
svn path=/trunk/libcss/; revision=7558
Diffstat (limited to 'src/parse/properties/properties.c')
-rw-r--r--src/parse/properties/properties.c354
1 files changed, 0 insertions, 354 deletions
diff --git a/src/parse/properties/properties.c b/src/parse/properties/properties.c
index 8033cf1..e2ac7f9 100644
--- a/src/parse/properties/properties.c
+++ b/src/parse/properties/properties.c
@@ -140,360 +140,6 @@ static inline css_error parse_content_list(css_language *c,
const parserutils_vector *vector, int *ctx,
uint16_t *value, uint8_t *buffer, uint32_t *buflen);
-css_error parse_background_attachment(css_language *c,
- const parserutils_vector *vector, int *ctx,
- css_style **result)
-{
- css_error error;
- const css_token *ident;
- uint8_t flags = 0;
- uint16_t value = 0;
- uint32_t opv;
-
- /* IDENT (fixed, scroll, inherit) */
- ident = parserutils_vector_iterate(vector, ctx);
- if (ident == NULL || ident->type != CSS_TOKEN_IDENT)
- return CSS_INVALID;
-
- error = parse_important(c, vector, ctx, &flags);
- if (error != CSS_OK)
- return error;
-
- if (ident->ilower == c->strings[INHERIT]) {
- flags |= FLAG_INHERIT;
- } else if (ident->ilower == c->strings[FIXED]) {
- value = BACKGROUND_ATTACHMENT_FIXED;
- } else if (ident->ilower == c->strings[SCROLL]) {
- value = BACKGROUND_ATTACHMENT_SCROLL;
- } else
- return CSS_INVALID;
-
- opv = buildOPV(CSS_PROP_BACKGROUND_ATTACHMENT, flags, value);
-
- /* Allocate result */
- error = css_stylesheet_style_create(c->sheet, sizeof(opv), result);
- if (error != CSS_OK)
- return error;
-
- /* Copy the bytecode to it */
- memcpy((*result)->bytecode, &opv, sizeof(opv));
-
- return CSS_OK;
-}
-
-css_error parse_background_color(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 colour = 0;
- uint32_t required_size;
-
- /* colour | IDENT (transparent, inherit) */
- token= parserutils_vector_peek(vector, *ctx);
- if (token == NULL)
- return CSS_INVALID;
-
- if (token->type == CSS_TOKEN_IDENT &&
- token->ilower == c->strings[INHERIT]) {
- parserutils_vector_iterate(vector, ctx);
- flags |= FLAG_INHERIT;
- } else if (token->type == CSS_TOKEN_IDENT &&
- token->ilower == c->strings[TRANSPARENT]) {
- parserutils_vector_iterate(vector, ctx);
- value = BACKGROUND_COLOR_TRANSPARENT;
- } else {
- error = parse_colour_specifier(c, vector, ctx, &colour);
- if (error != CSS_OK)
- return error;
-
- value = BACKGROUND_COLOR_SET;
- }
-
- error = parse_important(c, vector, ctx, &flags);
- if (error != CSS_OK)
- return error;
-
- opv = buildOPV(CSS_PROP_BACKGROUND_COLOR, flags, value);
-
- required_size = sizeof(opv);
- if ((flags & FLAG_INHERIT) == false && value == BACKGROUND_COLOR_SET)
- required_size += sizeof(colour);
-
- /* 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 == BACKGROUND_COLOR_SET) {
- memcpy(((uint8_t *) (*result)->bytecode) + sizeof(opv),
- &colour, sizeof(colour));
- }
-
- return CSS_OK;
-}
-
-css_error parse_background_image(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;
-
- /* 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->ilower == c->strings[INHERIT]) {
- flags |= FLAG_INHERIT;
- } else if (token->type == CSS_TOKEN_IDENT &&
- token->ilower == c->strings[NONE]) {
- value = BACKGROUND_IMAGE_NONE;
- } else if (token->type == CSS_TOKEN_URI) {
- value = BACKGROUND_IMAGE_URI;
- } else
- return CSS_INVALID;
-
- opv = buildOPV(CSS_PROP_BACKGROUND_IMAGE, flags, value);
-
- required_size = sizeof(opv);
- if ((flags & FLAG_INHERIT) == false && value == BACKGROUND_IMAGE_URI)
- required_size += sizeof(lwc_string *);
-
- /* 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 == BACKGROUND_IMAGE_URI) {
- lwc_context_string_ref(c->sheet->dictionary, token->idata);
- memcpy((uint8_t *) (*result)->bytecode + sizeof(opv),
- &token->idata,
- sizeof(lwc_string *));
- }
-
- return CSS_OK;
-}
-
-css_error parse_background_position(css_language *c,
- const parserutils_vector *vector, int *ctx,
- css_style **result)
-{
- css_error error;
- const css_token *token;
- uint8_t flags = 0;
- uint32_t opv;
- uint16_t value[2] = { 0 };
- css_fixed length[2] = { 0 };
- uint32_t unit[2] = { 0 };
- uint32_t required_size;
-
- /* [length | percentage | IDENT(left, right, top, bottom, center)]{1,2}
- * | IDENT(inherit) */
- token = parserutils_vector_peek(vector, *ctx);
- if (token == NULL)
- return CSS_INVALID;
-
- if (token->type == CSS_TOKEN_IDENT &&
- token->ilower == c->strings[INHERIT]) {
- parserutils_vector_iterate(vector, ctx);
- flags = FLAG_INHERIT;
- } else {
- int i;
-
- for (i = 0; i < 2; i++) {
- token = parserutils_vector_peek(vector, *ctx);
- /* This can only occur on the second attempt */
- /* Also detect start of !important on second attempt */
- if (token == NULL ||
- (i == 1 && tokenIsChar(token, '!')))
- break;
-
- if (token->type == CSS_TOKEN_IDENT) {
- parserutils_vector_iterate(vector, ctx);
-
- if (token->ilower == c->strings[LEFT]) {
- value[i] =
- BACKGROUND_POSITION_HORZ_LEFT;
- } else if (token->ilower == c->strings[RIGHT]) {
- value[i] =
- BACKGROUND_POSITION_HORZ_RIGHT;
- } else if (token->ilower == c->strings[TOP]) {
- value[i] = BACKGROUND_POSITION_VERT_TOP;
- } else if (token->ilower ==
- c->strings[BOTTOM]) {
- value[i] =
- BACKGROUND_POSITION_VERT_BOTTOM;
- } else if (token->ilower ==
- c->strings[CENTER]) {
- /* We'll fix this up later */
- value[i] =
- BACKGROUND_POSITION_VERT_CENTER;
- } else {
- return CSS_INVALID;
- }
- } else {
- error = parse_unit_specifier(c, vector, ctx,
- UNIT_PX, &length[i], &unit[i]);
- if (error != CSS_OK)
- return error;
-
- if (unit[i] & UNIT_ANGLE ||
- unit[i] & UNIT_TIME ||
- unit[i] & UNIT_FREQ)
- return CSS_INVALID;
-
- /* We'll fix this up later, too */
- value[i] = BACKGROUND_POSITION_VERT_SET;
- }
-
- consumeWhitespace(vector, ctx);
- }
-
- /* Now, sort out the mess we've got */
- if (i == 1) {
- assert(BACKGROUND_POSITION_VERT_CENTER ==
- BACKGROUND_POSITION_HORZ_CENTER);
-
- /* Only one value, so the other is center */
- switch (value[0]) {
- case BACKGROUND_POSITION_HORZ_LEFT:
- case BACKGROUND_POSITION_HORZ_RIGHT:
- case BACKGROUND_POSITION_VERT_CENTER:
- case BACKGROUND_POSITION_VERT_TOP:
- case BACKGROUND_POSITION_VERT_BOTTOM:
- break;
- case BACKGROUND_POSITION_VERT_SET:
- value[0] = BACKGROUND_POSITION_HORZ_SET;
- break;
- default:
- return CSS_INVALID;
- }
-
- value[1] = BACKGROUND_POSITION_VERT_CENTER;
- } else if (value[0] != BACKGROUND_POSITION_VERT_SET &&
- value[1] != BACKGROUND_POSITION_VERT_SET) {
- /* Two keywords. Verify the axes differ */
- if (((value[0] & 0xf) != 0 && (value[1] & 0xf) != 0) ||
- ((value[0] & 0xf0) != 0 &&
- (value[1] & 0xf0) != 0))
- return CSS_INVALID;
- } else {
- /* One or two non-keywords. First is horizontal */
- if (value[0] == BACKGROUND_POSITION_VERT_SET)
- value[0] = BACKGROUND_POSITION_HORZ_SET;
-
- /* Verify the axes differ */
- if (((value[0] & 0xf) != 0 && (value[1] & 0xf) != 0) ||
- ((value[0] & 0xf0) != 0 &&
- (value[1] & 0xf0) != 0))
- return CSS_INVALID;
- }
- }
-
- error = parse_important(c, vector, ctx, &flags);
- if (error != CSS_OK)
- return error;
-
- opv = buildOPV(CSS_PROP_BACKGROUND_POSITION, flags, value[0] | value[1]);
-
- required_size = sizeof(opv);
- if ((flags & FLAG_INHERIT) == false) {
- if (value[0] == BACKGROUND_POSITION_HORZ_SET)
- required_size += sizeof(length[0]) + sizeof(unit[0]);
- if (value[1] == BACKGROUND_POSITION_VERT_SET)
- required_size += sizeof(length[1]) + sizeof(unit[1]);
- }
-
- /* 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) {
- uint8_t *ptr = ((uint8_t *) (*result)->bytecode) + sizeof(opv);
- if (value[0] == BACKGROUND_POSITION_HORZ_SET) {
- memcpy(ptr, &length[0], sizeof(length[0]));
- ptr += sizeof(length[0]);
- memcpy(ptr, &unit[0], sizeof(unit[0]));
- ptr += sizeof(unit[0]);
- }
- if (value[1] == BACKGROUND_POSITION_VERT_SET) {
- memcpy(ptr, &length[1], sizeof(length[1]));
- ptr += sizeof(length[1]);
- memcpy(ptr, &unit[1], sizeof(unit[1]));
- }
- }
-
- return CSS_OK;
-}
-
-css_error parse_background_repeat(css_language *c,
- const parserutils_vector *vector, int *ctx,
- css_style **result)
-{
- css_error error;
- const css_token *ident;
- uint8_t flags = 0;
- uint16_t value = 0;
- uint32_t opv;
-
- /* IDENT (no-repeat, repeat-x, repeat-y, repeat, inherit) */
- ident = parserutils_vector_iterate(vector, ctx);
- if (ident == NULL || ident->type != CSS_TOKEN_IDENT)
- return CSS_INVALID;
-
- error = parse_important(c, vector, ctx, &flags);
- if (error != CSS_OK)
- return error;
-
- if (ident->ilower == c->strings[INHERIT]) {
- flags |= FLAG_INHERIT;
- } else if (ident->ilower == c->strings[NO_REPEAT]) {
- value = BACKGROUND_REPEAT_NO_REPEAT;
- } else if (ident->ilower == c->strings[REPEAT_X]) {
- value = BACKGROUND_REPEAT_REPEAT_X;
- } else if (ident->ilower == c->strings[REPEAT_Y]) {
- value = BACKGROUND_REPEAT_REPEAT_Y;
- } else if (ident->ilower == c->strings[REPEAT]) {
- value = BACKGROUND_REPEAT_REPEAT;
- } else
- return CSS_INVALID;
-
- opv = buildOPV(CSS_PROP_BACKGROUND_REPEAT, flags, value);
-
- /* Allocate result */
- error = css_stylesheet_style_create(c->sheet, sizeof(opv), result);
- if (error != CSS_OK)
- return error;
-
- /* Copy the bytecode to it */
- memcpy((*result)->bytecode, &opv, sizeof(opv));
-
- return CSS_OK;
-}
-
css_error parse_border_bottom_color(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style **result)