Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3584 sourcerer 1
/*
2
 * This file was generated by LibCSS gen_parser
3
 *
4
 * Generated from:
5
 *
6
 * background_image:CSS_PROP_BACKGROUND_IMAGE IDENT:( INHERIT: NONE:0,BACKGROUND_IMAGE_NONE IDENT:) URI:BACKGROUND_IMAGE_URI
7
 *
8
 * Licensed under the MIT License,
9
 *		  http://www.opensource.org/licenses/mit-license.php
10
 * Copyright 2010 The NetSurf Browser Project.
11
 */
12
 
13
#include 
14
#include 
15
 
16
#include "bytecode/bytecode.h"
17
#include "bytecode/opcodes.h"
18
#include "parse/properties/properties.h"
19
#include "parse/properties/utils.h"
20
 
21
/**
22
 * Parse background_image
23
 *
24
 * \param c	  Parsing context
25
 * \param vector  Vector of tokens to process
26
 * \param ctx	  Pointer to vector iteration context
27
 * \param result  resulting style
28
 * \return CSS_OK on success,
29
 *	   CSS_NOMEM on memory exhaustion,
30
 *	   CSS_INVALID if the input is not valid
31
 *
32
 * Post condition: \a *ctx is updated with the next token to process
33
 *		   If the input is invalid, then \a *ctx remains unchanged.
34
 */
35
css_error css__parse_background_image(css_language *c,
36
		const parserutils_vector *vector, int *ctx,
37
		css_style *result)
38
{
39
	int orig_ctx = *ctx;
40
	css_error error;
41
	const css_token *token;
42
	bool match;
43
 
44
	token = parserutils_vector_iterate(vector, ctx);
45
	if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT) && (token->type != CSS_TOKEN_URI))) {
46
		*ctx = orig_ctx;
47
		return CSS_INVALID;
48
	}
49
 
50
	if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[INHERIT], &match) == lwc_error_ok && match)) {
51
			error = css_stylesheet_style_inherit(result, CSS_PROP_BACKGROUND_IMAGE);
52
	} else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[NONE], &match) == lwc_error_ok && match)) {
53
			error = css__stylesheet_style_appendOPV(result, CSS_PROP_BACKGROUND_IMAGE, 0,BACKGROUND_IMAGE_NONE);
54
	} else if (token->type == CSS_TOKEN_URI) {
55
		lwc_string *uri = NULL;
56
		uint32_t uri_snumber;
57
 
58
		error = c->sheet->resolve(c->sheet->resolve_pw,
59
				c->sheet->url,
60
				token->idata, &uri);
61
		if (error != CSS_OK) {
62
			*ctx = orig_ctx;
63
			return error;
64
		}
65
 
66
		error = css__stylesheet_string_add(c->sheet, uri, &uri_snumber);
67
		if (error != CSS_OK) {
68
			*ctx = orig_ctx;
69
			return error;
70
		}
71
 
72
		error = css__stylesheet_style_appendOPV(result, CSS_PROP_BACKGROUND_IMAGE, 0, BACKGROUND_IMAGE_URI);
73
		if (error != CSS_OK) {
74
			*ctx = orig_ctx;
75
			return error;
76
		}
77
 
78
		error = css__stylesheet_style_append(result, uri_snumber);
79
	} else {
80
		error = CSS_INVALID;
81
	}
82
 
83
	if (error != CSS_OK)
84
		*ctx = orig_ctx;
85
 
86
	return error;
87
}
88