From 87d7c3d3dee8d22af977e346ba1c139131152077 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 28 Mar 2010 00:13:41 +0000 Subject: Make libcss suitable for the new libwapcaplet behaviour. svn path=/trunk/libcss/; revision=10168 --- src/parse/language.c | 76 +-- src/parse/properties/aural.c | 122 ++--- src/parse/properties/background.c | 74 +-- src/parse/properties/border_outline.c | 366 +++++++------- src/parse/properties/font.c | 88 ++-- src/parse/properties/generated_list.c | 158 +++--- src/parse/properties/margin.c | 72 +-- src/parse/properties/padding.c | 72 +-- src/select/dispatch.c | 504 ++++--------------- src/select/dispatch.h | 8 +- src/select/properties.c | 785 ++++++++++++++++++++++++++++- src/select/properties.h | 901 ++++------------------------------ src/stylesheet.c | 300 +++++------ src/stylesheet.h | 15 +- 14 files changed, 1676 insertions(+), 1865 deletions(-) (limited to 'src') diff --git a/src/parse/language.c b/src/parse/language.c index ee18463..cfe78e8 100644 --- a/src/parse/language.c +++ b/src/parse/language.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2008 John-Mark Bell */ @@ -92,14 +92,14 @@ static css_error parseProperty(css_language *c, /** * Create a CSS language parser * - * \param sheet The stylesheet object to parse for + * \param sheet The stylesheet object to parse for * \param parser The core parser object to use - * \param alloc Memory (de)allocation function - * \param pw Pointer to client-specific private data + * \param alloc Memory (de)allocation function + * \param pw Pointer to client-specific private data * \param language Pointer to location to receive parser object * \return CSS_OK on success, - * CSS_BADPARM on bad parameters, - * CSS_NOMEM on memory exhaustion + * CSS_BADPARM on bad parameters, + * CSS_NOMEM on memory exhaustion */ css_error css_language_create(css_stylesheet *sheet, css_parser *parser, css_allocator_fn alloc, void *pw, void **language) @@ -107,7 +107,7 @@ css_error css_language_create(css_stylesheet *sheet, css_parser *parser, css_language *c; css_parser_optparams params; parserutils_error perror; - lwc_error lerror; + lwc_error lerror; css_error error; int i; @@ -129,10 +129,10 @@ css_error css_language_create(css_stylesheet *sheet, css_parser *parser, /* Intern all known strings */ for (i = 0; i < LAST_KNOWN; i++) { - lerror = lwc_intern_string(stringmap[i].data, - stringmap[i].len, - &(c->strings[i])); - if (lerror != lwc_error_ok) { + lerror = lwc_intern_string(stringmap[i].data, + stringmap[i].len, + &(c->strings[i])); + if (lerror != lwc_error_ok) { parserutils_stack_destroy(c->context); alloc(c, 0, pw); return CSS_NOMEM; @@ -166,17 +166,17 @@ css_error css_language_create(css_stylesheet *sheet, css_parser *parser, */ css_error css_language_destroy(css_language *language) { - int i; - + int i; + if (language == NULL) return CSS_BADPARM; parserutils_stack_destroy(language->context); - - for (i = 0; i < LAST_KNOWN; ++i) { - lwc_string_unref(language->strings[i]); - } - + + for (i = 0; i < LAST_KNOWN; ++i) { + lwc_string_unref(language->strings[i]); + } + language->alloc(language, 0, language->pw); return CSS_OK; @@ -185,11 +185,11 @@ css_error css_language_destroy(css_language *language) /** * Handler for core parser events * - * \param type The event type + * \param type The event type * \param tokens Vector of tokens read since last event, or NULL - * \param pw Pointer to handler context + * \param pw Pointer to handler context * \return CSS_OK on success, CSS_INVALID to indicate parse error, - * appropriate error otherwise. + * appropriate error otherwise. */ css_error language_handle_event(css_parser_event type, const parserutils_vector *tokens, void *pw) @@ -223,7 +223,7 @@ css_error language_handle_event(css_parser_event type, } /****************************************************************************** - * Parser stages * + * Parser stages * ******************************************************************************/ css_error handleStartStylesheet(css_language *c, @@ -412,7 +412,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) uint64_t media = 0; /* any0 = (STRING | URI) ws - * (IDENT ws (',' ws IDENT ws)* )? */ + * (IDENT ws (',' ws IDENT ws)* )? */ const css_token *uri = parserutils_vector_iterate(vector, &ctx); if (uri == NULL || (uri->type != CSS_TOKEN_STRING && @@ -707,7 +707,7 @@ css_error handleDeclaration(css_language *c, const parserutils_vector *vector) } /****************************************************************************** - * At-rule parsing functions * + * At-rule parsing functions * ******************************************************************************/ css_error parseMediaList(css_language *c, const parserutils_vector *vector, int *ctx, @@ -789,7 +789,7 @@ css_error parseMediaList(css_language *c, } /****************************************************************************** - * Selector list parsing functions * + * Selector list parsing functions * ******************************************************************************/ css_error parseClass(css_language *c, const parserutils_vector *vector, @@ -817,8 +817,8 @@ css_error parseAttrib(css_language *c, const parserutils_vector *vector, css_selector_type type = CSS_SELECTOR_ATTRIBUTE; /* attrib -> '[' ws IDENT ws [ - * [ '=' | INCLUDES | DASHMATCH ] ws - * [ IDENT | STRING ] ws ]? ']' + * [ '=' | INCLUDES | DASHMATCH ] ws + * [ IDENT | STRING ] ws ]? ']' */ token = parserutils_vector_iterate(vector, ctx); if (token == NULL || tokenIsChar(token, '[') == false) @@ -907,7 +907,7 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, } if ((lwc_string_caseless_isequal( - name->idata, c->strings[FIRST_CHILD], + name->idata, c->strings[FIRST_CHILD], &match) == lwc_error_ok && match) || (lwc_string_caseless_isequal( name->idata, c->strings[LINK], @@ -938,7 +938,7 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, &match) == lwc_error_ok && match)) type = CSS_SELECTOR_PSEUDO_CLASS; else if ((lwc_string_caseless_isequal( - name->idata, c->strings[FIRST_LINE], + name->idata, c->strings[FIRST_LINE], &match) == lwc_error_ok && match) || (lwc_string_caseless_isequal( name->idata, c->strings[FIRST_LETTER], @@ -1029,8 +1029,8 @@ css_error parseSimpleSelector(css_language *c, css_selector *selector; /* simple_selector -> element_name specifics - * -> specific specifics - * element_name -> IDENT | '*' + * -> specific specifics + * element_name -> IDENT | '*' */ token = parserutils_vector_peek(vector, *ctx); @@ -1077,7 +1077,7 @@ css_error parseCombinator(css_language *c, const parserutils_vector *vector, const css_token *token; css_combinator comb = CSS_COMBINATOR_NONE; - /* combinator -> ws '+' ws | ws '>' ws | ws1 */ + /* combinator -> ws '+' ws | ws '>' ws | ws1 */ UNUSED(c); @@ -1160,8 +1160,10 @@ css_error parseSelector(css_language *c, const parserutils_vector *vector, error = css_stylesheet_selector_combine(c->sheet, comb, selector, other); - if (error != CSS_OK) + if (error != CSS_OK) { + css_stylesheet_selector_destroy(c->sheet, selector); return error; + } selector = other; } @@ -1229,7 +1231,7 @@ css_error parseSelectorList(css_language *c, const parserutils_vector *vector, } /****************************************************************************** - * Property parsing functions * + * Property parsing functions * ******************************************************************************/ css_error parseProperty(css_language *c, const css_token *property, @@ -1268,7 +1270,7 @@ css_error parseProperty(css_language *c, const css_token *property, /* Determine if this declaration is important or not */ error = parse_important(c, vector, ctx, &flags); if (error != CSS_OK) { - css_stylesheet_style_destroy(c->sheet, style); + css_stylesheet_style_destroy(c->sheet, style, false); return error; } @@ -1277,7 +1279,7 @@ css_error parseProperty(css_language *c, const css_token *property, token = parserutils_vector_iterate(vector, ctx); if (token != NULL) { /* Trailing junk, so discard declaration */ - css_stylesheet_style_destroy(c->sheet, style); + css_stylesheet_style_destroy(c->sheet, style, false); return CSS_INVALID; } @@ -1288,7 +1290,7 @@ css_error parseProperty(css_language *c, const css_token *property, /* Append style to rule */ error = css_stylesheet_rule_append_style(c->sheet, rule, style); if (error != CSS_OK) { - css_stylesheet_style_destroy(c->sheet, style); + css_stylesheet_style_destroy(c->sheet, style, false); return error; } diff --git a/src/parse/properties/aural.c b/src/parse/properties/aural.c index 0bc59ee..8821c5f 100644 --- a/src/parse/properties/aural.c +++ b/src/parse/properties/aural.c @@ -23,9 +23,9 @@ static css_error parse_pause_common(css_language *c, /** * Parse azimuth * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -53,7 +53,7 @@ css_error parse_azimuth(css_language *c, * center-right, right, far-right, right-side) || * IDENT(behind) * ] - * | IDENT(leftwards, rightwards, inherit) + * | IDENT(leftwards, rightwards, inherit) */ token = parserutils_vector_peek(vector, *ctx); if (token == NULL) { @@ -254,9 +254,9 @@ css_error parse_azimuth(css_language *c, /** * Parse cue shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -394,11 +394,11 @@ css_error parse_cue(css_language *c, /* Clean up after ourselves */ cleanup: if (before) - css_stylesheet_style_destroy(c->sheet, before); + css_stylesheet_style_destroy(c->sheet, before, error == CSS_OK); if (after) - css_stylesheet_style_destroy(c->sheet, after); + css_stylesheet_style_destroy(c->sheet, after, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -409,9 +409,9 @@ cleanup: /** * Parse cue-after * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -430,9 +430,9 @@ css_error parse_cue_after(css_language *c, /** * Parse cue-before * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -451,9 +451,9 @@ css_error parse_cue_before(css_language *c, /** * Parse elevation * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -582,9 +582,9 @@ css_error parse_elevation(css_language *c, /** * Parse pause shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -724,11 +724,11 @@ css_error parse_pause(css_language *c, /* Clean up after ourselves */ cleanup: if (before) - css_stylesheet_style_destroy(c->sheet, before); + css_stylesheet_style_destroy(c->sheet, before, error == CSS_OK); if (after) - css_stylesheet_style_destroy(c->sheet, after); + css_stylesheet_style_destroy(c->sheet, after, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -739,9 +739,9 @@ cleanup: /** * Parse pause-after * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -760,9 +760,9 @@ css_error parse_pause_after(css_language *c, /** * Parse pause-before * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -782,9 +782,9 @@ css_error parse_pause_before(css_language *c, /** * Parse pitch-range * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -866,9 +866,9 @@ css_error parse_pitch_range(css_language *c, /** * Parse pitch * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -985,9 +985,9 @@ css_error parse_pitch(css_language *c, /** * Parse play-during * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1101,7 +1101,7 @@ css_error parse_play_during(css_language *c, /* Copy the bytecode to it */ memcpy((*result)->bytecode, &opv, sizeof(opv)); if ((flags & FLAG_INHERIT) == false && - (value & PLAY_DURING_TYPE_MASK) == PLAY_DURING_URI) { + (value & PLAY_DURING_TYPE_MASK) == PLAY_DURING_URI) { /* Don't ref URI -- we want to pass ownership to the bytecode */ memcpy((uint8_t *) (*result)->bytecode + sizeof(opv), &uri, sizeof(lwc_string *)); @@ -1113,9 +1113,9 @@ css_error parse_play_during(css_language *c, /** * Parse richness * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1197,9 +1197,9 @@ css_error parse_richness(css_language *c, /** * Parse speak-header * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1262,9 +1262,9 @@ css_error parse_speak_header(css_language *c, /** * Parse speak-numeral * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1327,9 +1327,9 @@ css_error parse_speak_numeral(css_language *c, /** * Parse speak-punctuation * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1392,9 +1392,9 @@ css_error parse_speak_punctuation(css_language *c, /** * Parse speak * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1461,9 +1461,9 @@ css_error parse_speak(css_language *c, /** * Parse speech-rate * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1583,9 +1583,9 @@ css_error parse_speech_rate(css_language *c, /** * Parse stress * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1666,8 +1666,8 @@ css_error parse_stress(css_language *c, /** * Determine if a given voice-family ident is reserved * - * \param c Parsing context - * \param ident IDENT to consider + * \param c Parsing context + * \param ident IDENT to consider * \return True if IDENT is reserved, false otherwise */ static bool voice_family_reserved(css_language *c, const css_token *ident) @@ -1688,8 +1688,8 @@ static bool voice_family_reserved(css_language *c, const css_token *ident) /** * Convert a voice-family token into a bytecode value * - * \param c Parsing context - * \param token Token to consider + * \param c Parsing context + * \param token Token to consider * \return Bytecode value */ static uint16_t voice_family_value(css_language *c, const css_token *token) @@ -1722,9 +1722,9 @@ static uint16_t voice_family_value(css_language *c, const css_token *token) /** * Parse voice-family * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1800,7 +1800,7 @@ css_error parse_voice_family(css_language *c, token = parserutils_vector_iterate(vector, ctx); if (token == NULL || (token->type != CSS_TOKEN_IDENT && token->type != CSS_TOKEN_STRING)) { - css_stylesheet_style_destroy(c->sheet, *result); + css_stylesheet_style_destroy(c->sheet, *result, true); *result = NULL; *ctx = orig_ctx; return CSS_INVALID; @@ -1816,7 +1816,7 @@ css_error parse_voice_family(css_language *c, voice_family_reserved, voice_family_value, &ptr); if (error != CSS_OK) { - css_stylesheet_style_destroy(c->sheet, *result); + css_stylesheet_style_destroy(c->sheet, *result, true); *result = NULL; *ctx = orig_ctx; return error; @@ -1834,9 +1834,9 @@ css_error parse_voice_family(css_language *c, /** * Parse volume * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -1981,10 +1981,10 @@ css_error parse_volume(css_language *c, /** * Common parser for cue-after and cue-before * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context - * \param op Opcode to parse for + * \param ctx Pointer to vector iteration context + * \param op Opcode to parse for * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, @@ -2060,17 +2060,17 @@ css_error parse_cue_common(css_language *c, memcpy((uint8_t *) (*result)->bytecode + sizeof(opv), &uri, sizeof(lwc_string *)); } - + return CSS_OK; } /** * Common parser for pause-after and pause-before * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context - * \param op Opcode to parse for + * \param ctx Pointer to vector iteration context + * \param op Opcode to parse for * \param result Pointer to location to receive resulting style * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion, diff --git a/src/parse/properties/background.c b/src/parse/properties/background.c index 7403424..7d37a32 100644 --- a/src/parse/properties/background.c +++ b/src/parse/properties/background.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -16,16 +16,16 @@ /** * Parse background * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_background(css_language *c, const parserutils_vector *vector, int *ctx, @@ -227,17 +227,17 @@ css_error parse_background(css_language *c, /* Clean up after ourselves */ cleanup: if (attachment) - css_stylesheet_style_destroy(c->sheet, attachment); + css_stylesheet_style_destroy(c->sheet, attachment, error == CSS_OK); if (color) - css_stylesheet_style_destroy(c->sheet, color); + css_stylesheet_style_destroy(c->sheet, color, error == CSS_OK); if (image) - css_stylesheet_style_destroy(c->sheet, image); + css_stylesheet_style_destroy(c->sheet, image, error == CSS_OK); if (position) - css_stylesheet_style_destroy(c->sheet, position); + css_stylesheet_style_destroy(c->sheet, position, error == CSS_OK); if (repeat) - css_stylesheet_style_destroy(c->sheet, repeat); + css_stylesheet_style_destroy(c->sheet, repeat, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -248,16 +248,16 @@ cleanup: /** * Parse background-attachment * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_background_attachment(css_language *c, const parserutils_vector *vector, int *ctx, @@ -313,16 +313,16 @@ css_error parse_background_attachment(css_language *c, /** * Parse background-color * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_background_color(css_language *c, const parserutils_vector *vector, int *ctx, @@ -393,16 +393,16 @@ css_error parse_background_color(css_language *c, /** * Parse background-image * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_background_image(css_language *c, const parserutils_vector *vector, int *ctx, @@ -478,16 +478,16 @@ css_error parse_background_image(css_language *c, /** * Parse background-position * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_background_position(css_language *c, const parserutils_vector *vector, int *ctx, @@ -688,16 +688,16 @@ css_error parse_background_position(css_language *c, /** * Parse background-repeat * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_background_repeat(css_language *c, const parserutils_vector *vector, int *ctx, diff --git a/src/parse/properties/border_outline.c b/src/parse/properties/border_outline.c index b04f6cb..be6cafd 100644 --- a/src/parse/properties/border_outline.c +++ b/src/parse/properties/border_outline.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -31,16 +31,16 @@ static css_error parse_border_side_width(css_language *c, /** * Parse border shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border(css_language *c, const parserutils_vector *vector, int *ctx, @@ -107,15 +107,15 @@ css_error parse_border(css_language *c, /* Clean up after ourselves */ cleanup: if (top) - css_stylesheet_style_destroy(c->sheet, top); + css_stylesheet_style_destroy(c->sheet, top, error == CSS_OK); if (right) - css_stylesheet_style_destroy(c->sheet, right); + css_stylesheet_style_destroy(c->sheet, right, error == CSS_OK); if (bottom) - css_stylesheet_style_destroy(c->sheet, bottom); + css_stylesheet_style_destroy(c->sheet, bottom, error == CSS_OK); if (left) - css_stylesheet_style_destroy(c->sheet, left); + css_stylesheet_style_destroy(c->sheet, left, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -126,16 +126,16 @@ cleanup: /** * Parse border-bottom shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_bottom(css_language *c, const parserutils_vector *vector, int *ctx, @@ -147,16 +147,16 @@ css_error parse_border_bottom(css_language *c, /** * Parse border-bottom-color * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_bottom_color(css_language *c, const parserutils_vector *vector, int *ctx, @@ -169,16 +169,16 @@ css_error parse_border_bottom_color(css_language *c, /** * Parse border-bottom-style * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_bottom_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -191,16 +191,16 @@ css_error parse_border_bottom_style(css_language *c, /** * Parse border-bottom-width * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_bottom_width(css_language *c, const parserutils_vector *vector, int *ctx, @@ -213,16 +213,16 @@ css_error parse_border_bottom_width(css_language *c, /** * Parse border-collapse * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_collapse(css_language *c, const parserutils_vector *vector, int *ctx, @@ -278,16 +278,16 @@ css_error parse_border_collapse(css_language *c, /** * Parse border-color shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_color(css_language *c, const parserutils_vector *vector, int *ctx, @@ -511,15 +511,15 @@ css_error parse_border_color(css_language *c, /* Clean up after ourselves */ cleanup: if (top) - css_stylesheet_style_destroy(c->sheet, top); + css_stylesheet_style_destroy(c->sheet, top, error == CSS_OK); if (right) - css_stylesheet_style_destroy(c->sheet, right); + css_stylesheet_style_destroy(c->sheet, right, error == CSS_OK); if (bottom) - css_stylesheet_style_destroy(c->sheet, bottom); + css_stylesheet_style_destroy(c->sheet, bottom, error == CSS_OK); if (left) - css_stylesheet_style_destroy(c->sheet, left); + css_stylesheet_style_destroy(c->sheet, left, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -530,16 +530,16 @@ cleanup: /** * Parse border-left shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_left(css_language *c, const parserutils_vector *vector, int *ctx, @@ -551,16 +551,16 @@ css_error parse_border_left(css_language *c, /** * Parse border-left-color * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_left_color(css_language *c, const parserutils_vector *vector, int *ctx, @@ -573,16 +573,16 @@ css_error parse_border_left_color(css_language *c, /** * Parse border-left-style * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_left_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -595,16 +595,16 @@ css_error parse_border_left_style(css_language *c, /** * Parse border-left-width * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_left_width(css_language *c, const parserutils_vector *vector, int *ctx, @@ -617,16 +617,16 @@ css_error parse_border_left_width(css_language *c, /** * Parse border-right shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_right(css_language *c, const parserutils_vector *vector, int *ctx, @@ -638,16 +638,16 @@ css_error parse_border_right(css_language *c, /** * Parse border-right-color * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_right_color(css_language *c, const parserutils_vector *vector, int *ctx, @@ -660,16 +660,16 @@ css_error parse_border_right_color(css_language *c, /** * Parse border-right-style * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_right_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -682,16 +682,16 @@ css_error parse_border_right_style(css_language *c, /** * Parse border-right-width * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_right_width(css_language *c, const parserutils_vector *vector, int *ctx, @@ -704,16 +704,16 @@ css_error parse_border_right_width(css_language *c, /** * Parse border-spacing * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_spacing(css_language *c, const parserutils_vector *vector, int *ctx, @@ -833,16 +833,16 @@ css_error parse_border_spacing(css_language *c, /** * Parse border-style shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1066,15 +1066,15 @@ css_error parse_border_style(css_language *c, /* Clean up after ourselves */ cleanup: if (top) - css_stylesheet_style_destroy(c->sheet, top); + css_stylesheet_style_destroy(c->sheet, top, error == CSS_OK); if (right) - css_stylesheet_style_destroy(c->sheet, right); + css_stylesheet_style_destroy(c->sheet, right, error == CSS_OK); if (bottom) - css_stylesheet_style_destroy(c->sheet, bottom); + css_stylesheet_style_destroy(c->sheet, bottom, error == CSS_OK); if (left) - css_stylesheet_style_destroy(c->sheet, left); + css_stylesheet_style_destroy(c->sheet, left, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -1085,16 +1085,16 @@ cleanup: /** * Parse border-top shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_top(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1106,16 +1106,16 @@ css_error parse_border_top(css_language *c, /** * Parse border-top-color * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_top_color(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1128,16 +1128,16 @@ css_error parse_border_top_color(css_language *c, /** * Parse border-top-style * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_top_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1150,16 +1150,16 @@ css_error parse_border_top_style(css_language *c, /** * Parse border-top-width * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_top_width(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1172,16 +1172,16 @@ css_error parse_border_top_width(css_language *c, /** * Parse border-width shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_width(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1405,15 +1405,15 @@ css_error parse_border_width(css_language *c, /* Clean up after ourselves */ cleanup: if (top) - css_stylesheet_style_destroy(c->sheet, top); + css_stylesheet_style_destroy(c->sheet, top, error == CSS_OK); if (right) - css_stylesheet_style_destroy(c->sheet, right); + css_stylesheet_style_destroy(c->sheet, right, error == CSS_OK); if (bottom) - css_stylesheet_style_destroy(c->sheet, bottom); + css_stylesheet_style_destroy(c->sheet, bottom, error == CSS_OK); if (left) - css_stylesheet_style_destroy(c->sheet, left); + css_stylesheet_style_destroy(c->sheet, left, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -1424,16 +1424,16 @@ cleanup: /** * Parse outline shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_outline(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1590,13 +1590,13 @@ css_error parse_outline(css_language *c, /* Clean up after ourselves */ cleanup: if (color) - css_stylesheet_style_destroy(c->sheet, color); + css_stylesheet_style_destroy(c->sheet, color, error == CSS_OK); if (style) - css_stylesheet_style_destroy(c->sheet, style); + css_stylesheet_style_destroy(c->sheet, style, error == CSS_OK); if (width) - css_stylesheet_style_destroy(c->sheet, width); + css_stylesheet_style_destroy(c->sheet, width, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -1607,16 +1607,16 @@ cleanup: /** * Parse outline-color * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_outline_color(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1687,16 +1687,16 @@ css_error parse_outline_color(css_language *c, /** * Parse outline-style * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_outline_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1731,16 +1731,16 @@ css_error parse_outline_style(css_language *c, /** * Parse outline-width * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_outline_width(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1754,17 +1754,17 @@ css_error parse_outline_width(css_language *c, /** * Parse border-{top,right,bottom,left} shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context - * \param side The side we're parsing for + * \param ctx Pointer to vector iteration context + * \param side The side we're parsing for * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_side(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1916,13 +1916,13 @@ css_error parse_border_side(css_language *c, /* Clean up after ourselves */ cleanup: if (color) - css_stylesheet_style_destroy(c->sheet, color); + css_stylesheet_style_destroy(c->sheet, color, error == CSS_OK); if (style) - css_stylesheet_style_destroy(c->sheet, style); + css_stylesheet_style_destroy(c->sheet, style, error == CSS_OK); if (width) - css_stylesheet_style_destroy(c->sheet, width); + css_stylesheet_style_destroy(c->sheet, width, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -1933,17 +1933,17 @@ cleanup: /** * Parse border-{top,right,bottom,left}-color * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context - * \param op Opcode to parse for (encodes side) + * \param ctx Pointer to vector iteration context + * \param op Opcode to parse for (encodes side) * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_side_color(css_language *c, const parserutils_vector *vector, int *ctx, @@ -2014,17 +2014,17 @@ css_error parse_border_side_color(css_language *c, /** * Parse border-{top,right,bottom,left}-style * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context - * \param op Opcode to parse for (encodes side) + * \param ctx Pointer to vector iteration context + * \param op Opcode to parse for (encodes side) * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_side_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -2113,17 +2113,17 @@ css_error parse_border_side_style(css_language *c, /** * Parse border-{top,right,bottom,left}-width * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context - * \param op Opcode to parse for (encodes side) + * \param ctx Pointer to vector iteration context + * \param op Opcode to parse for (encodes side) * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_border_side_width(css_language *c, const parserutils_vector *vector, int *ctx, diff --git a/src/parse/properties/font.c b/src/parse/properties/font.c index 288b7f2..af8c19f 100644 --- a/src/parse/properties/font.c +++ b/src/parse/properties/font.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -16,16 +16,16 @@ /** * Parse font * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_font(css_language *c, const parserutils_vector *vector, int *ctx, @@ -286,19 +286,19 @@ css_error parse_font(css_language *c, /* Clean up after ourselves */ cleanup: if (style) - css_stylesheet_style_destroy(c->sheet, style); + css_stylesheet_style_destroy(c->sheet, style, error == CSS_OK); if (variant) - css_stylesheet_style_destroy(c->sheet, variant); + css_stylesheet_style_destroy(c->sheet, variant, error == CSS_OK); if (weight) - css_stylesheet_style_destroy(c->sheet, weight); + css_stylesheet_style_destroy(c->sheet, weight, error == CSS_OK); if (size) - css_stylesheet_style_destroy(c->sheet, size); + css_stylesheet_style_destroy(c->sheet, size, error == CSS_OK); if (line_height) - css_stylesheet_style_destroy(c->sheet, line_height); + css_stylesheet_style_destroy(c->sheet, line_height, error == CSS_OK); if (family) - css_stylesheet_style_destroy(c->sheet, family); + css_stylesheet_style_destroy(c->sheet, family, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -309,8 +309,8 @@ cleanup: /** * Determine if a given font-family ident is reserved * - * \param c Parsing context - * \param ident IDENT to consider + * \param c Parsing context + * \param ident IDENT to consider * \return True if IDENT is reserved, false otherwise */ static bool font_family_reserved(css_language *c, const css_token *ident) @@ -337,8 +337,8 @@ static bool font_family_reserved(css_language *c, const css_token *ident) /** * Convert a font-family token into a bytecode value * - * \param c Parsing context - * \param token Token to consider + * \param c Parsing context + * \param token Token to consider * \return Bytecode value */ static uint16_t font_family_value(css_language *c, const css_token *token) @@ -379,16 +379,16 @@ static uint16_t font_family_value(css_language *c, const css_token *token) /** * Parse font-family * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_font_family(css_language *c, const parserutils_vector *vector, int *ctx, @@ -460,7 +460,7 @@ css_error parse_font_family(css_language *c, token = parserutils_vector_iterate(vector, ctx); if (token == NULL || (token->type != CSS_TOKEN_IDENT && token->type != CSS_TOKEN_STRING)) { - css_stylesheet_style_destroy(c->sheet, *result); + css_stylesheet_style_destroy(c->sheet, *result, false); *result = NULL; *ctx = orig_ctx; return CSS_INVALID; @@ -476,7 +476,7 @@ css_error parse_font_family(css_language *c, font_family_reserved, font_family_value, &ptr); if (error != CSS_OK) { - css_stylesheet_style_destroy(c->sheet, *result); + css_stylesheet_style_destroy(c->sheet, *result, false); *result = NULL; *ctx = orig_ctx; return error; @@ -494,16 +494,16 @@ css_error parse_font_family(css_language *c, /** * Parse font-size * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_font_size(css_language *c, const parserutils_vector *vector, int *ctx, @@ -638,16 +638,16 @@ css_error parse_font_size(css_language *c, /** * Parse font-style * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_font_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -707,16 +707,16 @@ css_error parse_font_style(css_language *c, /** * Parse font-variant * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_font_variant(css_language *c, const parserutils_vector *vector, int *ctx, @@ -772,16 +772,16 @@ css_error parse_font_variant(css_language *c, /** * Parse font-weight * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_font_weight(css_language *c, const parserutils_vector *vector, int *ctx, diff --git a/src/parse/properties/generated_list.c b/src/parse/properties/generated_list.c index 423ba74..f20eade 100644 --- a/src/parse/properties/generated_list.c +++ b/src/parse/properties/generated_list.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -25,16 +25,16 @@ static css_error parse_counter_common(css_language *c, /** * Parse content * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_content(css_language *c, const parserutils_vector *vector, int *ctx, @@ -145,16 +145,16 @@ css_error parse_content(css_language *c, /** * Parse counter-increment * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_counter_increment(css_language *c, const parserutils_vector *vector, int *ctx, @@ -167,16 +167,16 @@ css_error parse_counter_increment(css_language *c, /** * Parse counter-reset * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_counter_reset(css_language *c, const parserutils_vector *vector, int *ctx, @@ -189,16 +189,16 @@ css_error parse_counter_reset(css_language *c, /** * Parse list-style * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_list_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -357,13 +357,13 @@ css_error parse_list_style(css_language *c, /* Clean up after ourselves */ cleanup: if (image) - css_stylesheet_style_destroy(c->sheet, image); + css_stylesheet_style_destroy(c->sheet, image, error == CSS_OK); if (position) - css_stylesheet_style_destroy(c->sheet, position); + css_stylesheet_style_destroy(c->sheet, position, error == CSS_OK); if (type) - css_stylesheet_style_destroy(c->sheet, type); + css_stylesheet_style_destroy(c->sheet, type, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -374,16 +374,16 @@ cleanup: /** * Parse list-style-image * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_list_style_image(css_language *c, const parserutils_vector *vector, int *ctx, @@ -459,16 +459,16 @@ css_error parse_list_style_image(css_language *c, /** * Parse list-style-position * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_list_style_position(css_language *c, const parserutils_vector *vector, int *ctx, @@ -524,16 +524,16 @@ css_error parse_list_style_position(css_language *c, /** * Parse list-style-type * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_list_style_type(css_language *c, const parserutils_vector *vector, int *ctx, @@ -548,9 +548,9 @@ css_error parse_list_style_type(css_language *c, bool match; /* IDENT (disc, circle, square, decimal, decimal-leading-zero, - * lower-roman, upper-roman, lower-greek, lower-latin, - * upper-latin, armenian, georgian, lower-alpha, upper-alpha, - * none, inherit) + * lower-roman, upper-roman, lower-greek, lower-latin, + * upper-latin, armenian, georgian, lower-alpha, upper-alpha, + * none, inherit) */ ident = parserutils_vector_iterate(vector, ctx); if (ident == NULL || ident->type != CSS_TOKEN_IDENT) { @@ -588,16 +588,16 @@ css_error parse_list_style_type(css_language *c, /** * Parse quotes * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_quotes(css_language *c, const parserutils_vector *vector, int *ctx, @@ -729,13 +729,13 @@ css_error parse_quotes(css_language *c, memcpy(ptr, &opv, sizeof(opv)); ptr += sizeof(opv); } - - lwc_string_ref(open); + + lwc_string_ref(open); memcpy(ptr, &open, sizeof(open)); ptr += sizeof(open); - lwc_string_ref(close); - memcpy(ptr, &close, sizeof(close)); + lwc_string_ref(close); + memcpy(ptr, &close, sizeof(close)); ptr += sizeof(close); first = false; @@ -758,11 +758,11 @@ css_error parse_quotes(css_language *c, /** * Parse list-style-type value * - * \param c Parsing context - * \param ident Identifier to consider - * \param value Pointer to location to receive value + * \param c Parsing context + * \param ident Identifier to consider + * \param value Pointer to location to receive value * \return CSS_OK on success, - * CSS_INVALID if the input is not valid + * CSS_INVALID if the input is not valid */ css_error parse_list_style_type_value(css_language *c, const css_token *ident, uint16_t *value) @@ -770,9 +770,9 @@ css_error parse_list_style_type_value(css_language *c, const css_token *ident, bool match; /* IDENT (disc, circle, square, decimal, decimal-leading-zero, - * lower-roman, upper-roman, lower-greek, lower-latin, - * upper-latin, armenian, georgian, lower-alpha, upper-alpha, - * none) + * lower-roman, upper-roman, lower-greek, lower-latin, + * upper-latin, armenian, georgian, lower-alpha, upper-alpha, + * none) */ if ((lwc_string_caseless_isequal( ident->idata, c->strings[DISC], @@ -843,18 +843,18 @@ css_error parse_list_style_type_value(css_language *c, const css_token *ident, /** * Parse content list * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context - * \param value Pointer to location to receive value + * \param ctx Pointer to vector iteration context + * \param value Pointer to location to receive value * \param buffer Pointer to output buffer, or NULL to read required length * \param buflen Pointer to location to receive buffer length * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_content_list(css_language *c, const parserutils_vector *vector, int *ctx, @@ -953,7 +953,7 @@ css_error parse_content_list(css_language *c, } if (buffer != NULL) { - lwc_string_ref(token->idata); + lwc_string_ref(token->idata); memcpy(buffer + offset, &token->idata, sizeof(token->idata)); } @@ -1013,7 +1013,7 @@ css_error parse_content_list(css_language *c, } if (buffer != NULL) { - lwc_string_ref(token->idata); + lwc_string_ref(token->idata); memcpy(buffer + offset, &token->idata, sizeof(token->idata)); } @@ -1107,7 +1107,7 @@ css_error parse_content_list(css_language *c, } if (buffer != NULL) { - lwc_string_ref(name); + lwc_string_ref(name); memcpy(buffer + offset, &name, sizeof(name)); } @@ -1212,14 +1212,14 @@ css_error parse_content_list(css_language *c, } if (buffer != NULL) { - lwc_string_ref(name); + lwc_string_ref(name); memcpy(buffer + offset, &name, sizeof(name)); } offset += sizeof(name); if (buffer != NULL) { - lwc_string_ref(sep); + lwc_string_ref(sep); memcpy(buffer + offset, &sep, sizeof(sep)); } @@ -1264,17 +1264,17 @@ css_error parse_content_list(css_language *c, /** * Common parser for counter-increment and counter-reset * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context - * \param op Opcode to parse for + * \param ctx Pointer to vector iteration context + * \param op Opcode to parse for * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_counter_common(css_language *c, const parserutils_vector *vector, int *ctx, @@ -1435,11 +1435,11 @@ css_error parse_counter_common(css_language *c, memcpy(ptr, &opv, sizeof(opv)); ptr += sizeof(opv); } - - lwc_string_ref(name); + + lwc_string_ref(name); memcpy(ptr, &name, sizeof(name)); ptr += sizeof(name); - + memcpy(ptr, &increment, sizeof(increment)); ptr += sizeof(increment); diff --git a/src/parse/properties/margin.c b/src/parse/properties/margin.c index 456e6ee..b3b390c 100644 --- a/src/parse/properties/margin.c +++ b/src/parse/properties/margin.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -20,16 +20,16 @@ static css_error parse_margin_side(css_language *c, /** * Parse margin shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_margin(css_language *c, const parserutils_vector *vector, int *ctx, @@ -249,15 +249,15 @@ css_error parse_margin(css_language *c, /* Clean up after ourselves */ cleanup: if (top) - css_stylesheet_style_destroy(c->sheet, top); + css_stylesheet_style_destroy(c->sheet, top, error == CSS_OK); if (right) - css_stylesheet_style_destroy(c->sheet, right); + css_stylesheet_style_destroy(c->sheet, right, error == CSS_OK); if (bottom) - css_stylesheet_style_destroy(c->sheet, bottom); + css_stylesheet_style_destroy(c->sheet, bottom, error == CSS_OK); if (left) - css_stylesheet_style_destroy(c->sheet, left); + css_stylesheet_style_destroy(c->sheet, left, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -268,16 +268,16 @@ cleanup: /** * Parse margin-bottom * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_margin_bottom(css_language *c, const parserutils_vector *vector, int *ctx, @@ -290,16 +290,16 @@ css_error parse_margin_bottom(css_language *c, /** * Parse margin-left * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_margin_left(css_language *c, const parserutils_vector *vector, int *ctx, @@ -311,16 +311,16 @@ css_error parse_margin_left(css_language *c, /** * Parse margin-right * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_margin_right(css_language *c, const parserutils_vector *vector, int *ctx, @@ -332,16 +332,16 @@ css_error parse_margin_right(css_language *c, /** * Parse margin-top * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_margin_top(css_language *c, const parserutils_vector *vector, int *ctx, @@ -353,16 +353,16 @@ css_error parse_margin_top(css_language *c, /** * Parse margin-{top,right,bottom,left} * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_margin_side(css_language *c, const parserutils_vector *vector, int *ctx, diff --git a/src/parse/properties/padding.c b/src/parse/properties/padding.c index 8562d20..767c1f1 100644 --- a/src/parse/properties/padding.c +++ b/src/parse/properties/padding.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -20,16 +20,16 @@ static css_error parse_padding_side(css_language *c, /** * Parse padding shorthand * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_padding(css_language *c, const parserutils_vector *vector, int *ctx, @@ -249,15 +249,15 @@ css_error parse_padding(css_language *c, /* Clean up after ourselves */ cleanup: if (top) - css_stylesheet_style_destroy(c->sheet, top); + css_stylesheet_style_destroy(c->sheet, top, error == CSS_OK); if (right) - css_stylesheet_style_destroy(c->sheet, right); + css_stylesheet_style_destroy(c->sheet, right, error == CSS_OK); if (bottom) - css_stylesheet_style_destroy(c->sheet, bottom); + css_stylesheet_style_destroy(c->sheet, bottom, error == CSS_OK); if (left) - css_stylesheet_style_destroy(c->sheet, left); + css_stylesheet_style_destroy(c->sheet, left, error == CSS_OK); if (ret) - css_stylesheet_style_destroy(c->sheet, ret); + css_stylesheet_style_destroy(c->sheet, ret, error == CSS_OK); if (error != CSS_OK) *ctx = orig_ctx; @@ -268,16 +268,16 @@ cleanup: /** * Parse padding-bottom * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_padding_bottom(css_language *c, const parserutils_vector *vector, int *ctx, @@ -290,16 +290,16 @@ css_error parse_padding_bottom(css_language *c, /** * Parse padding-left * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_padding_left(css_language *c, const parserutils_vector *vector, int *ctx, @@ -312,16 +312,16 @@ css_error parse_padding_left(css_language *c, /** * Parse padding-right * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_padding_right(css_language *c, const parserutils_vector *vector, int *ctx, @@ -334,16 +334,16 @@ css_error parse_padding_right(css_language *c, /** * Parse padding-top * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_padding_top(css_language *c, const parserutils_vector *vector, int *ctx, @@ -356,16 +356,16 @@ css_error parse_padding_top(css_language *c, /** * Parse padding-{top,right,bottom,left} * - * \param c Parsing context + * \param c Parsing context * \param vector Vector of tokens to process - * \param ctx Pointer to vector iteration context + * \param ctx Pointer to vector iteration context * \param result Pointer to location to receive resulting style * \return CSS_OK on success, - * CSS_NOMEM on memory exhaustion, - * CSS_INVALID if the input is not valid + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid * * Post condition: \a *ctx is updated with the next token to process - * If the input is invalid, then \a *ctx remains unchanged. + * If the input is invalid, then \a *ctx remains unchanged. */ css_error parse_padding_side(css_language *c, const parserutils_vector *vector, int *ctx, diff --git a/src/select/dispatch.c b/src/select/dispatch.c index c15465b..113ea0f 100644 --- a/src/select/dispatch.c +++ b/src/select/dispatch.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -11,796 +11,506 @@ /** * Dispatch table for properties, indexed by opcode */ +#define PROPERTY_FUNCS(pname) \ + cascade_##pname , \ + set_##pname##_from_hint, \ + initial_##pname , \ + compose_##pname , \ + destroy_##pname + struct prop_table prop_dispatch[CSS_N_PROPERTIES] = { { - cascade_azimuth, - set_azimuth_from_hint, - initial_azimuth, - compose_azimuth, + PROPERTY_FUNCS(azimuth), 1, GROUP_AURAL }, { - cascade_background_attachment, - set_background_attachment_from_hint, - initial_background_attachment, - compose_background_attachment, + PROPERTY_FUNCS(background_attachment), 0, GROUP_NORMAL }, { - cascade_background_color, - set_background_color_from_hint, - initial_background_color, - compose_background_color, + PROPERTY_FUNCS(background_color), 0, GROUP_NORMAL }, { - cascade_background_image, - set_background_image_from_hint, - initial_background_image, - compose_background_image, + PROPERTY_FUNCS(background_image), 0, GROUP_NORMAL }, { - cascade_background_position, - set_background_position_from_hint, - initial_background_position, - compose_background_position, + PROPERTY_FUNCS(background_position), 0, GROUP_NORMAL }, { - cascade_background_repeat, - set_background_repeat_from_hint, - initial_background_repeat, - compose_background_repeat, + PROPERTY_FUNCS(background_repeat), 0, GROUP_NORMAL }, { - cascade_border_collapse, - set_border_collapse_from_hint, - initial_border_collapse, - compose_border_collapse, + PROPERTY_FUNCS(border_collapse), 1, GROUP_NORMAL }, { - cascade_border_spacing, - set_border_spacing_from_hint, - initial_border_spacing, - compose_border_spacing, + PROPERTY_FUNCS(border_spacing), 1, GROUP_UNCOMMON }, { - cascade_border_top_color, - set_border_top_color_from_hint, - initial_border_top_color, - compose_border_top_color, + PROPERTY_FUNCS(border_top_color), 0, GROUP_NORMAL }, { - cascade_border_right_color, - set_border_right_color_from_hint, - initial_border_right_color, - compose_border_right_color, + PROPERTY_FUNCS(border_right_color), 0, GROUP_NORMAL }, { - cascade_border_bottom_color, - set_border_bottom_color_from_hint, - initial_border_bottom_color, - compose_border_bottom_color, + PROPERTY_FUNCS(border_bottom_color), 0, GROUP_NORMAL }, { - cascade_border_left_color, - set_border_left_color_from_hint, - initial_border_left_color, - compose_border_left_color, + PROPERTY_FUNCS(border_left_color), 0, GROUP_NORMAL }, { - cascade_border_top_style, - set_border_top_style_from_hint, - initial_border_top_style, - compose_border_top_style, + PROPERTY_FUNCS(border_top_style), 0, GROUP_NORMAL }, { - cascade_border_right_style, - set_border_right_style_from_hint, - initial_border_right_style, - compose_border_right_style, + PROPERTY_FUNCS(border_right_style), 0, GROUP_NORMAL }, { - cascade_border_bottom_style, - set_border_bottom_style_from_hint, - initial_border_bottom_style, - compose_border_bottom_style, + PROPERTY_FUNCS(border_bottom_style), 0, GROUP_NORMAL }, { - cascade_border_left_style, - set_border_left_style_from_hint, - initial_border_left_style, - compose_border_left_style, + PROPERTY_FUNCS(border_left_style), 0, GROUP_NORMAL }, { - cascade_border_top_width, - set_border_top_width_from_hint, - initial_border_top_width, - compose_border_top_width, + PROPERTY_FUNCS(border_top_width), 0, GROUP_NORMAL }, { - cascade_border_right_width, - set_border_right_width_from_hint, - initial_border_right_width, - compose_border_right_width, + PROPERTY_FUNCS(border_right_width), 0, GROUP_NORMAL }, { - cascade_border_bottom_width, - set_border_bottom_width_from_hint, - initial_border_bottom_width, - compose_border_bottom_width, + PROPERTY_FUNCS(border_bottom_width), 0, GROUP_NORMAL }, { - cascade_border_left_width, - set_border_left_width_from_hint, - initial_border_left_width, - compose_border_left_width, + PROPERTY_FUNCS(border_left_width), 0, GROUP_NORMAL }, { - cascade_bottom, - set_bottom_from_hint, - initial_bottom, - compose_bottom, + PROPERTY_FUNCS(bottom), 0, GROUP_NORMAL }, { - cascade_caption_side, - set_caption_side_from_hint, - initial_caption_side, - compose_caption_side, + PROPERTY_FUNCS(caption_side), 1, GROUP_NORMAL }, { - cascade_clear, - set_clear_from_hint, - initial_clear, - compose_clear, + PROPERTY_FUNCS(clear), 0, GROUP_NORMAL }, { - cascade_clip, - set_clip_from_hint, - initial_clip, - compose_clip, + PROPERTY_FUNCS(clip), 0, GROUP_UNCOMMON }, { - cascade_color, - set_color_from_hint, - initial_color, - compose_color, + PROPERTY_FUNCS(color), 1, GROUP_NORMAL }, { - cascade_content, - set_content_from_hint, - initial_content, - compose_content, + PROPERTY_FUNCS(content), 0, GROUP_UNCOMMON }, { - cascade_counter_increment, - set_counter_increment_from_hint, - initial_counter_increment, - compose_counter_increment, + PROPERTY_FUNCS(counter_increment), 0, GROUP_UNCOMMON }, { - cascade_counter_reset, - set_counter_reset_from_hint, - initial_counter_reset, - compose_counter_reset, + PROPERTY_FUNCS(counter_reset), 0, GROUP_UNCOMMON }, { - cascade_cue_after, - set_cue_after_from_hint, - initial_cue_after, - compose_cue_after, + PROPERTY_FUNCS(cue_after), 0, GROUP_AURAL }, { - cascade_cue_before, - set_cue_before_from_hint, - initial_cue_before, - compose_cue_before, + PROPERTY_FUNCS(cue_before), 0, GROUP_AURAL }, { - cascade_cursor, - set_cursor_from_hint, - initial_cursor, - compose_cursor, + PROPERTY_FUNCS(cursor), 1, GROUP_UNCOMMON }, { - cascade_direction, - set_direction_from_hint, - initial_direction, - compose_direction, + PROPERTY_FUNCS(direction), 1, GROUP_NORMAL }, { - cascade_display, - set_display_from_hint, - initial_display, - compose_display, + PROPERTY_FUNCS(display), 0, GROUP_NORMAL }, { - cascade_elevation, - set_elevation_from_hint, - initial_elevation, - compose_elevation, + PROPERTY_FUNCS(elevation), 1, GROUP_AURAL }, { - cascade_empty_cells, - set_empty_cells_from_hint, - initial_empty_cells, - compose_empty_cells, + PROPERTY_FUNCS(empty_cells), 1, GROUP_NORMAL }, { - cascade_float, - set_float_from_hint, - initial_float, - compose_float, + PROPERTY_FUNCS(float), 0, GROUP_NORMAL }, { - cascade_font_family, - set_font_family_from_hint, - initial_font_family, - compose_font_family, + PROPERTY_FUNCS(font_family), 1, GROUP_NORMAL }, { - cascade_font_size, - set_font_size_from_hint, - initial_font_size, - compose_font_size, + PROPERTY_FUNCS(font_size), 1, GROUP_NORMAL }, { - cascade_font_style, - set_font_style_from_hint, - initial_font_style, - compose_font_style, + PROPERTY_FUNCS(font_style), 1, GROUP_NORMAL }, { - cascade_font_variant, - set_font_variant_from_hint, - initial_font_variant, - compose_font_variant, + PROPERTY_FUNCS(font_variant), 1, GROUP_NORMAL }, { - cascade_font_weight, - set_font_weight_from_hint, - initial_font_weight, - compose_font_weight, + PROPERTY_FUNCS(font_weight), 1, GROUP_NORMAL }, { - cascade_height, - set_height_from_hint, - initial_height, - compose_height, + PROPERTY_FUNCS(height), 0, GROUP_NORMAL }, { - cascade_left, - set_left_from_hint, - initial_left, - compose_left, + PROPERTY_FUNCS(left), 0, GROUP_NORMAL }, { - cascade_letter_spacing, - set_letter_spacing_from_hint, - initial_letter_spacing, - compose_letter_spacing, + PROPERTY_FUNCS(letter_spacing), 1, GROUP_UNCOMMON }, { - cascade_line_height, - set_line_height_from_hint, - initial_line_height, - compose_line_height, + PROPERTY_FUNCS(line_height), 1, GROUP_NORMAL }, { - cascade_list_style_image, - set_list_style_image_from_hint, - initial_list_style_image, - compose_list_style_image, + PROPERTY_FUNCS(list_style_image), 1, GROUP_NORMAL }, { - cascade_list_style_position, - set_list_style_position_from_hint, - initial_list_style_position, - compose_list_style_position, + PROPERTY_FUNCS(list_style_position), 1, GROUP_NORMAL }, { - cascade_list_style_type, - set_list_style_type_from_hint, - initial_list_style_type, - compose_list_style_type, + PROPERTY_FUNCS(list_style_type), 1, GROUP_NORMAL }, { - cascade_margin_top, - set_margin_top_from_hint, - initial_margin_top, - compose_margin_top, + PROPERTY_FUNCS(margin_top), 0, GROUP_NORMAL }, { - cascade_margin_right, - set_margin_right_from_hint, - initial_margin_right, - compose_margin_right, + PROPERTY_FUNCS(margin_right), 0, GROUP_NORMAL }, { - cascade_margin_bottom, - set_margin_bottom_from_hint, - initial_margin_bottom, - compose_margin_bottom, + PROPERTY_FUNCS(margin_bottom), 0, GROUP_NORMAL }, { - cascade_margin_left, - set_margin_left_from_hint, - initial_margin_left, - compose_margin_left, + PROPERTY_FUNCS(margin_left), 0, GROUP_NORMAL }, { - cascade_max_height, - set_max_height_from_hint, - initial_max_height, - compose_max_height, + PROPERTY_FUNCS(max_height), 0, GROUP_NORMAL }, { - cascade_max_width, - set_max_width_from_hint, - initial_max_width, - compose_max_width, + PROPERTY_FUNCS(max_width), 0, GROUP_NORMAL }, { - cascade_min_height, - set_min_height_from_hint, - initial_min_height, - compose_min_height, + PROPERTY_FUNCS(min_height), 0, GROUP_NORMAL }, { - cascade_min_width, - set_min_width_from_hint, - initial_min_width, - compose_min_width, + PROPERTY_FUNCS(min_width), 0, GROUP_NORMAL }, { - cascade_orphans, - set_orphans_from_hint, - initial_orphans, - compose_orphans, + PROPERTY_FUNCS(orphans), 1, GROUP_PAGE }, { - cascade_outline_color, - set_outline_color_from_hint, - initial_outline_color, - compose_outline_color, + PROPERTY_FUNCS(outline_color), 0, GROUP_UNCOMMON }, { - cascade_outline_style, - set_outline_style_from_hint, - initial_outline_style, - compose_outline_style, + PROPERTY_FUNCS(outline_style), 0, GROUP_NORMAL }, { - cascade_outline_width, - set_outline_width_from_hint, - initial_outline_width, - compose_outline_width, + PROPERTY_FUNCS(outline_width), 0, GROUP_UNCOMMON }, { - cascade_overflow, - set_overflow_from_hint, - initial_overflow, - compose_overflow, + PROPERTY_FUNCS(overflow), 0, GROUP_NORMAL }, { - cascade_padding_top, - set_padding_top_from_hint, - initial_padding_top, - compose_padding_top, + PROPERTY_FUNCS(padding_top), 0, GROUP_NORMAL }, { - cascade_padding_right, - set_padding_right_from_hint, - initial_padding_right, - compose_padding_right, + PROPERTY_FUNCS(padding_right), 0, GROUP_NORMAL }, { - cascade_padding_bottom, - set_padding_bottom_from_hint, - initial_padding_bottom, - compose_padding_bottom, + PROPERTY_FUNCS(padding_bottom), 0, GROUP_NORMAL }, { - cascade_padding_left, - set_padding_left_from_hint, - initial_padding_left, - compose_padding_left, + PROPERTY_FUNCS(padding_left), 0, GROUP_NORMAL }, { - cascade_page_break_after, - set_page_break_after_from_hint, - initial_page_break_after, - compose_page_break_after, + PROPERTY_FUNCS(page_break_after), 0, GROUP_PAGE }, { - cascade_page_break_before, - set_page_break_before_from_hint, - initial_page_break_before, - compose_page_break_before, + PROPERTY_FUNCS(page_break_before), 0, GROUP_PAGE }, { - cascade_page_break_inside, - set_page_break_inside_from_hint, - initial_page_break_inside, - compose_page_break_inside, + PROPERTY_FUNCS(page_break_inside), 1, GROUP_PAGE }, { - cascade_pause_after, - set_pause_after_from_hint, - initial_pause_after, - compose_pause_after, + PROPERTY_FUNCS(pause_after), 0, GROUP_AURAL }, { - cascade_pause_before, - set_pause_before_from_hint, - initial_pause_before, - compose_pause_before, + PROPERTY_FUNCS(pause_before), 0, GROUP_AURAL }, { - cascade_pitch_range, - set_pitch_range_from_hint, - initial_pitch_range, - compose_pitch_range, + PROPERTY_FUNCS(pitch_range), 1, GROUP_AURAL }, { - cascade_pitch, - set_pitch_from_hint, - initial_pitch, - compose_pitch, + PROPERTY_FUNCS(pitch), 1, GROUP_AURAL }, { - cascade_play_during, - set_play_during_from_hint, - initial_play_during, - compose_play_during, + PROPERTY_FUNCS(play_during), 0, GROUP_AURAL }, { - cascade_position, - set_position_from_hint, - initial_position, - compose_position, + PROPERTY_FUNCS(position), 0, GROUP_NORMAL }, { - cascade_quotes, - set_quotes_from_hint, - initial_quotes, - compose_quotes, + PROPERTY_FUNCS(quotes), 1, GROUP_NORMAL }, { - cascade_richness, - set_richness_from_hint, - initial_richness, - compose_richness, + PROPERTY_FUNCS(richness), 1, GROUP_AURAL }, { - cascade_right, - set_right_from_hint, - initial_right, - compose_right, + PROPERTY_FUNCS(right), 0, GROUP_NORMAL }, { - cascade_speak_header, - set_speak_header_from_hint, - initial_speak_header, - compose_speak_header, + PROPERTY_FUNCS(speak_header), 1, GROUP_AURAL }, { - cascade_speak_numeral, - set_speak_numeral_from_hint, - initial_speak_numeral, - compose_speak_numeral, + PROPERTY_FUNCS(speak_numeral), 1, GROUP_AURAL }, { - cascade_speak_punctuation, - set_speak_punctuation_from_hint, - initial_speak_punctuation, - compose_speak_punctuation, + PROPERTY_FUNCS(speak_punctuation), 1, GROUP_AURAL }, { - cascade_speak, - set_speak_from_hint, - initial_speak, - compose_speak, + PROPERTY_FUNCS(speak), 1, GROUP_AURAL }, { - cascade_speech_rate, - set_speech_rate_from_hint, - initial_speech_rate, - compose_speech_rate, + PROPERTY_FUNCS(speech_rate), 1, GROUP_AURAL }, { - cascade_stress, - set_stress_from_hint, - initial_stress, - compose_stress, + PROPERTY_FUNCS(stress), 1, GROUP_AURAL }, { - cascade_table_layout, - set_table_layout_from_hint, - initial_table_layout, - compose_table_layout, + PROPERTY_FUNCS(table_layout), 0, GROUP_NORMAL }, { - cascade_text_align, - set_text_align_from_hint, - initial_text_align, - compose_text_align, + PROPERTY_FUNCS(text_align), 1, GROUP_NORMAL }, { - cascade_text_decoration, - set_text_decoration_from_hint, - initial_text_decoration, - compose_text_decoration, + PROPERTY_FUNCS(text_decoration), 0, GROUP_NORMAL }, { - cascade_text_indent, - set_text_indent_from_hint, - initial_text_indent, - compose_text_indent, + PROPERTY_FUNCS(text_indent), 1, GROUP_NORMAL }, { - cascade_text_transform, - set_text_transform_from_hint, - initial_text_transform, - compose_text_transform, + PROPERTY_FUNCS(text_transform), 1, GROUP_NORMAL }, { - cascade_top, - set_top_from_hint, - initial_top, - compose_top, + PROPERTY_FUNCS(top), 0, GROUP_NORMAL }, { - cascade_unicode_bidi, - set_unicode_bidi_from_hint, - initial_unicode_bidi, - compose_unicode_bidi, + PROPERTY_FUNCS(unicode_bidi), 0, GROUP_NORMAL }, { - cascade_vertical_align, - set_vertical_align_from_hint, - initial_vertical_align, - compose_vertical_align, + PROPERTY_FUNCS(vertical_align), 0, GROUP_NORMAL }, { - cascade_visibility, - set_visibility_from_hint, - initial_visibility, - compose_visibility, + PROPERTY_FUNCS(visibility), 1, GROUP_NORMAL }, { - cascade_voice_family, - set_voice_family_from_hint, - initial_voice_family, - compose_voice_family, + PROPERTY_FUNCS(voice_family), 1, GROUP_AURAL }, { - cascade_volume, - set_volume_from_hint, - initial_volume, - compose_volume, + PROPERTY_FUNCS(volume), 1, GROUP_AURAL }, { - cascade_white_space, - set_white_space_from_hint, - initial_white_space, - compose_white_space, + PROPERTY_FUNCS(white_space), 1, GROUP_NORMAL }, { - cascade_widows, - set_widows_from_hint, - initial_widows, - compose_widows, + PROPERTY_FUNCS(widows), 1, GROUP_PAGE }, { - cascade_width, - set_width_from_hint, - initial_width, - compose_width, + PROPERTY_FUNCS(width), 0, GROUP_NORMAL }, { - cascade_word_spacing, - set_word_spacing_from_hint, - initial_word_spacing, - compose_word_spacing, + PROPERTY_FUNCS(word_spacing), 1, GROUP_UNCOMMON }, { - cascade_z_index, - set_z_index_from_hint, - initial_z_index, - compose_z_index, + PROPERTY_FUNCS(z_index), 0, GROUP_NORMAL } diff --git a/src/select/dispatch.h b/src/select/dispatch.h index 9877458..6aa61ab 100644 --- a/src/select/dispatch.h +++ b/src/select/dispatch.h @@ -1,7 +1,7 @@ /* * This file is part of LibCSS * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -36,9 +36,9 @@ extern struct prop_table { css_error (*compose)(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result); - - unsigned int inherited : 1, - group : 2; + uint32_t (*destroy)(void *bytecode); + unsigned int inherited; + unsigned int group; } prop_dispatch[CSS_N_PROPERTIES]; #endif diff --git a/src/select/properties.c b/src/select/properties.c index 3974f1e..5342964 100644 --- a/src/select/properties.c +++ b/src/select/properties.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 John-Mark Bell */ @@ -56,6 +56,42 @@ static css_error cascade_counter_increment_reset(uint32_t opv, css_style *style, css_error (*fun)(css_computed_style *, uint8_t, css_computed_counter *)); +/* Generic destructors */ + +static uint32_t generic_destroy_color(void *bytecode) +{ + return sizeof(uint32_t) + + ((getValue(*((uint32_t*)bytecode)) == BACKGROUND_COLOR_SET) ? sizeof(css_color) : 0); +} + +static uint32_t generic_destroy_uri(void *bytecode) +{ + bool has_uri = (getValue(*((uint32_t*)bytecode)) & BACKGROUND_IMAGE_URI) == BACKGROUND_IMAGE_URI; + + if (has_uri) { + lwc_string *str = *(lwc_string **)(((uint8_t*)bytecode) + sizeof(uint32_t)); + lwc_string_unref(str); + } + return sizeof(uint32_t) + (has_uri ? sizeof(lwc_string*) : 0); +} + +static uint32_t generic_destroy_length(void *bytecode) +{ + bool has_length = (getValue(*((uint32_t*)bytecode)) & BORDER_WIDTH_SET) == BORDER_WIDTH_SET; + + return sizeof(uint32_t) + (has_length ? sizeof(css_fixed) + sizeof(uint32_t) : 0); +} + +static uint32_t generic_destroy_number(void *bytecode) +{ + uint32_t value = getValue(*((uint32_t*)bytecode)); + bool has_number = (value == ORPHANS_SET); + + return sizeof(uint32_t) + (has_number ? sizeof(css_fixed) : 0); +} + +/* Useful helpers */ + css_unit to_css_unit(uint32_t u) { switch (u) { @@ -152,6 +188,14 @@ css_error compose_azimuth(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_azimuth(void *bytecode) +{ + bool has_angle = (((getValue(*(uint32_t*)bytecode) & (1<<7)) != 0)); + uint32_t extra_size = has_angle ? (sizeof(css_fixed) + sizeof(uint32_t)) : 0; + + return sizeof(uint32_t) + extra_size; +} + css_error cascade_background_attachment(uint32_t opv, css_style *style, css_select_state *state) { @@ -203,6 +247,13 @@ css_error compose_background_attachment(const css_computed_style *parent, return set_background_attachment(result, type); } +uint32_t destroy_background_attachment(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_background_color(uint32_t opv, css_style *style, css_select_state *state) { @@ -235,6 +286,11 @@ css_error compose_background_color(const css_computed_style *parent, return set_background_color(result, type, color); } +uint32_t destroy_background_color(void *bytecode) +{ + return generic_destroy_color(bytecode); +} + css_error cascade_background_image(uint32_t opv, css_style *style, css_select_state *state) { @@ -267,6 +323,11 @@ css_error compose_background_image(const css_computed_style *parent, return set_background_image(result, type, url); } +uint32_t destroy_background_image(void *bytecode) +{ + return generic_destroy_uri(bytecode); +} + css_error cascade_background_position(uint32_t opv, css_style *style, css_select_state *state) { @@ -368,6 +429,19 @@ css_error compose_background_position(const css_computed_style *parent, } +uint32_t destroy_background_position(void *bytecode) +{ + uint32_t value = getValue(*((uint32_t*)bytecode)); + uint32_t extra_size = 0; + + if ((value & 0x0f) == BACKGROUND_POSITION_VERT_SET) + extra_size += sizeof(css_fixed) + sizeof(uint32_t); + if ((value & 0xf0) == BACKGROUND_POSITION_HORZ_SET) + extra_size += sizeof(css_fixed) + sizeof(uint32_t); + + return sizeof(uint32_t) + extra_size; +} + css_error cascade_background_repeat(uint32_t opv, css_style *style, css_select_state *state) { @@ -425,6 +499,13 @@ css_error compose_background_repeat(const css_computed_style *parent, return set_background_repeat(result, type); } +uint32_t destroy_background_repeat(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_border_collapse(uint32_t opv, css_style *style, css_select_state *state) { @@ -475,6 +556,13 @@ css_error compose_border_collapse(const css_computed_style *parent, return set_border_collapse(result, type); } +uint32_t destroy_border_collapse(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_border_spacing(uint32_t opv, css_style *style, css_select_state *state) { @@ -548,6 +636,13 @@ css_error compose_border_spacing(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_border_spacing(void *bytecode) +{ + bool has_values = (getValue(*((uint32_t*)bytecode)) == BORDER_SPACING_SET); + + return sizeof(uint32_t) + (has_values ? (sizeof(css_fixed) + sizeof(uint32_t)) * 2 : 0); +} + css_error cascade_border_top_color(uint32_t opv, css_style *style, css_select_state *state) { @@ -579,6 +674,11 @@ css_error compose_border_top_color(const css_computed_style *parent, return set_border_top_color(result, type, color); } +uint32_t destroy_border_top_color(void *bytecode) +{ + return generic_destroy_color(bytecode); +} + css_error cascade_border_right_color(uint32_t opv, css_style *style, css_select_state *state) { @@ -612,6 +712,11 @@ css_error compose_border_right_color(const css_computed_style *parent, return set_border_right_color(result, type, color); } +uint32_t destroy_border_right_color(void *bytecode) +{ + return generic_destroy_color(bytecode); +} + css_error cascade_border_bottom_color(uint32_t opv, css_style *style, css_select_state *state) { @@ -645,6 +750,11 @@ css_error compose_border_bottom_color(const css_computed_style *parent, return set_border_bottom_color(result, type, color); } +uint32_t destroy_border_bottom_color(void *bytecode) +{ + return generic_destroy_color(bytecode); +} + css_error cascade_border_left_color(uint32_t opv, css_style *style, css_select_state *state) { @@ -678,6 +788,11 @@ css_error compose_border_left_color(const css_computed_style *parent, return set_border_left_color(result, type, color); } +uint32_t destroy_border_left_color(void *bytecode) +{ + return generic_destroy_color(bytecode); +} + css_error cascade_border_top_style(uint32_t opv, css_style *style, css_select_state *state) { @@ -708,6 +823,13 @@ css_error compose_border_top_style(const css_computed_style *parent, return set_border_top_style(result, type); } +uint32_t destroy_border_top_style(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_border_right_style(uint32_t opv, css_style *style, css_select_state *state) { @@ -738,6 +860,13 @@ css_error compose_border_right_style(const css_computed_style *parent, return set_border_right_style(result, type); } +uint32_t destroy_border_right_style(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_border_bottom_style(uint32_t opv, css_style *style, css_select_state *state) { @@ -768,6 +897,13 @@ css_error compose_border_bottom_style(const css_computed_style *parent, return set_border_bottom_style(result, type); } +uint32_t destroy_border_bottom_style(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_border_left_style(uint32_t opv, css_style *style, css_select_state *state) { @@ -798,6 +934,13 @@ css_error compose_border_left_style(const css_computed_style *parent, return set_border_left_style(result, type); } +uint32_t destroy_border_left_style(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_border_top_width(uint32_t opv, css_style *style, css_select_state *state) { @@ -832,6 +975,11 @@ css_error compose_border_top_width(const css_computed_style *parent, return set_border_top_width(result, type, length, unit); } +uint32_t destroy_border_top_width(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_border_right_width(uint32_t opv, css_style *style, css_select_state *state) { @@ -866,6 +1014,11 @@ css_error compose_border_right_width(const css_computed_style *parent, return set_border_right_width(result, type, length, unit); } +uint32_t destroy_border_right_width(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_border_bottom_width(uint32_t opv, css_style *style, css_select_state *state) { @@ -900,6 +1053,11 @@ css_error compose_border_bottom_width(const css_computed_style *parent, return set_border_bottom_width(result, type, length, unit); } +uint32_t destroy_border_bottom_width(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_border_left_width(uint32_t opv, css_style *style, css_select_state *state) { @@ -934,6 +1092,11 @@ css_error compose_border_left_width(const css_computed_style *parent, return set_border_left_width(result, type, length, unit); } +uint32_t destroy_border_left_width(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_bottom(uint32_t opv, css_style *style, css_select_state *state) { @@ -967,6 +1130,11 @@ css_error compose_bottom(const css_computed_style *parent, return set_bottom(result, type, length, unit); } +uint32_t destroy_bottom(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_caption_side(uint32_t opv, css_style *style, css_select_state *state) { @@ -1017,6 +1185,13 @@ css_error compose_caption_side(const css_computed_style *parent, return set_caption_side(result, type); } +uint32_t destroy_caption_side(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_clear(uint32_t opv, css_style *style, css_select_state *state) { @@ -1073,6 +1248,13 @@ css_error compose_clear(const css_computed_style *parent, return set_clear(result, type); } +uint32_t destroy_clear(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_clip(uint32_t opv, css_style *style, css_select_state *state) { @@ -1174,6 +1356,26 @@ css_error compose_clip(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_clip(void *bytecode) +{ + uint32_t value = getValue(*((uint32_t*)bytecode)); + bool has_rect = value & CLIP_SHAPE_RECT; + bool nonautos = 0; + + if (has_rect) { + if ((value & CLIP_RECT_TOP_AUTO) == 0) + nonautos += 1; + if ((value & CLIP_RECT_RIGHT_AUTO) == 0) + nonautos += 1; + if ((value & CLIP_RECT_BOTTOM_AUTO) == 0) + nonautos += 1; + if ((value & CLIP_RECT_LEFT_AUTO) == 0) + nonautos += 1; + } + + return sizeof(uint32_t) + ((sizeof(css_fixed) + sizeof(uint32_t)) * nonautos); +} + css_error cascade_color(uint32_t opv, css_style *style, css_select_state *state) { @@ -1227,6 +1429,11 @@ css_error compose_color(const css_computed_style *parent, return set_color(result, type, color); } +uint32_t destroy_color(void *bytecode) +{ + return generic_destroy_color(bytecode); +} + css_error cascade_content(uint32_t opv, css_style *style, css_select_state *state) { @@ -1243,12 +1450,12 @@ css_error cascade_content(uint32_t opv, css_style *style, value = CSS_CONTENT_NONE; } else { value = CSS_CONTENT_SET; - - while (v != CONTENT_NORMAL) { - lwc_string *he = *((lwc_string **) style->bytecode); - css_computed_content_item *temp; - - temp = state->result->alloc(content, + + while (v != CONTENT_NORMAL) { + lwc_string *he = *((lwc_string **) style->bytecode); + css_computed_content_item *temp; + + temp = state->result->alloc(content, (n_contents + 1) * sizeof(css_computed_content_item), state->result->pw); @@ -1451,6 +1658,41 @@ css_error compose_content(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_content(void *bytecode) +{ + uint32_t consumed = sizeof(uint32_t); + uint32_t value = getValue(*((uint32_t*)bytecode)); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + + if (value == CONTENT_NONE || value == CONTENT_NORMAL) + return sizeof(uint32_t); + + while (value != 0) { + switch (value & 0xff) { + case CONTENT_COUNTERS: { + lwc_string *str = *(lwc_string **)bytecode; + lwc_string_unref(str); + consumed += sizeof(lwc_string*); + bytecode = (uint8_t*)bytecode + sizeof(lwc_string *); + } + case CONTENT_STRING: + case CONTENT_URI: + case CONTENT_COUNTER: + case CONTENT_ATTR: { + lwc_string *str = *(lwc_string **)bytecode; + lwc_string_unref(str); + consumed += sizeof(lwc_string*); + bytecode = (uint8_t*)bytecode + sizeof(lwc_string *); + } + } + consumed += sizeof(uint32_t); + value = *((uint32_t*)bytecode); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + } + + return consumed; +} + css_error cascade_counter_increment(uint32_t opv, css_style *style, css_select_state *state) { @@ -1540,6 +1782,28 @@ css_error compose_counter_increment(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_counter_increment(void *bytecode) +{ + uint32_t consumed = sizeof(uint32_t); + uint32_t value = getValue(*((uint32_t*)bytecode)); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + + if (value == COUNTER_INCREMENT_NAMED) { + while (value != COUNTER_INCREMENT_NONE) { + lwc_string *str = *((lwc_string **)bytecode); + consumed += sizeof(lwc_string*) + sizeof(css_fixed); + bytecode = ((uint8_t*)bytecode) + sizeof(lwc_string*) + sizeof(css_fixed); + lwc_string_unref(str); + + consumed += sizeof(uint32_t); + value = *((uint32_t*)bytecode); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + } + } + + return consumed; +} + css_error cascade_counter_reset(uint32_t opv, css_style *style, css_select_state *state) { @@ -1628,6 +1892,28 @@ css_error compose_counter_reset(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_counter_reset(void *bytecode) +{ + uint32_t consumed = sizeof(uint32_t); + uint32_t value = getValue(*((uint32_t*)bytecode)); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + + if (value == COUNTER_INCREMENT_NAMED) { + while (value != COUNTER_INCREMENT_NONE) { + lwc_string *str = *((lwc_string **)bytecode); + consumed += sizeof(lwc_string*) + sizeof(css_fixed); + bytecode = ((uint8_t*)bytecode) + sizeof(lwc_string*) + sizeof(css_fixed); + lwc_string_unref(str); + + consumed += sizeof(uint32_t); + value = *((uint32_t*)bytecode); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + } + } + + return consumed; +} + css_error cascade_cue_after(uint32_t opv, css_style *style, css_select_state *state) { @@ -1662,6 +1948,11 @@ css_error compose_cue_after(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_cue_after(void *bytecode) +{ + return generic_destroy_uri(bytecode); +} + css_error cascade_cue_before(uint32_t opv, css_style *style, css_select_state *state) { @@ -1696,6 +1987,11 @@ css_error compose_cue_before(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_cue_before(void *bytecode) +{ + return generic_destroy_uri(bytecode); +} + css_error cascade_cursor(uint32_t opv, css_style *style, css_select_state *state) { @@ -1902,6 +2198,26 @@ css_error compose_cursor(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_cursor(void *bytecode) +{ + uint32_t consumed = sizeof(uint32_t); + uint32_t value = getValue(*((uint32_t*)bytecode)); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + + while (value == CURSOR_URI) { + lwc_string *str = *((lwc_string **)bytecode); + consumed += sizeof(lwc_string*); + bytecode = ((uint8_t*)bytecode) + sizeof(lwc_string*); + lwc_string_unref(str); + + consumed += sizeof(uint32_t); + value = *((uint32_t*)bytecode); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + } + + return consumed; +} + css_error cascade_direction(uint32_t opv, css_style *style, css_select_state *state) { @@ -1952,6 +2268,13 @@ css_error compose_direction(const css_computed_style *parent, return set_direction(result, type); } +uint32_t destroy_direction(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_display(uint32_t opv, css_style *style, css_select_state *state) { @@ -2044,6 +2367,13 @@ css_error compose_display(const css_computed_style *parent, return set_display(result, type); } +uint32_t destroy_display(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_elevation(uint32_t opv, css_style *style, css_select_state *state) { @@ -2109,6 +2439,11 @@ css_error compose_elevation(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_elevation(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_empty_cells(uint32_t opv, css_style *style, css_select_state *state) { @@ -2159,6 +2494,13 @@ css_error compose_empty_cells(const css_computed_style *parent, return set_empty_cells(result, type); } +uint32_t destroy_empty_cells(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_float(uint32_t opv, css_style *style, css_select_state *state) { @@ -2212,6 +2554,13 @@ css_error compose_float(const css_computed_style *parent, return set_float(result, type); } +uint32_t destroy_float(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_font_family(uint32_t opv, css_style *style, css_select_state *state) { @@ -2400,6 +2749,28 @@ css_error compose_font_family(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_font_family(void *bytecode) +{ + uint32_t consumed = sizeof(uint32_t); + uint32_t value = getValue(*((uint32_t*)bytecode)); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + + while (value != FONT_FAMILY_END) { + if (value == FONT_FAMILY_STRING || value == FONT_FAMILY_IDENT_LIST) { + lwc_string *str = *((lwc_string **)bytecode); + consumed += sizeof(lwc_string*); + bytecode = ((uint8_t*)bytecode) + sizeof(lwc_string*); + lwc_string_unref(str); + } + + consumed += sizeof(uint32_t); + value = *((uint32_t*)bytecode); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + } + + return consumed; +} + css_error cascade_font_size(uint32_t opv, css_style *style, css_select_state *state) { @@ -2486,6 +2857,11 @@ css_error compose_font_size(const css_computed_style *parent, return set_font_size(result, type, size, unit); } +uint32_t destroy_font_size(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_font_style(uint32_t opv, css_style *style, css_select_state *state) { @@ -2539,6 +2915,13 @@ css_error compose_font_style(const css_computed_style *parent, return set_font_style(result, type); } +uint32_t destroy_font_style(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_font_variant(uint32_t opv, css_style *style, css_select_state *state) { @@ -2589,6 +2972,13 @@ css_error compose_font_variant(const css_computed_style *parent, return set_font_variant(result, type); } +uint32_t destroy_font_variant(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_font_weight(uint32_t opv, css_style *style, css_select_state *state) { @@ -2672,6 +3062,13 @@ css_error compose_font_weight(const css_computed_style *parent, return set_font_weight(result, type); } +uint32_t destroy_font_weight(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_height(uint32_t opv, css_style *style, css_select_state *state) { @@ -2705,6 +3102,11 @@ css_error compose_height(const css_computed_style *parent, return set_height(result, type, length, unit); } +uint32_t destroy_height(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_left(uint32_t opv, css_style *style, css_select_state *state) { @@ -2738,6 +3140,11 @@ css_error compose_left(const css_computed_style *parent, return set_left(result, type, length, unit); } +uint32_t destroy_left(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_letter_spacing(uint32_t opv, css_style *style, css_select_state *state) { @@ -2779,6 +3186,11 @@ css_error compose_letter_spacing(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_letter_spacing(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_line_height(uint32_t opv, css_style *style, css_select_state *state) { @@ -2844,6 +3256,15 @@ css_error compose_line_height(const css_computed_style *parent, return set_line_height(result, type, length, unit); } +uint32_t destroy_line_height(void *bytecode) +{ + uint32_t value = getValue(*((uint32_t*)bytecode)); + if (value == LINE_HEIGHT_NUMBER) + return generic_destroy_number(bytecode); + else + return generic_destroy_length(bytecode); +} + css_error cascade_list_style_image(uint32_t opv, css_style *style, css_select_state *state) { @@ -2876,6 +3297,11 @@ css_error compose_list_style_image(const css_computed_style *parent, return set_list_style_image(result, type, url); } +uint32_t destroy_list_style_image(void *bytecode) +{ + return generic_destroy_uri(bytecode); +} + css_error cascade_list_style_position(uint32_t opv, css_style *style, css_select_state *state) { @@ -2927,6 +3353,13 @@ css_error compose_list_style_position(const css_computed_style *parent, return set_list_style_position(result, type); } +uint32_t destroy_list_style_position(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_list_style_type(uint32_t opv, css_style *style, css_select_state *state) { @@ -3016,6 +3449,13 @@ css_error compose_list_style_type(const css_computed_style *parent, return set_list_style_type(result, type); } +uint32_t destroy_list_style_type(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_margin_top(uint32_t opv, css_style *style, css_select_state *state) { @@ -3049,6 +3489,11 @@ css_error compose_margin_top(const css_computed_style *parent, return set_margin_top(result, type, length, unit); } +uint32_t destroy_margin_top(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_margin_right(uint32_t opv, css_style *style, css_select_state *state) { @@ -3082,6 +3527,11 @@ css_error compose_margin_right(const css_computed_style *parent, return set_margin_right(result, type, length, unit); } +uint32_t destroy_margin_right(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_margin_bottom(uint32_t opv, css_style *style, css_select_state *state) { @@ -3115,6 +3565,11 @@ css_error compose_margin_bottom(const css_computed_style *parent, return set_margin_bottom(result, type, length, unit); } +uint32_t destroy_margin_bottom(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_margin_left(uint32_t opv, css_style *style, css_select_state *state) { @@ -3148,6 +3603,11 @@ css_error compose_margin_left(const css_computed_style *parent, return set_margin_left(result, type, length, unit); } +uint32_t destroy_margin_left(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_max_height(uint32_t opv, css_style *style, css_select_state *state) { @@ -3182,6 +3642,11 @@ css_error compose_max_height(const css_computed_style *parent, return set_max_height(result, type, length, unit); } +uint32_t destroy_max_height(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_max_width(uint32_t opv, css_style *style, css_select_state *state) { @@ -3215,6 +3680,11 @@ css_error compose_max_width(const css_computed_style *parent, return set_max_width(result, type, length, unit); } +uint32_t destroy_max_width(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_min_height(uint32_t opv, css_style *style, css_select_state *state) { @@ -3249,6 +3719,11 @@ css_error compose_min_height(const css_computed_style *parent, return set_min_height(result, type, length, unit); } +uint32_t destroy_min_height(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_min_width(uint32_t opv, css_style *style, css_select_state *state) { @@ -3282,6 +3757,11 @@ css_error compose_min_width(const css_computed_style *parent, return set_min_width(result, type, length, unit); } +uint32_t destroy_min_width(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_orphans(uint32_t opv, css_style *style, css_select_state *state) { @@ -3316,6 +3796,11 @@ css_error compose_orphans(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_orphans(void *bytecode) +{ + return generic_destroy_number(bytecode); +} + css_error cascade_outline_color(uint32_t opv, css_style *style, css_select_state *state) { @@ -3375,6 +3860,11 @@ css_error compose_outline_color(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_outline_color(void *bytecode) +{ + return generic_destroy_color(bytecode); +} + css_error cascade_outline_style(uint32_t opv, css_style *style, css_select_state *state) { @@ -3405,6 +3895,13 @@ css_error compose_outline_style(const css_computed_style *parent, return set_outline_style(result, type); } +uint32_t destroy_outline_style(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_outline_width(uint32_t opv, css_style *style, css_select_state *state) { @@ -3446,6 +3943,11 @@ css_error compose_outline_width(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_outline_width(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_overflow(uint32_t opv, css_style *style, css_select_state *state) { @@ -3502,6 +4004,13 @@ css_error compose_overflow(const css_computed_style *parent, return set_overflow(result, type); } +uint32_t destroy_overflow(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_padding_top(uint32_t opv, css_style *style, css_select_state *state) { @@ -3535,6 +4044,11 @@ css_error compose_padding_top(const css_computed_style *parent, return set_padding_top(result, type, length, unit); } +uint32_t destroy_padding_top(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_padding_right(uint32_t opv, css_style *style, css_select_state *state) { @@ -3569,6 +4083,11 @@ css_error compose_padding_right(const css_computed_style *parent, return set_padding_right(result, type, length, unit); } +uint32_t destroy_padding_right(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_padding_bottom(uint32_t opv, css_style *style, css_select_state *state) { @@ -3603,6 +4122,11 @@ css_error compose_padding_bottom(const css_computed_style *parent, return set_padding_bottom(result, type, length, unit); } +uint32_t destroy_padding_bottom(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_padding_left(uint32_t opv, css_style *style, css_select_state *state) { @@ -3636,6 +4160,11 @@ css_error compose_padding_left(const css_computed_style *parent, return set_padding_left(result, type, length, unit); } +uint32_t destroy_padding_left(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_page_break_after(uint32_t opv, css_style *style, css_select_state *state) { @@ -3670,6 +4199,13 @@ css_error compose_page_break_after(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_page_break_after(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_page_break_before(uint32_t opv, css_style *style, css_select_state *state) { @@ -3704,6 +4240,13 @@ css_error compose_page_break_before(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_page_break_before(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_page_break_inside(uint32_t opv, css_style *style, css_select_state *state) { @@ -3756,6 +4299,13 @@ css_error compose_page_break_inside(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_page_break_inside(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_pause_after(uint32_t opv, css_style *style, css_select_state *state) { @@ -3790,6 +4340,11 @@ css_error compose_pause_after(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_pause_after(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_pause_before(uint32_t opv, css_style *style, css_select_state *state) { @@ -3824,6 +4379,11 @@ css_error compose_pause_before(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_pause_before(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_pitch_range(uint32_t opv, css_style *style, css_select_state *state) { @@ -3858,6 +4418,11 @@ css_error compose_pitch_range(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_pitch_range(void *bytecode) +{ + return generic_destroy_number(bytecode); +} + css_error cascade_pitch(uint32_t opv, css_style *style, css_select_state *state) { @@ -3922,6 +4487,11 @@ css_error compose_pitch(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_pitch(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_play_during(uint32_t opv, css_style *style, css_select_state *state) { @@ -3980,6 +4550,11 @@ css_error compose_play_during(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_play_during(void *bytecode) +{ + return generic_destroy_uri(bytecode); +} + css_error cascade_position(uint32_t opv, css_style *style, css_select_state *state) { @@ -4036,6 +4611,13 @@ css_error compose_position(const css_computed_style *parent, return set_position(result, type); } +uint32_t destroy_position(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_quotes(uint32_t opv, css_style *style, css_select_state *state) { @@ -4197,6 +4779,27 @@ css_error compose_quotes(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_quotes(void *bytecode) +{ + uint32_t consumed = sizeof(uint32_t); + uint32_t value = getValue(*((uint32_t*)bytecode)); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + + while (value == QUOTES_STRING) { + lwc_string **str = ((lwc_string **)bytecode); + consumed += sizeof(lwc_string*) * 2; + bytecode = ((uint8_t*)bytecode) + (sizeof(lwc_string*) * 2); + lwc_string_unref(str[0]); + lwc_string_unref(str[1]); + + consumed += sizeof(uint32_t); + value = *((uint32_t*)bytecode); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + } + + return consumed; +} + css_error cascade_richness(uint32_t opv, css_style *style, css_select_state *state) { @@ -4231,6 +4834,11 @@ css_error compose_richness(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_richness(void *bytecode) +{ + return generic_destroy_number(bytecode); +} + css_error cascade_right(uint32_t opv, css_style *style, css_select_state *state) { @@ -4264,6 +4872,11 @@ css_error compose_right(const css_computed_style *parent, return set_right(result, type, length, unit); } +uint32_t destroy_right(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_speak_header(uint32_t opv, css_style *style, css_select_state *state) { @@ -4316,6 +4929,13 @@ css_error compose_speak_header(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_speak_header(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_speak_numeral(uint32_t opv, css_style *style, css_select_state *state) { @@ -4368,6 +4988,13 @@ css_error compose_speak_numeral(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_speak_numeral(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_speak_punctuation( uint32_t opv, css_style *style, css_select_state *state) { @@ -4420,6 +5047,13 @@ css_error compose_speak_punctuation(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_speak_punctuation(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_speak(uint32_t opv, css_style *style, css_select_state *state) { @@ -4473,6 +5107,13 @@ css_error compose_speak(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_speak(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_speech_rate(uint32_t opv, css_style *style, css_select_state *state) { @@ -4534,6 +5175,11 @@ css_error compose_speech_rate(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_speech_rate(void *bytecode) +{ + return generic_destroy_number(bytecode); +} + css_error cascade_stress(uint32_t opv, css_style *style, css_select_state *state) { @@ -4568,6 +5214,11 @@ css_error compose_stress(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_stress(void *bytecode) +{ + return generic_destroy_number(bytecode); +} + css_error cascade_table_layout(uint32_t opv, css_style *style, css_select_state *state) { @@ -4618,6 +5269,13 @@ css_error compose_table_layout(const css_computed_style *parent, return set_table_layout(result, type); } +uint32_t destroy_table_layout(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_text_align(uint32_t opv, css_style *style, css_select_state *state) { @@ -4694,6 +5352,13 @@ css_error compose_text_align(const css_computed_style *parent, return set_text_align(result, type); } +uint32_t destroy_text_align(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_text_decoration(uint32_t opv, css_style *style, css_select_state *state) { @@ -4750,6 +5415,13 @@ css_error compose_text_decoration(const css_computed_style *parent, return set_text_decoration(result, type); } +uint32_t destroy_text_decoration(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_text_indent(uint32_t opv, css_style *style, css_select_state *state) { @@ -4784,6 +5456,11 @@ css_error compose_text_indent(const css_computed_style *parent, return set_text_indent(result, type, length, unit); } +uint32_t destroy_text_indent(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_text_transform(uint32_t opv, css_style *style, css_select_state *state) { @@ -4840,6 +5517,13 @@ css_error compose_text_transform(const css_computed_style *parent, return set_text_transform(result, type); } +uint32_t destroy_text_transform(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_top(uint32_t opv, css_style *style, css_select_state *state) { @@ -4873,6 +5557,11 @@ css_error compose_top(const css_computed_style *parent, return set_top(result, type, length, unit); } +uint32_t destroy_top(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_unicode_bidi(uint32_t opv, css_style *style, css_select_state *state) { @@ -4926,6 +5615,13 @@ css_error compose_unicode_bidi(const css_computed_style *parent, return set_unicode_bidi(result, type); } +uint32_t destroy_unicode_bidi(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_vertical_align(uint32_t opv, css_style *style, css_select_state *state) { @@ -5008,6 +5704,11 @@ css_error compose_vertical_align(const css_computed_style *parent, return set_vertical_align(result, type, length, unit); } +uint32_t destroy_vertical_align(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_visibility(uint32_t opv, css_style *style, css_select_state *state) { @@ -5061,6 +5762,13 @@ css_error compose_visibility(const css_computed_style *parent, return set_visibility(result, type); } +uint32_t destroy_visibility(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_voice_family(uint32_t opv, css_style *style, css_select_state *state) { @@ -5181,6 +5889,28 @@ css_error compose_voice_family(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_voice_family(void *bytecode) +{ + uint32_t consumed = sizeof(uint32_t); + uint32_t value = getValue(*((uint32_t*)bytecode)); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + + while (value != VOICE_FAMILY_END) { + if (value == VOICE_FAMILY_STRING || value == VOICE_FAMILY_IDENT_LIST) { + lwc_string *str = *((lwc_string **)bytecode); + consumed += sizeof(lwc_string*); + bytecode = ((uint8_t*)bytecode) + sizeof(lwc_string*); + lwc_string_unref(str); + } + + consumed += sizeof(uint32_t); + value = *((uint32_t*)bytecode); + bytecode = ((uint8_t*)bytecode) + sizeof(uint32_t); + } + + return consumed; +} + css_error cascade_volume(uint32_t opv, css_style *style, css_select_state *state) { @@ -5252,6 +5982,18 @@ css_error compose_volume(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_volume(void *bytecode) +{ + uint32_t value = getValue(*((uint32_t*)bytecode)); + uint32_t additional = 0; + if (value == VOLUME_NUMBER) + additional = sizeof(css_fixed); + else if (value == VOLUME_DIMENSION) + additional = sizeof(css_fixed) + sizeof(uint32_t); + + return sizeof(uint32_t) + additional; +} + css_error cascade_white_space(uint32_t opv, css_style *style, css_select_state *state) { @@ -5311,6 +6053,13 @@ css_error compose_white_space(const css_computed_style *parent, return set_white_space(result, type); } +uint32_t destroy_white_space(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} + css_error cascade_widows(uint32_t opv, css_style *style, css_select_state *state) { @@ -5345,6 +6094,11 @@ css_error compose_widows(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_widows(void *bytecode) +{ + return generic_destroy_number(bytecode); +} + css_error cascade_width(uint32_t opv, css_style *style, css_select_state *state) { @@ -5378,6 +6132,11 @@ css_error compose_width(const css_computed_style *parent, return set_width(result, type, length, unit); } +uint32_t destroy_width(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_word_spacing(uint32_t opv, css_style *style, css_select_state *state) { @@ -5419,6 +6178,11 @@ css_error compose_word_spacing(const css_computed_style *parent, return CSS_OK; } +uint32_t destroy_word_spacing(void *bytecode) +{ + return generic_destroy_length(bytecode); +} + css_error cascade_z_index(uint32_t opv, css_style *style, css_select_state *state) { @@ -5472,8 +6236,13 @@ css_error compose_z_index(const css_computed_style *parent, return set_z_index(result, type, index); } +uint32_t destroy_z_index(void *bytecode) +{ + return generic_destroy_number(bytecode); +} + /****************************************************************************** - * Utilities below here * + * Utilities below here * ******************************************************************************/ css_error cascade_bg_border_color(uint32_t opv, css_style *style, css_select_state *state, diff --git a/src/select/properties.h b/src/select/properties.h index 9c98e10..0d9cd72 100644 --- a/src/select/properties.h +++ b/src/select/properties.h @@ -14,798 +14,113 @@ #include "stylesheet.h" #include "select/select.h" -css_error cascade_azimuth(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_azimuth_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_azimuth(css_select_state *state); -css_error compose_azimuth(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_background_attachment(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_background_attachment_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_background_attachment(css_select_state *state); -css_error compose_background_attachment(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_background_color(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_background_color_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_background_color(css_select_state *state); -css_error compose_background_color(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_background_image(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_background_image_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_background_image(css_select_state *state); -css_error compose_background_image(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_background_position(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_background_position_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_background_position(css_select_state *state); -css_error compose_background_position(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_background_repeat(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_background_repeat_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_background_repeat(css_select_state *state); -css_error compose_background_repeat(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_collapse(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_collapse_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_collapse(css_select_state *state); -css_error compose_border_collapse(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_spacing(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_spacing_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_spacing(css_select_state *state); -css_error compose_border_spacing(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_top_color(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_top_color_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_top_color(css_select_state *state); -css_error compose_border_top_color(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_right_color(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_right_color_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_right_color(css_select_state *state); -css_error compose_border_right_color(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_bottom_color(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_bottom_color_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_bottom_color(css_select_state *state); -css_error compose_border_bottom_color(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_left_color(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_left_color_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_left_color(css_select_state *state); -css_error compose_border_left_color(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_top_style(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_top_style_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_top_style(css_select_state *state); -css_error compose_border_top_style(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_right_style(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_right_style_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_right_style(css_select_state *state); -css_error compose_border_right_style(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_bottom_style(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_bottom_style_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_bottom_style(css_select_state *state); -css_error compose_border_bottom_style(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_left_style(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_left_style_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_left_style(css_select_state *state); -css_error compose_border_left_style(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_top_width(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_top_width_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_top_width(css_select_state *state); -css_error compose_border_top_width(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_right_width(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_right_width_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_right_width(css_select_state *state); -css_error compose_border_right_width(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_bottom_width(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_bottom_width_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_bottom_width(css_select_state *state); -css_error compose_border_bottom_width(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_border_left_width(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_border_left_width_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_border_left_width(css_select_state *state); -css_error compose_border_left_width(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_bottom(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_bottom_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_bottom(css_select_state *state); -css_error compose_bottom(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_caption_side(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_caption_side_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_caption_side(css_select_state *state); -css_error compose_caption_side(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_clear(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_clear_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_clear(css_select_state *state); -css_error compose_clear(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_clip(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_clip_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_clip(css_select_state *state); -css_error compose_clip(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_color(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_color_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_color(css_select_state *state); -css_error compose_color(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_content(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_content_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_content(css_select_state *state); -css_error compose_content(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_counter_increment(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_counter_increment_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_counter_increment(css_select_state *state); -css_error compose_counter_increment(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_counter_reset(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_counter_reset_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_counter_reset(css_select_state *state); -css_error compose_counter_reset(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_cue_after(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_cue_after_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_cue_after(css_select_state *state); -css_error compose_cue_after(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_cue_before(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_cue_before_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_cue_before(css_select_state *state); -css_error compose_cue_before(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_cursor(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_cursor_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_cursor(css_select_state *state); -css_error compose_cursor(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_direction(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_direction_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_direction(css_select_state *state); -css_error compose_direction(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_display(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_display_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_display(css_select_state *state); -css_error compose_display(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_elevation(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_elevation_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_elevation(css_select_state *state); -css_error compose_elevation(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_empty_cells(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_empty_cells_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_empty_cells(css_select_state *state); -css_error compose_empty_cells(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_float(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_float_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_float(css_select_state *state); -css_error compose_float(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_font_family(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_font_family_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_font_family(css_select_state *state); -css_error compose_font_family(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_font_size(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_font_size_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_font_size(css_select_state *state); -css_error compose_font_size(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_font_style(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_font_style_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_font_style(css_select_state *state); -css_error compose_font_style(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_font_variant(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_font_variant_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_font_variant(css_select_state *state); -css_error compose_font_variant(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_font_weight(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_font_weight_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_font_weight(css_select_state *state); -css_error compose_font_weight(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_height(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_height_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_height(css_select_state *state); -css_error compose_height(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_left(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_left_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_left(css_select_state *state); -css_error compose_left(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_letter_spacing(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_letter_spacing_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_letter_spacing(css_select_state *state); -css_error compose_letter_spacing(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_line_height(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_line_height_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_line_height(css_select_state *state); -css_error compose_line_height(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_list_style_image(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_list_style_image_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_list_style_image(css_select_state *state); -css_error compose_list_style_image(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_list_style_position(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_list_style_position_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_list_style_position(css_select_state *state); -css_error compose_list_style_position(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_list_style_type(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_list_style_type_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_list_style_type(css_select_state *state); -css_error compose_list_style_type(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_margin_top(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_margin_top_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_margin_top(css_select_state *state); -css_error compose_margin_top(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_margin_right(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_margin_right_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_margin_right(css_select_state *state); -css_error compose_margin_right(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_margin_bottom(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_margin_bottom_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_margin_bottom(css_select_state *state); -css_error compose_margin_bottom(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_margin_left(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_margin_left_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_margin_left(css_select_state *state); -css_error compose_margin_left(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_max_height(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_max_height_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_max_height(css_select_state *state); -css_error compose_max_height(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_max_width(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_max_width_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_max_width(css_select_state *state); -css_error compose_max_width(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_min_height(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_min_height_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_min_height(css_select_state *state); -css_error compose_min_height(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_min_width(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_min_width_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_min_width(css_select_state *state); -css_error compose_min_width(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_orphans(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_orphans_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_orphans(css_select_state *state); -css_error compose_orphans(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_outline_color(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_outline_color_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_outline_color(css_select_state *state); -css_error compose_outline_color(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_outline_style(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_outline_style_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_outline_style(css_select_state *state); -css_error compose_outline_style(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_outline_width(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_outline_width_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_outline_width(css_select_state *state); -css_error compose_outline_width(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_overflow(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_overflow_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_overflow(css_select_state *state); -css_error compose_overflow(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_padding_top(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_padding_top_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_padding_top(css_select_state *state); -css_error compose_padding_top(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_padding_right(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_padding_right_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_padding_right(css_select_state *state); -css_error compose_padding_right(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_padding_bottom(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_padding_bottom_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_padding_bottom(css_select_state *state); -css_error compose_padding_bottom(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_padding_left(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_padding_left_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_padding_left(css_select_state *state); -css_error compose_padding_left(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_page_break_after(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_page_break_after_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_page_break_after(css_select_state *state); -css_error compose_page_break_after(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_page_break_before(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_page_break_before_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_page_break_before(css_select_state *state); -css_error compose_page_break_before(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_page_break_inside(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_page_break_inside_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_page_break_inside(css_select_state *state); -css_error compose_page_break_inside(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_pause_after(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_pause_after_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_pause_after(css_select_state *state); -css_error compose_pause_after(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_pause_before(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_pause_before_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_pause_before(css_select_state *state); -css_error compose_pause_before(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_pitch_range(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_pitch_range_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_pitch_range(css_select_state *state); -css_error compose_pitch_range(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_pitch(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_pitch_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_pitch(css_select_state *state); -css_error compose_pitch(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_play_during(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_play_during_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_play_during(css_select_state *state); -css_error compose_play_during(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_position(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_position_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_position(css_select_state *state); -css_error compose_position(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_quotes(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_quotes_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_quotes(css_select_state *state); -css_error compose_quotes(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_richness(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_richness_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_richness(css_select_state *state); -css_error compose_richness(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_right(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_right_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_right(css_select_state *state); -css_error compose_right(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_speak_header(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_speak_header_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_speak_header(css_select_state *state); -css_error compose_speak_header(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_speak_numeral(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_speak_numeral_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_speak_numeral(css_select_state *state); -css_error compose_speak_numeral(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_speak_punctuation(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_speak_punctuation_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_speak_punctuation(css_select_state *state); -css_error compose_speak_punctuation(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_speak(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_speak_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_speak(css_select_state *state); -css_error compose_speak(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_speech_rate(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_speech_rate_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_speech_rate(css_select_state *state); -css_error compose_speech_rate(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_stress(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_stress_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_stress(css_select_state *state); -css_error compose_stress(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_table_layout(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_table_layout_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_table_layout(css_select_state *state); -css_error compose_table_layout(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_text_align(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_text_align_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_text_align(css_select_state *state); -css_error compose_text_align(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_text_decoration(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_text_decoration_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_text_decoration(css_select_state *state); -css_error compose_text_decoration(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_text_indent(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_text_indent_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_text_indent(css_select_state *state); -css_error compose_text_indent(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_text_transform(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_text_transform_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_text_transform(css_select_state *state); -css_error compose_text_transform(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_top(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_top_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_top(css_select_state *state); -css_error compose_top(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_unicode_bidi(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_unicode_bidi_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_unicode_bidi(css_select_state *state); -css_error compose_unicode_bidi(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_vertical_align(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_vertical_align_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_vertical_align(css_select_state *state); -css_error compose_vertical_align(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_visibility(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_visibility_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_visibility(css_select_state *state); -css_error compose_visibility(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_voice_family(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_voice_family_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_voice_family(css_select_state *state); -css_error compose_voice_family(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_volume(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_volume_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_volume(css_select_state *state); -css_error compose_volume(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_white_space(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_white_space_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_white_space(css_select_state *state); -css_error compose_white_space(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_widows(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_widows_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_widows(css_select_state *state); -css_error compose_widows(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_width(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_width_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_width(css_select_state *state); -css_error compose_width(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_word_spacing(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_word_spacing_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_word_spacing(css_select_state *state); -css_error compose_word_spacing(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); -css_error cascade_z_index(uint32_t opv, css_style *style, - css_select_state *state); -css_error set_z_index_from_hint(const css_hint *hint, - css_computed_style *style); -css_error initial_z_index(css_select_state *state); -css_error compose_z_index(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result); +#define PROPERTY_FUNCS(pname) \ + css_error cascade_##pname (uint32_t opv, css_style *style, css_select_state *state); \ + css_error set_##pname##_from_hint(const css_hint *hint, css_computed_style *style); \ + css_error initial_##pname (css_select_state *state); \ + css_error compose_##pname (const css_computed_style *parent, const css_computed_style *child, css_computed_style *result); \ + uint32_t destroy_##pname (void *bytecode) -#endif +PROPERTY_FUNCS(azimuth); +PROPERTY_FUNCS(background_attachment); +PROPERTY_FUNCS(background_color); +PROPERTY_FUNCS(background_image); +PROPERTY_FUNCS(background_position); +PROPERTY_FUNCS(background_repeat); +PROPERTY_FUNCS(border_collapse); +PROPERTY_FUNCS(border_spacing); +PROPERTY_FUNCS(border_top_color); +PROPERTY_FUNCS(border_right_color); +PROPERTY_FUNCS(border_bottom_color); +PROPERTY_FUNCS(border_left_color); +PROPERTY_FUNCS(border_top_style); +PROPERTY_FUNCS(border_right_style); +PROPERTY_FUNCS(border_bottom_style); +PROPERTY_FUNCS(border_left_style); +PROPERTY_FUNCS(border_top_width); +PROPERTY_FUNCS(border_right_width); +PROPERTY_FUNCS(border_bottom_width); +PROPERTY_FUNCS(border_left_width); +PROPERTY_FUNCS(bottom); +PROPERTY_FUNCS(caption_side); +PROPERTY_FUNCS(clear); +PROPERTY_FUNCS(clip); +PROPERTY_FUNCS(color); +PROPERTY_FUNCS(content); +PROPERTY_FUNCS(counter_increment); +PROPERTY_FUNCS(counter_reset); +PROPERTY_FUNCS(cue_after); +PROPERTY_FUNCS(cue_before); +PROPERTY_FUNCS(cursor); +PROPERTY_FUNCS(direction); +PROPERTY_FUNCS(display); +PROPERTY_FUNCS(elevation); +PROPERTY_FUNCS(empty_cells); +PROPERTY_FUNCS(float); +PROPERTY_FUNCS(font_family); +PROPERTY_FUNCS(font_size); +PROPERTY_FUNCS(font_style); +PROPERTY_FUNCS(font_variant); +PROPERTY_FUNCS(font_weight); +PROPERTY_FUNCS(height); +PROPERTY_FUNCS(left); +PROPERTY_FUNCS(letter_spacing); +PROPERTY_FUNCS(line_height); +PROPERTY_FUNCS(list_style_image); +PROPERTY_FUNCS(list_style_position); +PROPERTY_FUNCS(list_style_type); +PROPERTY_FUNCS(margin_top); +PROPERTY_FUNCS(margin_right); +PROPERTY_FUNCS(margin_bottom); +PROPERTY_FUNCS(margin_left); +PROPERTY_FUNCS(max_height); +PROPERTY_FUNCS(max_width); +PROPERTY_FUNCS(min_height); +PROPERTY_FUNCS(min_width); +PROPERTY_FUNCS(orphans); +PROPERTY_FUNCS(outline_color); +PROPERTY_FUNCS(outline_style); +PROPERTY_FUNCS(outline_width); +PROPERTY_FUNCS(overflow); +PROPERTY_FUNCS(padding_top); +PROPERTY_FUNCS(padding_right); +PROPERTY_FUNCS(padding_bottom); +PROPERTY_FUNCS(padding_left); +PROPERTY_FUNCS(page_break_after); +PROPERTY_FUNCS(page_break_before); +PROPERTY_FUNCS(page_break_inside); +PROPERTY_FUNCS(pause_after); +PROPERTY_FUNCS(pause_before); +PROPERTY_FUNCS(pitch_range); +PROPERTY_FUNCS(pitch); +PROPERTY_FUNCS(play_during); +PROPERTY_FUNCS(position); +PROPERTY_FUNCS(quotes); +PROPERTY_FUNCS(richness); +PROPERTY_FUNCS(right); +PROPERTY_FUNCS(speak_header); +PROPERTY_FUNCS(speak_numeral); +PROPERTY_FUNCS(speak_punctuation); +PROPERTY_FUNCS(speak); +PROPERTY_FUNCS(speech_rate); +PROPERTY_FUNCS(stress); +PROPERTY_FUNCS(table_layout); +PROPERTY_FUNCS(text_align); +PROPERTY_FUNCS(text_decoration); +PROPERTY_FUNCS(text_indent); +PROPERTY_FUNCS(text_transform); +PROPERTY_FUNCS(top); +PROPERTY_FUNCS(unicode_bidi); +PROPERTY_FUNCS(vertical_align); +PROPERTY_FUNCS(visibility); +PROPERTY_FUNCS(voice_family); +PROPERTY_FUNCS(volume); +PROPERTY_FUNCS(white_space); +PROPERTY_FUNCS(widows); +PROPERTY_FUNCS(width); +PROPERTY_FUNCS(word_spacing); +PROPERTY_FUNCS(z_index); + +#undef PROPERTY_FUNCS +#endif diff --git a/src/stylesheet.c b/src/stylesheet.c index 9603b18..cc6621a 100644 --- a/src/stylesheet.c +++ b/src/stylesheet.c @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2008 John-Mark Bell */ @@ -13,6 +13,7 @@ #include "parse/language.h" #include "utils/parserutilserror.h" #include "utils/utils.h" +#include "select/dispatch.h" static css_error _add_selectors(css_stylesheet *sheet, css_rule *rule); static css_error _remove_selectors(css_stylesheet *sheet, css_rule *rule); @@ -21,20 +22,20 @@ static size_t _rule_size(const css_rule *rule); /** * Create a stylesheet * - * \param level The language level of the stylesheet - * \param charset The charset of the stylesheet data, or NULL to detect - * \param url URL of stylesheet - * \param title Title of stylesheet - * \param allow_quirks Permit quirky parsing of stylesheets - * \param inline_style This stylesheet is an inline style - * \param alloc Memory (de)allocation function - * \param alloc_pw Client private data for alloc - * \param resolve URL resolution function - * \param resolve_pw Client private data for resolve - * \param stylesheet Pointer to location to receive stylesheet + * \param level The language level of the stylesheet + * \param charset The charset of the stylesheet data, or NULL to detect + * \param url URL of stylesheet + * \param title Title of stylesheet + * \param allow_quirks Permit quirky parsing of stylesheets + * \param inline_style This stylesheet is an inline style + * \param alloc Memory (de)allocation function + * \param alloc_pw Client private data for alloc + * \param resolve URL resolution function + * \param resolve_pw Client private data for resolve + * \param stylesheet Pointer to location to receive stylesheet * \return CSS_OK on success, - * CSS_BADPARM on bad parameters, - * CSS_NOMEM on memory exhaustion + * CSS_BADPARM on bad parameters, + * CSS_NOMEM on memory exhaustion */ css_error css_stylesheet_create(css_language_level level, const char *charset, const char *url, const char *title, @@ -57,7 +58,7 @@ css_error css_stylesheet_create(css_language_level level, return CSS_NOMEM; memset(sheet, 0, sizeof(css_stylesheet)); - + sheet->inline_style = inline_style; if (inline_style) { @@ -149,7 +150,7 @@ css_error css_stylesheet_create(css_language_level level, /** * Destroy a stylesheet * - * \param sheet The stylesheet to destroy + * \param sheet The stylesheet to destroy * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_destroy(css_stylesheet *sheet) @@ -204,9 +205,9 @@ css_error css_stylesheet_destroy(css_stylesheet *sheet) /** * Append source data to a stylesheet * - * \param sheet The stylesheet to append data to - * \param data Pointer to data to append - * \param len Length, in bytes, of data to append + * \param sheet The stylesheet to append data to + * \param data Pointer to data to append + * \param len Length, in bytes, of data to append * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_append_data(css_stylesheet *sheet, @@ -224,10 +225,10 @@ css_error css_stylesheet_append_data(css_stylesheet *sheet, /** * Flag that the last of a stylesheet's data has been seen * - * \param sheet The stylesheet in question + * \param sheet The stylesheet in question * \return CSS_OK on success, - * CSS_IMPORTS_PENDING if there are imports pending, - * appropriate error otherwise + * CSS_IMPORTS_PENDING if there are imports pending, + * appropriate error otherwise */ css_error css_stylesheet_data_done(css_stylesheet *sheet) { @@ -283,12 +284,12 @@ css_error css_stylesheet_data_done(css_stylesheet *sheet) * Retrieve the next pending import for the parent stylesheet * * \param parent Parent stylesheet - * \param url Pointer to object to be populated with details of URL of - * imported stylesheet (potentially relative) - * \param media Pointer to location to receive applicable media types for - * imported sheet, + * \param url Pointer to object to be populated with details of URL of + * imported stylesheet (potentially relative) + * \param media Pointer to location to receive applicable media types for + * imported sheet, * \return CSS_OK on success, - * CSS_INVALID if there are no pending imports remaining + * CSS_INVALID if there are no pending imports remaining * * The client must resolve the absolute URL of the imported stylesheet, * using the parent's URL as the base. It must then fetch the imported @@ -320,7 +321,7 @@ css_error css_stylesheet_next_pending_import(css_stylesheet *parent, break; if (r->type == CSS_RULE_IMPORT && i->sheet == NULL) { - *url = lwc_string_ref(i->url); + *url = lwc_string_ref(i->url); *media = i->media; return CSS_OK; @@ -336,8 +337,8 @@ css_error css_stylesheet_next_pending_import(css_stylesheet *parent, * \param parent Parent stylesheet * \param import Imported sheet * \return CSS_OK on success, - * CSS_INVALID if there are no outstanding imports, - * appropriate error otherwise. + * CSS_INVALID if there are no outstanding imports, + * appropriate error otherwise. * * Ownership of the imported stylesheet is transferred to the parent. */ @@ -372,8 +373,8 @@ css_error css_stylesheet_register_import(css_stylesheet *parent, /** * Retrieve the language level of a stylesheet * - * \param sheet The stylesheet to retrieve the language level of - * \param level Pointer to location to receive language level + * \param sheet The stylesheet to retrieve the language level of + * \param level Pointer to location to receive language level * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_get_language_level(css_stylesheet *sheet, @@ -390,8 +391,8 @@ css_error css_stylesheet_get_language_level(css_stylesheet *sheet, /** * Retrieve the URL associated with a stylesheet * - * \param sheet The stylesheet to retrieve the URL from - * \param url Pointer to location to receive pointer to URL + * \param sheet The stylesheet to retrieve the URL from + * \param url Pointer to location to receive pointer to URL * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_get_url(css_stylesheet *sheet, const char **url) @@ -407,8 +408,8 @@ css_error css_stylesheet_get_url(css_stylesheet *sheet, const char **url) /** * Retrieve the title associated with a stylesheet * - * \param sheet The stylesheet to retrieve the title from - * \param title Pointer to location to receive pointer to title + * \param sheet The stylesheet to retrieve the title from + * \param title Pointer to location to receive pointer to title * \return CSS_Ok on success, appropriate error otherwise */ css_error css_stylesheet_get_title(css_stylesheet *sheet, const char **title) @@ -424,7 +425,7 @@ css_error css_stylesheet_get_title(css_stylesheet *sheet, const char **title) /** * Determine whether quirky parsing was permitted on a stylesheet * - * \param sheet The stylesheet to consider + * \param sheet The stylesheet to consider * \param quirks Pointer to location to receive quirkyness * \return CSS_OK on success, appropriate error otherwise */ @@ -442,7 +443,7 @@ css_error css_stylesheet_quirks_allowed(css_stylesheet *sheet, bool *allowed) /** * Determine whether quirky parsing was used on a stylesheet * - * \param sheet The stylesheet to consider + * \param sheet The stylesheet to consider * \param quirks Pointer to location to receive quirkyness * \return CSS_OK on success, appropriate error otherwise */ @@ -459,7 +460,7 @@ css_error css_stylesheet_used_quirks(css_stylesheet *sheet, bool *quirks) /** * Get disabled status of a stylesheet * - * \param sheet The stylesheet to consider + * \param sheet The stylesheet to consider * \param disabled Pointer to location to receive disabled state * \return CSS_OK on success, appropriate error otherwise */ @@ -476,7 +477,7 @@ css_error css_stylesheet_get_disabled(css_stylesheet *sheet, bool *disabled) /** * Set a stylesheet's disabled state * - * \param sheet The stylesheet to modify + * \param sheet The stylesheet to modify * \param disabled The new disabled state * \return CSS_OK on success, appropriate error otherwise */ @@ -495,12 +496,12 @@ css_error css_stylesheet_set_disabled(css_stylesheet *sheet, bool disabled) /** * Determine the memory-resident size of a stylesheet * - * \param sheet Sheet to consider - * \param size Pointer to location to receive byte count + * \param sheet Sheet to consider + * \param size Pointer to location to receive byte count * \return CSS_OK on success. * * \note The returned size will not include the size of interned strings - * or imported stylesheets. + * or imported stylesheets. */ css_error css_stylesheet_size(css_stylesheet *sheet, size_t *size) { @@ -529,18 +530,18 @@ css_error css_stylesheet_size(css_stylesheet *sheet, size_t *size) } /****************************************************************************** - * Library-private API below here * + * Library-private API below here * ******************************************************************************/ /** * Create a style * - * \param sheet The stylesheet context - * \param len The required length of the style - * \param style Pointer to location to receive style + * \param sheet The stylesheet context + * \param len The required length of the style + * \param style Pointer to location to receive style * \return CSS_OK on success, - * CSS_BADPARM on bad parameters, - * CSS_NOMEM on memory exhaustion + * CSS_BADPARM on bad parameters, + * CSS_NOMEM on memory exhaustion */ css_error css_stylesheet_style_create(css_stylesheet *sheet, uint32_t len, css_style **style) @@ -574,19 +575,32 @@ css_error css_stylesheet_style_create(css_stylesheet *sheet, uint32_t len, /** * Destroy a style * - * \param sheet The stylesheet context - * \param style The style to destroy + * \param sheet The stylesheet context + * \param style The style to destroy + * \param suppress_bytecode_cleanup Whether or not to prevent the + * bytecode from unreffing strings + * etc. * \return CSS_OK on success, appropriate error otherwise - * - * \todo This really ought to unref all the strings in the bytecode. */ -css_error css_stylesheet_style_destroy(css_stylesheet *sheet, css_style *style) +css_error css_stylesheet_style_destroy(css_stylesheet *sheet, css_style *style, + bool suppress_bytecode_cleanup) { uint32_t alloclen, bucket; + uint8_t *bptr, *eptr; if (sheet == NULL || style == NULL) return CSS_BADPARM; - + + if (suppress_bytecode_cleanup == false) { + bptr = style->bytecode; + eptr = bptr + style->length; + while (bptr != eptr) { + uint32_t opcode = getOpcode(*((uint32_t*)bptr)); + uint32_t skip = prop_dispatch[opcode].destroy(bptr); + bptr += skip; + } + } + alloclen = ((style->length + 15) & ~15); bucket = (alloclen / N_ELEMENTS(sheet->free_styles)) - 1; @@ -603,12 +617,12 @@ css_error css_stylesheet_style_destroy(css_stylesheet *sheet, css_style *style) /** * Create an element selector * - * \param sheet The stylesheet context - * \param name Name of selector + * \param sheet The stylesheet context + * \param name Name of selector * \param selector Pointer to location to receive selector object * \return CSS_OK on success, - * CSS_BADPARM on bad parameters, - * CSS_NOMEM on memory exhaustion + * CSS_BADPARM on bad parameters, + * CSS_NOMEM on memory exhaustion */ css_error css_stylesheet_selector_create(css_stylesheet *sheet, lwc_string *name, css_selector **selector) @@ -649,7 +663,7 @@ css_error css_stylesheet_selector_create(css_stylesheet *sheet, /** * Destroy a selector object * - * \param sheet The stylesheet context + * \param sheet The stylesheet context * \param selector The selector to destroy * \return CSS_OK on success, appropriate error otherwise */ @@ -657,7 +671,7 @@ css_error css_stylesheet_selector_destroy(css_stylesheet *sheet, css_selector *selector) { css_selector *c, *d; - css_selector_detail *detail; + css_selector_detail *detail; if (sheet == NULL || selector == NULL) return CSS_BADPARM; @@ -669,36 +683,36 @@ css_error css_stylesheet_selector_destroy(css_stylesheet *sheet, for (c = selector->combinator; c != NULL; c = d) { d = c->combinator; - for (detail = &c->data; detail;) { - lwc_string_unref(detail->name); + for (detail = &c->data; detail;) { + lwc_string_unref(detail->name); - if (detail->value != NULL) { - lwc_string_unref(detail->value); + if (detail->value != NULL) { + lwc_string_unref(detail->value); } - if (detail->next) - detail++; - else - detail = NULL; - } - + if (detail->next) + detail++; + else + detail = NULL; + } + sheet->alloc(c, 0, sheet->pw); } - - for (detail = &selector->data; detail;) { - lwc_string_unref(detail->name); + + for (detail = &selector->data; detail;) { + lwc_string_unref(detail->name); - if (detail->value != NULL) { - lwc_string_unref(detail->value); + if (detail->value != NULL) { + lwc_string_unref(detail->value); } - if (detail->next) - detail++; - else - detail = NULL; - } - - + if (detail->next) + detail++; + else + detail = NULL; + } + + /* Destroy this selector */ sheet->alloc(selector, 0, sheet->pw); @@ -708,13 +722,13 @@ css_error css_stylesheet_selector_destroy(css_stylesheet *sheet, /** * Initialise a selector detail * - * \param sheet The stylesheet context - * \param type The type of selector to create - * \param name Name of selector - * \param value Value of selector, or NULL + * \param sheet The stylesheet context + * \param type The type of selector to create + * \param name Name of selector + * \param value Value of selector, or NULL * \param detail Pointer to detail object to initialise * \return CSS_OK on success, - * CSS_BADPARM on bad parameters + * CSS_BADPARM on bad parameters */ css_error css_stylesheet_selector_detail_init(css_stylesheet *sheet, css_selector_type type, lwc_string *name, @@ -736,7 +750,7 @@ css_error css_stylesheet_selector_detail_init(css_stylesheet *sheet, /** * Append a selector to the specifics chain of another selector * - * \param sheet The stylesheet context + * \param sheet The stylesheet context * \param parent Pointer to pointer to the parent selector (updated on exit) * \param specific The selector to append (copied) * \return CSS_OK on success, appropriate error otherwise. @@ -771,12 +785,12 @@ css_error css_stylesheet_selector_append_specific(css_stylesheet *sheet, (&temp->data)[num_details + 1] = *detail; /* Flag that there's another block */ (&temp->data)[num_details].next = 1; - - /* Ref the strings */ - lwc_string_ref(detail->name); - if (detail->value != NULL) - lwc_string_ref(detail->value); - + + /* Ref the strings */ + lwc_string_ref(detail->name); + if (detail->value != NULL) + lwc_string_ref(detail->value); + (*parent) = temp; /* Update parent's specificity */ @@ -804,10 +818,10 @@ css_error css_stylesheet_selector_append_specific(css_stylesheet *sheet, /** * Combine a pair of selectors * - * \param sheet The stylesheet context - * \param type The combinator type - * \param a The first operand - * \param b The second operand + * \param sheet The stylesheet context + * \param type The combinator type + * \param a The first operand + * \param b The second operand * \return CSS_OK on success, appropriate error otherwise. * * For example, given A + B, the combinator field of B would point at A, @@ -845,12 +859,12 @@ css_error css_stylesheet_selector_combine(css_stylesheet *sheet, /** * Create a CSS rule * - * \param sheet The stylesheet context - * \param type The rule type - * \param rule Pointer to location to receive rule object + * \param sheet The stylesheet context + * \param type The rule type + * \param rule Pointer to location to receive rule object * \return CSS_OK on success, - * CSS_BADPARM on bad parameters, - * CSS_NOMEM on memory exhaustion + * CSS_BADPARM on bad parameters, + * CSS_NOMEM on memory exhaustion */ css_error css_stylesheet_rule_create(css_stylesheet *sheet, css_rule_type type, css_rule **rule) @@ -901,8 +915,8 @@ css_error css_stylesheet_rule_create(css_stylesheet *sheet, css_rule_type type, /** * Destroy a CSS rule * - * \param sheet The stylesheet context - * \param rule The rule to destroy + * \param sheet The stylesheet context + * \param rule The rule to destroy * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule) @@ -936,21 +950,21 @@ css_error css_stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule) sheet->alloc(s->selectors, 0, sheet->pw); if (s->style != NULL) - css_stylesheet_style_destroy(sheet, s->style); + css_stylesheet_style_destroy(sheet, s->style, false); } break; case CSS_RULE_CHARSET: - { - css_rule_charset *charset = (css_rule_charset *) rule; - lwc_string_unref(charset->encoding); - } + { + css_rule_charset *charset = (css_rule_charset *) rule; + lwc_string_unref(charset->encoding); + } break; case CSS_RULE_IMPORT: { css_rule_import *import = (css_rule_import *) rule; - - lwc_string_unref(import->url); - + + lwc_string_unref(import->url); + if (import->sheet != NULL) css_stylesheet_destroy(import->sheet); } @@ -977,7 +991,7 @@ css_error css_stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule) css_rule_font_face *font_face = (css_rule_font_face *) rule; if (font_face->style != NULL) - css_stylesheet_style_destroy(sheet, font_face->style); + css_stylesheet_style_destroy(sheet, font_face->style, false); } break; case CSS_RULE_PAGE: @@ -990,7 +1004,7 @@ css_error css_stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule) } if (page->style != NULL) - css_stylesheet_style_destroy(sheet, page->style); + css_stylesheet_style_destroy(sheet, page->style, false); } break; } @@ -1004,8 +1018,8 @@ css_error css_stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule) /** * Add a selector to a CSS rule * - * \param sheet The stylesheet context - * \param rule The rule to add to (must be of type CSS_RULE_SELECTOR) + * \param sheet The stylesheet context + * \param rule The rule to add to (must be of type CSS_RULE_SELECTOR) * \param selector The selector to add * \return CSS_OK on success, appropriate error otherwise */ @@ -1041,9 +1055,9 @@ css_error css_stylesheet_rule_add_selector(css_stylesheet *sheet, /** * Append a style to a CSS rule * - * \param sheet The stylesheet context - * \param rule The rule to add to (must be CSS_RULE_SELECTOR or CSS_RULE_PAGE) - * \param style The style to add + * \param sheet The stylesheet context + * \param rule The rule to add to (must be CSS_RULE_SELECTOR or CSS_RULE_PAGE) + * \param style The style to add * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_rule_append_style(css_stylesheet *sheet, @@ -1079,7 +1093,7 @@ css_error css_stylesheet_rule_append_style(css_stylesheet *sheet, cur->length); temp->length = cur->length; - css_stylesheet_style_destroy(sheet, cur); + css_stylesheet_style_destroy(sheet, cur, false); cur = temp; } @@ -1094,7 +1108,7 @@ css_error css_stylesheet_rule_append_style(css_stylesheet *sheet, sheet->size += style->length; /* Done with style */ - css_stylesheet_style_destroy(sheet, style); + css_stylesheet_style_destroy(sheet, style, false); } else { /* No current style, so use this one */ cur = style; @@ -1114,8 +1128,8 @@ css_error css_stylesheet_rule_append_style(css_stylesheet *sheet, /** * Set the charset of a CSS rule * - * \param sheet The stylesheet context - * \param rule The rule to add to (must be of type CSS_RULE_CHARSET) + * \param sheet The stylesheet context + * \param rule The rule to add to (must be of type CSS_RULE_CHARSET) * \param charset The charset * \return CSS_OK on success, appropriate error otherwise */ @@ -1140,10 +1154,10 @@ css_error css_stylesheet_rule_set_charset(css_stylesheet *sheet, /** * Set the necessary data to import a stylesheet associated with a rule * - * \param sheet The stylesheet context - * \param rule The rule to add to (must be of type CSS_RULE_IMPORT) - * \param url The URL of the imported stylesheet - * \param media The applicable media types for the imported stylesheet + * \param sheet The stylesheet context + * \param rule The rule to add to (must be of type CSS_RULE_IMPORT) + * \param url The URL of the imported stylesheet + * \param media The applicable media types for the imported stylesheet * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_rule_set_nascent_import(css_stylesheet *sheet, @@ -1168,9 +1182,9 @@ css_error css_stylesheet_rule_set_nascent_import(css_stylesheet *sheet, /** * Set the media of an @media rule * - * \param sheet The stylesheet context - * \param rule The rule to add to (must be of type CSS_RULE_MEDIA) - * \param media The applicable media types for the rule + * \param sheet The stylesheet context + * \param rule The rule to add to (must be of type CSS_RULE_MEDIA) + * \param media The applicable media types for the rule * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_rule_set_media(css_stylesheet *sheet, @@ -1193,8 +1207,8 @@ css_error css_stylesheet_rule_set_media(css_stylesheet *sheet, /** * Set an @page rule selector * - * \param sheet The stylesheet context - * \param rule The rule to add to (must be of type CSS_RULE_PAGE) + * \param sheet The stylesheet context + * \param rule The rule to add to (must be of type CSS_RULE_PAGE) * \param selector The page selector * \return CSS_OK on success, appropriate error otherwise */ @@ -1223,8 +1237,8 @@ css_error css_stylesheet_rule_set_page_selector(css_stylesheet *sheet, /** * Add a rule to a stylesheet * - * \param sheet The stylesheet to add to - * \param rule The rule to add + * \param sheet The stylesheet to add to + * \param rule The rule to add * \param parent The parent rule, or NULL for a top-level rule * \return CSS_OK on success, appropriate error otherwise */ @@ -1294,8 +1308,8 @@ css_error css_stylesheet_add_rule(css_stylesheet *sheet, css_rule *rule, /** * Remove a rule from a stylesheet * - * \param sheet The sheet to remove from - * \param rule The rule to remove + * \param sheet The sheet to remove from + * \param rule The rule to remove * \return CSS_OK on success, appropriate error otherwise */ css_error css_stylesheet_remove_rule(css_stylesheet *sheet, css_rule *rule) @@ -1338,14 +1352,14 @@ css_error css_stylesheet_remove_rule(css_stylesheet *sheet, css_rule *rule) } /****************************************************************************** - * Private API below here * + * Private API below here * ******************************************************************************/ /** * Add selectors in a rule to the hash * - * \param sheet Stylesheet containing hash - * \param rule Rule to consider + * \param sheet Stylesheet containing hash + * \param rule Rule to consider * \return CSS_OK on success, appropriate error otherwise */ css_error _add_selectors(css_stylesheet *sheet, css_rule *rule) @@ -1409,8 +1423,8 @@ css_error _add_selectors(css_stylesheet *sheet, css_rule *rule) /** * Remove selectors in a rule from the hash * - * \param sheet Stylesheet containing hash - * \param rule Rule to consider + * \param sheet Stylesheet containing hash + * \param rule Rule to consider * \return CSS_OK on success, appropriate error otherwise */ css_error _remove_selectors(css_stylesheet *sheet, css_rule *rule) diff --git a/src/stylesheet.h b/src/stylesheet.h index 8072686..b708257 100644 --- a/src/stylesheet.h +++ b/src/stylesheet.h @@ -1,7 +1,7 @@ /* * This file is part of LibCSS. * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/mit-license.php * Copyright 2008 John-Mark Bell */ @@ -53,8 +53,8 @@ typedef struct css_selector_detail { lwc_string *value; /**< Interned value, or NULL */ unsigned int type : 4, /**< Type of selector */ - comb : 2, /**< Type of combinator */ - next : 1; /**< Another selector detail + comb : 2, /**< Type of combinator */ + next : 1; /**< Another selector detail * follows */ } css_selector_detail; @@ -95,9 +95,9 @@ struct css_rule { css_rule *prev; /**< previous in list */ unsigned int type : 4, /**< css_rule_type */ - index : 16, /**< index in sheet */ - items : 8, /**< # items in rule */ - ptype : 1; /**< css_rule_parent_type */ + index : 16, /**< index in sheet */ + items : 8, /**< # items in rule */ + ptype : 1; /**< css_rule_parent_type */ }; typedef struct css_rule_selector { @@ -182,7 +182,8 @@ struct css_stylesheet { css_error css_stylesheet_style_create(css_stylesheet *sheet, uint32_t len, css_style **style); -css_error css_stylesheet_style_destroy(css_stylesheet *sheet, css_style *style); +css_error css_stylesheet_style_destroy(css_stylesheet *sheet, css_style *style, + bool suppress_bytecode_cleanup); css_error css_stylesheet_selector_create(css_stylesheet *sheet, lwc_string *name, css_selector **selector); -- cgit v1.2.3