diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2017-09-04 14:56:51 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2017-09-04 14:56:51 +0100 |
commit | 2fcb157f28b152ba32e89baddbd811b0d6e76b79 (patch) | |
tree | 30f96332ac7993ff4acf88b4892f922a80ddd393 | |
parent | 2fc4177a09cc6fc6706f84dbe157077a41b6e22b (diff) | |
download | libcss-2fcb157f28b152ba32e89baddbd811b0d6e76b79.tar.gz libcss-2fcb157f28b152ba32e89baddbd811b0d6e76b79.tar.bz2 |
Strip trailing whitespace.
190 files changed, 1790 insertions, 1790 deletions
@@ -32,15 +32,15 @@ Compilation Verification ------------ - To verify that the parser is working, it is necessary to specify a + To verify that the parser is working, it is necessary to specify a different makefile target than that used for normal compilation, thus: - + $ make test API documentation ----------------- - Currently, there is none. However, the code is well commented and the - public API may be found in the "include" directory. The testcase sources + Currently, there is none. However, the code is well commented and the + public API may be found in the "include" directory. The testcase sources may also be of use in working out how to use it. diff --git a/build/mkprops.pl b/build/mkprops.pl index 5464053..33fb0f8 100755 --- a/build/mkprops.pl +++ b/build/mkprops.pl @@ -24,7 +24,7 @@ EOF foreach my $prop (@PROPS) { print <<EOF static css_error parse_$prop(css_css21 *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style **result); EOF } @@ -34,8 +34,8 @@ print <<EOF /** * Type of property handler function */ -typedef css_error (*css_prop_handler)(css_css21 *c, - const parserutils_vector *vector, int *ctx, +typedef css_error (*css_prop_handler)(css_css21 *c, + const parserutils_vector *vector, int *ctx, css_style **result); /** @@ -55,8 +55,8 @@ print "};\n"; foreach my $prop (@PROPS) { print <<EOF -css_error parse_$prop(css_css21 *c, - const parserutils_vector *vector, int *ctx, +css_error parse_$prop(css_css21 *c, + const parserutils_vector *vector, int *ctx, css_style **result) { UNUSED(c); @@ -182,12 +182,12 @@ The arguments are as follows: | directly; instead it gets information about it through the functions given | in the handler argument, described below. Usually this will be a node in a | document tree. -| +| + uint64_t media | The media that the style should apply to. The computed style will only | consider stylesheets or @media blocks that include this media. See the CSS | specification for more details. -| +| + const css_stylesheet *inline_style | + css_select_handler *handler @@ -213,7 +213,7 @@ following in common: * the last one or two arguments are pointers that must be updated with the required information - + * the return value is a css_error and should be CSS_OK if everything worked and an error code otherwise diff --git a/docs/Bytecode b/docs/Bytecode index f2d10cc..852a918 100644 --- a/docs/Bytecode +++ b/docs/Bytecode @@ -30,7 +30,7 @@ assigned to the fractional part. Strings are stored as a 32bit index into a table of interned string pointers. The table is found in the stylesheet object. -CSS dimensions are stored as two 32bit values: <length, units>. +CSS dimensions are stored as two 32bit values: <length, units>. Length is a 32bit numeric value (as described above) and unit is as follows: bit 8 clear => length unit @@ -160,7 +160,7 @@ Opcodes 04 - background-position <value> (14bits) : bits 8-13: MBZ - bits 0-7 : + bits 0-7 : bit 7: set => percentage or length unit follows bits 4-6: MBZ clear => keywords: @@ -251,7 +251,7 @@ Opcodes 14 - bottom <value> (14bits) : bits 8-13: MBZ - bits 0-7: + bits 0-7: bit 7 set => length/percentage follows bits 0-6: MBZ bit 7 clear => keywords: @@ -275,7 +275,7 @@ Opcodes 17 - clip <value> (14bits) : bits 8-13: MBZ - bits 0-7: + bits 0-7: bit 7 set => shape follows bits 0-2: 000 => rect, bit 3 => top auto @@ -284,19 +284,19 @@ Opcodes bit 6 => left auto other => rffe. bits 3-6: MBZ. - + bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. If the value is rect(top, right, bottom, left), then bits 3-6 encode - which of <top>, <right>, <bottom>, <left> is set to auto. The + which of <top>, <right>, <bottom>, <left> is set to auto. The subsequent parameter list is then 4 - <auto_side> entries long. - Each entry is a dimension. Entries are always ordered top, right, + Each entry is a dimension. Entries are always ordered top, right, bottom, left. For example, - clip: rect(10px, auto, auto, 10px) + clip: rect(10px, auto, auto, 10px) would produce the following bytecode: <02c00017> <00002800> <00000000> <00002800> <00000000> @@ -304,7 +304,7 @@ Opcodes 18 - color <value> (14bits) : bits 8-13: MBZ - bits 0-7: + bits 0-7: bit 7: set => colour follows. bits 0-6: MBZ. clear => keywords: @@ -341,8 +341,8 @@ Opcodes declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "normal"). - For example, - content: open-quote url('http://example.com/') + For example, + content: open-quote url('http://example.com/') " : " attr(name) " " counter(x) "." counters(y, ".") close-quote;" would result in the following bytecode: @@ -351,9 +351,9 @@ Opcodes <00000081> <ptr to "http://example.com"> <00000080> <ptr to " : "> <00000084> <ptr to "name"> - <00000080> <ptr to " "> + <00000080> <ptr to " "> <00000382> <ptr to "x"> - <00000080> <ptr to "."> + <00000080> <ptr to "."> <00000383> <ptr to "y"> <ptr to "."> <00000003> <00000000> @@ -368,8 +368,8 @@ Opcodes bits 0-6: 0000000 => none, other => rffe. - If the value is not "none", or "inherit", then there is a parameter - list. Each item is preceded by a <value> word which declares the type + If the value is not "none", or "inherit", then there is a parameter + list. Each item is preceded by a <value> word which declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "none"). @@ -384,8 +384,8 @@ Opcodes bits 0-6: 0000000 => none, other => rffe. - If the value is not "none", or "inherit", then there is a parameter - list. Each item is preceded by a <value> word which declares the type + If the value is not "none", or "inherit", then there is a parameter + list. Each item is preceded by a <value> word which declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "none"). @@ -435,7 +435,7 @@ Opcodes 0010000 => progress, other => rffe. - If the value indicates that a uri is present, then there is a + If the value indicates that a uri is present, then there is a parameter list. Each item is preceded by a <value> word which declares the type of the next item. The list is terminated by a word with bit 7 clear. @@ -499,7 +499,7 @@ Opcodes bits 0-7 : bit 7 set => data follows bits 1-6: MBZ - bit 0 : clear => string, + bit 0 : clear => string, set => ident list (as string) bit 7 clear => keywords: bits 0-6: 0000000 => Reserved. @@ -510,8 +510,8 @@ Opcodes 0000101 => monospace, other => rffe. - In all cases, there is a parameter list. Each item is preceded by a - <value> word which declares the type of the next item. The list is + In all cases, there is a parameter list. Each item is preceded by a + <value> word which declares the type of the next item. The list is terminated by a word with all bits clear. 25 - font-size @@ -855,7 +855,7 @@ Opcodes bits 0-6: 0000000 => none, other => rffe. - If the value indicates that strings are present, then there is a + If the value indicates that strings are present, then there is a parameter list. Each item is preceded by a <value> word which declares the type of the next item. The list is terminated by a word with all bits clear (the encoding for "none"). @@ -954,7 +954,7 @@ Opcodes otherwise: bits 4-7: MBZ bit 3: set => blink, clear => no blink - bit 2: set => line-through, + bit 2: set => line-through, clear => no line-through bit 1: set => overline, clear => no overline bit 0: set => underline, clear => no underline @@ -1023,7 +1023,7 @@ Opcodes bits 0-7 : bit 7 set => data follows bits 1-6: MBZ - bit 0 : clear => string, + bit 0 : clear => string, set => ident list (as string) bit 7 clear => keywords: bits 0-6: 0000000 => Reserved. @@ -1032,10 +1032,10 @@ Opcodes 0000011 => child, other => rffe. - In all cases, there is a parameter list. Each item is preceded by a - <value> word which declares the type of the next item. The list is + In all cases, there is a parameter list. Each item is preceded by a + <value> word which declares the type of the next item. The list is terminated by a word with all bits clear. - + 5d - volume <value> (14bits) : bits 8-13: MBZ diff --git a/docs/Grammar b/docs/Grammar index 0fd27d3..c3d24b4 100644 --- a/docs/Grammar +++ b/docs/Grammar @@ -86,16 +86,16 @@ Differences from the specification 1) The start non-terminal has been introduced. It eats any leading whitespace and handles EOF. 2) The "stylesheet -> S stylesheet" production has been removed. -3) The "stylesheet -> CDO stylesheet" production has been changed to +3) The "stylesheet -> CDO stylesheet" production has been changed to "stylesheet -> CDO ws stylesheet". 4) The "stylesheet -> CDC stylesheet" production has been changed to "stylesheet -> CDC ws stylesheet". Essentially, the above changes remove the expectation of leading whitespace -from the stylesheet non-terminal. This is handled by either the start -non-terminal, or by the changes made to the production rules for the stylesheet -non-terminal. Note that the "stylesheet -> statement stylesheet" production -does not require modification as the statement production rule already consumes +from the stylesheet non-terminal. This is handled by either the start +non-terminal, or by the changes made to the production rules for the stylesheet +non-terminal. Note that the "stylesheet -> statement stylesheet" production +does not require modification as the statement production rule already consumes any whitespace following the statement. If '{', '}', '[', ']', '(', ')', and ';' are omitted from any, then the above @@ -104,18 +104,18 @@ grammar is LL(1). Nullable productions -------------------- -stylesheet, block-content, decl-list, decl-list-end, value0, any0, ws +stylesheet, block-content, decl-list, decl-list-end, value0, any0, ws FIRST sets ---------- -start CDO, CDC, S, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +start CDO, CDC, S, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -stylesheet CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +stylesheet CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD statement IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, PREFIXMATCH, SUFFIXMATCH, @@ -162,29 +162,29 @@ FOLLOW sets start stylesheet EOF -statement CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +statement CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -ruleset CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +ruleset CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -ruleset-end CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +ruleset-end CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -at-rule CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +at-rule CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -at-rule-end CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +at-rule-end CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -block CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +block CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF, ';', '}' block-content '}' selector '{' @@ -202,9 +202,9 @@ any1 '{' any IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ';', ATKEYWORD, '}' -ws CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +ws CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF, ';', '}', ':' diff --git a/docs/Representation b/docs/Representation index 3eb63eb..b91419f 100644 --- a/docs/Representation +++ b/docs/Representation @@ -78,7 +78,7 @@ struct stylesheet { uint32_t rule_count; /**< Number of rules in sheet */ struct rule *rule_list; /**< List of rules in sheet */ - bool disabled; /**< Whether this sheet is + bool disabled; /**< Whether this sheet is * disabled */ char *url; /**< URL of this sheet */ diff --git a/docs/Tokens b/docs/Tokens index 907fabd..9535e81 100644 --- a/docs/Tokens +++ b/docs/Tokens @@ -54,13 +54,13 @@ Differences from the CSS3 Syntax module specification 2) escape follows CSS2.1. CSS3 defines it as: escape ::= unicode | '\' [#x20-#x7E#x80-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF] 3) urlchar omits ' and ): - a) If ' is permitted verbatim then, as stringchar inherits from urlchar, - single quoted strings may contain verbatim single quotes. This is + a) If ' is permitted verbatim then, as stringchar inherits from urlchar, + single quoted strings may contain verbatim single quotes. This is clearly nonsense. b) If ) is permitted verbatim then it becomes impossible to determine the true end of URI. Thus, for sanity's sake, it's omitted here. -4) stringchar explicitly includes ). See 3(b) for why it won't inherit it +4) stringchar explicitly includes ). See 3(b) for why it won't inherit it from urlchar as the spec implies. -5) BOM ::= #xFEFF is omitted. It is assumed that any leading BOM will be +5) BOM ::= #xFEFF is omitted. It is assumed that any leading BOM will be stripped from the document before lexing occurs. diff --git a/examples/example1.c b/examples/example1.c index be7a582..1c0dcf9 100644 --- a/examples/example1.c +++ b/examples/example1.c @@ -43,8 +43,8 @@ static css_error named_generic_sibling_node(void *pw, void *node, void **sibling); static css_error parent_node(void *pw, void *node, void **parent); static css_error sibling_node(void *pw, void *node, void **sibling); -static css_error node_has_name(void *pw, void *node, - const css_qname *qname, +static css_error node_has_name(void *pw, void *node, + const css_qname *qname, bool *match); static css_error node_has_class(void *pw, void *node, lwc_string *name, @@ -299,9 +299,9 @@ css_error node_name(void *pw, void *n, css_qname *qname) lwc_string *node = n; UNUSED(pw); - + qname->name = lwc_string_ref(node); - + return CSS_OK; } @@ -691,17 +691,17 @@ css_error compute_font_size(void *pw, const css_hint *parent, css_hint *size) size->data.length = sizes[size->status - 1]; } else if (size->status == CSS_FONT_SIZE_LARGER) { /** \todo Step within table, if appropriate */ - size->data.length.value = + size->data.length.value = FMUL(parent_size->value, FLTTOFIX(1.2)); size->data.length.unit = parent_size->unit; } else if (size->status == CSS_FONT_SIZE_SMALLER) { /** \todo Step within table, if appropriate */ - size->data.length.value = + size->data.length.value = FMUL(parent_size->value, FLTTOFIX(1.2)); size->data.length.unit = parent_size->unit; } else if (size->data.length.unit == CSS_UNIT_EM || size->data.length.unit == CSS_UNIT_EX) { - size->data.length.value = + size->data.length.value = FMUL(size->data.length.value, parent_size->value); if (size->data.length.unit == CSS_UNIT_EX) { diff --git a/include/libcss/font_face.h b/include/libcss/font_face.h index 6b18433..135682c 100644 --- a/include/libcss/font_face.h +++ b/include/libcss/font_face.h @@ -15,7 +15,7 @@ extern "C" #endif #include <libwapcaplet/libwapcaplet.h> - + #include <libcss/errors.h> #include <libcss/functypes.h> #include <libcss/properties.h> @@ -32,15 +32,15 @@ typedef enum css_font_face_format { /* Embedded OpenType; .eot */ CSS_FONT_FACE_FORMAT_SVG = 0x08, /* SVG Font; .svg, .svgz */ - + CSS_FONT_FACE_FORMAT_UNKNOWN = 0x10, /* Format specified, but not recognised */ - - /* We don't define CSS_FONT_FACE_SRC_FORMAT_TRUETYPE as might be - * expected, because the CSS3 specification + + /* We don't define CSS_FONT_FACE_SRC_FORMAT_TRUETYPE as might be + * expected, because the CSS3 specification * (http://www.w3.org/TR/css3-fonts/, §4.3) says: * "Given the overlap in common usage between TrueType and - * OpenType, the format hints "truetype" and "opentype" must be + * OpenType, the format hints "truetype" and "opentype" must be * considered as synonymous" * so we compute a hint of 'truetype' to css_font_face_format_opentype. */ @@ -52,19 +52,19 @@ typedef enum css_font_face_location_type { CSS_FONT_FACE_LOCATION_TYPE_URI = 2, } css_font_face_location_type; - + css_error css_font_face_get_font_family( - const css_font_face *font_face, + const css_font_face *font_face, lwc_string **font_family); - -css_error css_font_face_count_srcs(const css_font_face *font_face, + +css_error css_font_face_count_srcs(const css_font_face *font_face, uint32_t *count); css_error css_font_face_get_src(const css_font_face *font_face, uint32_t index, const css_font_face_src **src); - + css_error css_font_face_src_get_location(const css_font_face_src *src, lwc_string **location); - + css_font_face_location_type css_font_face_src_location_type( const css_font_face_src *src); css_font_face_format css_font_face_src_format(const css_font_face_src *src); diff --git a/include/libcss/fpmath.h b/include/libcss/fpmath.h index 91f2b7e..1e3fa43 100644 --- a/include/libcss/fpmath.h +++ b/include/libcss/fpmath.h @@ -22,66 +22,66 @@ extern "C" /* type for fixed point numbers */ typedef int32_t css_fixed; -static inline css_fixed +static inline css_fixed css_add_fixed(const css_fixed x, const css_fixed y) { int32_t ux = x; int32_t uy = y; int32_t res = ux + uy; - + /* Calculate overflowed result. (Don't change the sign bit of ux) */ ux = (ux >> 31) + INT_MAX; - + /* Force compiler to use cmovns instruction */ if ((int32_t) ((ux ^ uy) | ~(uy ^ res)) >= 0) { res = ux; } - + return res; } -static inline css_fixed +static inline css_fixed css_subtract_fixed(const css_fixed x, const css_fixed y) { int32_t ux = x; int32_t uy = y; int32_t res = ux - uy; - + ux = (ux >> 31) + INT_MAX; - + /* Force compiler to use cmovns instruction */ if ((int32_t)((ux ^ uy) & (ux ^ res)) < 0) { res = ux; } - + return res; } -static inline css_fixed +static inline css_fixed css_divide_fixed(const css_fixed x, const css_fixed y) { int64_t xx = ((int64_t)x << CSS_RADIX_POINT) / y; - + if (xx < INT_MIN) xx = INT_MIN; if (xx > INT_MAX) xx = INT_MAX; - + return xx; } -static inline css_fixed +static inline css_fixed css_multiply_fixed(const css_fixed x, const css_fixed y) { int64_t xx = ((int64_t)x * (int64_t)y) >> CSS_RADIX_POINT; - + if (xx < INT_MIN) xx = INT_MIN; if (xx > INT_MAX) xx = INT_MAX; - + return xx; } -static inline css_fixed +static inline css_fixed css_int_to_fixed(const int a) { int64_t xx = ((int64_t) a) << CSS_RADIX_POINT; @@ -90,11 +90,11 @@ css_int_to_fixed(const int a) { if (xx > INT_MAX) xx = INT_MAX; - + return xx; } -static inline css_fixed +static inline css_fixed css_float_to_fixed(const float a) { float xx = a * (float) (1 << CSS_RADIX_POINT); @@ -103,7 +103,7 @@ css_float_to_fixed(const float a) { if (xx > INT_MAX) xx = INT_MAX; - + return (css_fixed) xx; } diff --git a/include/libcss/select.h b/include/libcss/select.h index 3f1e14a..f1de409 100644 --- a/include/libcss/select.h +++ b/include/libcss/select.h @@ -34,9 +34,9 @@ typedef enum css_pseudo_element { */ typedef struct css_select_results { /** - * Array of pointers to computed styles, + * Array of pointers to computed styles, * indexed by css_pseudo_element. If there - * was no styling for a given pseudo element, + * was no styling for a given pseudo element, * then no computed style will be created and * the corresponding pointer will be set to NULL */ @@ -157,7 +157,7 @@ typedef struct css_select_handler { */ typedef struct css_select_font_faces_results { /** - * Array of pointers to computed font faces. + * Array of pointers to computed font faces. */ css_font_face **font_faces; uint32_t n_font_faces; @@ -204,8 +204,8 @@ css_error css_libcss_node_data_handler(css_select_handler *handler, css_error css_select_ctx_create(css_select_ctx **result); css_error css_select_ctx_destroy(css_select_ctx *ctx); -css_error css_select_ctx_append_sheet(css_select_ctx *ctx, - const css_stylesheet *sheet, +css_error css_select_ctx_append_sheet(css_select_ctx *ctx, + const css_stylesheet *sheet, css_origin origin, uint64_t media); css_error css_select_ctx_insert_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, uint32_t index, @@ -224,7 +224,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node, uint64_t media, const css_stylesheet *inline_style, css_select_handler *handler, void *pw, css_select_results **result); -css_error css_select_results_destroy(css_select_results *results); +css_error css_select_results_destroy(css_select_results *results); css_error css_select_font_faces(css_select_ctx *ctx, uint64_t media, lwc_string *font_family, diff --git a/include/libcss/stylesheet.h b/include/libcss/stylesheet.h index f92d870..68c4dfc 100644 --- a/include/libcss/stylesheet.h +++ b/include/libcss/stylesheet.h @@ -65,12 +65,12 @@ typedef struct css_system_font { enum css_font_style_e style; enum css_font_variant_e variant; enum css_font_weight_e weight; - struct { - css_fixed size; + struct { + css_fixed size; css_unit unit; } size; - struct { - css_fixed size; + struct { + css_fixed size; css_unit unit; } line_height; /* Note: must be a single family name only */ diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h index 4ac3dfb..656d7a5 100644 --- a/src/bytecode/bytecode.h +++ b/src/bytecode/bytecode.h @@ -14,7 +14,7 @@ #include <libcss/types.h> #include <libcss/properties.h> -typedef uint32_t css_code_t; +typedef uint32_t css_code_t; typedef enum css_properties_e opcode_t; diff --git a/src/charset/detect.c b/src/charset/detect.c index a6b2346..23c1bf9 100644 --- a/src/charset/detect.c +++ b/src/charset/detect.c @@ -13,13 +13,13 @@ #include "charset/detect.h" #include "utils/utils.h" -static parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, +static parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, size_t len, uint16_t *mibenum); -static parserutils_error try_utf32_charset(const uint8_t *data, +static parserutils_error try_utf32_charset(const uint8_t *data, size_t len, uint16_t *result); -static parserutils_error try_utf16_charset(const uint8_t *data, +static parserutils_error try_utf16_charset(const uint8_t *data, size_t len, uint16_t *result); -static parserutils_error try_ascii_compatible_charset(const uint8_t *data, +static parserutils_error try_ascii_compatible_charset(const uint8_t *data, size_t len, uint16_t *result); /** @@ -60,7 +60,7 @@ parserutils_error css__charset_extract(const uint8_t *data, size_t len, return PARSERUTILS_OK; } - /* If we've already got a charset from the linking mechanism or + /* If we've already got a charset from the linking mechanism or * referring document, then we've nothing further to do */ if (*source != CSS_CHARSET_DEFAULT) return PARSERUTILS_OK; @@ -84,7 +84,7 @@ parserutils_error css__charset_extract(const uint8_t *data, size_t len, * \param mibenum Pointer to location to receive MIB enum * \return PARSERUTILS_OK on success, appropriate error otherwise */ -parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, +parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, size_t len, uint16_t *mibenum) { parserutils_error error; @@ -99,30 +99,30 @@ parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, /* Look for BOM */ - if (data[0] == 0x00 && data[1] == 0x00 && + if (data[0] == 0x00 && data[1] == 0x00 && data[2] == 0xFE && data[3] == 0xFF) { - charset = parserutils_charset_mibenum_from_name("UTF-32BE", + charset = parserutils_charset_mibenum_from_name("UTF-32BE", SLEN("UTF-32BE")); } else if (data[0] == 0xFF && data[1] == 0xFE && data[2] == 0x00 && data[3] == 0x00) { - charset = parserutils_charset_mibenum_from_name("UTF-32LE", + charset = parserutils_charset_mibenum_from_name("UTF-32LE", SLEN("UTF-32LE")); } else if (data[0] == 0xFE && data[1] == 0xFF) { - charset = parserutils_charset_mibenum_from_name("UTF-16BE", + charset = parserutils_charset_mibenum_from_name("UTF-16BE", SLEN("UTF-16BE")); } else if (data[0] == 0xFF && data[1] == 0xFE) { - charset = parserutils_charset_mibenum_from_name("UTF-16LE", + charset = parserutils_charset_mibenum_from_name("UTF-16LE", SLEN("UTF-16LE")); } else if (data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF) { - charset = parserutils_charset_mibenum_from_name("UTF-8", + charset = parserutils_charset_mibenum_from_name("UTF-8", SLEN("UTF-8")); } /* BOM beats @charset. - * UAs differ here, but none appear to match the spec. - * The spec indicates that any @charset present in conjunction with a - * BOM, should match the BOM. In reality, it appears UAs just take the - * BOM as gospel and ignore any @charset rule. The w3c CSS validator + * UAs differ here, but none appear to match the spec. + * The spec indicates that any @charset present in conjunction with a + * BOM, should match the BOM. In reality, it appears UAs just take the + * BOM as gospel and ignore any @charset rule. The w3c CSS validator * appears to do the same (at the least, it doesn't complain about a * mismatch). */ @@ -150,7 +150,7 @@ parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, return PARSERUTILS_OK; } -static parserutils_error try_utf32_charset(const uint8_t *data, +static parserutils_error try_utf32_charset(const uint8_t *data, size_t len, uint16_t *result) { uint16_t charset = 0; @@ -170,7 +170,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, /* Look for "; at end of charset declaration */ for (end = start; end < data + len - 4; end += 4) { - uint32_t c = end[0] | (end[1] << 8) | + uint32_t c = end[0] | (end[1] << 8) | (end[2] << 16) | (end[3] << 24); /* Bail if non-ASCII */ @@ -202,7 +202,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, } /* Ensure we have something that looks like UTF-32(LE)? */ - if ((ptr - buf == SLEN("UTF-32LE") && + if ((ptr - buf == SLEN("UTF-32LE") && memcmp(buf, "UTF-32LE", ptr - buf) == 0) || (ptr - buf == SLEN("UTF-32") && memcmp(buf, "UTF-32", ptr - buf) == 0)) { @@ -218,7 +218,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, /* Look for "; at end of charset declaration */ for (end = start; end < data + len - 4; end += 4) { - uint32_t c = end[3] | (end[2] << 8) | + uint32_t c = end[3] | (end[2] << 8) | (end[1] << 16) | (end[0] << 24); /* Bail if non-ASCII */ @@ -250,7 +250,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, } /* Ensure we have something that looks like UTF-32(BE)? */ - if ((ptr - buf == SLEN("UTF-32BE") && + if ((ptr - buf == SLEN("UTF-32BE") && memcmp(buf, "UTF-32BE", ptr - buf) == 0) || (ptr - buf == SLEN("UTF-32") && memcmp(buf, "UTF-32", ptr - buf) == 0)) { @@ -268,7 +268,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, return PARSERUTILS_OK; } -static parserutils_error try_utf16_charset(const uint8_t *data, +static parserutils_error try_utf16_charset(const uint8_t *data, size_t len, uint16_t *result) { uint16_t charset = 0; @@ -318,7 +318,7 @@ static parserutils_error try_utf16_charset(const uint8_t *data, } /* Ensure we have something that looks like UTF-16(LE)? */ - if ((ptr - buf == SLEN("UTF-16LE") && + if ((ptr - buf == SLEN("UTF-16LE") && memcmp(buf, "UTF-16LE", ptr - buf) == 0) || (ptr - buf == SLEN("UTF-16") && memcmp(buf, "UTF-16", ptr - buf) == 0)) { @@ -364,7 +364,7 @@ static parserutils_error try_utf16_charset(const uint8_t *data, } /* Ensure we have something that looks like UTF-16(BE)? */ - if ((ptr - buf == SLEN("UTF-16BE") && + if ((ptr - buf == SLEN("UTF-16BE") && memcmp(buf, "UTF-16BE", ptr - buf) == 0) || (ptr - buf == SLEN("UTF-16") && memcmp(buf, "UTF-16", ptr - buf) == 0)) { @@ -399,7 +399,7 @@ parserutils_error try_ascii_compatible_charset(const uint8_t *data, size_t len, /* Look for "; at end of charset declaration */ for (end = start; end < data + len; end++) { - if (*end == '"' && end < data + len - 1 && + if (*end == '"' && end < data + len - 1 && *(end + 1) == ';') break; } diff --git a/src/lex/lex.c b/src/lex/lex.c index 0f956db..2be1145 100644 --- a/src/lex/lex.c +++ b/src/lex/lex.c @@ -6,7 +6,7 @@ */ /** \file CSS lexer - * + * * See docs/Tokens for the production rules used by this lexer. * * See docs/Lexer for the inferred first characters for each token. @@ -36,15 +36,15 @@ #include "utils/parserutilserror.h" #include "utils/utils.h" -/** \todo Optimisation -- we're currently revisiting a bunch of input - * characters (Currently, we're calling parserutils_inputstream_peek - * about 1.5x the number of characters in the input stream). Ideally, - * we'll visit each character in the input exactly once. In reality, - * the upper bound is twice, due to the need, in some cases, to read - * one character beyond the end of a token's input to detect the end - * of the token. Resumability adds a little overhead here, unless - * we're somewhat more clever when it comes to having support for - * restarting mid-escape sequence. Currently, we rewind back to the +/** \todo Optimisation -- we're currently revisiting a bunch of input + * characters (Currently, we're calling parserutils_inputstream_peek + * about 1.5x the number of characters in the input stream). Ideally, + * we'll visit each character in the input exactly once. In reality, + * the upper bound is twice, due to the need, in some cases, to read + * one character beyond the end of a token's input to detect the end + * of the token. Resumability adds a little overhead here, unless + * we're somewhat more clever when it comes to having support for + * restarting mid-escape sequence. Currently, we rewind back to the * start of the sequence and process the whole thing again. */ @@ -53,17 +53,17 @@ enum { sATKEYWORD = 1, sSTRING = 2, sHASH = 3, - sNUMBER = 4, + sNUMBER = 4, sCDO = 5, sCDC = 6, sS = 7, sCOMMENT = 8, - sMATCH = 9, + sMATCH = 9, sURI = 10, sIDENT = 11, sESCAPEDIDENT = 12, sURL = 13, - sUCR = 14 + sUCR = 14 }; /** @@ -73,16 +73,16 @@ struct css_lexer { parserutils_inputstream *input; /**< Inputstream containing CSS */ - size_t bytesReadForToken; /**< Total bytes read from the + size_t bytesReadForToken; /**< Total bytes read from the * inputstream for the current token */ css_token token; /**< The current token */ - bool escapeSeen; /**< Whether an escape sequence has + bool escapeSeen; /**< Whether an escape sequence has * been seen while processing the input * for the current token */ - parserutils_buffer *unescapedTokenData; /**< Buffer containing - * unescaped token data + parserutils_buffer *unescapedTokenData; /**< Buffer containing + * unescaped token data * (used iff escapeSeen == true) */ @@ -91,13 +91,13 @@ struct css_lexer struct { uint8_t first; /**< First character read for token */ - size_t origBytes; /**< Storage of current number of + size_t origBytes; /**< Storage of current number of * bytes read, for rewinding */ - bool lastWasStar; /**< Whether the previous character + bool lastWasStar; /**< Whether the previous character * was an asterisk */ bool lastWasCR; /**< Whether the previous character * was CR */ - size_t bytesForURL; /**< Input bytes read for "url(", for + size_t bytesForURL; /**< Input bytes read for "url(", for * rewinding */ size_t dataLenForURL; /**< Output length for "url(", for * rewinding */ @@ -121,7 +121,7 @@ do { \ (lexer)->currentCol += (len); \ } while(0) \ -static css_error appendToTokenData(css_lexer *lexer, +static css_error appendToTokenData(css_lexer *lexer, const uint8_t *data, size_t len); static css_error emitToken(css_lexer *lexer, css_token_type type, css_token **token); @@ -287,7 +287,7 @@ css_error css__lexer_get_token(css_lexer *lexer, css_token **token) return S(lexer, token); case sCOMMENT: error = Comment(lexer, token); - if (!lexer->emit_comments && error == CSS_OK && + if (!lexer->emit_comments && error == CSS_OK && (*token)->type == CSS_TOKEN_COMMENT) goto start; return error; @@ -324,7 +324,7 @@ css_error css__lexer_get_token(css_lexer *lexer, css_token **token) * \return CSS_OK on success, appropriate error otherwise * * This should not be called directly without good reason. Use the APPEND() - * macro instead. + * macro instead. */ css_error appendToTokenData(css_lexer *lexer, const uint8_t *data, size_t len) { @@ -358,16 +358,16 @@ css_error emitToken(css_lexer *lexer, css_token_type type, t->type = type; - /* Calculate token data start pointer. We have to do this here as + /* Calculate token data start pointer. We have to do this here as * the inputstream's buffer may have moved under us. */ if (lexer->escapeSeen) { t->data.data = lexer->unescapedTokenData->data; } else { size_t clen; const uint8_t *data; - parserutils_error error; + parserutils_error error; - error = parserutils_inputstream_peek(lexer->input, 0, + error = parserutils_inputstream_peek(lexer->input, 0, &data, &clen); #ifndef NDEBUG @@ -439,7 +439,7 @@ css_error emitToken(css_lexer *lexer, css_token_type type, } /* Strip any trailing quote */ - if (t->data.len > 0 && (t->data.data[t->data.len - 1] == '"' || + if (t->data.len > 0 && (t->data.data[t->data.len - 1] == '"' || t->data.data[t->data.len - 1] == '\'')) { t->data.len -= 1; } @@ -487,14 +487,14 @@ css_error AtKeyword(css_lexer *lexer, css_token **token) parserutils_error perror; enum { Initial = 0, Escape = 1, NMChar = 2 }; - /* ATKEYWORD = '@' ident - * + /* ATKEYWORD = '@' ident + * * The '@' has been consumed. */ switch (lexer->substate) { case Initial: - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -561,15 +561,15 @@ css_error CDCOrIdentOrFunctionOrNPD(css_lexer *lexer, css_token **token) * PERCENTAGE = num '%' * DIMENSION = num ident * - * The first dash has been consumed. Thus, we must consume the next - * character in the stream. If it's a dash, then we're dealing with - * CDC. If it's a digit or dot, then we're dealing with NPD. + * The first dash has been consumed. Thus, we must consume the next + * character in the stream. If it's a dash, then we're dealing with + * CDC. If it's a digit or dot, then we're dealing with NPD. * Otherwise, we're dealing with IDENT/FUNCTION. */ switch (lexer->substate) { case Initial: - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -617,7 +617,7 @@ css_error CDCOrIdentOrFunctionOrNPD(css_lexer *lexer, css_token **token) lexer->substate = Gt; /* Ok, so we're dealing with CDC. Expect a '>' */ - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -677,14 +677,14 @@ css_error CDO(css_lexer *lexer, css_token **token) enum { Initial = 0, Dash1 = 1, Dash2 = 2 }; /* CDO = "<!--" - * + * * The '<' has been consumed */ switch (lexer->substate) { case Initial: /* Expect '!' */ - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -707,7 +707,7 @@ css_error CDO(css_lexer *lexer, css_token **token) lexer->substate = Dash1; /* Expect '-' */ - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -736,7 +736,7 @@ css_error CDO(css_lexer *lexer, css_token **token) lexer->substate = Dash2; /* Expect '-' */ - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -778,7 +778,7 @@ css_error Comment(css_lexer *lexer, css_token **token) */ switch (lexer->substate) { case Initial: - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -792,7 +792,7 @@ css_error Comment(css_lexer *lexer, css_token **token) return emitToken(lexer, CSS_TOKEN_CHAR, token); APPEND(lexer, cptr, clen); - + /* Fall through */ case InComment: lexer->substate = InComment; @@ -800,12 +800,12 @@ css_error Comment(css_lexer *lexer, css_token **token) while (1) { perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); - if (perror != PARSERUTILS_OK && + if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); if (perror == PARSERUTILS_EOF) { - /* As per unterminated strings, + /* As per unterminated strings, * we ignore unterminated comments. */ return emitToken(lexer, CSS_TOKEN_EOF, token); } @@ -863,10 +863,10 @@ css_error EscapedIdentOrFunction(css_lexer *lexer, css_token **token) } css_error Hash(css_lexer *lexer, css_token **token) -{ +{ css_error error; - - /* HASH = '#' name = '#' nmchar+ + + /* HASH = '#' name = '#' nmchar+ * * The '#' has been consumed. */ @@ -909,7 +909,7 @@ css_error IdentOrFunction(css_lexer *lexer, css_token **token) case Bracket: lexer->substate = Bracket; - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -996,14 +996,14 @@ css_error NumberOrPercentageOrDimension(css_lexer *lexer, css_token **token) size_t clen; css_error error; parserutils_error perror; - enum { Initial = 0, Dot = 1, MoreDigits = 2, + enum { Initial = 0, Dot = 1, MoreDigits = 2, Suffix = 3, NMChars = 4, Escape = 5 }; /* NUMBER = num = [-+]? ([0-9]+ | [0-9]* '.' [0-9]+) * PERCENTAGE = num '%' * DIMENSION = num ident * - * The sign, or sign and first digit or dot, + * The sign, or sign and first digit or dot, * or first digit, or '.' has been consumed. */ @@ -1017,7 +1017,7 @@ css_error NumberOrPercentageOrDimension(css_lexer *lexer, css_token **token) case Dot: lexer->substate = Dot; - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1027,7 +1027,7 @@ css_error NumberOrPercentageOrDimension(css_lexer *lexer, css_token **token) lexer->context.first == '+')) return emitToken(lexer, CSS_TOKEN_CHAR, token); else - return emitToken(lexer, CSS_TOKEN_NUMBER, + return emitToken(lexer, CSS_TOKEN_NUMBER, token); } @@ -1062,7 +1062,7 @@ css_error NumberOrPercentageOrDimension(css_lexer *lexer, css_token **token) suffix: lexer->substate = Suffix; - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1072,7 +1072,7 @@ css_error NumberOrPercentageOrDimension(css_lexer *lexer, css_token **token) lexer->context.first == '+')) return emitToken(lexer, CSS_TOKEN_CHAR, token); else - return emitToken(lexer, CSS_TOKEN_NUMBER, + return emitToken(lexer, CSS_TOKEN_NUMBER, token); } @@ -1119,7 +1119,7 @@ css_error NumberOrPercentageOrDimension(css_lexer *lexer, css_token **token) lexer->bytesReadForToken -= 1; /* This can only be a number */ - return emitToken(lexer, + return emitToken(lexer, CSS_TOKEN_NUMBER, token); } @@ -1137,7 +1137,7 @@ css_error S(css_lexer *lexer, css_token **token) css_error error; /* S = wc* - * + * * The first whitespace character has been consumed. */ @@ -1209,7 +1209,7 @@ start: lexer->substate = 0; lexer->context.origBytes = lexer->bytesReadForToken; return Hash(lexer, token); - case '0': case '1': case '2': case '3': case '4': + case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': case '+': lexer->state = sNUMBER; @@ -1252,17 +1252,17 @@ start: lexer->state = sURI; lexer->substate = 0; return URIOrUnicodeRangeOrIdentOrFunction(lexer, token); - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': /* 'u'*/ case 'v': case 'w': case 'x': + case 's': case 't': /* 'u'*/ case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': /* 'U'*/ case 'V': case 'W': case 'X': case 'Y': case 'Z': - case '_': + case '_': lexer->state = sIDENT; lexer->substate = 0; return IdentOrFunction(lexer, token); @@ -1289,13 +1289,13 @@ css_error String(css_lexer *lexer, css_token **token) return error; /* EOF will be reprocessed in Start() */ - return emitToken(lexer, - error == CSS_INVALID ? CSS_TOKEN_INVALID_STRING - : CSS_TOKEN_STRING, + return emitToken(lexer, + error == CSS_INVALID ? CSS_TOKEN_INVALID_STRING + : CSS_TOKEN_STRING, token); } -css_error URIOrUnicodeRangeOrIdentOrFunction(css_lexer *lexer, +css_error URIOrUnicodeRangeOrIdentOrFunction(css_lexer *lexer, css_token **token) { const uint8_t *cptr; @@ -1303,7 +1303,7 @@ css_error URIOrUnicodeRangeOrIdentOrFunction(css_lexer *lexer, size_t clen; parserutils_error perror; - /* URI = "url(" w (string | urlchar*) w ')' + /* URI = "url(" w (string | urlchar*) w ')' * UNICODE-RANGE = [Uu] '+' [0-9a-fA-F?]{1,6}(-[0-9a-fA-F]{1,6})? * IDENT = ident = [-]? nmstart nmchar* * FUNCTION = ident '(' = [-]? nmstart nmchar* '(' @@ -1311,7 +1311,7 @@ css_error URIOrUnicodeRangeOrIdentOrFunction(css_lexer *lexer, * The 'u' (or 'U') has been consumed. */ - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1351,17 +1351,17 @@ css_error URI(css_lexer *lexer, css_token **token) size_t clen; css_error error; parserutils_error perror; - enum { Initial = 0, LParen = 1, W1 = 2, Quote = 3, + enum { Initial = 0, LParen = 1, W1 = 2, Quote = 3, URL = 4, W2 = 5, RParen = 6, String = 7 }; - /* URI = "url(" w (string | urlchar*) w ')' + /* URI = "url(" w (string | urlchar*) w ')' * * 'u' and 'r' have been consumed. */ switch (lexer->substate) { case Initial: - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1385,7 +1385,7 @@ css_error URI(css_lexer *lexer, css_token **token) case LParen: lexer->substate = LParen; - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1444,9 +1444,9 @@ css_error URI(css_lexer *lexer, css_token **token) goto string; } - /* Potential minor optimisation: If string is more common, - * then fall through to that state and branch for the URL - * state. Need to investigate a reasonably large corpus of + /* Potential minor optimisation: If string is more common, + * then fall through to that state and branch for the URL + * state. Need to investigate a reasonably large corpus of * real-world data to determine if this is worthwhile. */ /* Fall through */ @@ -1472,7 +1472,7 @@ css_error URI(css_lexer *lexer, css_token **token) case RParen: lexer->substate = RParen; - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1529,7 +1529,7 @@ css_error UnicodeRange(css_lexer *lexer, css_token **token) enum { Initial = 0, MoreDigits = 1 }; /* UNICODE-RANGE = [Uu] '+' [0-9a-fA-F?]{1,6}(-[0-9a-fA-F]{1,6})? - * + * * "U+" has been consumed. */ @@ -1539,7 +1539,7 @@ css_error UnicodeRange(css_lexer *lexer, css_token **token) for (; lexer->context.hexCount < 6; lexer->context.hexCount++) { perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); - if (perror != PARSERUTILS_OK && + if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1549,10 +1549,10 @@ css_error UnicodeRange(css_lexer *lexer, css_token **token) lexer->bytesReadForToken -= 1; t->data.len -= 1; /* u == IDENT */ - return emitToken(lexer, + return emitToken(lexer, CSS_TOKEN_IDENT, token); } else { - return emitToken(lexer, + return emitToken(lexer, CSS_TOKEN_UNICODE_RANGE, token); } } @@ -1573,24 +1573,24 @@ css_error UnicodeRange(css_lexer *lexer, css_token **token) t->data.len -= 1; /* 'u' == IDENT */ return emitToken(lexer, CSS_TOKEN_IDENT, token); - } + } if (lexer->context.hexCount == 6) { /* Consumed 6 valid characters. Look for '-' */ - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); - if (perror != PARSERUTILS_OK && + if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); if (perror == PARSERUTILS_EOF) - return emitToken(lexer, + return emitToken(lexer, CSS_TOKEN_UNICODE_RANGE, token); c = *cptr; } - /* If we've got a '-', then we may have a + /* If we've got a '-', then we may have a * second range component */ if (c != '-') { /* Reached the end of the range */ @@ -1608,7 +1608,7 @@ css_error UnicodeRange(css_lexer *lexer, css_token **token) /* Consume up to 6 hex digits */ for (; lexer->context.hexCount < 6; lexer->context.hexCount++) { - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) @@ -1621,7 +1621,7 @@ css_error UnicodeRange(css_lexer *lexer, css_token **token) t->data.len -= 1; } - return emitToken(lexer, + return emitToken(lexer, CSS_TOKEN_UNICODE_RANGE, token); } @@ -1659,7 +1659,7 @@ css_error consumeDigits(css_lexer *lexer) /* Consume all digits */ do { - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1685,12 +1685,12 @@ css_error consumeEscape(css_lexer *lexer, bool nl) css_error error; parserutils_error perror; - /* escape = unicode | '\' [^\n\r\f0-9a-fA-F] - * + /* escape = unicode | '\' [^\n\r\f0-9a-fA-F] + * * The '\' has been consumed. */ - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1723,7 +1723,7 @@ css_error consumeEscape(css_lexer *lexer, bool nl) /* -1 to skip '\\' */ perror = parserutils_buffer_append( - lexer->unescapedTokenData, + lexer->unescapedTokenData, sdata, lexer->bytesReadForToken - 1); if (perror != PARSERUTILS_OK) return css_error_from_parserutils_error(perror); @@ -1747,7 +1747,7 @@ css_error consumeEscape(css_lexer *lexer, bool nl) /* If we're handling escaped newlines, convert CR(LF)? to LF */ if (nl && c == '\r') { - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken + clen, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1799,7 +1799,7 @@ css_error consumeNMChars(css_lexer *lexer) /* nmchar = [a-zA-Z] | '-' | '_' | nonascii | escape */ do { - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1818,13 +1818,13 @@ css_error consumeNMChars(css_lexer *lexer) error = consumeEscape(lexer, false); if (error != CSS_OK) { - /* Rewind '\\', so we do the + /* Rewind '\\', so we do the * right thing next time */ lexer->bytesReadForToken -= clen; /* Convert either EOF or INVALID into OK. * This will cause the caller to believe that - * all NMChars in the sequence have been + * all NMChars in the sequence have been * processed (and thus proceed to the next * state). Eventually, the '\\' will be output * as a CHAR. */ @@ -1855,7 +1855,7 @@ css_error consumeString(css_lexer *lexer) */ do { - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -1913,7 +1913,7 @@ css_error consumeStringChars(css_lexer *lexer) error = consumeEscape(lexer, true); if (error != CSS_OK) { - /* Rewind '\\', so we do the + /* Rewind '\\', so we do the * right thing next time. */ lexer->bytesReadForToken -= clen; @@ -1946,14 +1946,14 @@ css_error consumeUnicode(css_lexer *lexer, uint32_t ucs) css_error error; parserutils_error perror; - /* unicode = '\' [0-9a-fA-F]{1,6} wc? + /* unicode = '\' [0-9a-fA-F]{1,6} wc? * * The '\' and the first digit have been consumed. */ /* Attempt to consume a further five hex digits */ for (count = 0; count < 5; count++) { - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) { /* Rewind what we've read */ @@ -2027,7 +2027,7 @@ css_error consumeUnicode(css_lexer *lexer, uint32_t ucs) /* We can't use the APPEND() macro here as we want to rewind correctly * on error. Additionally, lexer->bytesReadForToken has already been * advanced */ - error = appendToTokenData(lexer, (const uint8_t *) utf8, + error = appendToTokenData(lexer, (const uint8_t *) utf8, sizeof(utf8) - utf8len); if (error != CSS_OK) { /* Rewind what we've read */ @@ -2049,7 +2049,7 @@ css_error consumeUnicode(css_lexer *lexer, uint32_t ucs) lexer->currentLine++; } else { /* +2 for '\' and first digit */ - lexer->currentCol += lexer->bytesReadForToken - + lexer->currentCol += lexer->bytesReadForToken - bytesReadInit + 2; } @@ -2067,7 +2067,7 @@ css_error consumeURLChars(css_lexer *lexer) /* urlchar = [\t!#-&(*-~] | nonascii | escape */ do { - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -2092,7 +2092,7 @@ css_error consumeURLChars(css_lexer *lexer) /* Convert either EOF or INVALID into OK. * This will cause the caller to believe that - * all URLChars in the sequence have been + * all URLChars in the sequence have been * processed (and thus proceed to the next * state). Eventually, the '\\' will be output * as a CHAR. */ @@ -2115,7 +2115,7 @@ css_error consumeWChars(css_lexer *lexer) parserutils_error perror; do { - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -2155,7 +2155,7 @@ css_error consumeWChars(css_lexer *lexer) bool startNMChar(uint8_t c) { - return c == '_' || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || + return c == '_' || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '-' || c >= 0x80 || c == '\\'; } diff --git a/src/lex/lex.h b/src/lex/lex.h index 4a663ea..ac21444 100644 --- a/src/lex/lex.h +++ b/src/lex/lex.h @@ -35,18 +35,18 @@ typedef union css_lexer_optparams { /** * Token type */ -typedef enum css_token_type { +typedef enum css_token_type { CSS_TOKEN_IDENT, CSS_TOKEN_ATKEYWORD, CSS_TOKEN_HASH, - CSS_TOKEN_FUNCTION, CSS_TOKEN_STRING, CSS_TOKEN_INVALID_STRING, - CSS_TOKEN_URI, CSS_TOKEN_UNICODE_RANGE, CSS_TOKEN_CHAR, + CSS_TOKEN_FUNCTION, CSS_TOKEN_STRING, CSS_TOKEN_INVALID_STRING, + CSS_TOKEN_URI, CSS_TOKEN_UNICODE_RANGE, CSS_TOKEN_CHAR, CSS_TOKEN_NUMBER, CSS_TOKEN_PERCENTAGE, CSS_TOKEN_DIMENSION, /* Those tokens that want strings interned appear above */ CSS_TOKEN_LAST_INTERN, - CSS_TOKEN_CDO, CSS_TOKEN_CDC, CSS_TOKEN_S, CSS_TOKEN_COMMENT, - CSS_TOKEN_INCLUDES, CSS_TOKEN_DASHMATCH, CSS_TOKEN_PREFIXMATCH, - CSS_TOKEN_SUFFIXMATCH, CSS_TOKEN_SUBSTRINGMATCH, CSS_TOKEN_EOF + CSS_TOKEN_CDO, CSS_TOKEN_CDC, CSS_TOKEN_S, CSS_TOKEN_COMMENT, + CSS_TOKEN_INCLUDES, CSS_TOKEN_DASHMATCH, CSS_TOKEN_PREFIXMATCH, + CSS_TOKEN_SUFFIXMATCH, CSS_TOKEN_SUBSTRINGMATCH, CSS_TOKEN_EOF } css_token_type; /** @@ -55,13 +55,13 @@ typedef enum css_token_type { typedef struct css_token { css_token_type type; - struct { - uint8_t *data; - size_t len; - } data; + struct { + uint8_t *data; + size_t len; + } data; lwc_string *idata; - + uint32_t col; uint32_t line; } css_token; @@ -69,7 +69,7 @@ typedef struct css_token { css_error css__lexer_create(parserutils_inputstream *input, css_lexer **lexer); css_error css__lexer_destroy(css_lexer *lexer); -css_error css__lexer_setopt(css_lexer *lexer, css_lexer_opttype type, +css_error css__lexer_setopt(css_lexer *lexer, css_lexer_opttype type, css_lexer_optparams *params); css_error css__lexer_get_token(css_lexer *lexer, css_token **token); diff --git a/src/parse/font_face.c b/src/parse/font_face.c index 8eab006..f17d50e 100644 --- a/src/parse/font_face.c +++ b/src/parse/font_face.c @@ -15,22 +15,22 @@ #include "parse/properties/utils.h" #include "select/font_face.h" -static bool font_rule_font_family_reserved(css_language *c, +static bool font_rule_font_family_reserved(css_language *c, const css_token *ident) { bool match; return (lwc_string_caseless_isequal(ident->idata, c->strings[SERIF], &match) == lwc_error_ok && match) || - (lwc_string_caseless_isequal(ident->idata, - c->strings[SANS_SERIF], &match) == lwc_error_ok && + (lwc_string_caseless_isequal(ident->idata, + c->strings[SANS_SERIF], &match) == lwc_error_ok && match) || (lwc_string_caseless_isequal(ident->idata, c->strings[CURSIVE], &match) == lwc_error_ok && match) || (lwc_string_caseless_isequal(ident->idata, c->strings[FANTASY], &match) == lwc_error_ok && match) || - (lwc_string_caseless_isequal(ident->idata, - c->strings[MONOSPACE], &match) == lwc_error_ok && + (lwc_string_caseless_isequal(ident->idata, + c->strings[MONOSPACE], &match) == lwc_error_ok && match) || (lwc_string_caseless_isequal(ident->idata, c->strings[INHERIT], &match) == lwc_error_ok && match) || @@ -40,9 +40,9 @@ static bool font_rule_font_family_reserved(css_language *c, &match) == lwc_error_ok && match); } -static css_error font_face_parse_font_family(css_language *c, +static css_error font_face_parse_font_family(css_language *c, const parserutils_vector *vector, int *ctx, - css_font_face *font_face) + css_font_face *font_face) { css_error error; lwc_string *string; @@ -58,9 +58,9 @@ static css_error font_face_parse_font_family(css_language *c, return CSS_OK; } - -static css_error font_face_src_parse_format(css_language *c, - const parserutils_vector *vector, int *ctx, + +static css_error font_face_src_parse_format(css_language *c, + const parserutils_vector *vector, int *ctx, css_font_face_format *format) { bool match; @@ -68,8 +68,8 @@ static css_error font_face_src_parse_format(css_language *c, *format = CSS_FONT_FACE_FORMAT_UNSPECIFIED; - /* 'format(' STRING [ ',' STRING ]* ')' - * + /* 'format(' STRING [ ',' STRING ]* ')' + * * 'format(' already consumed */ @@ -80,27 +80,27 @@ static css_error font_face_src_parse_format(css_language *c, if (token == NULL || token->type != CSS_TOKEN_STRING) return CSS_INVALID; - if (lwc_string_isequal(token->idata, - c->strings[WOFF], &match) == lwc_error_ok && + if (lwc_string_isequal(token->idata, + c->strings[WOFF], &match) == lwc_error_ok && match) { *format |= CSS_FONT_FACE_FORMAT_WOFF; - } else if ((lwc_string_isequal(token->idata, + } else if ((lwc_string_isequal(token->idata, c->strings[TRUETYPE], &match) == lwc_error_ok && match) || - (lwc_string_isequal(token->idata, + (lwc_string_isequal(token->idata, c->strings[OPENTYPE], &match) == lwc_error_ok && match)) { *format |= CSS_FONT_FACE_FORMAT_OPENTYPE; - } else if (lwc_string_isequal(token->idata, - c->strings[EMBEDDED_OPENTYPE], + } else if (lwc_string_isequal(token->idata, + c->strings[EMBEDDED_OPENTYPE], &match) == lwc_error_ok && match) { *format |= CSS_FONT_FACE_FORMAT_EMBEDDED_OPENTYPE; - } else if (lwc_string_isequal(token->idata, - c->strings[SVG], &match) == lwc_error_ok && + } else if (lwc_string_isequal(token->idata, + c->strings[SVG], &match) == lwc_error_ok && match) { *format |= CSS_FONT_FACE_FORMAT_SVG; } else { - /* The spec gives a list of possible strings, which + /* The spec gives a list of possible strings, which * hints that unknown strings should be parse errors, * but it also talks about "unknown font formats", * so we treat any string we don't know not as a parse @@ -119,8 +119,8 @@ static css_error font_face_src_parse_format(css_language *c, return CSS_OK; } -static css_error font_face_src_parse_spec_or_name(css_language *c, - const parserutils_vector *vector, int *ctx, +static css_error font_face_src_parse_spec_or_name(css_language *c, + const parserutils_vector *vector, int *ctx, lwc_string **location, css_font_face_location_type *location_type, css_font_face_format *format) @@ -138,12 +138,12 @@ static css_error font_face_src_parse_spec_or_name(css_language *c, consumeWhitespace(vector, ctx); token = parserutils_vector_iterate(vector, ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; if (token->type == CSS_TOKEN_URI) { error = c->sheet->resolve(c->sheet->resolve_pw, - c->sheet->url, token->idata, + c->sheet->url, token->idata, location); if (error != CSS_OK) return error; @@ -154,10 +154,10 @@ static css_error font_face_src_parse_spec_or_name(css_language *c, token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_FUNCTION && - lwc_string_caseless_isequal(token->idata, - c->strings[FORMAT], &match) == lwc_error_ok && + lwc_string_caseless_isequal(token->idata, + c->strings[FORMAT], &match) == lwc_error_ok && match) { - parserutils_vector_iterate(vector, ctx); + parserutils_vector_iterate(vector, ctx); error = font_face_src_parse_format(c, vector, ctx, format); @@ -167,8 +167,8 @@ static css_error font_face_src_parse_spec_or_name(css_language *c, } } } else if (token->type == CSS_TOKEN_FUNCTION && - lwc_string_caseless_isequal(token->idata, - c->strings[LOCAL], + lwc_string_caseless_isequal(token->idata, + c->strings[LOCAL], &match) == lwc_error_ok && match) { consumeWhitespace(vector, ctx); @@ -179,7 +179,7 @@ static css_error font_face_src_parse_spec_or_name(css_language *c, consumeWhitespace(vector, ctx); - token = parserutils_vector_iterate(vector, ctx); + token = parserutils_vector_iterate(vector, ctx); if (token == NULL || tokenIsChar(token, ')') == false) { lwc_string_unref(*location); return CSS_INVALID; @@ -193,8 +193,8 @@ static css_error font_face_src_parse_spec_or_name(css_language *c, return CSS_OK; } -static css_error font_face_parse_src(css_language *c, - const parserutils_vector *vector, int *ctx, +static css_error font_face_parse_src(css_language *c, + const parserutils_vector *vector, int *ctx, css_font_face *font_face) { int orig_ctx = *ctx; @@ -213,11 +213,11 @@ static css_error font_face_parse_src(css_language *c, /* Create one css_font_face_src for each consecutive location and * [potentially] type pair in the comma-separated list */ - do { + do { lwc_string *location; css_font_face_location_type location_type = CSS_FONT_FACE_LOCATION_TYPE_UNSPECIFIED; - css_font_face_format format = + css_font_face_format format = CSS_FONT_FACE_FORMAT_UNSPECIFIED; error = font_face_src_parse_spec_or_name(c, vector, ctx, @@ -225,10 +225,10 @@ static css_error font_face_parse_src(css_language *c, if (error != CSS_OK) goto cleanup; - /* This will be inefficient if there are a lot of locations - + /* This will be inefficient if there are a lot of locations - * probably not a problem in practice. */ - new_srcs = realloc(srcs, + new_srcs = realloc(srcs, (n_srcs + 1) * sizeof(css_font_face_src)); if (new_srcs == NULL) { error = CSS_NOMEM; @@ -240,7 +240,7 @@ static css_error font_face_parse_src(css_language *c, srcs[n_srcs].bits[0] = format << 2 | location_type; ++n_srcs; - + consumeWhitespace(vector, ctx); token = parserutils_vector_iterate(vector, ctx); } while (token != NULL && tokenIsChar(token, ',')); @@ -250,7 +250,7 @@ static css_error font_face_parse_src(css_language *c, cleanup: if (error != CSS_OK) { *ctx = orig_ctx; - if (srcs != NULL) + if (srcs != NULL) free(srcs); } @@ -273,16 +273,16 @@ static css_error font_face_parse_font_style(css_language *c, if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT))) { *ctx = orig_ctx; return CSS_INVALID; - } - - if ((lwc_string_caseless_isequal(token->idata, + } + + if ((lwc_string_caseless_isequal(token->idata, c->strings[NORMAL], &match) == lwc_error_ok && match)) { style = CSS_FONT_STYLE_NORMAL; - } else if ((lwc_string_caseless_isequal(token->idata, + } else if ((lwc_string_caseless_isequal(token->idata, c->strings[ITALIC], &match) == lwc_error_ok && match)) { style = CSS_FONT_STYLE_ITALIC; - } else if ((lwc_string_caseless_isequal(token->idata, - c->strings[OBLIQUE], &match) == lwc_error_ok && + } else if ((lwc_string_caseless_isequal(token->idata, + c->strings[OBLIQUE], &match) == lwc_error_ok && match)) { style = CSS_FONT_STYLE_OBLIQUE; } else { @@ -294,12 +294,12 @@ static css_error font_face_parse_font_style(css_language *c, } else { *ctx = orig_ctx; } - + return error; } -static css_error font_face_parse_font_weight(css_language *c, - const parserutils_vector *vector, int *ctx, +static css_error font_face_parse_font_weight(css_language *c, + const parserutils_vector *vector, int *ctx, css_font_face *font_face) { int orig_ctx = *ctx; @@ -308,7 +308,7 @@ static css_error font_face_parse_font_weight(css_language *c, enum css_font_weight_e weight = 0; bool match; - /* NUMBER (100, 200, 300, 400, 500, 600, 700, 800, 900) | + /* NUMBER (100, 200, 300, 400, 500, 600, 700, 800, 900) | * IDENT (normal, bold) */ token = parserutils_vector_iterate(vector, ctx); if (token == NULL || (token->type != CSS_TOKEN_IDENT && @@ -319,7 +319,7 @@ static css_error font_face_parse_font_weight(css_language *c, if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - css_fixed num = css__number_from_lwc_string(token->idata, + css_fixed num = css__number_from_lwc_string(token->idata, true, &consumed); /* Invalid if there are trailing characters */ if (consumed != lwc_string_length(token->idata)) { @@ -339,10 +339,10 @@ static css_error font_face_parse_font_weight(css_language *c, case 900: weight = CSS_FONT_WEIGHT_900; break; default: error = CSS_INVALID; } - } else if ((lwc_string_caseless_isequal(token->idata, + } else if ((lwc_string_caseless_isequal(token->idata, c->strings[NORMAL], &match) == lwc_error_ok && match)) { weight = CSS_FONT_WEIGHT_NORMAL; - } else if ((lwc_string_caseless_isequal(token->idata, + } else if ((lwc_string_caseless_isequal(token->idata, c->strings[BOLD], &match) == lwc_error_ok && match)) { weight = CSS_FONT_WEIGHT_BOLD; } else { @@ -350,7 +350,7 @@ static css_error font_face_parse_font_weight(css_language *c, } if (error == CSS_OK) { - font_face->bits[0] = (font_face->bits[0] & 0xc3) | + font_face->bits[0] = (font_face->bits[0] & 0xc3) | (weight << 2); } else { *ctx = orig_ctx; @@ -372,7 +372,7 @@ static css_error font_face_parse_font_weight(css_language *c, * CSS_INVALID on invalid syntax, * CSS_NOMEM on memory exhaustion */ -css_error css__parse_font_descriptor(css_language *c, +css_error css__parse_font_descriptor(css_language *c, const css_token *descriptor, const parserutils_vector *vector, int *ctx, css_rule_font_face *rule) { @@ -388,24 +388,24 @@ css_error css__parse_font_descriptor(css_language *c, rule->font_face = font_face; } - - if (lwc_string_caseless_isequal(descriptor->idata, - c->strings[FONT_FAMILY], &match) == lwc_error_ok && + + if (lwc_string_caseless_isequal(descriptor->idata, + c->strings[FONT_FAMILY], &match) == lwc_error_ok && match) { return font_face_parse_font_family(c, vector, ctx, font_face); } else if (lwc_string_caseless_isequal(descriptor->idata, c->strings[SRC], &match) == lwc_error_ok && match) { return font_face_parse_src(c, vector, ctx, font_face); } else if (lwc_string_caseless_isequal(descriptor->idata, - c->strings[FONT_STYLE], &match) == lwc_error_ok && + c->strings[FONT_STYLE], &match) == lwc_error_ok && match) { return font_face_parse_font_style(c, vector, ctx, font_face); } else if (lwc_string_caseless_isequal(descriptor->idata, - c->strings[FONT_WEIGHT], &match) == lwc_error_ok && + c->strings[FONT_WEIGHT], &match) == lwc_error_ok && match) { return font_face_parse_font_weight(c, vector, ctx, font_face); } - + return CSS_INVALID; } diff --git a/src/parse/important.c b/src/parse/important.c index 5589467..ca4d60c 100644 --- a/src/parse/important.c +++ b/src/parse/important.c @@ -100,9 +100,9 @@ void css__make_style_important(css_style *style) case CSS_PROP_BORDER_LEFT_COLOR: case CSS_PROP_BACKGROUND_COLOR: case CSS_PROP_COLUMN_RULE_COLOR: - assert(BACKGROUND_COLOR_SET == + assert(BACKGROUND_COLOR_SET == (enum op_background_color)BORDER_COLOR_SET); - assert(BACKGROUND_COLOR_SET == + assert(BACKGROUND_COLOR_SET == (enum op_background_color)COLUMN_RULE_COLOR_SET); if (value == BACKGROUND_COLOR_SET) @@ -113,14 +113,14 @@ void css__make_style_important(css_style *style) case CSS_PROP_CUE_AFTER: case CSS_PROP_CUE_BEFORE: case CSS_PROP_LIST_STYLE_IMAGE: - assert(BACKGROUND_IMAGE_URI == + assert(BACKGROUND_IMAGE_URI == (enum op_background_image)CUE_AFTER_URI); - assert(BACKGROUND_IMAGE_URI == + assert(BACKGROUND_IMAGE_URI == (enum op_background_image)CUE_BEFORE_URI); assert(BACKGROUND_IMAGE_URI == (enum op_background_image)LIST_STYLE_IMAGE_URI); - if (value == BACKGROUND_IMAGE_URI) + if (value == BACKGROUND_IMAGE_URI) offset++; /* string table entry */ break; @@ -143,7 +143,7 @@ void css__make_style_important(css_style *style) case CSS_PROP_BORDER_LEFT_WIDTH: case CSS_PROP_OUTLINE_WIDTH: case CSS_PROP_COLUMN_RULE_WIDTH: - assert(BORDER_WIDTH_SET == + assert(BORDER_WIDTH_SET == (enum op_border_width)OUTLINE_WIDTH_SET); assert(BORDER_WIDTH_SET == (enum op_border_width)COLUMN_RULE_WIDTH_SET); @@ -173,7 +173,7 @@ void css__make_style_important(css_style *style) assert(BOTTOM_SET == (enum op_bottom)COLUMN_WIDTH_SET); assert(BOTTOM_SET == (enum op_bottom)COLUMN_GAP_SET); - if (value == BOTTOM_SET) + if (value == BOTTOM_SET) offset += 2; /* length + units */ break; @@ -233,7 +233,7 @@ void css__make_style_important(css_style *style) case CSS_PROP_COUNTER_INCREMENT: case CSS_PROP_COUNTER_RESET: - assert(COUNTER_INCREMENT_NONE == + assert(COUNTER_INCREMENT_NONE == (enum op_counter_increment)COUNTER_RESET_NONE); while (value != COUNTER_INCREMENT_NONE) { @@ -273,13 +273,13 @@ void css__make_style_important(css_style *style) break; case CSS_PROP_FONT_SIZE: - if (value == FONT_SIZE_DIMENSION) + if (value == FONT_SIZE_DIMENSION) offset += 2; /* length + units */ break; case CSS_PROP_LETTER_SPACING: case CSS_PROP_WORD_SPACING: - assert(LETTER_SPACING_SET == + assert(LETTER_SPACING_SET == (enum op_letter_spacing)WORD_SPACING_SET); if (value == LETTER_SPACING_SET) @@ -300,7 +300,7 @@ void css__make_style_important(css_style *style) case CSS_PROP_MAX_HEIGHT: case CSS_PROP_MAX_WIDTH: - assert(MAX_HEIGHT_SET == + assert(MAX_HEIGHT_SET == (enum op_max_height)MAX_WIDTH_SET); if (value == MAX_HEIGHT_SET) @@ -370,7 +370,7 @@ void css__make_style_important(css_style *style) break; case CSS_PROP_SPEECH_RATE: - if (value == SPEECH_RATE_SET) + if (value == SPEECH_RATE_SET) offset++; /* rate */ break; diff --git a/src/parse/language.c b/src/parse/language.c index 11e2b2f..9af2547 100644 --- a/src/parse/language.c +++ b/src/parse/language.c @@ -29,43 +29,43 @@ typedef struct context_entry { } context_entry; /* Event handlers */ -static css_error language_handle_event(css_parser_event type, +static css_error language_handle_event(css_parser_event type, const parserutils_vector *tokens, void *pw); -static css_error handleStartStylesheet(css_language *c, +static css_error handleStartStylesheet(css_language *c, const parserutils_vector *vector); -static css_error handleEndStylesheet(css_language *c, +static css_error handleEndStylesheet(css_language *c, const parserutils_vector *vector); -static css_error handleStartRuleset(css_language *c, +static css_error handleStartRuleset(css_language *c, const parserutils_vector *vector); -static css_error handleEndRuleset(css_language *c, +static css_error handleEndRuleset(css_language *c, const parserutils_vector *vector); -static css_error handleStartAtRule(css_language *c, +static css_error handleStartAtRule(css_language *c, const parserutils_vector *vector); -static css_error handleEndAtRule(css_language *c, +static css_error handleEndAtRule(css_language *c, const parserutils_vector *vector); -static css_error handleStartBlock(css_language *c, +static css_error handleStartBlock(css_language *c, const parserutils_vector *vector); -static css_error handleEndBlock(css_language *c, +static css_error handleEndBlock(css_language *c, const parserutils_vector *vector); -static css_error handleBlockContent(css_language *c, +static css_error handleBlockContent(css_language *c, const parserutils_vector *vector); -static css_error handleDeclaration(css_language *c, +static css_error handleDeclaration(css_language *c, const parserutils_vector *vector); /* At-rule parsing */ static css_error parseMediaList(css_language *c, const parserutils_vector *vector, int *ctx, uint64_t *media); -static css_error addNamespace(css_language *c, +static css_error addNamespace(css_language *c, lwc_string *prefix, lwc_string *uri); -static css_error lookupNamespace(css_language *c, +static css_error lookupNamespace(css_language *c, lwc_string *prefix, lwc_string **uri); /* Selector list parsing */ static css_error parseClass(css_language *c, const parserutils_vector *vector, int *ctx, css_selector_detail *specific); -static css_error parseAttrib(css_language *c, +static css_error parseAttrib(css_language *c, const parserutils_vector *vector, int *ctx, css_selector_detail *specific); static css_error parseNth(css_language *c, @@ -83,19 +83,19 @@ static css_error parseAppendSpecific(css_language *c, static css_error parseSelectorSpecifics(css_language *c, const parserutils_vector *vector, int *ctx, css_selector **parent); -static css_error parseTypeSelector(css_language *c, - const parserutils_vector *vector, int *ctx, +static css_error parseTypeSelector(css_language *c, + const parserutils_vector *vector, int *ctx, css_qname *qname); -static css_error parseSimpleSelector(css_language *c, - const parserutils_vector *vector, int *ctx, +static css_error parseSimpleSelector(css_language *c, + const parserutils_vector *vector, int *ctx, css_selector **result); -static css_error parseCombinator(css_language *c, - const parserutils_vector *vector, int *ctx, +static css_error parseCombinator(css_language *c, + const parserutils_vector *vector, int *ctx, css_combinator *result); -static css_error parseSelector(css_language *c, - const parserutils_vector *vector, int *ctx, +static css_error parseSelector(css_language *c, + const parserutils_vector *vector, int *ctx, css_selector **result); -static css_error parseSelectorList(css_language *c, +static css_error parseSelectorList(css_language *c, const parserutils_vector *vector, css_rule *rule); /* Declaration parsing */ @@ -128,7 +128,7 @@ css_error css__language_create(css_stylesheet *sheet, css_parser *parser, if (c == NULL) return CSS_NOMEM; - perror = parserutils_stack_create(sizeof(context_entry), + perror = parserutils_stack_create(sizeof(context_entry), STACK_CHUNK, &c->context); if (perror != PARSERUTILS_OK) { free(c); @@ -165,7 +165,7 @@ css_error css__language_create(css_stylesheet *sheet, css_parser *parser, css_error css__language_destroy(css_language *language) { uint32_t i; - + if (language == NULL) return CSS_BADPARM; @@ -182,7 +182,7 @@ css_error css__language_destroy(css_language *language) } parserutils_stack_destroy(language->context); - + free(language); return CSS_OK; @@ -194,10 +194,10 @@ css_error css__language_destroy(css_language *language) * \param type The event type * \param tokens Vector of tokens read since last event, or NULL * \param pw Pointer to handler context - * \return CSS_OK on success, CSS_INVALID to indicate parse error, + * \return CSS_OK on success, CSS_INVALID to indicate parse error, * appropriate error otherwise. */ -css_error language_handle_event(css_parser_event type, +css_error language_handle_event(css_parser_event type, const parserutils_vector *tokens, void *pw) { css_language *language = (css_language *) pw; @@ -232,7 +232,7 @@ css_error language_handle_event(css_parser_event type, * Parser stages * ******************************************************************************/ -css_error handleStartStylesheet(css_language *c, +css_error handleStartStylesheet(css_language *c, const parserutils_vector *vector) { parserutils_error perror; @@ -315,7 +315,7 @@ css_error handleStartRuleset(css_language *c, const parserutils_vector *vector) return error; } - /* Flag that we've had a valid rule, so @import/@namespace/@charset + /* Flag that we've had a valid rule, so @import/@namespace/@charset * have no effect. */ c->state = HAD_RULE; @@ -364,11 +364,11 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) consumeWhitespace(vector, &ctx); - /* We now have an ATKEYWORD and the context for the start of any0, if + /* We now have an ATKEYWORD and the context for the start of any0, if * there is one */ assert(atkeyword != NULL && atkeyword->type == CSS_TOKEN_ATKEYWORD); - if (lwc_string_caseless_isequal(atkeyword->idata, c->strings[CHARSET], + if (lwc_string_caseless_isequal(atkeyword->idata, c->strings[CHARSET], &match) == lwc_error_ok && match) { if (c->state == CHARSET_PERMITTED) { const css_token *charset; @@ -378,7 +378,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) return CSS_INVALID; charset = parserutils_vector_iterate(vector, &ctx); - if (charset == NULL || + if (charset == NULL || charset->type != CSS_TOKEN_STRING) return CSS_INVALID; @@ -386,7 +386,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) if (token != NULL) return CSS_INVALID; - error = css__stylesheet_rule_create(c->sheet, + error = css__stylesheet_rule_create(c->sheet, CSS_RULE_CHARSET, &rule); if (error != CSS_OK) return error; @@ -404,25 +404,25 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) return error; } - /* Rule is now owned by the sheet, + /* Rule is now owned by the sheet, * so no need to destroy it */ c->state = IMPORT_PERMITTED; } else { return CSS_INVALID; } - } else if (lwc_string_caseless_isequal(atkeyword->idata, - c->strings[LIBCSS_IMPORT], &match) == lwc_error_ok && + } else if (lwc_string_caseless_isequal(atkeyword->idata, + c->strings[LIBCSS_IMPORT], &match) == lwc_error_ok && match) { if (c->state <= IMPORT_PERMITTED) { lwc_string *url; uint64_t media = 0; - /* any0 = (STRING | URI) ws + /* any0 = (STRING | URI) ws * (IDENT ws (',' ws IDENT ws)* )? */ - const css_token *uri = + const css_token *uri = parserutils_vector_iterate(vector, &ctx); - if (uri == NULL || (uri->type != CSS_TOKEN_STRING && + if (uri == NULL || (uri->type != CSS_TOKEN_STRING && uri->type != CSS_TOKEN_URI)) return CSS_INVALID; @@ -434,7 +434,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) return error; /* Create rule */ - error = css__stylesheet_rule_create(c->sheet, + error = css__stylesheet_rule_create(c->sheet, CSS_RULE_IMPORT, &rule); if (error != CSS_OK) return error; @@ -463,7 +463,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) c->sheet, url, media); if (error != CSS_OK) { lwc_string_unref(url); - css__stylesheet_rule_destroy(c->sheet, + css__stylesheet_rule_destroy(c->sheet, rule); return error; } @@ -479,15 +479,15 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) return error; } - /* Rule is now owned by the sheet, + /* Rule is now owned by the sheet, * so no need to destroy it */ c->state = IMPORT_PERMITTED; } else { return CSS_INVALID; } - } else if (lwc_string_caseless_isequal(atkeyword->idata, - c->strings[NAMESPACE], &match) == lwc_error_ok && + } else if (lwc_string_caseless_isequal(atkeyword->idata, + c->strings[NAMESPACE], &match) == lwc_error_ok && match) { if (c->state <= NAMESPACE_PERMITTED) { lwc_string *prefix = NULL; @@ -503,7 +503,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) consumeWhitespace(vector, &ctx); - token = parserutils_vector_iterate(vector, + token = parserutils_vector_iterate(vector, &ctx); } @@ -525,7 +525,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) } else { return CSS_INVALID; } - } else if (lwc_string_caseless_isequal(atkeyword->idata, c->strings[MEDIA], + } else if (lwc_string_caseless_isequal(atkeyword->idata, c->strings[MEDIA], &match) == lwc_error_ok && match) { uint64_t media = 0; @@ -535,7 +535,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) if (error != CSS_OK) return error; - error = css__stylesheet_rule_create(c->sheet, + error = css__stylesheet_rule_create(c->sheet, CSS_RULE_MEDIA, &rule); if (error != CSS_OK) return error; @@ -552,18 +552,18 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) return error; } - /* Rule is now owned by the sheet, + /* Rule is now owned by the sheet, * so no need to destroy it */ c->state = HAD_RULE; - } else if (lwc_string_caseless_isequal(atkeyword->idata, - c->strings[FONT_FACE], &match) == lwc_error_ok && + } else if (lwc_string_caseless_isequal(atkeyword->idata, + c->strings[FONT_FACE], &match) == lwc_error_ok && match) { error = css__stylesheet_rule_create(c->sheet, CSS_RULE_FONT_FACE, &rule); if (error != CSS_OK) return error; - + consumeWhitespace(vector, &ctx); error = css__stylesheet_add_rule(c->sheet, rule, NULL); @@ -572,11 +572,11 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) return error; } - /* Rule is now owned by the sheet, + /* Rule is now owned by the sheet, * so no need to destroy it */ c->state = HAD_RULE; - } else if (lwc_string_caseless_isequal(atkeyword->idata, c->strings[PAGE], + } else if (lwc_string_caseless_isequal(atkeyword->idata, c->strings[PAGE], &match) == lwc_error_ok && match) { const css_token *token; @@ -614,7 +614,7 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) return error; } - /* Rule is now owned by the sheet, + /* Rule is now owned by the sheet, * so no need to destroy it */ c->state = HAD_RULE; @@ -661,7 +661,7 @@ css_error handleStartBlock(css_language *c, const parserutils_vector *vector) UNUSED(vector); - /* If the current item on the stack isn't a block, + /* If the current item on the stack isn't a block, * then clone its data field. This ensures that the relevant rule * is available when parsing the block contents. */ cur = parserutils_stack_get_current(c->context); @@ -693,7 +693,7 @@ css_error handleEndBlock(css_language *c, const parserutils_vector *vector) return css_error_from_parserutils_error(perror); } - /* If the block we just popped off the stack was associated with a + /* If the block we just popped off the stack was associated with a * non-block stack entry, and that entry is not a top-level statement, * then report the end of that entry, too. */ if (rule != NULL && rule->ptype != CSS_RULE_PARENT_STYLESHEET) { @@ -718,9 +718,9 @@ css_error handleBlockContent(css_language *c, const parserutils_vector *vector) return CSS_INVALID; rule = entry->data; - if (rule == NULL || (rule->type != CSS_RULE_SELECTOR && + if (rule == NULL || (rule->type != CSS_RULE_SELECTOR && rule->type != CSS_RULE_PAGE && - rule->type != CSS_RULE_MEDIA && + rule->type != CSS_RULE_MEDIA && rule->type != CSS_RULE_FONT_FACE)) return CSS_INVALID; @@ -754,16 +754,16 @@ css_error handleDeclaration(css_language *c, const parserutils_vector *vector) return CSS_INVALID; rule = entry->data; - if (rule == NULL || (rule->type != CSS_RULE_SELECTOR && - rule->type != CSS_RULE_PAGE && + if (rule == NULL || (rule->type != CSS_RULE_SELECTOR && + rule->type != CSS_RULE_PAGE && rule->type != CSS_RULE_FONT_FACE)) return CSS_INVALID; /* Strip any leading whitespace (can happen if in nested block) */ consumeWhitespace(vector, &ctx); - /* IDENT ws ':' ws value - * + /* IDENT ws ':' ws value + * * In CSS 2.1, value is any1, so '{' or ATKEYWORD => parse error */ ident = parserutils_vector_iterate(vector, &ctx); @@ -809,47 +809,47 @@ css_error parseMediaList(css_language *c, if (token->type != CSS_TOKEN_IDENT) return CSS_INVALID; - if (lwc_string_caseless_isequal(token->idata, c->strings[AURAL], + if (lwc_string_caseless_isequal(token->idata, c->strings[AURAL], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_AURAL; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[BRAILLE], + token->idata, c->strings[BRAILLE], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_BRAILLE; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[EMBOSSED], + token->idata, c->strings[EMBOSSED], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_EMBOSSED; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[HANDHELD], + token->idata, c->strings[HANDHELD], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_HANDHELD; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[PRINT], + token->idata, c->strings[PRINT], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_PRINT; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[PROJECTION], + token->idata, c->strings[PROJECTION], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_PROJECTION; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[SCREEN], + token->idata, c->strings[SCREEN], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_SCREEN; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[SPEECH], + token->idata, c->strings[SPEECH], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_SPEECH; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[TTY], + token->idata, c->strings[TTY], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_TTY; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[TV], + token->idata, c->strings[TV], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_TV; } else if (lwc_string_caseless_isequal( - token->idata, c->strings[ALL], + token->idata, c->strings[ALL], &match) == lwc_error_ok && match) { ret |= CSS_MEDIA_ALL; } else @@ -864,7 +864,7 @@ css_error parseMediaList(css_language *c, consumeWhitespace(vector, ctx); } - /* If, after parsing the media list, we still have no media, + /* If, after parsing the media list, we still have no media, * then it must be ALL. */ if (ret == 0) ret = CSS_MEDIA_ALL; @@ -908,8 +908,8 @@ css_error addNamespace(css_language *c, lwc_string *prefix, lwc_string *uri) if (idx == c->num_namespaces) { /* Not found, create a new mapping */ - css_namespace *ns = realloc(c->namespaces, - sizeof(css_namespace) * + css_namespace *ns = realloc(c->namespaces, + sizeof(css_namespace) * (c->num_namespaces + 1)); if (ns == NULL) @@ -972,7 +972,7 @@ css_error lookupNamespace(css_language *c, lwc_string *prefix, lwc_string **uri) * Selector list parsing functions * ******************************************************************************/ -css_error parseClass(css_language *c, const parserutils_vector *vector, +css_error parseClass(css_language *c, const parserutils_vector *vector, int *ctx, css_selector_detail *specific) { css_qname qname; @@ -998,12 +998,12 @@ css_error parseClass(css_language *c, const parserutils_vector *vector, lwc__intern_caseless_string(qname.name) != lwc_error_ok) return CSS_NOMEM; - return css__stylesheet_selector_detail_init(c->sheet, + return css__stylesheet_selector_detail_init(c->sheet, CSS_SELECTOR_CLASS, &qname, detail_value, CSS_SELECTOR_DETAIL_VALUE_STRING, false, specific); } -css_error parseAttrib(css_language *c, const parserutils_vector *vector, +css_error parseAttrib(css_language *c, const parserutils_vector *vector, int *ctx, css_selector_detail *specific) { css_qname qname; @@ -1014,12 +1014,12 @@ css_error parseAttrib(css_language *c, const parserutils_vector *vector, lwc_string *prefix = NULL; /* attrib -> '[' ws namespace_prefix? IDENT ws [ - * [ '=' | - * INCLUDES | - * DASHMATCH | + * [ '=' | + * INCLUDES | + * DASHMATCH | * PREFIXMATCH | - * SUFFIXMATCH | - * SUBSTRINGMATCH + * SUFFIXMATCH | + * SUBSTRINGMATCH * ] ws * [ IDENT | STRING ] ws ]? ']' * namespace_prefix -> [ IDENT | '*' ]? '|' @@ -1100,8 +1100,8 @@ css_error parseAttrib(css_language *c, const parserutils_vector *vector, detail_value.string = value != NULL ? value->idata : NULL; - return css__stylesheet_selector_detail_init(c->sheet, type, - &qname, detail_value, + return css__stylesheet_selector_detail_init(c->sheet, type, + &qname, detail_value, CSS_SELECTOR_DETAIL_VALUE_STRING, false, specific); } @@ -1178,7 +1178,7 @@ css_error parseNth(css_language *c, data += 1; len -= 1; } else { - if (data[0] != '-' || + if (data[0] != '-' || (data[1] != 'n' && data[1] != 'N')) return CSS_INVALID; @@ -1204,7 +1204,7 @@ css_error parseNth(css_language *c, /* -n-b */ b = css__number_from_string( - (const uint8_t *) data + 1, + (const uint8_t *) data + 1, len - 1, true, &consumed); @@ -1216,7 +1216,7 @@ css_error parseNth(css_language *c, } } else { /* 2n */ - a = css__number_from_lwc_string(token->idata, + a = css__number_from_lwc_string(token->idata, true, &consumed); if (consumed == 0 || (data[consumed] != 'n' && data[consumed] != 'N')) @@ -1306,7 +1306,7 @@ css_error parseNth(css_language *c, return CSS_OK; } -css_error parsePseudo(css_language *c, const parserutils_vector *vector, +css_error parsePseudo(css_language *c, const parserutils_vector *vector, int *ctx, bool in_not, css_selector_detail *specific) { static const struct @@ -1347,7 +1347,7 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, { AFTER, CSS_SELECTOR_PSEUDO_ELEMENT } }; css_selector_detail_value detail_value; - css_selector_detail_value_type value_type = + css_selector_detail_value_type value_type = CSS_SELECTOR_DETAIL_VALUE_STRING; css_qname qname; const css_token *token; @@ -1375,7 +1375,7 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, } /* Expect IDENT or FUNCTION */ - if (token == NULL || (token->type != CSS_TOKEN_IDENT && + if (token == NULL || (token->type != CSS_TOKEN_IDENT && token->type != CSS_TOKEN_FUNCTION)) return CSS_INVALID; @@ -1384,7 +1384,7 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, /* Search lut for selector type */ for (lut_idx = 0; lut_idx < N_ELEMENTS(pseudo_lut); lut_idx++) { - if ((lwc_string_caseless_isequal(qname.name, + if ((lwc_string_caseless_isequal(qname.name, c->strings[pseudo_lut[lut_idx].index], &match) == lwc_error_ok) && match) { type = pseudo_lut[lut_idx].type; @@ -1401,7 +1401,7 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, return CSS_INVALID; /* :not() and pseudo elements are not permitted in :not() */ - if (in_not && (type == CSS_SELECTOR_PSEUDO_ELEMENT || + if (in_not && (type == CSS_SELECTOR_PSEUDO_ELEMENT || pseudo_lut[lut_idx].index == NOT)) return CSS_INVALID; @@ -1420,9 +1420,9 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, value_type = CSS_SELECTOR_DETAIL_VALUE_STRING; consumeWhitespace(vector, ctx); - } else if (fun_type == NTH_CHILD || - fun_type == NTH_LAST_CHILD || - fun_type == NTH_OF_TYPE || + } else if (fun_type == NTH_CHILD || + fun_type == NTH_LAST_CHILD || + fun_type == NTH_OF_TYPE || fun_type == NTH_LAST_OF_TYPE) { /* an + b */ error = parseNth(c, vector, ctx, &detail_value); @@ -1436,11 +1436,11 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, if (token == NULL) return CSS_INVALID; - if (token->type == CSS_TOKEN_IDENT || + if (token->type == CSS_TOKEN_IDENT || tokenIsChar(token, '*') || tokenIsChar(token, '|')) { /* Have type selector */ - error = parseTypeSelector(c, vector, ctx, + error = parseTypeSelector(c, vector, ctx, &qname); if (error != CSS_OK) return error; @@ -1460,7 +1460,7 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, /* specific */ css_selector_detail det; - error = parseSpecific(c, vector, ctx, true, + error = parseSpecific(c, vector, ctx, true, &det); if (error != CSS_OK) return error; @@ -1481,8 +1481,8 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, return CSS_INVALID; } - return css__stylesheet_selector_detail_init(c->sheet, - type, &qname, detail_value, value_type, + return css__stylesheet_selector_detail_init(c->sheet, + type, &qname, detail_value, value_type, negate, specific); } @@ -1516,7 +1516,7 @@ css_error parseSpecific(css_language *c, error = css__stylesheet_selector_detail_init(c->sheet, CSS_SELECTOR_ID, &qname, detail_value, - CSS_SELECTOR_DETAIL_VALUE_STRING, false, + CSS_SELECTOR_DETAIL_VALUE_STRING, false, specific); if (error != CSS_OK) return error; @@ -1541,7 +1541,7 @@ css_error parseSpecific(css_language *c, return CSS_OK; } -css_error parseAppendSpecific(css_language *c, +css_error parseAppendSpecific(css_language *c, const parserutils_vector *vector, int *ctx, css_selector **parent) { @@ -1552,7 +1552,7 @@ css_error parseAppendSpecific(css_language *c, if (error != CSS_OK) return error; - return css__stylesheet_selector_append_specific(c->sheet, parent, + return css__stylesheet_selector_append_specific(c->sheet, parent, &specific); } @@ -1565,7 +1565,7 @@ css_error parseSelectorSpecifics(css_language *c, /* specifics -> specific* */ while ((token = parserutils_vector_peek(vector, *ctx)) != NULL && - token->type != CSS_TOKEN_S && + token->type != CSS_TOKEN_S && tokenIsChar(token, '+') == false && tokenIsChar(token, '>') == false && tokenIsChar(token, '~') == false && @@ -1639,8 +1639,8 @@ css_error parseTypeSelector(css_language *c, const parserutils_vector *vector, return CSS_OK; } -css_error parseSimpleSelector(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error parseSimpleSelector(css_language *c, + const parserutils_vector *vector, int *ctx, css_selector **result) { int orig_ctx = *ctx; @@ -1746,7 +1746,7 @@ css_error parseCombinator(css_language *c, const parserutils_vector *vector, return CSS_OK; } -css_error parseSelector(css_language *c, const parserutils_vector *vector, +css_error parseSelector(css_language *c, const parserutils_vector *vector, int *ctx, css_selector **result) { css_error error; @@ -1754,10 +1754,10 @@ css_error parseSelector(css_language *c, const parserutils_vector *vector, css_selector *selector = NULL; /* selector -> simple_selector [ combinator simple_selector ]* ws - * + * * Note, however, that, as combinator can be wholly whitespace, - * there's an ambiguity as to whether "ws" has been reached. We - * resolve this by attempting to extract a combinator, then + * there's an ambiguity as to whether "ws" has been reached. We + * resolve this by attempting to extract a combinator, then * recovering when we detect that we've reached the end of the * selector. */ @@ -1778,13 +1778,13 @@ css_error parseSelector(css_language *c, const parserutils_vector *vector, /* In the case of "html , body { ... }", the whitespace after * "html" and "body" will be considered an ancestor combinator. - * This clearly is not the case, however. Therefore, as a - * special case, if we've got an ancestor combinator and there + * This clearly is not the case, however. Therefore, as a + * special case, if we've got an ancestor combinator and there * are no further tokens, or if the next token is a comma, * we ignore the supposed combinator and continue. */ - if (comb == CSS_COMBINATOR_ANCESTOR && - ((token = parserutils_vector_peek(vector, - *ctx)) == NULL || + if (comb == CSS_COMBINATOR_ANCESTOR && + ((token = parserutils_vector_peek(vector, + *ctx)) == NULL || tokenIsChar(token, ','))) continue; @@ -1847,7 +1847,7 @@ css_error parseSelectorList(css_language *c, const parserutils_vector *vector, error = parseSelector(c, vector, &ctx, &selector); if (error != CSS_OK) { if (selector != NULL) { - css__stylesheet_selector_destroy(c->sheet, + css__stylesheet_selector_destroy(c->sheet, selector); } return error; @@ -1855,7 +1855,7 @@ css_error parseSelectorList(css_language *c, const parserutils_vector *vector, assert(selector != NULL); - error = css__stylesheet_rule_add_selector(c->sheet, rule, + error = css__stylesheet_rule_add_selector(c->sheet, rule, selector); if (error != CSS_OK) { css__stylesheet_selector_destroy(c->sheet, selector); @@ -1870,7 +1870,7 @@ css_error parseSelectorList(css_language *c, const parserutils_vector *vector, * Property parsing functions * ******************************************************************************/ -css_error parseProperty(css_language *c, const css_token *property, +css_error parseProperty(css_language *c, const css_token *property, const parserutils_vector *vector, int *ctx, css_rule *rule) { css_error error; @@ -1898,7 +1898,7 @@ css_error parseProperty(css_language *c, const css_token *property, /* allocate style */ error = css__stylesheet_style_create(c->sheet, &style); - if (error != CSS_OK) + if (error != CSS_OK) return error; assert (style != NULL); diff --git a/src/parse/language.h b/src/parse/language.h index f7c8536..2ab4987 100644 --- a/src/parse/language.h +++ b/src/parse/language.h @@ -84,7 +84,7 @@ static inline bool tokenIsChar(const css_token *token, uint8_t c) { bool result = false; - if (token != NULL && token->type == CSS_TOKEN_CHAR && + if (token != NULL && token->type == CSS_TOKEN_CHAR && lwc_string_length(token->idata) == 1) { char d = lwc_string_data(token->idata)[0]; diff --git a/src/parse/parse.c b/src/parse/parse.c index b65b0f5..68492d4 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -107,8 +107,8 @@ struct css_parser void *event_pw; /**< Client data for event handler */ }; -static css_error css__parser_create_internal(const char *charset, - css_charset_source cs_source, parser_state initial, +static css_error css__parser_create_internal(const char *charset, + css_charset_source cs_source, parser_state initial, css_parser **parser); static css_error transition(css_parser *parser, parser_state to, @@ -280,7 +280,7 @@ css_error css__parser_setopt(css_parser *parser, css_parser_opttype type, * \param len Length of chunk * \return CSS_OK on success, appropriate error otherwise */ -css_error css__parser_parse_chunk(css_parser *parser, const uint8_t *data, +css_error css__parser_parse_chunk(css_parser *parser, const uint8_t *data, size_t len) { parserutils_error perror; @@ -344,7 +344,7 @@ css_error css__parser_completed(css_parser *parser) * \param source Pointer to location to receive charset source * \return Pointer to charset name (constant; do not free) */ -const char *css__parser_read_charset(css_parser *parser, +const char *css__parser_read_charset(css_parser *parser, css_charset_source *source) { const char *charset; @@ -386,8 +386,8 @@ bool css__parser_quirks_permitted(css_parser *parser) * CSS_BADPARM on bad parameters, * CSS_NOMEM on memory exhaustion */ -css_error css__parser_create_internal(const char *charset, - css_charset_source cs_source, parser_state initial, +css_error css__parser_create_internal(const char *charset, + css_charset_source cs_source, parser_state initial, css_parser **parser) { css_parser *p; @@ -415,7 +415,7 @@ css_error css__parser_create_internal(const char *charset, return error; } - perror = parserutils_stack_create(sizeof(parser_state), + perror = parserutils_stack_create(sizeof(parser_state), STACK_CHUNK, &p->states); if (perror != PARSERUTILS_OK) { css__lexer_destroy(p->lexer); @@ -424,7 +424,7 @@ css_error css__parser_create_internal(const char *charset, return css_error_from_parserutils_error(perror); } - perror = parserutils_vector_create(sizeof(css_token), + perror = parserutils_vector_create(sizeof(css_token), STACK_CHUNK, &p->tokens); if (perror != PARSERUTILS_OK) { parserutils_stack_destroy(p->states); @@ -434,7 +434,7 @@ css_error css__parser_create_internal(const char *charset, return css_error_from_parserutils_error(perror); } - perror = parserutils_stack_create(sizeof(char), + perror = parserutils_stack_create(sizeof(char), STACK_CHUNK, &p->open_items); if (perror != PARSERUTILS_OK) { parserutils_vector_destroy(p->tokens); @@ -481,7 +481,7 @@ css_error css__parser_create_internal(const char *charset, * \param subsequent The state to return to * \return CSS_OK on success, appropriate error otherwise */ -css_error transition(css_parser *parser, parser_state to, +css_error transition(css_parser *parser, parser_state to, parser_state subsequent) { parser_state *state = parserutils_stack_get_current(parser->states); @@ -556,7 +556,7 @@ css_error done(css_parser *parser) /** * Assert that the expected token is next in the input - * + * * \param parser The parser instance * \param type The expected token type * \return CSS_OK on success, appropriate error otherwise @@ -638,7 +638,7 @@ css_error getToken(css_parser *parser, const css_token **token) } /* Append token to vector */ - perror = parserutils_vector_append(parser->tokens, + perror = parserutils_vector_append(parser->tokens, (css_token *) (*token)); if (perror != PARSERUTILS_OK) return css_error_from_parserutils_error(perror); @@ -661,7 +661,7 @@ css_error pushBack(css_parser *parser, const css_token *token) /* The pushback buffer depth is 1 token. Assert this. */ assert(parser->pushback == NULL); - + perror = parserutils_vector_remove_last(parser->tokens); if (perror != PARSERUTILS_OK) return css_error_from_parserutils_error(perror); @@ -713,7 +713,7 @@ css_error parseStart(css_parser *parser) printf("Begin stylesheet\n"); #endif if (parser->event != NULL) { - parser->event(CSS_PARSER_START_STYLESHEET, NULL, + parser->event(CSS_PARSER_START_STYLESHEET, NULL, parser->event_pw); } @@ -742,10 +742,10 @@ css_error parseStart(css_parser *parser) printf("End stylesheet\n"); #endif if (parser->event != NULL) { - parser->event(CSS_PARSER_END_STYLESHEET, NULL, + parser->event(CSS_PARSER_END_STYLESHEET, NULL, parser->event_pw); } - + unref_interned_strings_in_tokens(parser); parserutils_vector_clear(parser->tokens); @@ -843,7 +843,7 @@ css_error parseRuleset(css_parser *parser) const css_token *token; css_error error; - /* ruleset -> selector '{' ws ruleset-end + /* ruleset -> selector '{' ws ruleset-end * -> '{' ws ruleset-end */ @@ -856,20 +856,20 @@ css_error parseRuleset(css_parser *parser) if (error != CSS_OK) return error; - /* The grammar's ambiguous here -- selectors may start with a - * brace. We're going to assume that that won't happen, + /* The grammar's ambiguous here -- selectors may start with a + * brace. We're going to assume that that won't happen, * however. */ - if (token->type == CSS_TOKEN_CHAR && - lwc_string_length(token->idata) == 1 && + if (token->type == CSS_TOKEN_CHAR && + lwc_string_length(token->idata) == 1 && lwc_string_data(token->idata)[0] == '{') { #if !defined(NDEBUG) && defined(DEBUG_EVENTS) printf("Begin ruleset\n"); #endif if (parser->event != NULL) { - if (parser->event(CSS_PARSER_START_RULESET, - NULL, parser->event_pw) == + if (parser->event(CSS_PARSER_START_RULESET, + NULL, parser->event_pw) == CSS_INVALID) { - parser_state to = + parser_state to = { sMalformedSelector, Initial }; return transitionNoRet(parser, to); @@ -895,7 +895,7 @@ css_error parseRuleset(css_parser *parser) parserutils_vector_dump(parser->tokens, __func__, tprinter); #endif if (parser->parseError == false && parser->event != NULL) { - if (parser->event(CSS_PARSER_START_RULESET, + if (parser->event(CSS_PARSER_START_RULESET, parser->tokens, parser->event_pw) == CSS_INVALID) parser->parseError = true; @@ -919,14 +919,14 @@ css_error parseRuleset(css_parser *parser) return done(parser); } - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || lwc_string_data(token->idata)[0] != '{') { - /* This should never happen, as FOLLOW(selector) + /* This should never happen, as FOLLOW(selector) * contains only '{' */ assert(0 && "Expected {"); } - + state->substate = WS; /* Fall through */ case WS: @@ -948,7 +948,7 @@ css_error parseRulesetEnd(css_parser *parser) const css_token *token; css_error error; - /* ruleset-end -> declaration decl-list '}' ws + /* ruleset-end -> declaration decl-list '}' ws * -> decl-list '}' ws */ @@ -969,7 +969,7 @@ css_error parseRulesetEnd(css_parser *parser) * attempt to parse a declaration. This will catch any invalid * input at this point and read to the start of the next * declaration. FIRST(decl-list) = (';', '}') */ - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || (lwc_string_data(token->idata)[0] != '}' && lwc_string_data(token->idata)[0] != ';')) { @@ -1001,7 +1001,7 @@ css_error parseRulesetEnd(css_parser *parser) return done(parser); } - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || lwc_string_data(token->idata)[0] != '}') { /* This should never happen, as FOLLOW(decl-list) @@ -1077,9 +1077,9 @@ css_error parseAtRule(css_parser *parser) if (error != CSS_OK) return error; - /* Grammar ambiguity: any0 can be followed by '{',';',')',']'. + /* Grammar ambiguity: any0 can be followed by '{',';',')',']'. * at-rule can only be followed by '{' and ';'. */ - if (token->type == CSS_TOKEN_CHAR && + if (token->type == CSS_TOKEN_CHAR && lwc_string_length(token->idata) == 1) { if (lwc_string_data(token->idata)[0] == ')' || lwc_string_data( @@ -1119,7 +1119,7 @@ css_error parseAtRuleEnd(css_parser *parser) parserutils_vector_dump(parser->tokens, __func__, tprinter); #endif if (parser->event != NULL) { - if (parser->event(CSS_PARSER_START_ATRULE, + if (parser->event(CSS_PARSER_START_ATRULE, parser->tokens, parser->event_pw) == CSS_INVALID) { parser_state to = { sMalformedAtRule, Initial }; @@ -1140,12 +1140,12 @@ css_error parseAtRuleEnd(css_parser *parser) return done(parser); } - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1) { /* Should never happen FOLLOW(at-rule) == '{', ';'*/ assert(0 && "Expected { or ;"); } - + if (lwc_string_data(token->idata)[0] == '{') { parser_state to = { sBlock, Initial }; parser_state subsequent = { sAtRuleEnd, AfterBlock }; @@ -1205,7 +1205,7 @@ css_error parseBlock(css_parser *parser) parser->event_pw); } - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || lwc_string_data(token->idata)[0] != '{') { /* This should never happen, as FIRST(block) == '{' */ @@ -1244,10 +1244,10 @@ css_error parseBlock(css_parser *parser) return done(parser); } - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || lwc_string_data(token->idata)[0] != '}') { - /* This should never happen, as + /* This should never happen, as * FOLLOW(block-content) == '}' */ assert(0 && "Expected }"); } @@ -1282,7 +1282,7 @@ css_error parseBlockContent(css_parser *parser) const css_token *token; css_error error; - /* block-content -> any block-content + /* block-content -> any block-content * -> block block-content * -> ATKEYWORD ws block-content * -> ';' ws block-content @@ -1299,12 +1299,12 @@ css_error parseBlockContent(css_parser *parser) if (token->type == CSS_TOKEN_ATKEYWORD) { state->substate = WS; } else if (token->type == CSS_TOKEN_CHAR) { - if (lwc_string_length(token->idata) == 1 && + if (lwc_string_length(token->idata) == 1 && lwc_string_data( token->idata)[0] == '{') { /* Grammar ambiguity. Assume block */ parser_state to = { sBlock, Initial }; - parser_state subsequent = + parser_state subsequent = { sBlockContent, Initial }; error = pushBack(parser, token); @@ -1318,7 +1318,7 @@ css_error parseBlockContent(css_parser *parser) if (parser->event != NULL) { parser->event( CSS_PARSER_BLOCK_CONTENT, - parser->tokens, + parser->tokens, parser->event_pw); } @@ -1327,7 +1327,7 @@ css_error parseBlockContent(css_parser *parser) parserutils_vector_clear( parser->tokens); - return transition(parser, to, + return transition(parser, to, subsequent); } else if (lwc_string_length( token->idata) == 1 && @@ -1345,7 +1345,7 @@ css_error parseBlockContent(css_parser *parser) if (parser->event != NULL) { parser->event( CSS_PARSER_BLOCK_CONTENT, - parser->tokens, + parser->tokens, parser->event_pw); } @@ -1409,7 +1409,7 @@ css_error parseBlockContent(css_parser *parser) if (state->substate == Initial) { parser_state to = { sAny, Initial }; - parser_state subsequent = + parser_state subsequent = { sBlockContent, Initial }; error = pushBack(parser, token); @@ -1498,7 +1498,7 @@ css_error parseDeclaration(css_parser *parser) return done(parser); } - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || lwc_string_data(token->idata)[0] != ':') { /* parse error -- expected : */ @@ -1572,9 +1572,9 @@ css_error parseDeclList(css_parser *parser) return done(parser); } - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || - (lwc_string_data(token->idata)[0] != '}' && + (lwc_string_data(token->idata)[0] != '}' && lwc_string_data(token->idata)[0] != ';')) { /* Should never happen */ assert(0 && "Expected ; or }"); @@ -1611,7 +1611,7 @@ css_error parseDeclListEnd(css_parser *parser) const css_token *token; css_error error; - /* decl-list-end -> declaration decl-list + /* decl-list-end -> declaration decl-list * -> decl-list */ @@ -1621,12 +1621,12 @@ css_error parseDeclListEnd(css_parser *parser) if (error != CSS_OK) return error; - if (token->type != CSS_TOKEN_CHAR || - lwc_string_length(token->idata) != 1 || + if (token->type != CSS_TOKEN_CHAR || + lwc_string_length(token->idata) != 1 || (lwc_string_data(token->idata)[0] != ';' && lwc_string_data(token->idata)[0] != '}')) { parser_state to = { sDeclaration, Initial }; - parser_state subsequent = + parser_state subsequent = { sDeclListEnd, AfterDeclaration }; error = pushBack(parser, token); @@ -1717,7 +1717,7 @@ css_error parseValue1(css_parser *parser) return error; /* Grammar ambiguity -- assume ';' or '}' mark end */ - if (token->type == CSS_TOKEN_CHAR && + if (token->type == CSS_TOKEN_CHAR && lwc_string_length(token->idata) == 1 && (lwc_string_data(token->idata)[0] == ';' || lwc_string_data(token->idata)[0] == '}')) { @@ -1746,7 +1746,7 @@ css_error parseValue0(css_parser *parser) css_error error; /* value0 -> value value0 - * -> + * -> */ while (1) { @@ -1768,7 +1768,7 @@ css_error parseValue0(css_parser *parser) return done(parser); /* Grammar ambiguity -- assume ';' or '}' mark end */ - if (token->type == CSS_TOKEN_CHAR && + if (token->type == CSS_TOKEN_CHAR && lwc_string_length( token->idata) == 1 && (lwc_string_data( @@ -1813,8 +1813,8 @@ css_error parseValue(css_parser *parser) if (token->type == CSS_TOKEN_ATKEYWORD) { state->substate = WS; - } else if (token->type == CSS_TOKEN_CHAR && - lwc_string_length(token->idata) == 1 && + } else if (token->type == CSS_TOKEN_CHAR && + lwc_string_length(token->idata) == 1 && lwc_string_data(token->idata)[0] == '{') { /* Grammar ambiguity. Assume block. */ parser_state to = { sBlock, Initial }; @@ -1854,7 +1854,7 @@ css_error parseAny0(css_parser *parser) css_error error; /* any0 -> any any0 - * -> + * -> */ while (1) { @@ -1875,9 +1875,9 @@ css_error parseAny0(css_parser *parser) if (token->type == CSS_TOKEN_EOF) return done(parser); - /* Grammar ambiguity: + /* Grammar ambiguity: * assume '{', ';', ')', ']' mark end */ - if (token->type == CSS_TOKEN_CHAR && + if (token->type == CSS_TOKEN_CHAR && lwc_string_length( token->idata) == 1 && (lwc_string_data( @@ -1945,9 +1945,9 @@ css_error parseAny1(css_parser *parser) if (error != CSS_OK) return error; - /* Grammar ambiguity: any0 can be followed by + /* Grammar ambiguity: any0 can be followed by * '{', ';', ')', ']'. any1 can only be followed by '{'. */ - if (token->type == CSS_TOKEN_CHAR && + if (token->type == CSS_TOKEN_CHAR && lwc_string_length(token->idata) == 1) { if (lwc_string_data(token->idata)[0] == ';' || lwc_string_data( @@ -2003,20 +2003,20 @@ css_error parseAny(css_parser *parser) if (error != CSS_OK) return error; - if (token->type != CSS_TOKEN_IDENT && - token->type != CSS_TOKEN_NUMBER && - token->type != CSS_TOKEN_PERCENTAGE && - token->type != CSS_TOKEN_DIMENSION && - token->type != CSS_TOKEN_STRING && - token->type != CSS_TOKEN_CHAR && - token->type != CSS_TOKEN_URI && - token->type != CSS_TOKEN_HASH && - token->type != CSS_TOKEN_UNICODE_RANGE && - token->type != CSS_TOKEN_INCLUDES && - token->type != CSS_TOKEN_DASHMATCH && - token->type != CSS_TOKEN_PREFIXMATCH && - token->type != CSS_TOKEN_SUFFIXMATCH && - token->type != CSS_TOKEN_SUBSTRINGMATCH && + if (token->type != CSS_TOKEN_IDENT && + token->type != CSS_TOKEN_NUMBER && + token->type != CSS_TOKEN_PERCENTAGE && + token->type != CSS_TOKEN_DIMENSION && + token->type != CSS_TOKEN_STRING && + token->type != CSS_TOKEN_CHAR && + token->type != CSS_TOKEN_URI && + token->type != CSS_TOKEN_HASH && + token->type != CSS_TOKEN_UNICODE_RANGE && + token->type != CSS_TOKEN_INCLUDES && + token->type != CSS_TOKEN_DASHMATCH && + token->type != CSS_TOKEN_PREFIXMATCH && + token->type != CSS_TOKEN_SUFFIXMATCH && + token->type != CSS_TOKEN_SUBSTRINGMATCH && token->type != CSS_TOKEN_FUNCTION) { /* parse error */ parser->parseError = true; @@ -2027,14 +2027,14 @@ css_error parseAny(css_parser *parser) if (token->type == CSS_TOKEN_FUNCTION) { parser->match_char = ')'; state->substate = WS; - } else if (token->type == CSS_TOKEN_CHAR && - lwc_string_length(token->idata) == 1 && - (lwc_string_data(token->idata)[0] == '(' || + } else if (token->type == CSS_TOKEN_CHAR && + lwc_string_length(token->idata) == 1 && + (lwc_string_data(token->idata)[0] == '(' || lwc_string_data(token->idata)[0] == '[')) { parser->match_char = lwc_string_data( token->idata)[0] == '(' ? ')' : ']'; state->substate = WS; - } + } state->substate = WS2; /* Fall through */ @@ -2064,9 +2064,9 @@ css_error parseAny(css_parser *parser) return error; /* Match correct close bracket (grammar ambiguity) */ - if (token->type == CSS_TOKEN_CHAR && + if (token->type == CSS_TOKEN_CHAR && lwc_string_length(token->idata) == 1 && - lwc_string_data(token->idata)[0] == + lwc_string_data(token->idata)[0] == parser->match_char) { state->substate = WS2; goto ws2; @@ -2086,14 +2086,14 @@ css_error parseMalformedDeclaration(css_parser *parser) const css_token *token = NULL; css_error error; - /* Malformed declaration: read everything up to the next ; or } + /* Malformed declaration: read everything up to the next ; or } * We must ensure that pairs of {}, (), [], are balanced */ switch (state->substate) { case Initial: { /* Clear stack of open items */ - while (parserutils_stack_pop(parser->open_items, NULL) == + while (parserutils_stack_pop(parser->open_items, NULL) == PARSERUTILS_OK) ; @@ -2156,13 +2156,13 @@ css_error parseMalformedDeclaration(css_parser *parser) break; } - /* Either pop off the stack, if we've matched the + /* Either pop off the stack, if we've matched the * current item, or push the start token on */ if (match != NULL && *match == want) { parserutils_stack_pop( parser->open_items, NULL); } else if (want == 0) { - parserutils_stack_push(parser->open_items, + parserutils_stack_push(parser->open_items, &data[0]); } } @@ -2193,7 +2193,7 @@ css_error parseMalformedSelector(css_parser *parser) switch (state->substate) { case Initial: /* Clear the stack of open items */ - while (parserutils_stack_pop(parser->open_items, NULL) == + while (parserutils_stack_pop(parser->open_items, NULL) == PARSERUTILS_OK) ; @@ -2243,21 +2243,21 @@ css_error parseMalformedSelector(css_parser *parser) break; } - /* Either pop off the stack, if we've matched the + /* Either pop off the stack, if we've matched the * current item, or push the start token on */ if (match != NULL && *match == want) { parserutils_stack_pop( parser->open_items, NULL); } else if (want == 0) { - parserutils_stack_push(parser->open_items, + parserutils_stack_push(parser->open_items, &data[0]); } /* If we encountered a '}', there was data on the stack * before, and the stack's now empty, then we've popped - * a '{' off the stack. That means we've found the end + * a '{' off the stack. That means we've found the end * of the block, so we're done here. */ - if (want == '{' && match != NULL && + if (want == '{' && match != NULL && parserutils_stack_get_current( parser->open_items) == NULL) break; @@ -2291,7 +2291,7 @@ css_error parseMalformedAtRule(css_parser *parser) case Initial: { /* Clear stack of open items */ - while (parserutils_stack_pop(parser->open_items, NULL) == + while (parserutils_stack_pop(parser->open_items, NULL) == PARSERUTILS_OK) ; @@ -2352,21 +2352,21 @@ css_error parseMalformedAtRule(css_parser *parser) break; } - /* Either pop off the stack, if we've matched the + /* Either pop off the stack, if we've matched the * current item, or push the start token on */ if (match != NULL && *match == want) { parserutils_stack_pop( parser->open_items, NULL); } else if (want == 0) { - parserutils_stack_push(parser->open_items, + parserutils_stack_push(parser->open_items, &data[0]); } /* If we encountered a '}', there was data on the stack * before, and the stack's now empty, then we've popped - * a '{' off the stack. That means we've found the end + * a '{' off the stack. That means we've found the end * of the block, so we're done here. */ - if (want == '{' && match != NULL && + if (want == '{' && match != NULL && parserutils_stack_get_current( parser->open_items) == NULL) break; @@ -2395,7 +2395,7 @@ css_error parseInlineStyle(css_parser *parser) switch (state->substate) { case Initial: - /* Emit fake events such that the language parser knows + /* Emit fake events such that the language parser knows * no different from a normal parse. */ if (parser->event != NULL) { @@ -2430,7 +2430,7 @@ css_error parseInlineStyle(css_parser *parser) /* Emit remaining fake events to end the parse */ if (parser->event != NULL) { /* 1) end ruleset */ - parser->event(CSS_PARSER_END_RULESET, NULL, + parser->event(CSS_PARSER_END_RULESET, NULL, parser->event_pw); /* 2) end stylesheet */ @@ -2497,7 +2497,7 @@ css_error parseISBody(css_parser *parser) const css_token *token; css_error error; - /* is-body -> declaration decl-list '}' ws + /* is-body -> declaration decl-list '}' ws * -> decl-list '}' ws * * Note that this looks suspiciously similar to ruleset-end. @@ -2518,7 +2518,7 @@ css_error parseISBody(css_parser *parser) * attempt to parse a declaration. This will catch any invalid * input at this point and read to the start of the next * declaration. FIRST(decl-list) = (';', '}') */ - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || (lwc_string_data(token->idata)[0] != '}' && lwc_string_data(token->idata)[0] != ';')) { @@ -2550,7 +2550,7 @@ css_error parseISBody(css_parser *parser) return done(parser); } - if (token->type != CSS_TOKEN_CHAR || + if (token->type != CSS_TOKEN_CHAR || lwc_string_length(token->idata) != 1 || lwc_string_data(token->idata)[0] != '}') { /* This should never happen, as FOLLOW(decl-list) @@ -2580,7 +2580,7 @@ void unref_interned_strings_in_tokens(css_parser *parser) { int32_t ctx = 0; const css_token *tok; - + while ((tok = parserutils_vector_iterate( parser->tokens, &ctx)) != NULL) { if (tok->idata != NULL) { diff --git a/src/parse/parse.h b/src/parse/parse.h index 6b95acb..833aa51 100644 --- a/src/parse/parse.h +++ b/src/parse/parse.h @@ -34,7 +34,7 @@ typedef enum css_parser_event { CSS_PARSER_DECLARATION } css_parser_event; -typedef css_error (*css_parser_event_handler)(css_parser_event type, +typedef css_error (*css_parser_event_handler)(css_parser_event type, const parserutils_vector *tokens, void *pw); /** @@ -59,18 +59,18 @@ typedef union css_parser_optparams { css_error css__parser_create(const char *charset, css_charset_source cs_source, css_parser **parser); -css_error css__parser_create_for_inline_style(const char *charset, +css_error css__parser_create_for_inline_style(const char *charset, css_charset_source cs_source, css_parser **parser); css_error css__parser_destroy(css_parser *parser); css_error css__parser_setopt(css_parser *parser, css_parser_opttype type, css_parser_optparams *params); -css_error css__parser_parse_chunk(css_parser *parser, const uint8_t *data, +css_error css__parser_parse_chunk(css_parser *parser, const uint8_t *data, size_t len); css_error css__parser_completed(css_parser *parser); -const char *css__parser_read_charset(css_parser *parser, +const char *css__parser_read_charset(css_parser *parser, css_charset_source *source); bool css__parser_quirks_permitted(css_parser *parser); diff --git a/src/parse/properties/azimuth.c b/src/parse/properties/azimuth.c index 7df7298..f54189b 100644 --- a/src/parse/properties/azimuth.c +++ b/src/parse/properties/azimuth.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_azimuth(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_azimuth(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -40,10 +40,10 @@ css_error css__parse_azimuth(css_language *c, uint32_t unit = 0; bool match; - /* angle | [ IDENT(left-side, far-left, left, center-left, center, - * center-right, right, far-right, right-side) || - * IDENT(behind) - * ] + /* angle | [ IDENT(left-side, far-left, left, center-left, center, + * center-right, right, far-right, right-side) || + * IDENT(behind) + * ] * | IDENT(leftwards, rightwards, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -71,7 +71,7 @@ css_error css__parse_azimuth(css_language *c, parserutils_vector_iterate(vector, ctx); /* Now, we may have one of the other keywords or behind, - * potentially followed by behind or other keyword, + * potentially followed by behind or other keyword, * respectively */ if ((lwc_string_caseless_isequal( token->idata, c->strings[LEFT_SIDE], @@ -184,7 +184,7 @@ css_error css__parse_azimuth(css_language *c, value |= AZIMUTH_CENTER; } } else { - error = css__parse_unit_specifier(c, vector, ctx, UNIT_DEG, + error = css__parse_unit_specifier(c, vector, ctx, UNIT_DEG, &length, &unit); if (error != CSS_OK) { *ctx = orig_ctx; diff --git a/src/parse/properties/background.c b/src/parse/properties/background.c index cae069c..01b995e 100644 --- a/src/parse/properties/background.c +++ b/src/parse/properties/background.c @@ -49,36 +49,36 @@ css_error css__parse_background(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_BACKGROUND_ATTACHMENT); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BACKGROUND_COLOR); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BACKGROUND_IMAGE); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BACKGROUND_POSITION); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BACKGROUND_REPEAT); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* allocate styles */ error = css__stylesheet_style_create(c->sheet, &attachment_style); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css__stylesheet_style_create(c->sheet, &color_style); @@ -124,24 +124,24 @@ css_error css__parse_background(css_language *c, /* Try each property parser in turn, but only if we * haven't already got a value for this property. */ - if ((attachment) && - (error = css__parse_background_attachment(c, vector, ctx, + if ((attachment) && + (error = css__parse_background_attachment(c, vector, ctx, attachment_style)) == CSS_OK) { attachment = false; - } else if ((color) && + } else if ((color) && (error = css__parse_background_color(c, vector, ctx, color_style)) == CSS_OK) { color = false; - } else if ((image) && + } else if ((image) && (error = css__parse_background_image(c, vector, ctx, image_style)) == CSS_OK) { image = false; } else if ((position) && - (error = css__parse_background_position(c, vector, ctx, + (error = css__parse_background_position(c, vector, ctx, position_style)) == CSS_OK) { position = false; } else if ((repeat) && - (error = css__parse_background_repeat(c, vector, ctx, + (error = css__parse_background_repeat(c, vector, ctx, repeat_style)) == CSS_OK) { repeat = false; } @@ -157,23 +157,23 @@ css_error css__parse_background(css_language *c, } while (*ctx != prev_ctx && token != NULL); if (attachment) { - error = css__stylesheet_style_appendOPV(attachment_style, - CSS_PROP_BACKGROUND_ATTACHMENT, 0, + error = css__stylesheet_style_appendOPV(attachment_style, + CSS_PROP_BACKGROUND_ATTACHMENT, 0, BACKGROUND_ATTACHMENT_SCROLL); if (error != CSS_OK) goto css__parse_background_cleanup; } if (color) { - error = css__stylesheet_style_appendOPV(color_style, - CSS_PROP_BACKGROUND_COLOR, 0, + error = css__stylesheet_style_appendOPV(color_style, + CSS_PROP_BACKGROUND_COLOR, 0, BACKGROUND_COLOR_TRANSPARENT); if (error != CSS_OK) goto css__parse_background_cleanup; } if (image) { - error = css__stylesheet_style_appendOPV(image_style, + error = css__stylesheet_style_appendOPV(image_style, CSS_PROP_BACKGROUND_IMAGE, 0, BACKGROUND_IMAGE_NONE); if (error != CSS_OK) @@ -190,7 +190,7 @@ css_error css__parse_background(css_language *c, } if (repeat) { - error = css__stylesheet_style_appendOPV(repeat_style, + error = css__stylesheet_style_appendOPV(repeat_style, CSS_PROP_BACKGROUND_REPEAT, 0, BACKGROUND_REPEAT_REPEAT); if (error != CSS_OK) diff --git a/src/parse/properties/background_position.c b/src/parse/properties/background_position.c index d4b31dc..6932c05 100644 --- a/src/parse/properties/background_position.c +++ b/src/parse/properties/background_position.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_background_position(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_background_position(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -65,35 +65,35 @@ css_error css__parse_background_position(css_language *c, if (token->type == CSS_TOKEN_IDENT) { if ((lwc_string_caseless_isequal( token->idata, c->strings[LEFT], - &match) == lwc_error_ok && + &match) == lwc_error_ok && match)) { - value[i] = + value[i] = BACKGROUND_POSITION_HORZ_LEFT; } else if ((lwc_string_caseless_isequal( token->idata, c->strings[RIGHT], - &match) == lwc_error_ok && + &match) == lwc_error_ok && match)) { - value[i] = + value[i] = BACKGROUND_POSITION_HORZ_RIGHT; } else if ((lwc_string_caseless_isequal( token->idata, c->strings[TOP], - &match) == lwc_error_ok && + &match) == lwc_error_ok && match)) { value[i] = BACKGROUND_POSITION_VERT_TOP; } else if ((lwc_string_caseless_isequal( - token->idata, + token->idata, c->strings[BOTTOM], - &match) == lwc_error_ok && + &match) == lwc_error_ok && match)) { - value[i] = + value[i] = BACKGROUND_POSITION_VERT_BOTTOM; } else if ((lwc_string_caseless_isequal( - token->idata, + token->idata, c->strings[CENTER], - &match) == lwc_error_ok && + &match) == lwc_error_ok && match)) { /* We'll fix this up later */ - value[i] = + value[i] = BACKGROUND_POSITION_VERT_CENTER; } else if (i == 1) { /* Second pass, so ignore this one */ @@ -108,15 +108,15 @@ css_error css__parse_background_position(css_language *c, } else if (token->type == CSS_TOKEN_DIMENSION || token->type == CSS_TOKEN_NUMBER || token->type == CSS_TOKEN_PERCENTAGE) { - error = css__parse_unit_specifier(c, vector, ctx, + error = css__parse_unit_specifier(c, vector, ctx, UNIT_PX, &length[i], &unit[i]); if (error != CSS_OK) { *ctx = orig_ctx; return error; } - if (unit[i] & UNIT_ANGLE || - unit[i] & UNIT_TIME || + if (unit[i] & UNIT_ANGLE || + unit[i] & UNIT_TIME || unit[i] & UNIT_FREQ) { *ctx = orig_ctx; return CSS_INVALID; @@ -163,7 +163,7 @@ css_error css__parse_background_position(css_language *c, value[1] != BACKGROUND_POSITION_VERT_SET) { /* Two keywords. Verify the axes differ */ if (((value[0] & 0xf) != 0 && (value[1] & 0xf) != 0) || - ((value[0] & 0xf0) != 0 && + ((value[0] & 0xf0) != 0 && (value[1] & 0xf0) != 0)) { *ctx = orig_ctx; return CSS_INVALID; @@ -175,7 +175,7 @@ css_error css__parse_background_position(css_language *c, /* Verify the axes differ */ if (((value[0] & 0xf) != 0 && (value[1] & 0xf) != 0) || - ((value[0] & 0xf0) != 0 && + ((value[0] & 0xf0) != 0 && (value[1] & 0xf0) != 0)) { *ctx = orig_ctx; return CSS_INVALID; @@ -183,9 +183,9 @@ css_error css__parse_background_position(css_language *c, } } - error = css__stylesheet_style_appendOPV(result, - CSS_PROP_BACKGROUND_POSITION, - flags, + error = css__stylesheet_style_appendOPV(result, + CSS_PROP_BACKGROUND_POSITION, + flags, value[0] | value[1]); if (error != CSS_OK) { *ctx = orig_ctx; diff --git a/src/parse/properties/border.c b/src/parse/properties/border.c index 98ad08b..26cdbcd 100644 --- a/src/parse/properties/border.c +++ b/src/parse/properties/border.c @@ -56,9 +56,9 @@ css_error css__parse_border(css_language *c, *ctx = orig_ctx; error = css__parse_border_side(c, vector, ctx, result, BORDER_SIDE_LEFT); - if (error != CSS_OK) + if (error != CSS_OK) *ctx = orig_ctx; - + return error; - + } diff --git a/src/parse/properties/border_color.c b/src/parse/properties/border_color.c index 7495ffc..28d30b7 100644 --- a/src/parse/properties/border_color.c +++ b/src/parse/properties/border_color.c @@ -41,28 +41,28 @@ css_error css__parse_border_color(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_TOP_COLOR); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_RIGHT_COLOR); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_BOTTOM_COLOR); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_LEFT_COLOR); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* Attempt to parse up to 4 colours */ do { diff --git a/src/parse/properties/border_spacing.c b/src/parse/properties/border_spacing.c index e9949fd..2322a5a 100644 --- a/src/parse/properties/border_spacing.c +++ b/src/parse/properties/border_spacing.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_border_spacing(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_border_spacing(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -65,7 +65,7 @@ css_error css__parse_border_spacing(css_language *c, return error; } - if (unit[0] & UNIT_ANGLE || unit[0] & UNIT_TIME || + if (unit[0] & UNIT_ANGLE || unit[0] & UNIT_TIME || unit[0] & UNIT_FREQ || unit[0] & UNIT_PCT) { *ctx = orig_ctx; return CSS_INVALID; @@ -78,16 +78,16 @@ css_error css__parse_border_spacing(css_language *c, token = parserutils_vector_peek(vector, *ctx); if (token != NULL) { /* Attempt second length, ignoring errors. - * The core !important parser will ensure + * The core !important parser will ensure * any remaining junk is thrown out. * Ctx will be preserved on error, as usual */ error = css__parse_unit_specifier(c, vector, ctx, UNIT_PX, &length[1], &unit[1]); if (error == CSS_OK) { - if (unit[1] & UNIT_ANGLE || + if (unit[1] & UNIT_ANGLE || unit[1] & UNIT_TIME || - unit[1] & UNIT_FREQ || + unit[1] & UNIT_FREQ || unit[1] & UNIT_PCT) { *ctx = orig_ctx; return CSS_INVALID; @@ -119,11 +119,11 @@ css_error css__parse_border_spacing(css_language *c, return error; } - error = css__stylesheet_style_vappend(result, - 4, - length[0], - unit[0], - length[1], + error = css__stylesheet_style_vappend(result, + 4, + length[0], + unit[0], + length[1], unit[1]); } diff --git a/src/parse/properties/border_style.c b/src/parse/properties/border_style.c index d4a4d12..a0d264d 100644 --- a/src/parse/properties/border_style.c +++ b/src/parse/properties/border_style.c @@ -41,28 +41,28 @@ css_error css__parse_border_style(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_TOP_STYLE); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_RIGHT_STYLE); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_BOTTOM_STYLE); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_LEFT_STYLE); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* Attempt to parse up to 4 styles */ do { @@ -73,7 +73,7 @@ css_error css__parse_border_style(css_language *c, return CSS_INVALID; } - if (token->type != CSS_TOKEN_IDENT) + if (token->type != CSS_TOKEN_IDENT) break; if ((lwc_string_caseless_isequal(token->idata, c->strings[NONE], &match) == lwc_error_ok && match)) { @@ -101,9 +101,9 @@ css_error css__parse_border_style(css_language *c, } side_count++; - + parserutils_vector_iterate(vector, ctx); - + consumeWhitespace(vector, ctx); token = parserutils_vector_peek(vector, *ctx); @@ -113,7 +113,7 @@ css_error css__parse_border_style(css_language *c, #define SIDE_APPEND(OP,NUM) \ error = css__stylesheet_style_appendOPV(result, (OP), 0, side_val[(NUM)]); \ if (error != CSS_OK) \ - break + break switch (side_count) { case 1: diff --git a/src/parse/properties/border_width.c b/src/parse/properties/border_width.c index 8b86bc4..bc911c9 100644 --- a/src/parse/properties/border_width.c +++ b/src/parse/properties/border_width.c @@ -43,28 +43,28 @@ css_error css__parse_border_width(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_TOP_WIDTH); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_RIGHT_WIDTH); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_BOTTOM_WIDTH); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_LEFT_WIDTH); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* Attempt to parse up to 4 widths */ do { diff --git a/src/parse/properties/clip.c b/src/parse/properties/clip.c index 3d200f5..7862d4a 100644 --- a/src/parse/properties/clip.c +++ b/src/parse/properties/clip.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_clip(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_clip(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -39,7 +39,7 @@ css_error css__parse_clip(css_language *c, uint32_t unit[4] = { 0 }; bool match; - /* FUNCTION(rect) [ [ IDENT(auto) | length ] CHAR(,)? ]{3} + /* FUNCTION(rect) [ [ IDENT(auto) | length ] CHAR(,)? ]{3} * [ IDENT(auto) | length ] CHAR{)} | * IDENT(auto, inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -81,11 +81,11 @@ css_error css__parse_clip(css_language *c, } if (token->type == CSS_TOKEN_IDENT) { - /* Slightly magical way of generating the auto + /* Slightly magical way of generating the auto * values. These are bits 3-6 of the value. */ if ((lwc_string_caseless_isequal( token->idata, c->strings[AUTO], - &match) == lwc_error_ok && + &match) == lwc_error_ok && match)) value |= 1 << (i + 3); else { @@ -95,16 +95,16 @@ css_error css__parse_clip(css_language *c, parserutils_vector_iterate(vector, ctx); } else { - error = css__parse_unit_specifier(c, vector, ctx, - UNIT_PX, - &length[num_lengths], + error = css__parse_unit_specifier(c, vector, ctx, + UNIT_PX, + &length[num_lengths], &unit[num_lengths]); if (error != CSS_OK) { *ctx = orig_ctx; return error; } - if (unit[num_lengths] & UNIT_ANGLE || + if (unit[num_lengths] & UNIT_ANGLE || unit[num_lengths] & UNIT_TIME || unit[num_lengths] & UNIT_FREQ || unit[num_lengths] & UNIT_PCT) { @@ -150,11 +150,11 @@ css_error css__parse_clip(css_language *c, } for (i = 0; i < num_lengths; i++) { - error = css__stylesheet_style_vappend(result, - 2, - length[i], + error = css__stylesheet_style_vappend(result, + 2, + length[i], unit[i]); - if (error != CSS_OK) + if (error != CSS_OK) break; } diff --git a/src/parse/properties/content.c b/src/parse/properties/content.c index 860d0f1..10f221f 100644 --- a/src/parse/properties/content.c +++ b/src/parse/properties/content.c @@ -127,15 +127,15 @@ css_error css__parse_content(css_language *c, error = c->sheet->resolve(c->sheet->resolve_pw, c->sheet->url, - token->idata, + token->idata, &uri); if (error != CSS_OK) { *ctx = orig_ctx; return error; } - error = css__stylesheet_string_add(c->sheet, - uri, + error = css__stylesheet_string_add(c->sheet, + uri, &uri_snumber); if (error != CSS_OK) { *ctx = orig_ctx; diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c index a430c9b..0e6ce72 100644 --- a/src/parse/properties/css_property_parser_gen.c +++ b/src/parse/properties/css_property_parser_gen.c @@ -109,8 +109,8 @@ void output_header(FILE *outputf, const char *descriptor, struct keyval *parser_ " const parserutils_vector *vector, int *ctx,\n" " css_style *result%s)\n" "{\n", - descriptor, - parser_id->key, + descriptor, + parser_id->key, is_generic ? " * \\param op Bytecode OpCode for CSS property to encode\n" : "", parser_id->key, is_generic ? ", enum css_properties_e op" : ""); @@ -249,7 +249,7 @@ void output_number(FILE *outputf, struct keyval *parseid, struct keyval_list *kv "\t\tif (%s) {\n" "\t\t\t*ctx = orig_ctx;\n" "\t\t\treturn CSS_INVALID;\n" - "\t\t}\n\n", + "\t\t}\n\n", ulkv->val); } @@ -264,7 +264,7 @@ void output_number(FILE *outputf, struct keyval *parseid, struct keyval_list *kv "\t\terror = css__stylesheet_style_append(result, num);\n" "\t} else ", parseid->val, - ckv->val); + ckv->val); } void output_color(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist) @@ -317,21 +317,21 @@ void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_lis "\t\tif ((%s) == false) {\n" "\t\t\t*ctx = orig_ctx;\n" "\t\t\treturn CSS_INVALID;\n" - "\t\t}\n\n", + "\t\t}\n\n", ulkv->val); } else if (strcmp(ulkv->key, "DISALLOW") == 0) { fprintf(outputf, "\t\tif (%s) {\n" "\t\t\t*ctx = orig_ctx;\n" "\t\t\treturn CSS_INVALID;\n" - "\t\t}\n\n", + "\t\t}\n\n", ulkv->val); } else if (strcmp(ulkv->key, "RANGE") == 0) { fprintf(outputf, "\t\tif (length %s) {\n" "\t\t\t*ctx = orig_ctx;\n" "\t\t\treturn CSS_INVALID;\n" - "\t\t}\n\n", + "\t\t}\n\n", ulkv->val); } @@ -350,9 +350,9 @@ void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_lis ckv->val); } -void -output_ident_list(FILE *outputf, - struct keyval *parseid, +void +output_ident_list(FILE *outputf, + struct keyval *parseid, struct keyval_list *kvlist) { struct keyval *ckv = kvlist->item[0]; /* list type : opv value */ @@ -387,7 +387,7 @@ output_ident_list(FILE *outputf, "\t\t\t\t*ctx = orig_ctx;\n" "\t\t\t\treturn error;\n" "\t\t\t}\n\n" - "\t\t\terror = css__stylesheet_style_append(result, snumber);\n" + "\t\t\terror = css__stylesheet_style_append(result, snumber);\n" "\t\t\tif (error != CSS_OK) {\n" "\t\t\t\t*ctx = orig_ctx;\n" "\t\t\t\treturn error;\n" @@ -553,13 +553,13 @@ int main(int argc, char **argv) curlist = &IDENT_LIST; } else if (rkv->val[0] == ')') { curlist = &base; - } + } } else if (strcmp(rkv->key, "LENGTH_UNIT") == 0) { if (rkv->val[0] == '(') { curlist = &LENGTH_UNIT; } else if (rkv->val[0] == ')') { curlist = &base; - } + } only_ident = false; do_token_check = false; } else if (strcmp(rkv->key, "COLOR") == 0) { diff --git a/src/parse/properties/cue.c b/src/parse/properties/cue.c index ea94adb..eef10d1 100644 --- a/src/parse/properties/cue.c +++ b/src/parse/properties/cue.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_cue(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_cue(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -47,7 +47,7 @@ css_error css__parse_cue(css_language *c, error = css__parse_cue_before(c, vector, ctx, result); if (error == CSS_OK) { /* first token parsed */ - + consumeWhitespace(vector, ctx); token = parserutils_vector_peek(vector, *ctx); @@ -62,7 +62,7 @@ css_error css__parse_cue(css_language *c, error = CSS_INVALID; } else { error = css__parse_cue_after(c, vector, ctx, result); - if (error == CSS_OK) { + if (error == CSS_OK) { /* second token parsed */ if (is_css_inherit(c, first_token)) { /* valid second token after inherit */ diff --git a/src/parse/properties/cursor.c b/src/parse/properties/cursor.c index 6b9eadf..ad3ac47 100644 --- a/src/parse/properties/cursor.c +++ b/src/parse/properties/cursor.c @@ -26,8 +26,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_cursor(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_cursor(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -37,11 +37,11 @@ css_error css__parse_cursor(css_language *c, /* [ (URI ',')* IDENT(auto, crosshair, default, pointer, move, e-resize, * ne-resize, nw-resize, n-resize, se-resize, sw-resize, - * s-resize, w-resize, text, wait, help, progress) ] - * | IDENT(inherit) + * s-resize, w-resize, text, wait, help, progress) ] + * | IDENT(inherit) */ token = parserutils_vector_iterate(vector, ctx); - if ((token == NULL) || + if ((token == NULL) || (token->type != CSS_TOKEN_IDENT && token->type != CSS_TOKEN_URI)) { *ctx = orig_ctx; @@ -75,8 +75,8 @@ css_error css__parse_cursor(css_language *c, return error; } - error = css__stylesheet_string_add(c->sheet, - uri, + error = css__stylesheet_string_add(c->sheet, + uri, &uri_snumber); if (error != CSS_OK) { *ctx = orig_ctx; diff --git a/src/parse/properties/elevation.c b/src/parse/properties/elevation.c index 0b5fdc4..fea35a3 100644 --- a/src/parse/properties/elevation.c +++ b/src/parse/properties/elevation.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_elevation(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_elevation(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; diff --git a/src/parse/properties/font.c b/src/parse/properties/font.c index 2cdb488..9903f75 100644 --- a/src/parse/properties/font.c +++ b/src/parse/properties/font.c @@ -15,7 +15,7 @@ static css_error parse_system_font(css_language *c, - css_style *result, css_system_font *system_font) + css_style *result, css_system_font *system_font) { css_error error; bool match; @@ -38,7 +38,7 @@ static css_error parse_system_font(css_language *c, error = CSS_BADPARM; break; } - if (error != CSS_OK) + if (error != CSS_OK) return error; /* variant */ @@ -55,8 +55,8 @@ static css_error parse_system_font(css_language *c, error = CSS_BADPARM; break; } - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; /* weight */ switch(system_font->weight) { @@ -116,29 +116,29 @@ static css_error parse_system_font(css_language *c, error = CSS_BADPARM; break; } - if (error != CSS_OK) + if (error != CSS_OK) return error; /* size */ error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0, FONT_SIZE_DIMENSION); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css__stylesheet_style_vappend(result, 2, system_font->size.size, system_font->size.unit); - if (error != CSS_OK) + if (error != CSS_OK) return error; /* line height */ error = css__stylesheet_style_appendOPV(result, CSS_PROP_LINE_HEIGHT, 0, LINE_HEIGHT_DIMENSION); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css__stylesheet_style_vappend(result, 2, system_font->line_height.size, system_font->line_height.unit); - if (error != CSS_OK) + if (error != CSS_OK) return error; /* font family */ - if ((lwc_string_caseless_isequal(system_font->family, c->strings[SERIF], &match) == lwc_error_ok && match)) + if ((lwc_string_caseless_isequal(system_font->family, c->strings[SERIF], &match) == lwc_error_ok && match)) error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_FAMILY, 0, FONT_FAMILY_SERIF); else if ((lwc_string_caseless_isequal(system_font->family, c->strings[SANS_SERIF], &match) == lwc_error_ok && match)) error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_FAMILY, 0, FONT_FAMILY_SANS_SERIF); @@ -207,47 +207,47 @@ css_error css__parse_font(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_FONT_STYLE); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_FONT_VARIANT); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_FONT_WEIGHT); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_FONT_SIZE); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_LINE_HEIGHT); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_FONT_FAMILY); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* Perhaps an unknown font name; ask the client */ - if ((token->type == CSS_TOKEN_IDENT) && + if ((token->type == CSS_TOKEN_IDENT) && (c->sheet->font != NULL) && - (c->sheet->font(c->sheet->font_pw, - token->idata, + (c->sheet->font(c->sheet->font_pw, + token->idata, &system_font) == CSS_OK)) { - + error = parse_system_font(c, result, &system_font); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; @@ -256,7 +256,7 @@ css_error css__parse_font(css_language *c, /* allocate styles */ error = css__stylesheet_style_create(c->sheet, &style_style); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css__stylesheet_style_create(c->sheet, &variant_style); @@ -312,15 +312,15 @@ css_error css__parse_font(css_language *c, goto css__parse_font_cleanup; } - if ((style) && + if ((style) && (error = css__parse_font_style(c, vector, ctx, style_style)) == CSS_OK) { style = false; - } else if ((variant) && + } else if ((variant) && (error = css__parse_font_variant(c, vector, ctx, variant_style)) == CSS_OK) { variant = false; - } else if ((weight) && + } else if ((weight) && (error = css__parse_font_weight(c, vector, ctx, weight_style)) == CSS_OK) { weight = false; @@ -389,23 +389,23 @@ css_error css__parse_font(css_language *c, /* defaults */ if (style) { - error = css__stylesheet_style_appendOPV(style_style, - CSS_PROP_FONT_STYLE, 0, + error = css__stylesheet_style_appendOPV(style_style, + CSS_PROP_FONT_STYLE, 0, FONT_STYLE_NORMAL); if (error != CSS_OK) goto css__parse_font_cleanup; } if (variant) { - error = css__stylesheet_style_appendOPV(variant_style, - CSS_PROP_FONT_VARIANT, 0, + error = css__stylesheet_style_appendOPV(variant_style, + CSS_PROP_FONT_VARIANT, 0, FONT_VARIANT_NORMAL); if (error != CSS_OK) goto css__parse_font_cleanup; } if (weight) { - error = css__stylesheet_style_appendOPV(weight_style, + error = css__stylesheet_style_appendOPV(weight_style, CSS_PROP_FONT_WEIGHT, 0, FONT_WEIGHT_NORMAL); if (error != CSS_OK) @@ -413,7 +413,7 @@ css_error css__parse_font(css_language *c, } if (line_height) { - error = css__stylesheet_style_appendOPV(line_height_style, + error = css__stylesheet_style_appendOPV(line_height_style, CSS_PROP_LINE_HEIGHT, 0, LINE_HEIGHT_NORMAL); if (error != CSS_OK) diff --git a/src/parse/properties/font_family.c b/src/parse/properties/font_family.c index 60c069d..23c080b 100644 --- a/src/parse/properties/font_family.c +++ b/src/parse/properties/font_family.c @@ -98,8 +98,8 @@ static css_code_t font_family_value(css_language *c, const css_token *token, boo * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_font_family(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_font_family(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -108,11 +108,11 @@ css_error css__parse_font_family(css_language *c, bool match; /* [ IDENT+ | STRING ] [ ',' [ IDENT+ | STRING ] ]* | IDENT(inherit) - * + * * In the case of IDENT+, any whitespace between tokens is collapsed to * a single space * - * \todo Mozilla makes the comma optional. + * \todo Mozilla makes the comma optional. * Perhaps this is a quirk we should inherit? */ diff --git a/src/parse/properties/font_weight.c b/src/parse/properties/font_weight.c index 4853106..8e57e5f 100644 --- a/src/parse/properties/font_weight.c +++ b/src/parse/properties/font_weight.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_font_weight(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_font_weight(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -38,7 +38,7 @@ css_error css__parse_font_weight(css_language *c, uint16_t value = 0; bool match; - /* NUMBER (100, 200, 300, 400, 500, 600, 700, 800, 900) | + /* NUMBER (100, 200, 300, 400, 500, 600, 700, 800, 900) | * IDENT (normal, bold, bolder, lighter, inherit) */ token = parserutils_vector_iterate(vector, ctx); if (token == NULL || (token->type != CSS_TOKEN_IDENT && @@ -53,7 +53,7 @@ css_error css__parse_font_weight(css_language *c, flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - css_fixed num = css__number_from_lwc_string(token->idata, + css_fixed num = css__number_from_lwc_string(token->idata, true, &consumed); /* Invalid if there are trailing characters */ if (consumed != lwc_string_length(token->idata)) { @@ -98,9 +98,9 @@ css_error css__parse_font_weight(css_language *c, CSS_PROP_FONT_WEIGHT, flags, value); - if (error != CSS_OK) + if (error != CSS_OK) *ctx = orig_ctx; - + return error; } diff --git a/src/parse/properties/list_style.c b/src/parse/properties/list_style.c index 4ef4ce8..f12fa2e 100644 --- a/src/parse/properties/list_style.c +++ b/src/parse/properties/list_style.c @@ -44,29 +44,29 @@ css_error css__parse_list_style(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_LIST_STYLE_IMAGE); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_LIST_STYLE_POSITION); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_LIST_STYLE_TYPE); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* allocate styles */ error = css__stylesheet_style_create(c->sheet, &image_style); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css__stylesheet_style_create(c->sheet, &position_style); @@ -94,15 +94,15 @@ css_error css__parse_list_style(css_language *c, goto css__parse_list_style_cleanup; } - if ((type) && + if ((type) && (error = css__parse_list_style_type(c, vector, ctx, type_style)) == CSS_OK) { type = false; - } else if ((position) && - (error = css__parse_list_style_position(c, vector, + } else if ((position) && + (error = css__parse_list_style_position(c, vector, ctx, position_style)) == CSS_OK) { position = false; - } else if ((image) && + } else if ((image) && (error = css__parse_list_style_image(c, vector, ctx, image_style)) == CSS_OK) { image = false; @@ -121,19 +121,19 @@ css_error css__parse_list_style(css_language *c, /* defaults */ if (image) { - error = css__stylesheet_style_appendOPV(image_style, + error = css__stylesheet_style_appendOPV(image_style, CSS_PROP_LIST_STYLE_IMAGE, 0, LIST_STYLE_IMAGE_NONE); } if (position) { - error = css__stylesheet_style_appendOPV(position_style, + error = css__stylesheet_style_appendOPV(position_style, CSS_PROP_LIST_STYLE_POSITION, 0, LIST_STYLE_POSITION_OUTSIDE); } if (type) { - error = css__stylesheet_style_appendOPV(type_style, + error = css__stylesheet_style_appendOPV(type_style, CSS_PROP_LIST_STYLE_TYPE, 0, LIST_STYLE_TYPE_DISC); } diff --git a/src/parse/properties/list_style_type.c b/src/parse/properties/list_style_type.c index b73bcb7..ccaa133 100644 --- a/src/parse/properties/list_style_type.c +++ b/src/parse/properties/list_style_type.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_list_style_type(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_list_style_type(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -63,8 +63,8 @@ css_error css__parse_list_style_type(css_language *c, error = css__stylesheet_style_appendOPV(result, CSS_PROP_LIST_STYLE_TYPE, flags, value); - if (error != CSS_OK) + if (error != CSS_OK) *ctx = orig_ctx; - + return error; } diff --git a/src/parse/properties/margin.c b/src/parse/properties/margin.c index 896e300..7817d50 100644 --- a/src/parse/properties/margin.c +++ b/src/parse/properties/margin.c @@ -43,28 +43,28 @@ css_error css__parse_margin(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_MARGIN_TOP); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_MARGIN_RIGHT); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_MARGIN_BOTTOM); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_MARGIN_LEFT); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* Attempt to parse up to 4 widths */ do { diff --git a/src/parse/properties/opacity.c b/src/parse/properties/opacity.c index edad9f8..e8b7c3e 100644 --- a/src/parse/properties/opacity.c +++ b/src/parse/properties/opacity.c @@ -73,7 +73,7 @@ css_error css__parse_opacity(css_language *c, if (error != CSS_OK) *ctx = orig_ctx; - + return error; } diff --git a/src/parse/properties/outline.c b/src/parse/properties/outline.c index eb4f525..d9d9ec2 100644 --- a/src/parse/properties/outline.c +++ b/src/parse/properties/outline.c @@ -44,29 +44,29 @@ css_error css__parse_outline(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_OUTLINE_COLOR); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_OUTLINE_STYLE); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_OUTLINE_WIDTH); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* allocate styles */ error = css__stylesheet_style_create(c->sheet, &color_style); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css__stylesheet_style_create(c->sheet, &style_style); @@ -94,19 +94,19 @@ css_error css__parse_outline(css_language *c, goto css__parse_outline_cleanup; } - if ((color) && + if ((color) && (error = css__parse_outline_color(c, vector, ctx, color_style)) == CSS_OK) { color = false; - } else if ((style) && - (error = css__parse_outline_style(c, vector, + } else if ((style) && + (error = css__parse_outline_style(c, vector, ctx, style_style)) == CSS_OK) { style = false; - } else if ((width) && + } else if ((width) && (error = css__parse_outline_width(c, vector, ctx, width_style)) == CSS_OK) { width = false; - } + } if (error == CSS_OK) { consumeWhitespace(vector, ctx); @@ -121,19 +121,19 @@ css_error css__parse_outline(css_language *c, /* defaults */ if (color) { - error = css__stylesheet_style_appendOPV(color_style, + error = css__stylesheet_style_appendOPV(color_style, CSS_PROP_OUTLINE_COLOR, 0, OUTLINE_COLOR_INVERT); } if (style) { - error = css__stylesheet_style_appendOPV(style_style, + error = css__stylesheet_style_appendOPV(style_style, CSS_PROP_OUTLINE_STYLE, 0, OUTLINE_STYLE_NONE); } if (width) { - error = css__stylesheet_style_appendOPV(width_style, + error = css__stylesheet_style_appendOPV(width_style, CSS_PROP_OUTLINE_WIDTH, 0, OUTLINE_WIDTH_MEDIUM); } diff --git a/src/parse/properties/padding.c b/src/parse/properties/padding.c index 7a5b88b..7f5b9f6 100644 --- a/src/parse/properties/padding.c +++ b/src/parse/properties/padding.c @@ -41,28 +41,28 @@ css_error css__parse_padding(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_PADDING_TOP); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_PADDING_RIGHT); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_PADDING_BOTTOM); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_PADDING_LEFT); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* Attempt to parse up to 4 widths */ do { @@ -81,7 +81,7 @@ css_error css__parse_padding(css_language *c, *ctx = orig_ctx; return CSS_INVALID; } - + if (side_length[side_count] < 0) { *ctx = orig_ctx; return CSS_INVALID; diff --git a/src/parse/properties/pause.c b/src/parse/properties/pause.c index fcb4644..e45a8f4 100644 --- a/src/parse/properties/pause.c +++ b/src/parse/properties/pause.c @@ -62,7 +62,7 @@ css_error css__parse_pause(css_language *c, error = CSS_INVALID; } else { error = css__parse_pause_after(c, vector, ctx, result); - if (error == CSS_OK) { + if (error == CSS_OK) { /* second token parsed */ if (is_css_inherit(c, first_token)) { /* valid second token after inherit */ diff --git a/src/parse/properties/play_during.c b/src/parse/properties/play_during.c index 1e5ad63..109ae64 100644 --- a/src/parse/properties/play_during.c +++ b/src/parse/properties/play_during.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_play_during(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_play_during(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -42,7 +42,7 @@ css_error css__parse_play_during(css_language *c, /* URI [ IDENT(mix) || IDENT(repeat) ]? | IDENT(auto,none,inherit) */ token = parserutils_vector_iterate(vector, ctx); - if ((token == NULL) || + if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT) && (token->type != CSS_TOKEN_URI))) { *ctx = orig_ctx; @@ -79,8 +79,8 @@ css_error css__parse_play_during(css_language *c, return error; } - error = css__stylesheet_string_add(c->sheet, - uri, + error = css__stylesheet_string_add(c->sheet, + uri, &uri_snumber); if (error != CSS_OK) { *ctx = orig_ctx; @@ -95,7 +95,7 @@ css_error css__parse_play_during(css_language *c, if (token != NULL && token->type == CSS_TOKEN_IDENT) { if ((lwc_string_caseless_isequal( token->idata, c->strings[MIX], - &match) == lwc_error_ok && + &match) == lwc_error_ok && match)) { if ((value & PLAY_DURING_MIX) == 0) value |= PLAY_DURING_MIX; @@ -104,7 +104,7 @@ css_error css__parse_play_during(css_language *c, return CSS_INVALID; } } else if (lwc_string_caseless_isequal( - token->idata, + token->idata, c->strings[REPEAT], &match) == lwc_error_ok && match) { @@ -130,12 +130,12 @@ css_error css__parse_play_during(css_language *c, return error; } - if ((flags & FLAG_INHERIT) == false && + if ((flags & FLAG_INHERIT) == false && (value & PLAY_DURING_TYPE_MASK) == PLAY_DURING_URI) { error = css__stylesheet_style_append(result, uri_snumber); } - if (error != CSS_OK) + if (error != CSS_OK) *ctx = orig_ctx; return error; diff --git a/src/parse/properties/properties.h b/src/parse/properties/properties.h index e7b2bf7..4517515 100644 --- a/src/parse/properties/properties.h +++ b/src/parse/properties/properties.h @@ -16,32 +16,32 @@ /** * Type of property handler function */ -typedef css_error (*css_prop_handler)(css_language *c, - const parserutils_vector *vector, int *ctx, +typedef css_error (*css_prop_handler)(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result); extern const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP]; css_error css__parse_azimuth(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_background(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_background_attachment(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_background_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_background_image(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_background_position(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_background_repeat(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border(css_language *c, const parserutils_vector *vector, int *ctx, @@ -50,46 +50,46 @@ css_error css__parse_border_bottom(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_bottom_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_bottom_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_bottom_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_color(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_collapse(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_left(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_left_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_left_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_left_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_right(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_right_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_right_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_right_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_spacing(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_style(css_language *c, const parserutils_vector *vector, int *ctx, @@ -98,19 +98,19 @@ css_error css__parse_border_top(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_top_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_top_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_top_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_border_width(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_bottom(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_box_sizing(css_language *c, const parserutils_vector *vector, int *ctx, @@ -125,169 +125,169 @@ css_error css__parse_break_inside(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_caption_side(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_clear(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_clip(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_columns(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_count(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_fill(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_gap(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_rule(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_rule_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_rule_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_rule_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_span(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_column_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_content(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_counter_increment(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_counter_reset(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_cue(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_cue_after(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_cue_before(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_cursor(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_direction(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_display(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_elevation(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_empty_cells(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_float(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_font(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_font_family(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_font_size(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_font_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_font_variant(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_font_weight(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_height(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_left(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_letter_spacing(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_line_height(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_list_style(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_list_style_image(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_list_style_position(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_list_style_type(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_margin(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_margin_bottom(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_margin_left(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_margin_right(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_margin_top(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_max_height(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_max_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_min_height(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_min_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_opacity(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_orphans(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_outline(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_outline_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_outline_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_outline_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_overflow(css_language *c, const parserutils_vector *vector, int *ctx, @@ -302,124 +302,124 @@ css_error css__parse_padding(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_padding_bottom(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_padding_left(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_padding_right(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_padding_top(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_page_break_after(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_page_break_before(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_page_break_inside(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_pause(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_pause_after(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_pause_before(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_pitch_range(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_pitch(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_play_during(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_position(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_quotes(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_richness(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_right(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_speak_header(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_speak_numeral(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_speak_punctuation(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_speak(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_speech_rate(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_stress(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_table_layout(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_text_align(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_text_decoration(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_text_indent(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_text_transform(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_top(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_unicode_bidi(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_vertical_align(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_visibility(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_voice_family(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_volume(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_white_space(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_widows(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_word_spacing(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_writing_mode(css_language *c, const parserutils_vector *vector, int *ctx, css_style *result); css_error css__parse_z_index(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int *ctx, css_style *result); #endif diff --git a/src/parse/properties/quotes.c b/src/parse/properties/quotes.c index b7fc294..9d3c4c9 100644 --- a/src/parse/properties/quotes.c +++ b/src/parse/properties/quotes.c @@ -69,39 +69,39 @@ css_error css__parse_quotes(css_language *c, uint32_t open_snumber; uint32_t close_snumber; - error = css__stylesheet_string_add(c->sheet, - lwc_string_ref(token->idata), + error = css__stylesheet_string_add(c->sheet, + lwc_string_ref(token->idata), &open_snumber); - if (error != CSS_OK) + if (error != CSS_OK) break; consumeWhitespace(vector, ctx); token = parserutils_vector_iterate(vector, ctx); - if ((token == NULL) || + if ((token == NULL) || (token->type != CSS_TOKEN_STRING)) { error = CSS_INVALID; break; } - error = css__stylesheet_string_add(c->sheet, - lwc_string_ref(token->idata), + error = css__stylesheet_string_add(c->sheet, + lwc_string_ref(token->idata), &close_snumber); - if (error != CSS_OK) + if (error != CSS_OK) break; consumeWhitespace(vector, ctx); error = CSS_FIRST_APPEND(QUOTES_STRING); - if (error != CSS_OK) + if (error != CSS_OK) break; error = css__stylesheet_style_append(result, open_snumber); - if (error != CSS_OK) + if (error != CSS_OK) break; error = css__stylesheet_style_append(result, close_snumber); - if (error != CSS_OK) + if (error != CSS_OK) break; first = false; @@ -115,7 +115,7 @@ css_error css__parse_quotes(css_language *c, if (error == CSS_OK) { /* AddTerminator */ error = css__stylesheet_style_append(result, QUOTES_NONE); - } + } } else { error = CSS_INVALID; } diff --git a/src/parse/properties/text_decoration.c b/src/parse/properties/text_decoration.c index 9bfdec2..a7bae24 100644 --- a/src/parse/properties/text_decoration.c +++ b/src/parse/properties/text_decoration.c @@ -27,8 +27,8 @@ * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_text_decoration(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_text_decoration(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c index 82dacf8..47b06e3 100644 --- a/src/parse/properties/utils.c +++ b/src/parse/properties/utils.c @@ -136,28 +136,28 @@ css_error css__parse_border_side(css_language *c, /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); - if (token == NULL) + if (token == NULL) return CSS_INVALID; - + if (is_css_inherit(c, token)) { error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_TOP_COLOR + side); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_TOP_STYLE + side); - if (error != CSS_OK) - return error; + if (error != CSS_OK) + return error; error = css_stylesheet_style_inherit(result, CSS_PROP_BORDER_TOP_WIDTH + side); - if (error == CSS_OK) + if (error == CSS_OK) parserutils_vector_iterate(vector, ctx); return error; - } + } /* allocate styles */ error = css__stylesheet_style_create(c->sheet, &color_style); - if (error != CSS_OK) + if (error != CSS_OK) return error; error = css__stylesheet_style_create(c->sheet, &style_style); @@ -188,19 +188,19 @@ css_error css__parse_border_side(css_language *c, /* Try each property parser in turn, but only if we * haven't already got a value for this property. */ - if ((color) && - (error = css__parse_border_side_color(c, vector, ctx, + if ((color) && + (error = css__parse_border_side_color(c, vector, ctx, color_style, CSS_PROP_BORDER_TOP_COLOR + side)) == CSS_OK) { color = false; - } else if ((style) && + } else if ((style) && (error = css__parse_border_side_style(c, vector, ctx, style_style, CSS_PROP_BORDER_TOP_STYLE + side)) == CSS_OK) { style = false; - } else if ((width) && + } else if ((width) && (error = css__parse_border_side_width(c, vector, ctx, width_style, CSS_PROP_BORDER_TOP_WIDTH + side)) == CSS_OK) { width = false; - } + } if (error == CSS_OK) { consumeWhitespace(vector, ctx); @@ -214,7 +214,7 @@ css_error css__parse_border_side(css_language *c, if (style) { error = css__stylesheet_style_appendOPV(style_style, - CSS_PROP_BORDER_TOP_STYLE + side, 0, + CSS_PROP_BORDER_TOP_STYLE + side, 0, BORDER_STYLE_NONE); if (error != CSS_OK) goto css__parse_border_side_cleanup; @@ -295,7 +295,7 @@ static void HSL_to_RGB(css_fixed hue, css_fixed sat, css_fixed lit, uint8_t *r, /* Compute min(r,g,b) */ min_rgb = FSUB(FMUL(lit, INTTOFIX(2)), max_rgb); - /* We know that the value of at least one of the components is + /* We know that the value of at least one of the components is * max(r,g,b) and that the value of at least one of the other * components is min(r,g,b). * @@ -370,7 +370,7 @@ css_error css__parse_colour_specifier(css_language *c, consumeWhitespace(vector, ctx); - /* IDENT(<colour name>) | + /* IDENT(<colour name>) | * HASH(rgb | rrggbb) | * FUNCTION(rgb) [ [ NUMBER | PERCENTAGE ] ',' ] {3} ')' * FUNCTION(rgba) [ [ NUMBER | PERCENTAGE ] ',' ] {4} ')' @@ -539,8 +539,8 @@ css_error css__parse_colour_specifier(css_language *c, css_fixed hue, sat, lit; int32_t alpha = 255; - /* hue is a number without a unit representing an - * angle (0-360) degrees + /* hue is a number without a unit representing an + * angle (0-360) degrees */ consumeWhitespace(vector, ctx); @@ -615,7 +615,7 @@ css_error css__parse_colour_specifier(css_language *c, if (!tokenIsChar(token, ',')) goto invalid; - + consumeWhitespace(vector, ctx); token = parserutils_vector_iterate(vector, ctx); @@ -625,7 +625,7 @@ css_error css__parse_colour_specifier(css_language *c, alpha = css__number_from_lwc_string(token->idata, false, &consumed); if (consumed != lwc_string_length(token->idata)) goto invalid; /* failed to consume the whole string as a number */ - + alpha = FIXTOINT(FMUL(alpha, F_255)); consumeWhitespace(vector, ctx); @@ -1074,11 +1074,11 @@ css_error css__ident_list_or_string_to_string(css_language *c, lwc_string **result) { const css_token *token; - + token = parserutils_vector_peek(vector, *ctx); if (token == NULL) return CSS_INVALID; - + if (token->type == CSS_TOKEN_STRING) { token = parserutils_vector_iterate(vector, ctx); *result = lwc_string_ref(token->idata); @@ -1087,7 +1087,7 @@ css_error css__ident_list_or_string_to_string(css_language *c, return css__ident_list_to_string(c, vector, ctx, reserved, result); } - + return CSS_INVALID; } @@ -1126,7 +1126,7 @@ css_error css__ident_list_to_string(css_language *c, /* We know this token exists, and is an IDENT */ token = parserutils_vector_iterate(vector, ctx); - /* Consume all subsequent IDENT or S tokens */ + /* Consume all subsequent IDENT or S tokens */ while (token != NULL && (token->type == CSS_TOKEN_IDENT || token->type == CSS_TOKEN_S)) { if (token->type == CSS_TOKEN_IDENT) { @@ -1136,12 +1136,12 @@ css_error css__ident_list_to_string(css_language *c, goto cleanup; } - perror = parserutils_buffer_append(buffer, - (const uint8_t *) lwc_string_data(token->idata), + perror = parserutils_buffer_append(buffer, + (const uint8_t *) lwc_string_data(token->idata), lwc_string_length(token->idata)); } else { /* S */ - perror = parserutils_buffer_append(buffer, + perror = parserutils_buffer_append(buffer, (const uint8_t *) " ", 1); } @@ -1232,7 +1232,7 @@ css_error css__comma_list_to_style(css_language *c, if (error != CSS_OK) goto cleanup; - error = css__stylesheet_style_append(result, + error = css__stylesheet_style_append(result, value); if (error != CSS_OK) goto cleanup; @@ -1251,7 +1251,7 @@ css_error css__comma_list_to_style(css_language *c, css_code_t value = get_value(c, token, first); uint32_t snumber; - error = css__stylesheet_string_add(c->sheet, + error = css__stylesheet_string_add(c->sheet, lwc_string_ref(token->idata), &snumber); if (error != CSS_OK) goto cleanup; diff --git a/src/parse/properties/utils.h b/src/parse/properties/utils.h index b7b31da..e4c97c7 100644 --- a/src/parse/properties/utils.h +++ b/src/parse/properties/utils.h @@ -10,7 +10,7 @@ #include "parse/language.h" -static inline bool is_css_inherit(css_language *c, const css_token *token) +static inline bool is_css_inherit(css_language *c, const css_token *token) { bool match; return ((token->type == CSS_TOKEN_IDENT) && @@ -168,7 +168,7 @@ css_error css__parse_colour_specifier(css_language *c, const parserutils_vector *vector, int *ctx, uint16_t *value, uint32_t *result); -css_error css__parse_named_colour(css_language *c, lwc_string *data, +css_error css__parse_named_colour(css_language *c, lwc_string *data, uint32_t *result); css_error css__parse_hash_colour(lwc_string *data, uint32_t *result); @@ -178,7 +178,7 @@ css_error css__parse_unit_specifier(css_language *c, uint32_t default_unit, css_fixed *length, uint32_t *unit); -css_error css__parse_unit_keyword(const char *ptr, size_t len, +css_error css__parse_unit_keyword(const char *ptr, size_t len, uint32_t *unit); css_error css__ident_list_or_string_to_string(css_language *c, @@ -195,7 +195,7 @@ css_error css__comma_list_to_style(css_language *c, const parserutils_vector *vector, int *ctx, bool (*reserved)(css_language *c, const css_token *ident), css_code_t (*get_value)(css_language *c, - const css_token *token, + const css_token *token, bool first), css_style *result); diff --git a/src/parse/properties/voice_family.c b/src/parse/properties/voice_family.c index 8a969a6..193cb6b 100644 --- a/src/parse/properties/voice_family.c +++ b/src/parse/properties/voice_family.c @@ -83,8 +83,8 @@ static css_code_t voice_family_value(css_language *c, const css_token *token, bo * Post condition: \a *ctx is updated with the next token to process * If the input is invalid, then \a *ctx remains unchanged. */ -css_error css__parse_voice_family(css_language *c, - const parserutils_vector *vector, int *ctx, +css_error css__parse_voice_family(css_language *c, + const parserutils_vector *vector, int *ctx, css_style *result) { int orig_ctx = *ctx; @@ -93,7 +93,7 @@ css_error css__parse_voice_family(css_language *c, bool match; /* [ IDENT+ | STRING ] [ ',' [ IDENT+ | STRING ] ]* | IDENT(inherit) - * + * * In the case of IDENT+, any whitespace between tokens is collapsed to * a single space */ diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h index 1203c22..e0d16e2 100644 --- a/src/parse/propstrings.h +++ b/src/parse/propstrings.h @@ -22,15 +22,15 @@ enum { CHARSET, LIBCSS_IMPORT, MEDIA, NAMESPACE, FONT_FACE, PAGE, /* Media types */ - AURAL, BRAILLE, EMBOSSED, HANDHELD, PRINT, PROJECTION, + AURAL, BRAILLE, EMBOSSED, HANDHELD, PRINT, PROJECTION, SCREEN, SPEECH, TTY, TV, ALL, /* Pseudo classes */ - FIRST_CHILD, LINK, VISITED, HOVER, ACTIVE, FOCUS, LANG, + FIRST_CHILD, LINK, VISITED, HOVER, ACTIVE, FOCUS, LANG, /* LEFT, RIGHT, -- already in properties */ FIRST, ROOT, NTH_CHILD, NTH_LAST_CHILD, NTH_OF_TYPE, NTH_LAST_OF_TYPE, LAST_CHILD, FIRST_OF_TYPE, LAST_OF_TYPE, ONLY_CHILD, - ONLY_OF_TYPE, EMPTY, TARGET, ENABLED, DISABLED, CHECKED, NOT, + ONLY_OF_TYPE, EMPTY, TARGET, ENABLED, DISABLED, CHECKED, NOT, /* Pseudo elements */ FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, @@ -38,14 +38,14 @@ enum { /* Properties */ FIRST_PROP, - AZIMUTH = FIRST_PROP, BACKGROUND, BACKGROUND_ATTACHMENT, - BACKGROUND_COLOR, BACKGROUND_IMAGE, BACKGROUND_POSITION, - BACKGROUND_REPEAT, BORDER, BORDER_BOTTOM, BORDER_BOTTOM_COLOR, - BORDER_BOTTOM_STYLE, BORDER_BOTTOM_WIDTH, BORDER_COLLAPSE, - BORDER_COLOR, BORDER_LEFT, BORDER_LEFT_COLOR, BORDER_LEFT_STYLE, - BORDER_LEFT_WIDTH, BORDER_RIGHT, BORDER_RIGHT_COLOR, - BORDER_RIGHT_STYLE, BORDER_RIGHT_WIDTH, BORDER_SPACING, - BORDER_STYLE, BORDER_TOP, BORDER_TOP_COLOR, BORDER_TOP_STYLE, + AZIMUTH = FIRST_PROP, BACKGROUND, BACKGROUND_ATTACHMENT, + BACKGROUND_COLOR, BACKGROUND_IMAGE, BACKGROUND_POSITION, + BACKGROUND_REPEAT, BORDER, BORDER_BOTTOM, BORDER_BOTTOM_COLOR, + BORDER_BOTTOM_STYLE, BORDER_BOTTOM_WIDTH, BORDER_COLLAPSE, + BORDER_COLOR, BORDER_LEFT, BORDER_LEFT_COLOR, BORDER_LEFT_STYLE, + BORDER_LEFT_WIDTH, BORDER_RIGHT, BORDER_RIGHT_COLOR, + BORDER_RIGHT_STYLE, BORDER_RIGHT_WIDTH, BORDER_SPACING, + BORDER_STYLE, BORDER_TOP, BORDER_TOP_COLOR, BORDER_TOP_STYLE, BORDER_TOP_WIDTH, BORDER_WIDTH, BOTTOM, BOX_SIZING, BREAK_AFTER, BREAK_BEFORE, BREAK_INSIDE, CAPTION_SIDE, CLEAR, CLIP, COLOR, COLUMNS, COLUMN_COUNT, COLUMN_FILL, COLUMN_GAP, COLUMN_RULE, COLUMN_RULE_COLOR, @@ -79,7 +79,7 @@ enum { TABLE_CELL, TABLE_CAPTION, BELOW, LEVEL, ABOVE, HIGHER, LOWER, SHOW, HIDE, XX_SMALL, X_SMALL, SMALL, LARGE, X_LARGE, XX_LARGE, LARGER, SMALLER, NORMAL, ITALIC, OBLIQUE, SMALL_CAPS, BOLD, BOLDER, - LIGHTER, INSIDE, OUTSIDE, DISC, CIRCLE, SQUARE, DECIMAL, + LIGHTER, INSIDE, OUTSIDE, DISC, CIRCLE, SQUARE, DECIMAL, DECIMAL_LEADING_ZERO, LOWER_ROMAN, UPPER_ROMAN, LOWER_GREEK, LOWER_LATIN, UPPER_LATIN, ARMENIAN, GEORGIAN, LOWER_ALPHA, UPPER_ALPHA, INVERT, VISIBLE, ALWAYS, AVOID, X_LOW, LOW, HIGH, X_HIGH, LIBCSS_STATIC, @@ -88,12 +88,12 @@ enum { UPPERCASE, LOWERCASE, EMBED, BIDI_OVERRIDE, BASELINE, SUB, SUPER, TEXT_TOP, MIDDLE, TEXT_BOTTOM, SILENT, X_SOFT, SOFT, LOUD, X_LOUD, PRE, NOWRAP, PRE_WRAP, PRE_LINE, LEFTWARDS, RIGHTWARDS, LEFT_SIDE, - FAR_LEFT, CENTER_LEFT, CENTER_RIGHT, FAR_RIGHT, RIGHT_SIDE, BEHIND, - RECT, OPEN_QUOTE, CLOSE_QUOTE, NO_OPEN_QUOTE, NO_CLOSE_QUOTE, ATTR, - COUNTER, COUNTERS, CROSSHAIR, DEFAULT, POINTER, MOVE, E_RESIZE, - NE_RESIZE, NW_RESIZE, N_RESIZE, SE_RESIZE, SW_RESIZE, S_RESIZE, + FAR_LEFT, CENTER_LEFT, CENTER_RIGHT, FAR_RIGHT, RIGHT_SIDE, BEHIND, + RECT, OPEN_QUOTE, CLOSE_QUOTE, NO_OPEN_QUOTE, NO_CLOSE_QUOTE, ATTR, + COUNTER, COUNTERS, CROSSHAIR, DEFAULT, POINTER, MOVE, E_RESIZE, + NE_RESIZE, NW_RESIZE, N_RESIZE, SE_RESIZE, SW_RESIZE, S_RESIZE, W_RESIZE, LIBCSS_TEXT, WAIT, HELP, PROGRESS, SERIF, SANS_SERIF, CURSIVE, - FANTASY, MONOSPACE, MALE, FEMALE, CHILD, MIX, UNDERLINE, OVERLINE, + FANTASY, MONOSPACE, MALE, FEMALE, CHILD, MIX, UNDERLINE, OVERLINE, LINE_THROUGH, BLINK, RGB, RGBA, HSL, HSLA, LIBCSS_LEFT, LIBCSS_CENTER, LIBCSS_RIGHT, CURRENTCOLOR, ODD, EVEN, SRC, LOCAL, INITIAL, FORMAT, WOFF, TRUETYPE, OPENTYPE, EMBEDDED_OPENTYPE, SVG, COLUMN, @@ -111,14 +111,14 @@ enum { DARKORCHID, DARKRED, DARKSALMON, DARKSEAGREEN, DARKSLATEBLUE, DARKSLATEGRAY, DARKSLATEGREY, DARKTURQUOISE, DARKVIOLET, DEEPPINK, DEEPSKYBLUE, DIMGRAY, DIMGREY, DODGERBLUE, FELDSPAR, FIREBRICK, - FLORALWHITE, FORESTGREEN, FUCHSIA, GAINSBORO, GHOSTWHITE, GOLD, + FLORALWHITE, FORESTGREEN, FUCHSIA, GAINSBORO, GHOSTWHITE, GOLD, GOLDENROD, GRAY, GREEN, GREENYELLOW, GREY, HONEYDEW, HOTPINK, INDIANRED, INDIGO, IVORY, KHAKI, LAVENDER, LAVENDERBLUSH, LAWNGREEN, LEMONCHIFFON, LIGHTBLUE, LIGHTCORAL, LIGHTCYAN, LIGHTGOLDENRODYELLOW, LIGHTGRAY, LIGHTGREEN, LIGHTGREY, LIGHTPINK, LIGHTSALMON, LIGHTSEAGREEN, - LIGHTSKYBLUE, LIGHTSLATEBLUE, LIGHTSLATEGRAY, LIGHTSLATEGREY, + LIGHTSKYBLUE, LIGHTSLATEBLUE, LIGHTSLATEGRAY, LIGHTSLATEGREY, LIGHTSTEELBLUE, LIGHTYELLOW, LIME, LIMEGREEN, LINEN, MAGENTA, MAROON, - MEDIUMAQUAMARINE, MEDIUMBLUE, MEDIUMORCHID, MEDIUMPURPLE, + MEDIUMAQUAMARINE, MEDIUMBLUE, MEDIUMORCHID, MEDIUMPURPLE, MEDIUMSEAGREEN, MEDIUMSLATEBLUE, MEDIUMSPRINGGREEN, MEDIUMTURQUOISE, MEDIUMVIOLETRED, MIDNIGHTBLUE, MINTCREAM, MISTYROSE, MOCCASIN, NAVAJOWHITE, NAVY, OLDLACE, OLIVE, OLIVEDRAB, ORANGE, ORANGERED, @@ -126,7 +126,7 @@ enum { PAPAYAWHIP, PEACHPUFF, PERU, PINK, PLUM, POWDERBLUE, PURPLE, RED, ROSYBROWN, ROYALBLUE, SADDLEBROWN, SALMON, SANDYBROWN, SEAGREEN, SEASHELL, SIENNA, SILVER, SKYBLUE, SLATEBLUE, SLATEGRAY, SLATEGREY, - SNOW, SPRINGGREEN, STEELBLUE, TAN, TEAL, THISTLE, TOMATO, TURQUOISE, + SNOW, SPRINGGREEN, STEELBLUE, TAN, TEAL, THISTLE, TOMATO, TURQUOISE, VIOLET, VIOLETRED, WHEAT, WHITE, WHITESMOKE, YELLOW, YELLOWGREEN, LAST_COLOUR = YELLOWGREEN, diff --git a/src/select/computed.c b/src/select/computed.c index 23f7ea4..03e7c15 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -25,7 +25,7 @@ static css_error compute_absolute_border_width(css_computed_style *style, const css_hint_length *ex_size); static css_error compute_absolute_border_side_width(css_computed_style *style, const css_hint_length *ex_size, - uint8_t (*get)(const css_computed_style *style, + uint8_t (*get)(const css_computed_style *style, css_fixed *len, css_unit *unit), css_error (*set)(css_computed_style *style, uint8_t type, css_fixed len, css_unit unit)); @@ -43,13 +43,13 @@ static css_error compute_absolute_vertical_align(css_computed_style *style, const css_hint_length *ex_size); static css_error compute_absolute_length(css_computed_style *style, const css_hint_length *ex_size, - uint8_t (*get)(const css_computed_style *style, + uint8_t (*get)(const css_computed_style *style, css_fixed *len, css_unit *unit), css_error (*set)(css_computed_style *style, uint8_t type, css_fixed len, css_unit unit)); static css_error compute_absolute_length_pair(css_computed_style *style, const css_hint_length *ex_size, - uint8_t (*get)(const css_computed_style *style, + uint8_t (*get)(const css_computed_style *style, css_fixed *len1, css_unit *unit1, css_fixed *len2, css_unit *unit2), css_error (*set)(css_computed_style *style, uint8_t type, @@ -534,7 +534,7 @@ uint8_t css_computed_right(const css_computed_style *style, *length = -style->i.left; *unit = (css_unit) (left >> 2); } else { - /** \todo Consider containing block's direction + /** \todo Consider containing block's direction * if overconstrained */ } @@ -598,7 +598,7 @@ uint8_t css_computed_left(const css_computed_style *style, *length = -style->i.right; *unit = (css_unit) (right >> 2); } else { - /** \todo Consider containing block's direction + /** \todo Consider containing block's direction * if overconstrained */ } @@ -921,7 +921,7 @@ uint8_t css_computed_display(const css_computed_style *style, if (display == CSS_DISPLAY_NONE) return display; /* 1. */ - if ((position == CSS_POSITION_ABSOLUTE || + if ((position == CSS_POSITION_ABSOLUTE || position == CSS_POSITION_FIXED) /* 2. */ || css_computed_float(style) != CSS_FLOAT_NONE /* 3. */ || root /* 4. */) { @@ -1031,12 +1031,12 @@ uint8_t css_computed_page_break_after(const css_computed_style *style) { return get_page_break_after(style); } - + uint8_t css_computed_page_break_before(const css_computed_style *style) { return get_page_break_before(style); } - + uint8_t css_computed_page_break_inside(const css_computed_style *style) { return get_page_break_inside(style); @@ -1070,7 +1070,7 @@ uint8_t css_computed_widows(const css_computed_style *style, */ css_error css__compute_absolute_values(const css_computed_style *parent, css_computed_style *style, - css_error (*compute_font_size)(void *pw, + css_error (*compute_font_size)(void *pw, const css_hint *parent, css_hint *size), void *pw) { @@ -1079,13 +1079,13 @@ css_error css__compute_absolute_values(const css_computed_style *parent, /* Ensure font-size is absolute */ if (parent != NULL) { - psize.status = get_font_size(parent, - &psize.data.length.value, + psize.status = get_font_size(parent, + &psize.data.length.value, &psize.data.length.unit); } - size.status = get_font_size(style, - &size.data.length.value, + size.status = get_font_size(style, + &size.data.length.value, &size.data.length.unit); error = compute_font_size(pw, parent != NULL ? &psize : NULL, &size); @@ -1093,7 +1093,7 @@ css_error css__compute_absolute_values(const css_computed_style *parent, return error; error = set_font_size(style, size.status, - size.data.length.value, + size.data.length.value, size.data.length.unit); if (error != CSS_OK) return error; @@ -1108,14 +1108,14 @@ css_error css__compute_absolute_values(const css_computed_style *parent, /* Convert ex size into ems */ if (size.data.length.value != 0) - ex_size.data.length.value = FDIV(ex_size.data.length.value, + ex_size.data.length.value = FDIV(ex_size.data.length.value, size.data.length.value); else ex_size.data.length.value = 0; ex_size.data.length.unit = CSS_UNIT_EM; /* Fix up background-position */ - error = compute_absolute_length_pair(style, &ex_size.data.length, + error = compute_absolute_length_pair(style, &ex_size.data.length, get_background_position, set_background_position); if (error != CSS_OK) @@ -1223,7 +1223,7 @@ css_error css__compute_absolute_values(const css_computed_style *parent, /* Fix up letter-spacing */ error = compute_absolute_length(style, &ex_size.data.length, - get_letter_spacing, + get_letter_spacing, set_letter_spacing); if (error != CSS_OK) return error; @@ -1236,9 +1236,9 @@ css_error css__compute_absolute_values(const css_computed_style *parent, return error; /* Fix up outline-width */ - error = compute_absolute_border_side_width(style, - &ex_size.data.length, - get_outline_width, + error = compute_absolute_border_side_width(style, + &ex_size.data.length, + get_outline_width, set_outline_width); if (error != CSS_OK) return error; @@ -1246,7 +1246,7 @@ css_error css__compute_absolute_values(const css_computed_style *parent, /* Fix up word-spacing */ error = compute_absolute_length(style, &ex_size.data.length, - get_word_spacing, + get_word_spacing, set_word_spacing); if (error != CSS_OK) return error; @@ -1313,7 +1313,7 @@ css_error compute_absolute_color(css_computed_style *style, } /** - * Compute border colours, replacing any set to currentColor with + * Compute border colours, replacing any set to currentColor with * the computed value of color. * * \param style The style to process @@ -1327,28 +1327,28 @@ css_error compute_border_colors(css_computed_style *style) css_computed_color(style, &color); if (get_border_top_color(style, &bcol) == CSS_BORDER_COLOR_CURRENT_COLOR) { - error = set_border_top_color(style, + error = set_border_top_color(style, CSS_BORDER_COLOR_COLOR, color); if (error != CSS_OK) return error; } if (get_border_right_color(style, &bcol) == CSS_BORDER_COLOR_CURRENT_COLOR) { - error = set_border_right_color(style, + error = set_border_right_color(style, CSS_BORDER_COLOR_COLOR, color); if (error != CSS_OK) return error; } if (get_border_bottom_color(style, &bcol) == CSS_BORDER_COLOR_CURRENT_COLOR) { - error = set_border_bottom_color(style, + error = set_border_bottom_color(style, CSS_BORDER_COLOR_COLOR, color); if (error != CSS_OK) return error; } if (get_border_left_color(style, &bcol) == CSS_BORDER_COLOR_CURRENT_COLOR) { - error = set_border_left_color(style, + error = set_border_left_color(style, CSS_BORDER_COLOR_COLOR, color); if (error != CSS_OK) return error; @@ -1370,25 +1370,25 @@ css_error compute_absolute_border_width(css_computed_style *style, css_error error; error = compute_absolute_border_side_width(style, ex_size, - get_border_top_width, + get_border_top_width, set_border_top_width); if (error != CSS_OK) return error; error = compute_absolute_border_side_width(style, ex_size, - get_border_right_width, + get_border_right_width, set_border_right_width); if (error != CSS_OK) return error; error = compute_absolute_border_side_width(style, ex_size, - get_border_bottom_width, + get_border_bottom_width, set_border_bottom_width); if (error != CSS_OK) return error; error = compute_absolute_border_side_width(style, ex_size, - get_border_left_width, + get_border_left_width, set_border_left_width); if (error != CSS_OK) return error; @@ -1407,7 +1407,7 @@ css_error compute_absolute_border_width(css_computed_style *style, */ css_error compute_absolute_border_side_width(css_computed_style *style, const css_hint_length *ex_size, - uint8_t (*get)(const css_computed_style *style, + uint8_t (*get)(const css_computed_style *style, css_fixed *len, css_unit *unit), css_error (*set)(css_computed_style *style, uint8_t type, css_fixed len, css_unit unit)) @@ -1588,7 +1588,7 @@ css_error compute_absolute_margins(css_computed_style *style, get_margin_left, set_margin_left); if (error != CSS_OK) return error; - + return CSS_OK; } @@ -1623,7 +1623,7 @@ css_error compute_absolute_padding(css_computed_style *style, get_padding_left, set_padding_left); if (error != CSS_OK) return error; - + return CSS_OK; } @@ -1669,7 +1669,7 @@ css_error compute_absolute_vertical_align(css_computed_style *style, */ css_error compute_absolute_length(css_computed_style *style, const css_hint_length *ex_size, - uint8_t (*get)(const css_computed_style *style, + uint8_t (*get)(const css_computed_style *style, css_fixed *len, css_unit *unit), css_error (*set)(css_computed_style *style, uint8_t type, css_fixed len, css_unit unit)) @@ -1702,7 +1702,7 @@ css_error compute_absolute_length(css_computed_style *style, */ css_error compute_absolute_length_pair(css_computed_style *style, const css_hint_length *ex_size, - uint8_t (*get)(const css_computed_style *style, + uint8_t (*get)(const css_computed_style *style, css_fixed *len1, css_unit *unit1, css_fixed *len2, css_unit *unit2), css_error (*set)(css_computed_style *style, uint8_t type, diff --git a/src/select/computed.h b/src/select/computed.h index d2301f5..9f2abdd 100644 --- a/src/select/computed.h +++ b/src/select/computed.h @@ -124,11 +124,11 @@ typedef struct css_computed_page { * 2 ......wo widows | orphans */ uint8_t bits[2]; - + int32_t widows; int32_t orphans; } css_computed_page; - + struct css_computed_style_i { /* * background_attachment 2 @@ -205,7 +205,7 @@ struct css_computed_style_i { * --- --- * 181 bits 140 + 2sizeof(ptr) bytes * - * Encode font family as an array of string objects, terminated with a + * Encode font family as an array of string objects, terminated with a * blank entry. * * font_family 3 sizeof(ptr) @@ -357,7 +357,7 @@ css_error css__computed_uncommon_destroy(css_computed_uncommon *uncommon); css_error css__compute_absolute_values(const css_computed_style *parent, css_computed_style *style, - css_error (*compute_font_size)(void *pw, + css_error (*compute_font_size)(void *pw, const css_hint *parent, css_hint *size), void *pw); diff --git a/src/select/dispatch.h b/src/select/dispatch.h index 2fcb739..c1db7d9 100644 --- a/src/select/dispatch.h +++ b/src/select/dispatch.h @@ -28,9 +28,9 @@ enum prop_group { }; extern struct prop_table { - css_error (*cascade)(uint32_t opv, css_style *style, + css_error (*cascade)(uint32_t opv, css_style *style, css_select_state *state); - css_error (*set_from_hint)(const css_hint *hint, + css_error (*set_from_hint)(const css_hint *hint, css_computed_style *style); css_error (*initial)(css_select_state *state); css_error (*compose)(const css_computed_style *parent, diff --git a/src/select/font_face.c b/src/select/font_face.c index ea790eb..07e4ef9 100644 --- a/src/select/font_face.c +++ b/src/select/font_face.c @@ -20,7 +20,7 @@ static void font_faces_srcs_destroy(css_font_face *font_face) lwc_string_unref(srcs[i].location); } } - + free(srcs); font_face->srcs = NULL; } @@ -43,18 +43,18 @@ static const css_font_face default_font_face = { css_error css__font_face_create(css_font_face **result) { css_font_face *f; - + if (result == NULL) return CSS_BADPARM; - + f = malloc(sizeof(css_font_face)); if (f == NULL) return CSS_NOMEM; - + memcpy(f, &default_font_face, sizeof(css_font_face)); - + *result = f; - + return CSS_OK; } @@ -65,18 +65,18 @@ css_error css__font_face_create(css_font_face **result) * \return CSS_OK on success, appropriate error otherwise */ css_error css__font_face_destroy(css_font_face *font_face) -{ +{ if (font_face == NULL) return CSS_BADPARM; if (font_face->font_family != NULL) lwc_string_unref(font_face->font_family); - + if (font_face->srcs != NULL) font_faces_srcs_destroy(font_face); free(font_face); - + return CSS_OK; } @@ -95,10 +95,10 @@ css_error css__font_face_set_font_family(css_font_face *font_face, { if (font_face == NULL || font_family == NULL) return CSS_BADPARM; - + if (font_face->font_family != NULL) lwc_string_unref(font_face->font_family); - + font_face->font_family = lwc_string_ref(font_family); return CSS_OK; @@ -117,9 +117,9 @@ css_error css_font_face_get_font_family(const css_font_face *font_face, { if (font_face == NULL || font_family == NULL) return CSS_BADPARM; - + *font_family = font_face->font_family; - + return CSS_OK; } @@ -153,7 +153,7 @@ uint8_t css_font_face_font_weight(const css_font_face *font_face) * \return CSS_OK on success, * CSS_BADPARM on bad parameters. */ -css_error css_font_face_count_srcs(const css_font_face *font_face, +css_error css_font_face_count_srcs(const css_font_face *font_face, uint32_t *count) { if (font_face == NULL || count == NULL) @@ -179,7 +179,7 @@ css_error css_font_face_get_src(const css_font_face *font_face, return CSS_BADPARM; *src = &(font_face->srcs[index]); - + return CSS_OK; } @@ -191,19 +191,19 @@ css_error css_font_face_get_src(const css_font_face *font_face, * \return CSS_OK on success, * CSS_BADPARM on bad parameters. * - * \note The type of location (local or URL) can be gathered from + * \note The type of location (local or URL) can be gathered from * css_font_face_src_location_type, and the format of font (if specified) * from css_font_face_src_format. */ css_error css_font_face_src_get_location(const css_font_face_src *src, lwc_string **location) { - if (src == NULL || location == NULL) + if (src == NULL || location == NULL) return CSS_BADPARM; - + *location = src->location; - return CSS_OK; + return CSS_OK; } /** @@ -232,9 +232,9 @@ css_font_face_format css_font_face_src_format(const css_font_face_src *src) /** * Set a font-faces array of srcs. * - * \param font_face The font-face + * \param font_face The font-face * \param srcs The array of css_font_face_srcs - * \param n_srcs The count of css_font_face_srcs in the array + * \param n_srcs The count of css_font_face_srcs in the array * \return The format, if specified */ css_error css__font_face_set_srcs(css_font_face *font_face, @@ -242,10 +242,10 @@ css_error css__font_face_set_srcs(css_font_face *font_face, { if (font_face->srcs != NULL) font_faces_srcs_destroy(font_face); - + font_face->srcs = srcs; font_face->n_srcs = n_srcs; - + return CSS_OK; } diff --git a/src/select/font_face.h b/src/select/font_face.h index 4e6d094..5f46433 100644 --- a/src/select/font_face.h +++ b/src/select/font_face.h @@ -27,7 +27,7 @@ struct css_font_face { lwc_string *font_family; css_font_face_src *srcs; uint32_t n_srcs; - + /* * Bit allocations: * diff --git a/src/select/hash.c b/src/select/hash.c index 4807e0f..dce4065 100644 --- a/src/select/hash.c +++ b/src/select/hash.c @@ -43,7 +43,7 @@ static hash_entry empty_slot; static inline lwc_string *_class_name(const css_selector *selector); static inline lwc_string *_id_name(const css_selector *selector); -static css_error _insert_into_chain(css_selector_hash *ctx, hash_entry *head, +static css_error _insert_into_chain(css_selector_hash *ctx, hash_entry *head, const css_selector *selector); static css_error _remove_from_chain(css_selector_hash *ctx, hash_entry *head, const css_selector *selector); @@ -183,7 +183,7 @@ css_error css__selector_hash_create(css_selector_hash **hash) /* Universal chain head already initiliased by calloc of `h`. */ - h->hash_size = sizeof(css_selector_hash) + + h->hash_size = sizeof(css_selector_hash) + DEFAULT_SLOTS * sizeof(hash_entry) + DEFAULT_SLOTS * sizeof(hash_entry) + DEFAULT_SLOTS * sizeof(hash_entry); @@ -810,7 +810,7 @@ static void print_chain_bloom_details(css_bloom bloom[CSS_BLOOM_SIZE]) * \return CSS_OK on success, * CSS_NOMEM on memory exhaustion. */ -css_error _insert_into_chain(css_selector_hash *ctx, hash_entry *head, +css_error _insert_into_chain(css_selector_hash *ctx, hash_entry *head, const css_selector *selector) { if (head->sel == NULL) { @@ -836,7 +836,7 @@ css_error _insert_into_chain(css_selector_hash *ctx, hash_entry *head, /* Sort by ascending rule index */ if (search->sel->specificity == selector->specificity && - search->sel->rule->index > + search->sel->rule->index > selector->rule->index) break; diff --git a/src/select/properties/azimuth.c b/src/select/properties/azimuth.c index 275ae2f..d52110f 100644 --- a/src/select/properties/azimuth.c +++ b/src/select/properties/azimuth.c @@ -46,7 +46,7 @@ css_error css__cascade_azimuth(uint32_t opv, css_style *style, unit = css__to_css_unit(unit); - if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, + if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, isInherit(opv))) { /** \todo set computed azimuth */ } @@ -54,7 +54,7 @@ css_error css__cascade_azimuth(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_azimuth_from_hint(const css_hint *hint, +css_error css__set_azimuth_from_hint(const css_hint *hint, css_computed_style *style) { UNUSED(hint); diff --git a/src/select/properties/background_attachment.c b/src/select/properties/background_attachment.c index 89fd181..834c830 100644 --- a/src/select/properties/background_attachment.c +++ b/src/select/properties/background_attachment.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_background_attachment(uint32_t opv, css_style *style, +css_error css__cascade_background_attachment(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BACKGROUND_ATTACHMENT_INHERIT; @@ -40,7 +40,7 @@ css_error css__cascade_background_attachment(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_background_attachment_from_hint(const css_hint *hint, +css_error css__set_background_attachment_from_hint(const css_hint *hint, css_computed_style *style) { return set_background_attachment(style, hint->status); @@ -48,7 +48,7 @@ css_error css__set_background_attachment_from_hint(const css_hint *hint, css_error css__initial_background_attachment(css_select_state *state) { - return set_background_attachment(state->computed, + return set_background_attachment(state->computed, CSS_BACKGROUND_ATTACHMENT_SCROLL); } diff --git a/src/select/properties/background_color.c b/src/select/properties/background_color.c index 07ba82e..bb90604 100644 --- a/src/select/properties/background_color.c +++ b/src/select/properties/background_color.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_background_color(uint32_t opv, css_style *style, +css_error css__cascade_background_color(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_bg_border_color(opv, style, state, set_background_color); } -css_error css__set_background_color_from_hint(const css_hint *hint, +css_error css__set_background_color_from_hint(const css_hint *hint, css_computed_style *style) { return set_background_color(style, hint->status, hint->data.color); @@ -28,7 +28,7 @@ css_error css__set_background_color_from_hint(const css_hint *hint, css_error css__initial_background_color(css_select_state *state) { - return set_background_color(state->computed, + return set_background_color(state->computed, CSS_BACKGROUND_COLOR_COLOR, 0); } diff --git a/src/select/properties/background_image.c b/src/select/properties/background_image.c index e371a15..96f7409 100644 --- a/src/select/properties/background_image.c +++ b/src/select/properties/background_image.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_background_image(uint32_t opv, css_style *style, +css_error css__cascade_background_image(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_uri_none(opv, style, state, set_background_image); } -css_error css__set_background_image_from_hint(const css_hint *hint, +css_error css__set_background_image_from_hint(const css_hint *hint, css_computed_style *style) { css_error error; @@ -35,7 +35,7 @@ css_error css__set_background_image_from_hint(const css_hint *hint, css_error css__initial_background_image(css_select_state *state) { - return set_background_image(state->computed, + return set_background_image(state->computed, CSS_BACKGROUND_IMAGE_NONE, NULL); } diff --git a/src/select/properties/background_position.c b/src/select/properties/background_position.c index e7b5d6f..d925b9c 100644 --- a/src/select/properties/background_position.c +++ b/src/select/properties/background_position.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_background_position(uint32_t opv, css_style *style, +css_error css__cascade_background_position(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BACKGROUND_POSITION_INHERIT; @@ -81,18 +81,18 @@ css_error css__cascade_background_position(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_background_position_from_hint(const css_hint *hint, +css_error css__set_background_position_from_hint(const css_hint *hint, css_computed_style *style) { - return set_background_position(style, hint->status, + return set_background_position(style, hint->status, hint->data.position.h.value, hint->data.position.h.unit, hint->data.position.v.value, hint->data.position.v.unit); } css_error css__initial_background_position(css_select_state *state) { - return set_background_position(state->computed, - CSS_BACKGROUND_POSITION_SET, + return set_background_position(state->computed, + CSS_BACKGROUND_POSITION_SET, 0, CSS_UNIT_PCT, 0, CSS_UNIT_PCT); } @@ -102,7 +102,7 @@ css_error css__compose_background_position(const css_computed_style *parent, { css_fixed hlength = 0, vlength = 0; css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX; - uint8_t type = get_background_position(child, &hlength, &hunit, + uint8_t type = get_background_position(child, &hlength, &hunit, &vlength, &vunit); if (type == CSS_BACKGROUND_POSITION_INHERIT) { diff --git a/src/select/properties/background_repeat.c b/src/select/properties/background_repeat.c index e31275f..3881573 100644 --- a/src/select/properties/background_repeat.c +++ b/src/select/properties/background_repeat.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_background_repeat(uint32_t opv, css_style *style, +css_error css__cascade_background_repeat(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BACKGROUND_REPEAT_INHERIT; @@ -46,7 +46,7 @@ css_error css__cascade_background_repeat(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_background_repeat_from_hint(const css_hint *hint, +css_error css__set_background_repeat_from_hint(const css_hint *hint, css_computed_style *style) { return set_background_repeat(style, hint->status); @@ -54,7 +54,7 @@ css_error css__set_background_repeat_from_hint(const css_hint *hint, css_error css__initial_background_repeat(css_select_state *state) { - return set_background_repeat(state->computed, + return set_background_repeat(state->computed, CSS_BACKGROUND_REPEAT_REPEAT); } diff --git a/src/select/properties/border_bottom_color.c b/src/select/properties/border_bottom_color.c index 2e63982..bdbecb7 100644 --- a/src/select/properties/border_bottom_color.c +++ b/src/select/properties/border_bottom_color.c @@ -14,14 +14,14 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_bottom_color(uint32_t opv, css_style *style, +css_error css__cascade_border_bottom_color(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_bg_border_color(opv, style, state, set_border_bottom_color); } -css_error css__set_border_bottom_color_from_hint(const css_hint *hint, +css_error css__set_border_bottom_color_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_bottom_color(style, hint->status, hint->data.color); @@ -29,7 +29,7 @@ css_error css__set_border_bottom_color_from_hint(const css_hint *hint, css_error css__initial_border_bottom_color(css_select_state *state) { - return set_border_bottom_color(state->computed, + return set_border_bottom_color(state->computed, CSS_BORDER_COLOR_CURRENT_COLOR, 0); } diff --git a/src/select/properties/border_bottom_style.c b/src/select/properties/border_bottom_style.c index 2a6cd6a..b5caccb 100644 --- a/src/select/properties/border_bottom_style.c +++ b/src/select/properties/border_bottom_style.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_bottom_style(uint32_t opv, css_style *style, +css_error css__cascade_border_bottom_style(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_style(opv, style, state, set_border_bottom_style); } -css_error css__set_border_bottom_style_from_hint(const css_hint *hint, +css_error css__set_border_bottom_style_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_bottom_style(style, hint->status); diff --git a/src/select/properties/border_bottom_width.c b/src/select/properties/border_bottom_width.c index fdf0824..b071fba 100644 --- a/src/select/properties/border_bottom_width.c +++ b/src/select/properties/border_bottom_width.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_bottom_width(uint32_t opv, css_style *style, +css_error css__cascade_border_bottom_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_width(opv, style, state, set_border_bottom_width); } -css_error css__set_border_bottom_width_from_hint(const css_hint *hint, +css_error css__set_border_bottom_width_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_bottom_width(style, hint->status, diff --git a/src/select/properties/border_collapse.c b/src/select/properties/border_collapse.c index 5da1a00..1363c7c 100644 --- a/src/select/properties/border_collapse.c +++ b/src/select/properties/border_collapse.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_collapse(uint32_t opv, css_style *style, +css_error css__cascade_border_collapse(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BORDER_COLLAPSE_INHERIT; @@ -40,7 +40,7 @@ css_error css__cascade_border_collapse(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_border_collapse_from_hint(const css_hint *hint, +css_error css__set_border_collapse_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_collapse(style, hint->status); @@ -60,7 +60,7 @@ css_error css__compose_border_collapse(const css_computed_style *parent, if (type == CSS_BORDER_COLLAPSE_INHERIT) { type = get_border_collapse(parent); } - + return set_border_collapse(result, type); } diff --git a/src/select/properties/border_left_color.c b/src/select/properties/border_left_color.c index cf08257..2880751 100644 --- a/src/select/properties/border_left_color.c +++ b/src/select/properties/border_left_color.c @@ -14,14 +14,14 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_left_color(uint32_t opv, css_style *style, +css_error css__cascade_border_left_color(uint32_t opv, css_style *style, css_select_state *state) { - return css__cascade_bg_border_color(opv, style, state, + return css__cascade_bg_border_color(opv, style, state, set_border_left_color); } -css_error css__set_border_left_color_from_hint(const css_hint *hint, +css_error css__set_border_left_color_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_left_color(style, hint->status, hint->data.color); @@ -29,7 +29,7 @@ css_error css__set_border_left_color_from_hint(const css_hint *hint, css_error css__initial_border_left_color(css_select_state *state) { - return set_border_left_color(state->computed, + return set_border_left_color(state->computed, CSS_BORDER_COLOR_CURRENT_COLOR, 0); } diff --git a/src/select/properties/border_left_style.c b/src/select/properties/border_left_style.c index 89708f7..e6472b3 100644 --- a/src/select/properties/border_left_style.c +++ b/src/select/properties/border_left_style.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_left_style(uint32_t opv, css_style *style, +css_error css__cascade_border_left_style(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_style(opv, style, state, set_border_left_style); } -css_error css__set_border_left_style_from_hint(const css_hint *hint, +css_error css__set_border_left_style_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_left_style(style, hint->status); diff --git a/src/select/properties/border_left_width.c b/src/select/properties/border_left_width.c index a4633da..1278fa9 100644 --- a/src/select/properties/border_left_width.c +++ b/src/select/properties/border_left_width.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_left_width(uint32_t opv, css_style *style, +css_error css__cascade_border_left_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_width(opv, style, state, set_border_left_width); } -css_error css__set_border_left_width_from_hint(const css_hint *hint, +css_error css__set_border_left_width_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_left_width(style, hint->status, diff --git a/src/select/properties/border_right_color.c b/src/select/properties/border_right_color.c index 1829784..b8563e6 100644 --- a/src/select/properties/border_right_color.c +++ b/src/select/properties/border_right_color.c @@ -14,14 +14,14 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_right_color(uint32_t opv, css_style *style, +css_error css__cascade_border_right_color(uint32_t opv, css_style *style, css_select_state *state) { - return css__cascade_bg_border_color(opv, style, state, + return css__cascade_bg_border_color(opv, style, state, set_border_right_color); } -css_error css__set_border_right_color_from_hint(const css_hint *hint, +css_error css__set_border_right_color_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_right_color(style, hint->status, hint->data.color); @@ -29,7 +29,7 @@ css_error css__set_border_right_color_from_hint(const css_hint *hint, css_error css__initial_border_right_color(css_select_state *state) { - return set_border_right_color(state->computed, + return set_border_right_color(state->computed, CSS_BORDER_COLOR_CURRENT_COLOR, 0); } diff --git a/src/select/properties/border_right_style.c b/src/select/properties/border_right_style.c index 3f5934b..d75a99e 100644 --- a/src/select/properties/border_right_style.c +++ b/src/select/properties/border_right_style.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_right_style(uint32_t opv, css_style *style, +css_error css__cascade_border_right_style(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_style(opv, style, state, set_border_right_style); } -css_error css__set_border_right_style_from_hint(const css_hint *hint, +css_error css__set_border_right_style_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_right_style(style, hint->status); diff --git a/src/select/properties/border_right_width.c b/src/select/properties/border_right_width.c index 269fefe..18cacd2 100644 --- a/src/select/properties/border_right_width.c +++ b/src/select/properties/border_right_width.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_right_width(uint32_t opv, css_style *style, +css_error css__cascade_border_right_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_width(opv, style, state, set_border_right_width); } -css_error css__set_border_right_width_from_hint(const css_hint *hint, +css_error css__set_border_right_width_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_right_width(style, hint->status, diff --git a/src/select/properties/border_spacing.c b/src/select/properties/border_spacing.c index db7b1f2..147f56f 100644 --- a/src/select/properties/border_spacing.c +++ b/src/select/properties/border_spacing.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_spacing(uint32_t opv, css_style *style, +css_error css__cascade_border_spacing(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BORDER_SPACING_INHERIT; @@ -48,7 +48,7 @@ css_error css__cascade_border_spacing(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_border_spacing_from_hint(const css_hint *hint, +css_error css__set_border_spacing_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_spacing(style, hint->status, @@ -68,7 +68,7 @@ css_error css__compose_border_spacing(const css_computed_style *parent, { css_fixed hlength = 0, vlength = 0; css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX; - uint8_t type = get_border_spacing(child, &hlength, &hunit, + uint8_t type = get_border_spacing(child, &hlength, &hunit, &vlength, &vunit); if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || @@ -76,11 +76,11 @@ css_error css__compose_border_spacing(const css_computed_style *parent, (child->i.uncommon != NULL && result != child)) { if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || type == CSS_BORDER_SPACING_INHERIT) { - type = get_border_spacing(parent, + type = get_border_spacing(parent, &hlength, &hunit, &vlength, &vunit); } - return set_border_spacing(result, type, hlength, hunit, + return set_border_spacing(result, type, hlength, hunit, vlength, vunit); } diff --git a/src/select/properties/border_top_color.c b/src/select/properties/border_top_color.c index 1517eea..fd2ced4 100644 --- a/src/select/properties/border_top_color.c +++ b/src/select/properties/border_top_color.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_top_color(uint32_t opv, css_style *style, +css_error css__cascade_border_top_color(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_bg_border_color(opv, style, state, set_border_top_color); } -css_error css__set_border_top_color_from_hint(const css_hint *hint, +css_error css__set_border_top_color_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_top_color(style, hint->status, hint->data.color); diff --git a/src/select/properties/border_top_style.c b/src/select/properties/border_top_style.c index 9841202..48d6b6d 100644 --- a/src/select/properties/border_top_style.c +++ b/src/select/properties/border_top_style.c @@ -14,13 +14,13 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_top_style(uint32_t opv, css_style *style, +css_error css__cascade_border_top_style(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_style(opv, style, state, set_border_top_style); } -css_error css__set_border_top_style_from_hint(const css_hint *hint, +css_error css__set_border_top_style_from_hint(const css_hint *hint, css_computed_style *style) { return set_border_top_style(style, hint->status); diff --git a/src/select/properties/border_top_width.c b/src/select/properties/border_top_width.c index 237d594..c0fb7da 100644 --- a/src/select/properties/border_top_width.c +++ b/src/select/properties/border_top_width.c @@ -14,22 +14,22 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_border_top_width(uint32_t opv, css_style *style, +css_error css__cascade_border_top_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_width(opv, style, state, set_border_top_width); } -css_error css__set_border_top_width_from_hint(const css_hint *hint, +css_error css__set_border_top_width_from_hint(const css_hint *hint, css_computed_style *style) { - return set_border_top_width(style, hint->status, + return set_border_top_width(style, hint->status, hint->data.length.value, hint->data.length.unit); } css_error css__initial_border_top_width(css_select_state *state) { - return set_border_top_width(state->computed, CSS_BORDER_WIDTH_MEDIUM, + return set_border_top_width(state->computed, CSS_BORDER_WIDTH_MEDIUM, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/bottom.c b/src/select/properties/bottom.c index 7c9b509..82754f1 100644 --- a/src/select/properties/bottom.c +++ b/src/select/properties/bottom.c @@ -14,16 +14,16 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_bottom(uint32_t opv, css_style *style, +css_error css__cascade_bottom(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_bottom); } -css_error css__set_bottom_from_hint(const css_hint *hint, +css_error css__set_bottom_from_hint(const css_hint *hint, css_computed_style *style) { - return set_bottom(style, hint->status, + return set_bottom(style, hint->status, hint->data.length.value, hint->data.length.unit); } diff --git a/src/select/properties/box_sizing.c b/src/select/properties/box_sizing.c index 91c475d..2d19c95 100644 --- a/src/select/properties/box_sizing.c +++ b/src/select/properties/box_sizing.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_box_sizing(uint32_t opv, css_style *style, +css_error css__cascade_box_sizing(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BOX_SIZING_INHERIT; diff --git a/src/select/properties/break_after.c b/src/select/properties/break_after.c index 496a59b..1f253aa 100644 --- a/src/select/properties/break_after.c +++ b/src/select/properties/break_after.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_break_after(uint32_t opv, css_style *style, +css_error css__cascade_break_after(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_break_after_before_inside(opv, style, state, diff --git a/src/select/properties/break_before.c b/src/select/properties/break_before.c index b8a8d77..3dcda76 100644 --- a/src/select/properties/break_before.c +++ b/src/select/properties/break_before.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_break_before(uint32_t opv, css_style *style, +css_error css__cascade_break_before(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_break_after_before_inside(opv, style, state, diff --git a/src/select/properties/break_inside.c b/src/select/properties/break_inside.c index 4252fb8..fdc44c1 100644 --- a/src/select/properties/break_inside.c +++ b/src/select/properties/break_inside.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_break_inside(uint32_t opv, css_style *style, +css_error css__cascade_break_inside(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BREAK_INSIDE_AUTO; diff --git a/src/select/properties/caption_side.c b/src/select/properties/caption_side.c index c097348..ecccc1d 100644 --- a/src/select/properties/caption_side.c +++ b/src/select/properties/caption_side.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_caption_side(uint32_t opv, css_style *style, +css_error css__cascade_caption_side(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CAPTION_SIDE_INHERIT; @@ -40,7 +40,7 @@ css_error css__cascade_caption_side(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_caption_side_from_hint(const css_hint *hint, +css_error css__set_caption_side_from_hint(const css_hint *hint, css_computed_style *style) { return set_caption_side(style, hint->status); @@ -60,7 +60,7 @@ css_error css__compose_caption_side(const css_computed_style *parent, if (type == CSS_CAPTION_SIDE_INHERIT) { type = get_caption_side(parent); } - + return set_caption_side(result, type); } diff --git a/src/select/properties/clear.c b/src/select/properties/clear.c index 55ca087..bbb2673 100644 --- a/src/select/properties/clear.c +++ b/src/select/properties/clear.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_clear(uint32_t opv, css_style *style, +css_error css__cascade_clear(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CLEAR_INHERIT; @@ -46,7 +46,7 @@ css_error css__cascade_clear(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_clear_from_hint(const css_hint *hint, +css_error css__set_clear_from_hint(const css_hint *hint, css_computed_style *style) { return set_clear(style, hint->status); diff --git a/src/select/properties/clip.c b/src/select/properties/clip.c index cc39d99..fe1dd87 100644 --- a/src/select/properties/clip.c +++ b/src/select/properties/clip.c @@ -14,11 +14,11 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_clip(uint32_t opv, css_style *style, +css_error css__cascade_clip(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CLIP_INHERIT; - css_computed_clip_rect rect = { 0, 0, 0, 0, + css_computed_clip_rect rect = { 0, 0, 0, 0, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, false, false, false, false }; @@ -78,7 +78,7 @@ css_error css__cascade_clip(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_clip_from_hint(const css_hint *hint, +css_error css__set_clip_from_hint(const css_hint *hint, css_computed_style *style) { return set_clip(style, hint->status, hint->data.clip); @@ -86,7 +86,7 @@ css_error css__set_clip_from_hint(const css_hint *hint, css_error css__initial_clip(css_select_state *state) { - css_computed_clip_rect rect = { 0, 0, 0, 0, + css_computed_clip_rect rect = { 0, 0, 0, 0, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, false, false, false, false }; @@ -97,7 +97,7 @@ css_error css__compose_clip(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { - css_computed_clip_rect rect = { 0, 0, 0, 0, + css_computed_clip_rect rect = { 0, 0, 0, 0, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, false, false, false, false }; uint8_t type = get_clip(child, &rect); diff --git a/src/select/properties/color.c b/src/select/properties/color.c index dad2b9d..806f2cc 100644 --- a/src/select/properties/color.c +++ b/src/select/properties/color.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_color(uint32_t opv, css_style *style, +css_error css__cascade_color(uint32_t opv, css_style *style, css_select_state *state) { bool inherit = isInherit(opv); @@ -39,7 +39,7 @@ css_error css__cascade_color(uint32_t opv, css_style *style, } } - if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, + if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, inherit)) { return set_color(state->computed, value, color); } @@ -47,7 +47,7 @@ css_error css__cascade_color(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_color_from_hint(const css_hint *hint, +css_error css__set_color_from_hint(const css_hint *hint, css_computed_style *style) { return set_color(style, hint->status, hint->data.color); @@ -58,7 +58,7 @@ css_error css__initial_color(css_select_state *state) css_hint hint; css_error error; - error = state->handler->ua_default_for_property(state->pw, + error = state->handler->ua_default_for_property(state->pw, CSS_PROP_COLOR, &hint); if (error != CSS_OK) return error; diff --git a/src/select/properties/column_count.c b/src/select/properties/column_count.c index 4ded377..7e929b0 100644 --- a/src/select/properties/column_count.c +++ b/src/select/properties/column_count.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_column_count(uint32_t opv, css_style *style, +css_error css__cascade_column_count(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_COLUMN_COUNT_INHERIT; @@ -22,7 +22,7 @@ css_error css__cascade_column_count(uint32_t opv, css_style *style, if (isInherit(opv) == false) { switch (getValue(opv)) { - case COLUMN_COUNT_SET: + case COLUMN_COUNT_SET: value = CSS_COLUMN_COUNT_SET; count = *((css_fixed *) style->bytecode); advance_bytecode(style, sizeof(count)); diff --git a/src/select/properties/column_fill.c b/src/select/properties/column_fill.c index 9b4f1e0..31f19f0 100644 --- a/src/select/properties/column_fill.c +++ b/src/select/properties/column_fill.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_column_fill(uint32_t opv, css_style *style, +css_error css__cascade_column_fill(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_COLUMN_FILL_INHERIT; diff --git a/src/select/properties/column_gap.c b/src/select/properties/column_gap.c index f544f44..824b3a4 100644 --- a/src/select/properties/column_gap.c +++ b/src/select/properties/column_gap.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_column_gap(uint32_t opv, css_style *style, +css_error css__cascade_column_gap(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_normal(opv, style, state, set_column_gap); diff --git a/src/select/properties/column_rule_color.c b/src/select/properties/column_rule_color.c index a5666e4..f54c2ab 100644 --- a/src/select/properties/column_rule_color.c +++ b/src/select/properties/column_rule_color.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_column_rule_color(uint32_t opv, css_style *style, +css_error css__cascade_column_rule_color(uint32_t opv, css_style *style, css_select_state *state) { bool inherit = isInherit(opv); diff --git a/src/select/properties/column_rule_style.c b/src/select/properties/column_rule_style.c index 586ce5d..1d9a41e 100644 --- a/src/select/properties/column_rule_style.c +++ b/src/select/properties/column_rule_style.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_column_rule_style(uint32_t opv, css_style *style, +css_error css__cascade_column_rule_style(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_style(opv, style, state, diff --git a/src/select/properties/column_rule_width.c b/src/select/properties/column_rule_width.c index 8694a09..3ca9367 100644 --- a/src/select/properties/column_rule_width.c +++ b/src/select/properties/column_rule_width.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_column_rule_width(uint32_t opv, css_style *style, +css_error css__cascade_column_rule_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_width(opv, style, state, diff --git a/src/select/properties/content.c b/src/select/properties/content.c index 472a66a..0506ef3 100644 --- a/src/select/properties/content.c +++ b/src/select/properties/content.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_content(uint32_t opv, css_style *style, +css_error css__cascade_content(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CONTENT_INHERIT; @@ -30,14 +30,14 @@ css_error css__cascade_content(uint32_t opv, css_style *style, value = CSS_CONTENT_NONE; } else { value = CSS_CONTENT_SET; - + while (v != CONTENT_NORMAL) { lwc_string *he; css_computed_content_item *temp; css__stylesheet_string_get(style->sheet, *((css_code_t *) style->bytecode), &he); - + temp = realloc(content, (n_contents + 1) * sizeof(css_computed_content_item)); @@ -63,7 +63,7 @@ css_error css__cascade_content(uint32_t opv, css_style *style, case CONTENT_COUNTERS: { lwc_string *sep; - + advance_bytecode(style, sizeof(css_code_t)); css__stylesheet_string_get(style->sheet, *((css_code_t *) style->bytecode), &sep); @@ -155,7 +155,7 @@ css_error css__cascade_content(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_content_from_hint(const css_hint *hint, +css_error css__set_content_from_hint(const css_hint *hint, css_computed_style *style) { css_computed_content_item *item; @@ -221,16 +221,16 @@ css_error css__compose_content(const css_computed_style *parent, if (type == CSS_CONTENT_SET) { const css_computed_content_item *i; - for (i = items; i->type != CSS_COMPUTED_CONTENT_NONE; + for (i = items; i->type != CSS_COMPUTED_CONTENT_NONE; i++) n_items++; - copy = malloc((n_items + 1) * + copy = malloc((n_items + 1) * sizeof(css_computed_content_item)); if (copy == NULL) return CSS_NOMEM; - memcpy(copy, items, (n_items + 1) * + memcpy(copy, items, (n_items + 1) * sizeof(css_computed_content_item)); } diff --git a/src/select/properties/counter_increment.c b/src/select/properties/counter_increment.c index 644607b..9888e0a 100644 --- a/src/select/properties/counter_increment.c +++ b/src/select/properties/counter_increment.c @@ -14,14 +14,14 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_counter_increment(uint32_t opv, css_style *style, +css_error css__cascade_counter_increment(uint32_t opv, css_style *style, css_select_state *state) -{ - return css__cascade_counter_increment_reset(opv, style, state, +{ + return css__cascade_counter_increment_reset(opv, style, state, set_counter_increment); } -css_error css__set_counter_increment_from_hint(const css_hint *hint, +css_error css__set_counter_increment_from_hint(const css_hint *hint, css_computed_style *style) { css_computed_counter *item; @@ -44,7 +44,7 @@ css_error css__set_counter_increment_from_hint(const css_hint *hint, css_error css__initial_counter_increment(css_select_state *state) { - return set_counter_increment(state->computed, + return set_counter_increment(state->computed, CSS_COUNTER_INCREMENT_NONE, NULL); } @@ -57,7 +57,7 @@ css_error css__compose_counter_increment(const css_computed_style *parent, uint8_t type = get_counter_increment(child, &items); if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COUNTER_INCREMENT_INHERIT || + type == CSS_COUNTER_INCREMENT_INHERIT || (child->i.uncommon != NULL && result != child)) { size_t n_items = 0; css_computed_counter *copy = NULL; @@ -73,12 +73,12 @@ css_error css__compose_counter_increment(const css_computed_style *parent, for (i = items; i->name != NULL; i++) n_items++; - copy = malloc((n_items + 1) * + copy = malloc((n_items + 1) * sizeof(css_computed_counter)); if (copy == NULL) return CSS_NOMEM; - memcpy(copy, items, (n_items + 1) * + memcpy(copy, items, (n_items + 1) * sizeof(css_computed_counter)); } diff --git a/src/select/properties/counter_reset.c b/src/select/properties/counter_reset.c index 05559f5..9d20609 100644 --- a/src/select/properties/counter_reset.c +++ b/src/select/properties/counter_reset.c @@ -14,14 +14,14 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_counter_reset(uint32_t opv, css_style *style, +css_error css__cascade_counter_reset(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_counter_increment_reset(opv, style, state, set_counter_reset); } -css_error css__set_counter_reset_from_hint(const css_hint *hint, +css_error css__set_counter_reset_from_hint(const css_hint *hint, css_computed_style *style) { css_computed_counter *item; @@ -72,12 +72,12 @@ css_error css__compose_counter_reset(const css_computed_style *parent, for (i = items; i->name != NULL; i++) n_items++; - copy = malloc((n_items + 1) * + copy = malloc((n_items + 1) * sizeof(css_computed_counter)); if (copy == NULL) return CSS_NOMEM; - memcpy(copy, items, (n_items + 1) * + memcpy(copy, items, (n_items + 1) * sizeof(css_computed_counter)); } diff --git a/src/select/properties/cue_after.c b/src/select/properties/cue_after.c index 86dd4a7..e1c09e8 100644 --- a/src/select/properties/cue_after.c +++ b/src/select/properties/cue_after.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_cue_after(uint32_t opv, css_style *style, +css_error css__cascade_cue_after(uint32_t opv, css_style *style, css_select_state *state) { /** \todo cue-after */ diff --git a/src/select/properties/cue_before.c b/src/select/properties/cue_before.c index cf89475..d562b3b 100644 --- a/src/select/properties/cue_before.c +++ b/src/select/properties/cue_before.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_cue_before(uint32_t opv, css_style *style, +css_error css__cascade_cue_before(uint32_t opv, css_style *style, css_select_state *state) { /** \todo cue-before */ diff --git a/src/select/properties/cursor.c b/src/select/properties/cursor.c index 1ca497f..6effdb5 100644 --- a/src/select/properties/cursor.c +++ b/src/select/properties/cursor.c @@ -14,9 +14,9 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_cursor(uint32_t opv, css_style *style, +css_error css__cascade_cursor(uint32_t opv, css_style *style, css_select_state *state) -{ +{ uint16_t value = CSS_CURSOR_INHERIT; lwc_string **uris = NULL; uint32_t n_uris = 0; @@ -33,7 +33,7 @@ css_error css__cascade_cursor(uint32_t opv, css_style *style, &uri); advance_bytecode(style, sizeof(css_code_t)); - temp = realloc(uris, + temp = realloc(uris, (n_uris + 1) * sizeof(lwc_string *)); if (temp == NULL) { if (uris != NULL) { @@ -111,7 +111,7 @@ css_error css__cascade_cursor(uint32_t opv, css_style *style, if (n_uris > 0) { lwc_string **temp; - temp = realloc(uris, + temp = realloc(uris, (n_uris + 1) * sizeof(lwc_string *)); if (temp == NULL) { free(uris); @@ -148,7 +148,7 @@ css_error css__set_cursor_from_hint(const css_hint *hint, error = set_cursor(style, hint->status, hint->data.strings); - for (item = hint->data.strings; + for (item = hint->data.strings; item != NULL && (*item) != NULL; item++) { lwc_string_unref(*item); } @@ -189,12 +189,12 @@ css_error css__compose_cursor(const css_computed_style *parent, for (i = urls; (*i) != NULL; i++) n_urls++; - copy = malloc((n_urls + 1) * + copy = malloc((n_urls + 1) * sizeof(lwc_string *)); if (copy == NULL) return CSS_NOMEM; - memcpy(copy, urls, (n_urls + 1) * + memcpy(copy, urls, (n_urls + 1) * sizeof(lwc_string *)); } diff --git a/src/select/properties/direction.c b/src/select/properties/direction.c index 1e68123..f4a5c46 100644 --- a/src/select/properties/direction.c +++ b/src/select/properties/direction.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_direction(uint32_t opv, css_style *style, +css_error css__cascade_direction(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_DIRECTION_INHERIT; diff --git a/src/select/properties/display.c b/src/select/properties/display.c index e5e7711..40c2e3e 100644 --- a/src/select/properties/display.c +++ b/src/select/properties/display.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_display(uint32_t opv, css_style *style, +css_error css__cascade_display(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_DISPLAY_INHERIT; diff --git a/src/select/properties/elevation.c b/src/select/properties/elevation.c index d893748..ee7d036 100644 --- a/src/select/properties/elevation.c +++ b/src/select/properties/elevation.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_elevation(uint32_t opv, css_style *style, +css_error css__cascade_elevation(uint32_t opv, css_style *style, css_select_state *state) { css_fixed val = 0; @@ -22,7 +22,7 @@ css_error css__cascade_elevation(uint32_t opv, css_style *style, if (isInherit(opv) == false) { switch (getValue(opv)) { - case ELEVATION_ANGLE: + case ELEVATION_ANGLE: val = *((css_fixed *) style->bytecode); advance_bytecode(style, sizeof(val)); diff --git a/src/select/properties/empty_cells.c b/src/select/properties/empty_cells.c index 5e749c2..fecdbdc 100644 --- a/src/select/properties/empty_cells.c +++ b/src/select/properties/empty_cells.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_empty_cells(uint32_t opv, css_style *style, +css_error css__cascade_empty_cells(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_EMPTY_CELLS_INHERIT; diff --git a/src/select/properties/float.c b/src/select/properties/float.c index 82df983..c3ba909 100644 --- a/src/select/properties/float.c +++ b/src/select/properties/float.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_float(uint32_t opv, css_style *style, +css_error css__cascade_float(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FLOAT_INHERIT; diff --git a/src/select/properties/font_family.c b/src/select/properties/font_family.c index 514a43a..f853fcc 100644 --- a/src/select/properties/font_family.c +++ b/src/select/properties/font_family.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_font_family(uint32_t opv, css_style *style, +css_error css__cascade_font_family(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_FAMILY_INHERIT; @@ -31,8 +31,8 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style, switch (v) { case FONT_FAMILY_STRING: case FONT_FAMILY_IDENT_LIST: - css__stylesheet_string_get(style->sheet, - *((css_code_t *) style->bytecode), + css__stylesheet_string_get(style->sheet, + *((css_code_t *) style->bytecode), &font); advance_bytecode(style, sizeof(css_code_t)); break; @@ -63,7 +63,7 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style, * first generic-family are ignored. */ /** \todo Do this at bytecode generation time? */ if (value == CSS_FONT_FAMILY_INHERIT && font != NULL) { - temp = realloc(fonts, + temp = realloc(fonts, (n_fonts + 1) * sizeof(lwc_string *)); if (temp == NULL) { if (fonts != NULL) { @@ -97,25 +97,25 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style, fonts = temp; fonts[n_fonts] = NULL; - + if (value == CSS_FONT_FAMILY_INHERIT) { /* The stylesheet doesn't specify a generic family, * but it has specified named fonts. * Fall back to the user agent's default family. - * We don't want to inherit, because that will + * We don't want to inherit, because that will * incorrectly overwrite the named fonts list too. */ css_hint hint; css_error error; - + error = state->handler->ua_default_for_property( state->pw, CSS_PROP_FONT_FAMILY, &hint); if (error == CSS_OK) { lwc_string **item; value = hint.status; - - for (item = hint.data.strings; + + for (item = hint.data.strings; item != NULL && (*item) != NULL; item++) { lwc_string_unref(*item); @@ -158,7 +158,7 @@ css_error css__set_font_family_from_hint(const css_hint *hint, error = set_font_family(style, hint->status, hint->data.strings); - for (item = hint->data.strings; + for (item = hint->data.strings; item != NULL && (*item) != NULL; item++) { lwc_string_unref(*item); } @@ -207,7 +207,7 @@ css_error css__compose_font_family(const css_computed_style *parent, if (copy == NULL) return CSS_NOMEM; - memcpy(copy, names, (n_names + 1) * + memcpy(copy, names, (n_names + 1) * sizeof(lwc_string *)); } diff --git a/src/select/properties/font_size.c b/src/select/properties/font_size.c index 65fbb94..a0269be 100644 --- a/src/select/properties/font_size.c +++ b/src/select/properties/font_size.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_font_size(uint32_t opv, css_style *style, +css_error css__cascade_font_size(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_SIZE_INHERIT; @@ -23,7 +23,7 @@ css_error css__cascade_font_size(uint32_t opv, css_style *style, if (isInherit(opv) == false) { switch (getValue(opv)) { - case FONT_SIZE_DIMENSION: + case FONT_SIZE_DIMENSION: value = CSS_FONT_SIZE_DIMENSION; size = *((css_fixed *) style->bytecode); @@ -75,13 +75,13 @@ css_error css__cascade_font_size(uint32_t opv, css_style *style, css_error css__set_font_size_from_hint(const css_hint *hint, css_computed_style *style) { - return set_font_size(style, hint->status, + return set_font_size(style, hint->status, hint->data.length.value, hint->data.length.unit); } css_error css__initial_font_size(css_select_state *state) { - return set_font_size(state->computed, CSS_FONT_SIZE_MEDIUM, + return set_font_size(state->computed, CSS_FONT_SIZE_MEDIUM, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/font_style.c b/src/select/properties/font_style.c index 68846d6..0ba1fdd 100644 --- a/src/select/properties/font_style.c +++ b/src/select/properties/font_style.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_font_style(uint32_t opv, css_style *style, +css_error css__cascade_font_style(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_STYLE_INHERIT; @@ -63,7 +63,7 @@ css_error css__compose_font_style(const css_computed_style *parent, if (type == CSS_FONT_STYLE_INHERIT) { type= get_font_style(parent); } - + return set_font_style(result, type); } diff --git a/src/select/properties/font_variant.c b/src/select/properties/font_variant.c index b6bb2e9..a9b6e56 100644 --- a/src/select/properties/font_variant.c +++ b/src/select/properties/font_variant.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_font_variant(uint32_t opv, css_style *style, +css_error css__cascade_font_variant(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_VARIANT_INHERIT; diff --git a/src/select/properties/font_weight.c b/src/select/properties/font_weight.c index bd67f89..c0c2f2b 100644 --- a/src/select/properties/font_weight.c +++ b/src/select/properties/font_weight.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_font_weight(uint32_t opv, css_style *style, +css_error css__cascade_font_weight(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_WEIGHT_INHERIT; diff --git a/src/select/properties/height.c b/src/select/properties/height.c index 7aeec3f..1d74c4a 100644 --- a/src/select/properties/height.c +++ b/src/select/properties/height.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_height(uint32_t opv, css_style *style, +css_error css__cascade_height(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_height); diff --git a/src/select/properties/helpers.c b/src/select/properties/helpers.c index 1091a10..36c3cba 100644 --- a/src/select/properties/helpers.c +++ b/src/select/properties/helpers.c @@ -46,17 +46,17 @@ css_unit css__to_css_unit(uint32_t u) * Utilities below here * ******************************************************************************/ css_error css__cascade_bg_border_color(uint32_t opv, css_style *style, - css_select_state *state, + css_select_state *state, css_error (*fun)(css_computed_style *, uint8_t, css_color)) { uint16_t value = CSS_BACKGROUND_COLOR_INHERIT; css_color color = 0; - assert(CSS_BACKGROUND_COLOR_INHERIT == + assert(CSS_BACKGROUND_COLOR_INHERIT == (enum css_background_color_e)CSS_BORDER_COLOR_INHERIT); - assert(CSS_BACKGROUND_COLOR_COLOR == + assert(CSS_BACKGROUND_COLOR_COLOR == (enum css_background_color_e)CSS_BORDER_COLOR_COLOR); - assert(CSS_BACKGROUND_COLOR_CURRENT_COLOR == + assert(CSS_BACKGROUND_COLOR_CURRENT_COLOR == (enum css_background_color_e)CSS_BORDER_COLOR_CURRENT_COLOR); if (isInherit(opv) == false) { @@ -85,7 +85,7 @@ css_error css__cascade_bg_border_color(uint32_t opv, css_style *style, css_error css__cascade_uri_none(uint32_t opv, css_style *style, css_select_state *state, - css_error (*fun)(css_computed_style *, uint8_t, + css_error (*fun)(css_computed_style *, uint8_t, lwc_string *)) { uint16_t value = CSS_BACKGROUND_IMAGE_INHERIT; @@ -105,7 +105,7 @@ css_error css__cascade_uri_none(uint32_t opv, css_style *style, } /** \todo lose fun != NULL once all properties have set routines */ - if (fun != NULL && css__outranks_existing(getOpcode(opv), + if (fun != NULL && css__outranks_existing(getOpcode(opv), isImportant(opv), state, isInherit(opv))) { return fun(state->computed, value, uri); } @@ -114,7 +114,7 @@ css_error css__cascade_uri_none(uint32_t opv, css_style *style, } css_error css__cascade_border_style(uint32_t opv, css_style *style, - css_select_state *state, + css_select_state *state, css_error (*fun)(css_computed_style *, uint8_t)) { uint16_t value = CSS_BORDER_STYLE_INHERIT; @@ -165,8 +165,8 @@ css_error css__cascade_border_style(uint32_t opv, css_style *style, } css_error css__cascade_border_width(uint32_t opv, css_style *style, - css_select_state *state, - css_error (*fun)(css_computed_style *, uint8_t, css_fixed, + css_select_state *state, + css_error (*fun)(css_computed_style *, uint8_t, css_fixed, css_unit)) { uint16_t value = CSS_BORDER_WIDTH_INHERIT; @@ -326,7 +326,7 @@ css_error css__cascade_length(uint32_t opv, css_style *style, unit = css__to_css_unit(unit); /** \todo lose fun != NULL once all properties have set routines */ - if (fun != NULL && css__outranks_existing(getOpcode(opv), + if (fun != NULL && css__outranks_existing(getOpcode(opv), isImportant(opv), state, isInherit(opv))) { return fun(state->computed, value, length, unit); } @@ -350,7 +350,7 @@ css_error css__cascade_number(uint32_t opv, css_style *style, } /** \todo lose fun != NULL once all properties have set routines */ - if (fun != NULL && css__outranks_existing(getOpcode(opv), + if (fun != NULL && css__outranks_existing(getOpcode(opv), isImportant(opv), state, isInherit(opv))) { return fun(state->computed, value, length); } @@ -358,7 +358,7 @@ css_error css__cascade_number(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__cascade_page_break_after_before_inside(uint32_t opv, +css_error css__cascade_page_break_after_before_inside(uint32_t opv, css_style *style, css_select_state *state, css_error (*fun)(css_computed_style *, uint8_t)) { @@ -387,7 +387,7 @@ css_error css__cascade_page_break_after_before_inside(uint32_t opv, } /** \todo lose fun != NULL */ - if (fun != NULL && css__outranks_existing(getOpcode(opv), + if (fun != NULL && css__outranks_existing(getOpcode(opv), isImportant(opv), state, isInherit(opv))) { return fun(state->computed, value); } @@ -471,7 +471,7 @@ css_error css__cascade_counter_increment_reset(uint32_t opv, css_style *style, advance_bytecode(style, sizeof(css_code_t)); temp = realloc(counters, - (n_counters + 1) * + (n_counters + 1) * sizeof(css_computed_counter)); if (temp == NULL) { if (counters != NULL) { diff --git a/src/select/properties/helpers.h b/src/select/properties/helpers.h index feed146..901bcf0 100644 --- a/src/select/properties/helpers.h +++ b/src/select/properties/helpers.h @@ -16,18 +16,18 @@ uint32_t generic_destroy_number(void *bytecode); css_unit css__to_css_unit(uint32_t u); css_error css__cascade_bg_border_color(uint32_t opv, css_style *style, - css_select_state *state, + css_select_state *state, css_error (*fun)(css_computed_style *, uint8_t, css_color)); css_error css__cascade_uri_none(uint32_t opv, css_style *style, css_select_state *state, - css_error (*fun)(css_computed_style *, uint8_t, + css_error (*fun)(css_computed_style *, uint8_t, lwc_string *)); css_error css__cascade_border_style(uint32_t opv, css_style *style, - css_select_state *state, + css_select_state *state, css_error (*fun)(css_computed_style *, uint8_t)); css_error css__cascade_border_width(uint32_t opv, css_style *style, - css_select_state *state, - css_error (*fun)(css_computed_style *, uint8_t, css_fixed, + css_select_state *state, + css_error (*fun)(css_computed_style *, uint8_t, css_fixed, css_unit)); css_error css__cascade_length_auto(uint32_t opv, css_style *style, css_select_state *state, @@ -48,7 +48,7 @@ css_error css__cascade_length(uint32_t opv, css_style *style, css_error css__cascade_number(uint32_t opv, css_style *style, css_select_state *state, css_error (*fun)(css_computed_style *, uint8_t, css_fixed)); -css_error css__cascade_page_break_after_before_inside(uint32_t opv, +css_error css__cascade_page_break_after_before_inside(uint32_t opv, css_style *style, css_select_state *state, css_error (*fun)(css_computed_style *, uint8_t)); css_error css__cascade_break_after_before_inside(uint32_t opv, diff --git a/src/select/properties/left.c b/src/select/properties/left.c index faf76bb..4baa324 100644 --- a/src/select/properties/left.c +++ b/src/select/properties/left.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_left(uint32_t opv, css_style *style, +css_error css__cascade_left(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_left); diff --git a/src/select/properties/letter_spacing.c b/src/select/properties/letter_spacing.c index cc00100..d799467 100644 --- a/src/select/properties/letter_spacing.c +++ b/src/select/properties/letter_spacing.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_letter_spacing(uint32_t opv, css_style *style, +css_error css__cascade_letter_spacing(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_normal(opv, style, state, set_letter_spacing); @@ -29,7 +29,7 @@ css_error css__set_letter_spacing_from_hint(const css_hint *hint, css_error css__initial_letter_spacing(css_select_state *state) { - return set_letter_spacing(state->computed, CSS_LETTER_SPACING_NORMAL, + return set_letter_spacing(state->computed, CSS_LETTER_SPACING_NORMAL, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/line_height.c b/src/select/properties/line_height.c index 24b9e80..091a575 100644 --- a/src/select/properties/line_height.c +++ b/src/select/properties/line_height.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_line_height(uint32_t opv, css_style *style, +css_error css__cascade_line_height(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_LINE_HEIGHT_INHERIT; @@ -60,7 +60,7 @@ css_error css__set_line_height_from_hint(const css_hint *hint, css_error css__initial_line_height(css_select_state *state) { - return set_line_height(state->computed, CSS_LINE_HEIGHT_NORMAL, + return set_line_height(state->computed, CSS_LINE_HEIGHT_NORMAL, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/list_style_image.c b/src/select/properties/list_style_image.c index edc92fb..cc77eb4 100644 --- a/src/select/properties/list_style_image.c +++ b/src/select/properties/list_style_image.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_list_style_image(uint32_t opv, css_style *style, +css_error css__cascade_list_style_image(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_uri_none(opv, style, state, set_list_style_image); @@ -35,7 +35,7 @@ css_error css__set_list_style_image_from_hint(const css_hint *hint, css_error css__initial_list_style_image(css_select_state *state) { - return set_list_style_image(state->computed, + return set_list_style_image(state->computed, CSS_LIST_STYLE_IMAGE_NONE, NULL); } diff --git a/src/select/properties/list_style_position.c b/src/select/properties/list_style_position.c index acdbedb..02d7651 100644 --- a/src/select/properties/list_style_position.c +++ b/src/select/properties/list_style_position.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_list_style_position(uint32_t opv, css_style *style, +css_error css__cascade_list_style_position(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_LIST_STYLE_POSITION_INHERIT; @@ -48,7 +48,7 @@ css_error css__set_list_style_position_from_hint(const css_hint *hint, css_error css__initial_list_style_position(css_select_state *state) { - return set_list_style_position(state->computed, + return set_list_style_position(state->computed, CSS_LIST_STYLE_POSITION_OUTSIDE); } diff --git a/src/select/properties/list_style_type.c b/src/select/properties/list_style_type.c index 470bfb0..b1e5db6 100644 --- a/src/select/properties/list_style_type.c +++ b/src/select/properties/list_style_type.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_list_style_type(uint32_t opv, css_style *style, +css_error css__cascade_list_style_type(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_LIST_STYLE_TYPE_INHERIT; diff --git a/src/select/properties/margin_bottom.c b/src/select/properties/margin_bottom.c index c34004e..3b1d8a1 100644 --- a/src/select/properties/margin_bottom.c +++ b/src/select/properties/margin_bottom.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_margin_bottom(uint32_t opv, css_style *style, +css_error css__cascade_margin_bottom(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_margin_bottom); diff --git a/src/select/properties/margin_left.c b/src/select/properties/margin_left.c index ac22c3d..240285a 100644 --- a/src/select/properties/margin_left.c +++ b/src/select/properties/margin_left.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_margin_left(uint32_t opv, css_style *style, +css_error css__cascade_margin_left(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_margin_left); diff --git a/src/select/properties/margin_right.c b/src/select/properties/margin_right.c index a10df13..737fbee 100644 --- a/src/select/properties/margin_right.c +++ b/src/select/properties/margin_right.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_margin_right(uint32_t opv, css_style *style, +css_error css__cascade_margin_right(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_margin_right); diff --git a/src/select/properties/margin_top.c b/src/select/properties/margin_top.c index f66c8ee..5563a48 100644 --- a/src/select/properties/margin_top.c +++ b/src/select/properties/margin_top.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_margin_top(uint32_t opv, css_style *style, +css_error css__cascade_margin_top(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_margin_top); diff --git a/src/select/properties/max_height.c b/src/select/properties/max_height.c index 51fae8c..e03c8da 100644 --- a/src/select/properties/max_height.c +++ b/src/select/properties/max_height.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_max_height(uint32_t opv, css_style *style, +css_error css__cascade_max_height(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_none(opv, style, state, set_max_height); @@ -29,7 +29,7 @@ css_error css__set_max_height_from_hint(const css_hint *hint, css_error css__initial_max_height(css_select_state *state) { - return set_max_height(state->computed, CSS_MAX_HEIGHT_NONE, + return set_max_height(state->computed, CSS_MAX_HEIGHT_NONE, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/max_width.c b/src/select/properties/max_width.c index f9ccc03..ec98712 100644 --- a/src/select/properties/max_width.c +++ b/src/select/properties/max_width.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_max_width(uint32_t opv, css_style *style, +css_error css__cascade_max_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_none(opv, style, state, set_max_width);; diff --git a/src/select/properties/min_height.c b/src/select/properties/min_height.c index a3ab6b9..687d8a1 100644 --- a/src/select/properties/min_height.c +++ b/src/select/properties/min_height.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_min_height(uint32_t opv, css_style *style, +css_error css__cascade_min_height(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length(opv, style, state, set_min_height); @@ -29,7 +29,7 @@ css_error css__set_min_height_from_hint(const css_hint *hint, css_error css__initial_min_height(css_select_state *state) { - return set_min_height(state->computed, CSS_MIN_HEIGHT_SET, + return set_min_height(state->computed, CSS_MIN_HEIGHT_SET, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/min_width.c b/src/select/properties/min_width.c index 4139eda..5365588 100644 --- a/src/select/properties/min_width.c +++ b/src/select/properties/min_width.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_min_width(uint32_t opv, css_style *style, +css_error css__cascade_min_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length(opv, style, state, set_min_width); diff --git a/src/select/properties/opacity.c b/src/select/properties/opacity.c index 9ef0998..aadab0b 100644 --- a/src/select/properties/opacity.c +++ b/src/select/properties/opacity.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_opacity(uint32_t opv, css_style *style, +css_error css__cascade_opacity(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_OPACITY_INHERIT; diff --git a/src/select/properties/orphans.c b/src/select/properties/orphans.c index d5c4937..f169b81 100644 --- a/src/select/properties/orphans.c +++ b/src/select/properties/orphans.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_orphans(uint32_t opv, css_style *style, +css_error css__cascade_orphans(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_number(opv, style, state, set_orphans); @@ -37,11 +37,11 @@ css_error css__compose_orphans(const css_computed_style *parent, { int32_t count = 0; uint8_t type = get_orphans(child, &count); - + if (type == CSS_ORPHANS_INHERIT) { type = get_orphans(parent, &count); } - + return set_orphans(result, type, count); } diff --git a/src/select/properties/outline_color.c b/src/select/properties/outline_color.c index 2613839..c6c576b 100644 --- a/src/select/properties/outline_color.c +++ b/src/select/properties/outline_color.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_outline_color(uint32_t opv, css_style *style, +css_error css__cascade_outline_color(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_OUTLINE_COLOR_INHERIT; diff --git a/src/select/properties/outline_style.c b/src/select/properties/outline_style.c index 7b64381..5c30735 100644 --- a/src/select/properties/outline_style.c +++ b/src/select/properties/outline_style.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_outline_style(uint32_t opv, css_style *style, +css_error css__cascade_outline_style(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_style(opv, style, state, set_outline_style); diff --git a/src/select/properties/outline_width.c b/src/select/properties/outline_width.c index 547c42a..4d9101c 100644 --- a/src/select/properties/outline_width.c +++ b/src/select/properties/outline_width.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_outline_width(uint32_t opv, css_style *style, +css_error css__cascade_outline_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_border_width(opv, style, state, set_outline_width); diff --git a/src/select/properties/overflow_x.c b/src/select/properties/overflow_x.c index 0173f5a..817d1d2 100644 --- a/src/select/properties/overflow_x.c +++ b/src/select/properties/overflow_x.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_overflow_x(uint32_t opv, css_style *style, +css_error css__cascade_overflow_x(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_OVERFLOW_INHERIT; diff --git a/src/select/properties/overflow_y.c b/src/select/properties/overflow_y.c index 13213b5..b54c4c8 100644 --- a/src/select/properties/overflow_y.c +++ b/src/select/properties/overflow_y.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_overflow_y(uint32_t opv, css_style *style, +css_error css__cascade_overflow_y(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_OVERFLOW_INHERIT; diff --git a/src/select/properties/padding_bottom.c b/src/select/properties/padding_bottom.c index 806f0f5..e3b36f7 100644 --- a/src/select/properties/padding_bottom.c +++ b/src/select/properties/padding_bottom.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_padding_bottom(uint32_t opv, css_style *style, +css_error css__cascade_padding_bottom(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length(opv, style, state, set_padding_bottom); @@ -29,7 +29,7 @@ css_error css__set_padding_bottom_from_hint(const css_hint *hint, css_error css__initial_padding_bottom(css_select_state *state) { - return set_padding_bottom(state->computed, CSS_PADDING_SET, + return set_padding_bottom(state->computed, CSS_PADDING_SET, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/padding_left.c b/src/select/properties/padding_left.c index 8873652..bdea11e 100644 --- a/src/select/properties/padding_left.c +++ b/src/select/properties/padding_left.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_padding_left(uint32_t opv, css_style *style, +css_error css__cascade_padding_left(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length(opv, style, state, set_padding_left); diff --git a/src/select/properties/padding_right.c b/src/select/properties/padding_right.c index a79d8f4..82c1ed3 100644 --- a/src/select/properties/padding_right.c +++ b/src/select/properties/padding_right.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_padding_right(uint32_t opv, css_style *style, +css_error css__cascade_padding_right(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length(opv, style, state, set_padding_right); @@ -29,7 +29,7 @@ css_error css__set_padding_right_from_hint(const css_hint *hint, css_error css__initial_padding_right(css_select_state *state) { - return set_padding_right(state->computed, CSS_PADDING_SET, + return set_padding_right(state->computed, CSS_PADDING_SET, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/padding_top.c b/src/select/properties/padding_top.c index 20fbe1e..f6d8b3e 100644 --- a/src/select/properties/padding_top.c +++ b/src/select/properties/padding_top.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_padding_top(uint32_t opv, css_style *style, +css_error css__cascade_padding_top(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length(opv, style, state, set_padding_top); diff --git a/src/select/properties/page_break_after.c b/src/select/properties/page_break_after.c index 0fd44c4..fdb6774 100644 --- a/src/select/properties/page_break_after.c +++ b/src/select/properties/page_break_after.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_page_break_after(uint32_t opv, css_style *style, +css_error css__cascade_page_break_after(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_page_break_after_before_inside(opv, style, state, diff --git a/src/select/properties/page_break_before.c b/src/select/properties/page_break_before.c index 0acae48..1491997 100644 --- a/src/select/properties/page_break_before.c +++ b/src/select/properties/page_break_before.c @@ -14,10 +14,10 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_page_break_before(uint32_t opv, css_style *style, +css_error css__cascade_page_break_before(uint32_t opv, css_style *style, css_select_state *state) { - return css__cascade_page_break_after_before_inside(opv, style, state, + return css__cascade_page_break_after_before_inside(opv, style, state, set_page_break_before); } @@ -29,7 +29,7 @@ css_error css__set_page_break_before_from_hint(const css_hint *hint, css_error css__initial_page_break_before(css_select_state *state) { - return set_page_break_before(state->computed, + return set_page_break_before(state->computed, CSS_PAGE_BREAK_BEFORE_AUTO); } @@ -38,10 +38,10 @@ css_error css__compose_page_break_before(const css_computed_style *parent, css_computed_style *result) { uint8_t type = get_page_break_before(child); - + if (type == CSS_PAGE_BREAK_BEFORE_INHERIT) { type = get_page_break_before(parent); } - + return set_page_break_before(result, type); } diff --git a/src/select/properties/page_break_inside.c b/src/select/properties/page_break_inside.c index 20b8bf5..ddcb19f 100644 --- a/src/select/properties/page_break_inside.c +++ b/src/select/properties/page_break_inside.c @@ -14,10 +14,10 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_page_break_inside(uint32_t opv, css_style *style, +css_error css__cascade_page_break_inside(uint32_t opv, css_style *style, css_select_state *state) { - return css__cascade_page_break_after_before_inside(opv, style, state, + return css__cascade_page_break_after_before_inside(opv, style, state, set_page_break_inside); } @@ -38,11 +38,11 @@ css_error css__compose_page_break_inside(const css_computed_style *parent, css_computed_style *result) { uint8_t type = get_page_break_inside(child); - + if (type == CSS_PAGE_BREAK_INSIDE_INHERIT) { type = get_page_break_inside(parent); } - + return set_page_break_inside(result, type); } diff --git a/src/select/properties/pause_after.c b/src/select/properties/pause_after.c index a33ee66..16bbefe 100644 --- a/src/select/properties/pause_after.c +++ b/src/select/properties/pause_after.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_pause_after(uint32_t opv, css_style *style, +css_error css__cascade_pause_after(uint32_t opv, css_style *style, css_select_state *state) { /** \todo pause-after */ diff --git a/src/select/properties/pause_before.c b/src/select/properties/pause_before.c index b33e94a..7770615 100644 --- a/src/select/properties/pause_before.c +++ b/src/select/properties/pause_before.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_pause_before(uint32_t opv, css_style *style, +css_error css__cascade_pause_before(uint32_t opv, css_style *style, css_select_state *state) { /** \todo pause-before */ diff --git a/src/select/properties/pitch.c b/src/select/properties/pitch.c index b6dc649..c5484d9 100644 --- a/src/select/properties/pitch.c +++ b/src/select/properties/pitch.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_pitch(uint32_t opv, css_style *style, +css_error css__cascade_pitch(uint32_t opv, css_style *style, css_select_state *state) { css_fixed freq = 0; diff --git a/src/select/properties/pitch_range.c b/src/select/properties/pitch_range.c index 9a2ea24..52a5751 100644 --- a/src/select/properties/pitch_range.c +++ b/src/select/properties/pitch_range.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_pitch_range(uint32_t opv, css_style *style, +css_error css__cascade_pitch_range(uint32_t opv, css_style *style, css_select_state *state) { /** \todo pitch-range */ diff --git a/src/select/properties/play_during.c b/src/select/properties/play_during.c index 0210567..413d75a 100644 --- a/src/select/properties/play_during.c +++ b/src/select/properties/play_during.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_play_during(uint32_t opv, css_style *style, +css_error css__cascade_play_during(uint32_t opv, css_style *style, css_select_state *state) { lwc_string *uri = NULL; diff --git a/src/select/properties/position.c b/src/select/properties/position.c index 7f566da..9f9658f 100644 --- a/src/select/properties/position.c +++ b/src/select/properties/position.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_position(uint32_t opv, css_style *style, +css_error css__cascade_position(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_POSITION_INHERIT; diff --git a/src/select/properties/quotes.c b/src/select/properties/quotes.c index 2dd6af4..4144d8e 100644 --- a/src/select/properties/quotes.c +++ b/src/select/properties/quotes.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_quotes(uint32_t opv, css_style *style, +css_error css__cascade_quotes(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_QUOTES_INHERIT; @@ -40,7 +40,7 @@ css_error css__cascade_quotes(uint32_t opv, css_style *style, &close); advance_bytecode(style, sizeof(css_code_t)); - temp = realloc(quotes, + temp = realloc(quotes, (n_quotes + 2) * sizeof(lwc_string *)); if (temp == NULL) { if (quotes != NULL) { @@ -96,7 +96,7 @@ css_error css__set_quotes_from_hint(const css_hint *hint, { lwc_string **item; css_error error; - + error = set_quotes(style, hint->status, hint->data.strings); for (item = hint->data.strings; @@ -149,7 +149,7 @@ css_error css__compose_quotes(const css_computed_style *parent, if (copy == NULL) return CSS_NOMEM; - memcpy(copy, quotes, (n_quotes + 1) * + memcpy(copy, quotes, (n_quotes + 1) * sizeof(lwc_string *)); } diff --git a/src/select/properties/richness.c b/src/select/properties/richness.c index d05ed7b..9656486 100644 --- a/src/select/properties/richness.c +++ b/src/select/properties/richness.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_richness(uint32_t opv, css_style *style, +css_error css__cascade_richness(uint32_t opv, css_style *style, css_select_state *state) { /** \todo richness */ diff --git a/src/select/properties/right.c b/src/select/properties/right.c index b87e63e..142e7e8 100644 --- a/src/select/properties/right.c +++ b/src/select/properties/right.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_right(uint32_t opv, css_style *style, +css_error css__cascade_right(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_right); diff --git a/src/select/properties/speak.c b/src/select/properties/speak.c index 0b52e62..eb5528b 100644 --- a/src/select/properties/speak.c +++ b/src/select/properties/speak.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_speak(uint32_t opv, css_style *style, +css_error css__cascade_speak(uint32_t opv, css_style *style, css_select_state *state) { UNUSED(style); diff --git a/src/select/properties/speak_header.c b/src/select/properties/speak_header.c index 6fc37d5..0935528 100644 --- a/src/select/properties/speak_header.c +++ b/src/select/properties/speak_header.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_speak_header(uint32_t opv, css_style *style, +css_error css__cascade_speak_header(uint32_t opv, css_style *style, css_select_state *state) { UNUSED(style); diff --git a/src/select/properties/speak_numeral.c b/src/select/properties/speak_numeral.c index 1e74abd..fc54caf 100644 --- a/src/select/properties/speak_numeral.c +++ b/src/select/properties/speak_numeral.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_speak_numeral(uint32_t opv, css_style *style, +css_error css__cascade_speak_numeral(uint32_t opv, css_style *style, css_select_state *state) { UNUSED(style); diff --git a/src/select/properties/speak_punctuation.c b/src/select/properties/speak_punctuation.c index 9898b7c..67cbdaf 100644 --- a/src/select/properties/speak_punctuation.c +++ b/src/select/properties/speak_punctuation.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_speak_punctuation( +css_error css__cascade_speak_punctuation( uint32_t opv, css_style *style, css_select_state *state) { UNUSED(style); diff --git a/src/select/properties/speech_rate.c b/src/select/properties/speech_rate.c index c974997..5cec19b 100644 --- a/src/select/properties/speech_rate.c +++ b/src/select/properties/speech_rate.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_speech_rate(uint32_t opv, css_style *style, +css_error css__cascade_speech_rate(uint32_t opv, css_style *style, css_select_state *state) { css_fixed rate = 0; diff --git a/src/select/properties/stress.c b/src/select/properties/stress.c index 81cf0e4..c9d61dd 100644 --- a/src/select/properties/stress.c +++ b/src/select/properties/stress.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_stress(uint32_t opv, css_style *style, +css_error css__cascade_stress(uint32_t opv, css_style *style, css_select_state *state) { /** \todo stress */ diff --git a/src/select/properties/table_layout.c b/src/select/properties/table_layout.c index c28cdae..c911e10 100644 --- a/src/select/properties/table_layout.c +++ b/src/select/properties/table_layout.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_table_layout(uint32_t opv, css_style *style, +css_error css__cascade_table_layout(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_TABLE_LAYOUT_INHERIT; diff --git a/src/select/properties/text_align.c b/src/select/properties/text_align.c index 611fcd3..808107f 100644 --- a/src/select/properties/text_align.c +++ b/src/select/properties/text_align.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_text_align(uint32_t opv, css_style *style, +css_error css__cascade_text_align(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_TEXT_ALIGN_INHERIT; @@ -66,7 +66,7 @@ css_error css__initial_text_align(css_select_state *state) return set_text_align(state->computed, CSS_TEXT_ALIGN_DEFAULT); } -css_error css__compose_text_align(const css_computed_style *parent, +css_error css__compose_text_align(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { @@ -78,8 +78,8 @@ css_error css__compose_text_align(const css_computed_style *parent, /* This is purely for the benefit of HTML tables */ type = get_text_align(parent); - /* If the parent's text-align is a magical one, - * then reset to the default value. Otherwise, + /* If the parent's text-align is a magical one, + * then reset to the default value. Otherwise, * inherit as normal. */ if (type == CSS_TEXT_ALIGN_LIBCSS_LEFT || type == CSS_TEXT_ALIGN_LIBCSS_CENTER || diff --git a/src/select/properties/text_decoration.c b/src/select/properties/text_decoration.c index 7f5a172..0e7544d 100644 --- a/src/select/properties/text_decoration.c +++ b/src/select/properties/text_decoration.c @@ -16,11 +16,11 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_text_decoration(uint32_t opv, css_style *style, +css_error css__cascade_text_decoration(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_TEXT_DECORATION_INHERIT; - + UNUSED(style); if (isInherit(opv) == false) { @@ -59,7 +59,7 @@ css_error css__initial_text_decoration(css_select_state *state) return set_text_decoration(state->computed, CSS_TEXT_DECORATION_NONE); } -css_error css__compose_text_decoration(const css_computed_style *parent, +css_error css__compose_text_decoration(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { diff --git a/src/select/properties/text_indent.c b/src/select/properties/text_indent.c index 867292e..787c0be 100644 --- a/src/select/properties/text_indent.c +++ b/src/select/properties/text_indent.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_text_indent(uint32_t opv, css_style *style, +css_error css__cascade_text_indent(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length(opv, style, state, set_text_indent); @@ -29,7 +29,7 @@ css_error css__set_text_indent_from_hint(const css_hint *hint, css_error css__initial_text_indent(css_select_state *state) { - return set_text_indent(state->computed, CSS_TEXT_INDENT_SET, + return set_text_indent(state->computed, CSS_TEXT_INDENT_SET, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/text_transform.c b/src/select/properties/text_transform.c index 43117e9..38cb427 100644 --- a/src/select/properties/text_transform.c +++ b/src/select/properties/text_transform.c @@ -14,11 +14,11 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_text_transform(uint32_t opv, css_style *style, +css_error css__cascade_text_transform(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_TEXT_TRANSFORM_INHERIT; - + UNUSED(style); if (isInherit(opv) == false) { @@ -57,7 +57,7 @@ css_error css__initial_text_transform(css_select_state *state) return set_text_transform(state->computed, CSS_TEXT_TRANSFORM_NONE); } -css_error css__compose_text_transform(const css_computed_style *parent, +css_error css__compose_text_transform(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { diff --git a/src/select/properties/top.c b/src/select/properties/top.c index 8fd1935..72129aa 100644 --- a/src/select/properties/top.c +++ b/src/select/properties/top.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_top(uint32_t opv, css_style *style, +css_error css__cascade_top(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_top); diff --git a/src/select/properties/unicode_bidi.c b/src/select/properties/unicode_bidi.c index d798ff2..5b91df1 100644 --- a/src/select/properties/unicode_bidi.c +++ b/src/select/properties/unicode_bidi.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_unicode_bidi(uint32_t opv, css_style *style, +css_error css__cascade_unicode_bidi(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_UNICODE_BIDI_INHERIT; @@ -54,7 +54,7 @@ css_error css__initial_unicode_bidi(css_select_state *state) return set_unicode_bidi(state->computed, CSS_UNICODE_BIDI_NORMAL); } -css_error css__compose_unicode_bidi(const css_computed_style *parent, +css_error css__compose_unicode_bidi(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { diff --git a/src/select/properties/vertical_align.c b/src/select/properties/vertical_align.c index dba2343..9fb7143 100644 --- a/src/select/properties/vertical_align.c +++ b/src/select/properties/vertical_align.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_vertical_align(uint32_t opv, css_style *style, +css_error css__cascade_vertical_align(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_VERTICAL_ALIGN_INHERIT; diff --git a/src/select/properties/visibility.c b/src/select/properties/visibility.c index dd1c1e3..ef95252 100644 --- a/src/select/properties/visibility.c +++ b/src/select/properties/visibility.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_visibility(uint32_t opv, css_style *style, +css_error css__cascade_visibility(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_VISIBILITY_INHERIT; @@ -54,7 +54,7 @@ css_error css__initial_visibility(css_select_state *state) return set_visibility(state->computed, CSS_VISIBILITY_VISIBLE); } -css_error css__compose_visibility(const css_computed_style *parent, +css_error css__compose_visibility(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { diff --git a/src/select/properties/voice_family.c b/src/select/properties/voice_family.c index 5c70d1e..b370a2b 100644 --- a/src/select/properties/voice_family.c +++ b/src/select/properties/voice_family.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_voice_family(uint32_t opv, css_style *style, +css_error css__cascade_voice_family(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -55,7 +55,7 @@ css_error css__cascade_voice_family(uint32_t opv, css_style *style, * first generic-family are ignored. */ /** \todo Do this at bytecode generation time? */ if (value == 0 && voice != NULL) { - temp = realloc(voices, + temp = realloc(voices, (n_voices + 1) * sizeof(lwc_string *)); if (temp == NULL) { if (voices != NULL) { diff --git a/src/select/properties/volume.c b/src/select/properties/volume.c index ca0e9dd..96787fa 100644 --- a/src/select/properties/volume.c +++ b/src/select/properties/volume.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_volume(uint32_t opv, css_style *style, +css_error css__cascade_volume(uint32_t opv, css_style *style, css_select_state *state) { css_fixed val = 0; diff --git a/src/select/properties/white_space.c b/src/select/properties/white_space.c index d537768..b8d2e02 100644 --- a/src/select/properties/white_space.c +++ b/src/select/properties/white_space.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_white_space(uint32_t opv, css_style *style, +css_error css__cascade_white_space(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_WHITE_SPACE_INHERIT; @@ -60,7 +60,7 @@ css_error css__initial_white_space(css_select_state *state) return set_white_space(state->computed, CSS_WHITE_SPACE_NORMAL); } -css_error css__compose_white_space(const css_computed_style *parent, +css_error css__compose_white_space(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { diff --git a/src/select/properties/widows.c b/src/select/properties/widows.c index 916966a..61126c2 100644 --- a/src/select/properties/widows.c +++ b/src/select/properties/widows.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_widows(uint32_t opv, css_style *style, +css_error css__cascade_widows(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_number(opv, style, state, set_widows); @@ -37,11 +37,11 @@ css_error css__compose_widows(const css_computed_style *parent, { int32_t count = 0; uint8_t type = get_widows(child, &count); - + if (type == CSS_WIDOWS_INHERIT) { type = get_widows(parent, &count); } - + return set_widows(result, type, count); } diff --git a/src/select/properties/width.c b/src/select/properties/width.c index 4b43a8c..829df91 100644 --- a/src/select/properties/width.c +++ b/src/select/properties/width.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_width(uint32_t opv, css_style *style, +css_error css__cascade_width(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_auto(opv, style, state, set_width); diff --git a/src/select/properties/word_spacing.c b/src/select/properties/word_spacing.c index 24eda89..4cb9422 100644 --- a/src/select/properties/word_spacing.c +++ b/src/select/properties/word_spacing.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_word_spacing(uint32_t opv, css_style *style, +css_error css__cascade_word_spacing(uint32_t opv, css_style *style, css_select_state *state) { return css__cascade_length_normal(opv, style, state, set_word_spacing); @@ -29,7 +29,7 @@ css_error css__set_word_spacing_from_hint(const css_hint *hint, css_error css__initial_word_spacing(css_select_state *state) { - return set_word_spacing(state->computed, CSS_WORD_SPACING_NORMAL, + return set_word_spacing(state->computed, CSS_WORD_SPACING_NORMAL, 0, CSS_UNIT_PX); } diff --git a/src/select/properties/writing_mode.c b/src/select/properties/writing_mode.c index 3ec1352..bbd3753 100644 --- a/src/select/properties/writing_mode.c +++ b/src/select/properties/writing_mode.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_writing_mode(uint32_t opv, css_style *style, +css_error css__cascade_writing_mode(uint32_t opv, css_style *style, css_select_state *state) { bool inherit = isInherit(opv); @@ -35,7 +35,7 @@ css_error css__cascade_writing_mode(uint32_t opv, css_style *style, } } - if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, + if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, inherit)) { return set_writing_mode(state->computed, writing_mode); } @@ -43,7 +43,7 @@ css_error css__cascade_writing_mode(uint32_t opv, css_style *style, return CSS_OK; } -css_error css__set_writing_mode_from_hint(const css_hint *hint, +css_error css__set_writing_mode_from_hint(const css_hint *hint, css_computed_style *style) { return set_writing_mode(style, hint->status); diff --git a/src/select/properties/z_index.c b/src/select/properties/z_index.c index 3ad15e7..59cf242 100644 --- a/src/select/properties/z_index.c +++ b/src/select/properties/z_index.c @@ -14,7 +14,7 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_z_index(uint32_t opv, css_style *style, +css_error css__cascade_z_index(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_Z_INDEX_INHERIT; diff --git a/src/select/select.c b/src/select/select.c index 580c29e..6b5225a 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -118,38 +118,38 @@ typedef struct css_select_rule_source { static css_error set_hint(css_select_state *state, css_hint *hint); -static css_error set_initial(css_select_state *state, +static css_error set_initial(css_select_state *state, uint32_t prop, css_pseudo_element pseudo, void *parent); static css_error intern_strings(css_select_ctx *ctx); static void destroy_strings(css_select_ctx *ctx); -static css_error select_from_sheet(css_select_ctx *ctx, +static css_error select_from_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, css_origin origin, css_select_state *state); -static css_error match_selectors_in_sheet(css_select_ctx *ctx, +static css_error match_selectors_in_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, css_select_state *state); -static css_error match_selector_chain(css_select_ctx *ctx, +static css_error match_selector_chain(css_select_ctx *ctx, const css_selector *selector, css_select_state *state); -static css_error match_named_combinator(css_select_ctx *ctx, - css_combinator type, const css_selector *selector, +static css_error match_named_combinator(css_select_ctx *ctx, + css_combinator type, const css_selector *selector, css_select_state *state, void *node, void **next_node); -static css_error match_universal_combinator(css_select_ctx *ctx, - css_combinator type, const css_selector *selector, +static css_error match_universal_combinator(css_select_ctx *ctx, + css_combinator type, const css_selector *selector, css_select_state *state, void *node, bool may_optimise, bool *rejected_by_cache, void **next_node); -static css_error match_details(css_select_ctx *ctx, void *node, - const css_selector_detail *detail, css_select_state *state, +static css_error match_details(css_select_ctx *ctx, void *node, + const css_selector_detail *detail, css_select_state *state, bool *match, css_pseudo_element *pseudo_element); -static css_error match_detail(css_select_ctx *ctx, void *node, - const css_selector_detail *detail, css_select_state *state, +static css_error match_detail(css_select_ctx *ctx, void *node, + const css_selector_detail *detail, css_select_state *state, bool *match, css_pseudo_element *pseudo_element); static css_error cascade_style(const css_style *style, css_select_state *state); static css_error select_font_faces_from_sheet( - const css_stylesheet *sheet, - css_origin origin, + const css_stylesheet *sheet, + css_origin origin, css_select_font_faces_state *state); #ifdef DEBUG_CHAIN_MATCHING @@ -305,7 +305,7 @@ css_error css_select_ctx_destroy(css_select_ctx *ctx) * \param media Media types to which the sheet applies * \return CSS_OK on success, appropriate error otherwise */ -css_error css_select_ctx_append_sheet(css_select_ctx *ctx, +css_error css_select_ctx_append_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, css_origin origin, uint64_t media) { @@ -318,7 +318,7 @@ css_error css_select_ctx_append_sheet(css_select_ctx *ctx, /** * Insert a stylesheet into a selection context - * + * * \param ctx The context to insert into * \param sheet Sheet to insert * \param index Index in context to insert sheet @@ -344,7 +344,7 @@ css_error css_select_ctx_insert_sheet(css_select_ctx *ctx, if (index > ctx->n_sheets) return CSS_INVALID; - temp = realloc(ctx->sheets, + temp = realloc(ctx->sheets, (ctx->n_sheets + 1) * sizeof(css_select_sheet)); if (temp == NULL) return CSS_NOMEM; @@ -1245,7 +1245,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node, if ((s.media & media) != 0 && s.sheet->disabled == false) { - error = select_from_sheet(ctx, s.sheet, + error = select_from_sheet(ctx, s.sheet, s.origin, &state); if (error != CSS_OK) goto cleanup; @@ -1254,12 +1254,12 @@ css_error css_select_style(css_select_ctx *ctx, void *node, /* Consider any inline style for the node */ if (inline_style != NULL) { - css_rule_selector *sel = + css_rule_selector *sel = (css_rule_selector *) inline_style->rule_list; /* Sanity check style */ if (inline_style->rule_count != 1 || - inline_style->rule_list->type != CSS_RULE_SELECTOR || + inline_style->rule_list->type != CSS_RULE_SELECTOR || inline_style->rule_list->items != 0) { error = CSS_INVALID; goto cleanup; @@ -1284,16 +1284,16 @@ css_error css_select_style(css_select_ctx *ctx, void *node, state.current_pseudo = CSS_PSEUDO_ELEMENT_NONE; state.computed = state.results->styles[CSS_PSEUDO_ELEMENT_NONE]; for (i = 0; i < CSS_N_PROPERTIES; i++) { - const prop_state *prop = + const prop_state *prop = &state.props[i][CSS_PSEUDO_ELEMENT_NONE]; - /* If the property is still unset or it's set to inherit - * and we're the root element, then set it to its initial + /* If the property is still unset or it's set to inherit + * and we're the root element, then set it to its initial * value. */ - if (prop->set == false || - (parent == NULL && + if (prop->set == false || + (parent == NULL && prop->inherit == true)) { - error = set_initial(&state, i, + error = set_initial(&state, i, CSS_PSEUDO_ELEMENT_NONE, parent); if (error != CSS_OK) goto cleanup; @@ -1312,7 +1312,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node, for (i = 0; i < CSS_N_PROPERTIES; i++) { const prop_state *prop = &state.props[i][j]; - /* If the property is still unset then set it + /* If the property is still unset then set it * to its initial value. */ if (prop->set == false) { error = set_initial(&state, i, j, parent); @@ -1323,8 +1323,8 @@ css_error css_select_style(css_select_ctx *ctx, void *node, } /* If this is the root element, then we must ensure that all - * length values are absolute, display and float are correctly - * computed, and the default border-{top,right,bottom,left}-color + * length values are absolute, display and float are correctly + * computed, and the default border-{top,right,bottom,left}-color * is set to the computed value of color. */ if (parent == NULL) { /* Only compute absolute values for the base element */ @@ -1406,20 +1406,20 @@ css_error css_select_font_faces(css_select_ctx *ctx, css_error error; css_select_font_faces_state state; uint32_t n_font_faces; - + if (ctx == NULL || font_family == NULL || result == NULL) return CSS_BADPARM; memset(&state, 0, sizeof(css_select_font_faces_state)); state.font_family = font_family; state.media = media; - + /* Iterate through the top-level stylesheets, selecting font-faces * from those which apply to our current media requirements and * are not disabled */ for (i = 0; i < ctx->n_sheets; i++) { const css_select_sheet s = ctx->sheets[i]; - + if ((s.media & media) != 0 && s.sheet->disabled == false) { error = select_font_faces_from_sheet(s.sheet, @@ -1428,23 +1428,23 @@ css_error css_select_font_faces(css_select_ctx *ctx, goto cleanup; } } - - n_font_faces = state.ua_font_faces.count + + + n_font_faces = state.ua_font_faces.count + state.user_font_faces.count + state.author_font_faces.count; - - + + if (n_font_faces > 0) { /* We found some matching faces. Make a results structure with * the font faces in priority order. */ css_select_font_faces_results *results; - + results = malloc(sizeof(css_select_font_faces_results)); if (results == NULL) { error = CSS_NOMEM; goto cleanup; } - + results->font_faces = malloc( n_font_faces * sizeof(css_font_face *)); if (results->font_faces == NULL) { @@ -1454,47 +1454,47 @@ css_error css_select_font_faces(css_select_ctx *ctx, } results->n_font_faces = n_font_faces; - + i = 0; if (state.ua_font_faces.count != 0) { - memcpy(results->font_faces, + memcpy(results->font_faces, state.ua_font_faces.font_faces, - sizeof(css_font_face *) * + sizeof(css_font_face *) * state.ua_font_faces.count); - + i += state.ua_font_faces.count; } - + if (state.user_font_faces.count != 0) { - memcpy(results->font_faces + i, + memcpy(results->font_faces + i, state.user_font_faces.font_faces, - sizeof(css_font_face *) * + sizeof(css_font_face *) * state.user_font_faces.count); i += state.user_font_faces.count; } - + if (state.author_font_faces.count != 0) { - memcpy(results->font_faces + i, + memcpy(results->font_faces + i, state.author_font_faces.font_faces, - sizeof(css_font_face *) * + sizeof(css_font_face *) * state.author_font_faces.count); } *result = results; } - + error = CSS_OK; - + cleanup: - if (state.ua_font_faces.count != 0) + if (state.ua_font_faces.count != 0) free(state.ua_font_faces.font_faces); - if (state.user_font_faces.count != 0) + if (state.user_font_faces.count != 0) free(state.user_font_faces.font_faces); - - if (state.author_font_faces.count != 0) + + if (state.author_font_faces.count != 0) free(state.author_font_faces.font_faces); - + return error; } @@ -1509,15 +1509,15 @@ css_error css_select_font_faces_results_destroy( { if (results == NULL) return CSS_BADPARM; - + if (results->font_faces != NULL) { /* Don't destroy the individual css_font_faces, they're owned by their respective sheets */ free(results->font_faces); } - + free(results); - + return CSS_OK; } @@ -1536,37 +1536,37 @@ css_error intern_strings(css_select_ctx *ctx) /* Pseudo classes */ error = lwc_intern_string( - "first-child", SLEN("first-child"), + "first-child", SLEN("first-child"), &ctx->first_child); if (error != lwc_error_ok) return css_error_from_lwc_error(error); error = lwc_intern_string( - "link", SLEN("link"), + "link", SLEN("link"), &ctx->link); if (error != lwc_error_ok) return css_error_from_lwc_error(error); error = lwc_intern_string( - "visited", SLEN("visited"), + "visited", SLEN("visited"), &ctx->visited); if (error != lwc_error_ok) return css_error_from_lwc_error(error); error = lwc_intern_string( - "hover", SLEN("hover"), + "hover", SLEN("hover"), &ctx->hover); if (error != lwc_error_ok) return css_error_from_lwc_error(error); error = lwc_intern_string( - "active", SLEN("active"), + "active", SLEN("active"), &ctx->active); if (error != lwc_error_ok) return css_error_from_lwc_error(error); error = lwc_intern_string( - "focus", SLEN("focus"), + "focus", SLEN("focus"), &ctx->focus); if (error != lwc_error_ok) return css_error_from_lwc_error(error); @@ -1669,7 +1669,7 @@ css_error intern_strings(css_select_ctx *ctx) /* Pseudo elements */ error = lwc_intern_string( - "first-line", SLEN("first-line"), + "first-line", SLEN("first-line"), &ctx->first_line); if (error != lwc_error_ok) return css_error_from_lwc_error(error); @@ -1681,13 +1681,13 @@ css_error intern_strings(css_select_ctx *ctx) return css_error_from_lwc_error(error); error = lwc_intern_string( - "before", SLEN("before"), + "before", SLEN("before"), &ctx->before); if (error != lwc_error_ok) return css_error_from_lwc_error(error); error = lwc_intern_string( - "after", SLEN("after"), + "after", SLEN("after"), &ctx->after); if (error != lwc_error_ok) return css_error_from_lwc_error(error); @@ -1774,29 +1774,29 @@ css_error set_hint(css_select_state *state, css_hint *hint) return CSS_OK; } -css_error set_initial(css_select_state *state, +css_error set_initial(css_select_state *state, uint32_t prop, css_pseudo_element pseudo, void *parent) { css_error error; - /* Do nothing if this property is inherited (the default state + /* Do nothing if this property is inherited (the default state * of a clean computed style is for everything to be set to inherit) * - * If the node is tree root and we're dealing with the base element, + * If the node is tree root and we're dealing with the base element, * everything should be defaulted. */ - if (prop_dispatch[prop].inherited == false || + if (prop_dispatch[prop].inherited == false || (pseudo == CSS_PSEUDO_ELEMENT_NONE && parent == NULL)) { enum prop_group group = prop_dispatch[prop].group; - /* Remaining properties are neither inherited nor - * already set. Thus, we set them to their initial - * values here. Except, however, if the property in - * question resides in one of the extension blocks and - * the extension block has yet to be allocated. In that - * case, we do nothing and leave it to the property - * accessors to return the initial values for the + /* Remaining properties are neither inherited nor + * already set. Thus, we set them to their initial + * values here. Except, however, if the property in + * question resides in one of the extension blocks and + * the extension block has yet to be allocated. In that + * case, we do nothing and leave it to the property + * accessors to return the initial values for the * property. */ switch (group) { @@ -1825,7 +1825,7 @@ css_error set_initial(css_select_state *state, #define IMPORT_STACK_SIZE 256 -css_error select_from_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, +css_error select_from_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, css_origin origin, css_select_state *state) { const css_stylesheet *s = sheet; @@ -1842,7 +1842,7 @@ css_error select_from_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, if (rule != NULL && rule->type == CSS_RULE_IMPORT) { /* Current rule is an import */ - const css_rule_import *import = + const css_rule_import *import = (const css_rule_import *) rule; if (import->sheet != NULL && @@ -1893,7 +1893,7 @@ static inline bool _rule_applies_to_media(const css_rule *rule, uint64_t media) while (ancestor != NULL) { const css_rule_media *m = (const css_rule_media *) ancestor; - if (ancestor->type == CSS_RULE_MEDIA && + if (ancestor->type == CSS_RULE_MEDIA && (m->media & media) == 0) { applies = false; break; @@ -1917,7 +1917,7 @@ static css_error _select_font_face_from_rule( if (lwc_string_isequal( rule->font_face->font_family, - state->font_family, + state->font_family, &correct_family) == lwc_error_ok && correct_family) { css_select_font_faces_list *faces = NULL; @@ -1936,16 +1936,16 @@ static css_error _select_font_face_from_rule( faces = &state->author_font_faces; break; } - - index = faces->count++; + + index = faces->count++; new_size = faces->count * sizeof(css_font_face *); - + new_faces = realloc(faces->font_faces, new_size); if (new_faces == NULL) { return CSS_NOMEM; } faces->font_faces = new_faces; - + faces->font_faces[index] = rule->font_face; } } @@ -1954,35 +1954,35 @@ static css_error _select_font_face_from_rule( } static css_error select_font_faces_from_sheet( - const css_stylesheet *sheet, - css_origin origin, + const css_stylesheet *sheet, + css_origin origin, css_select_font_faces_state *state) { const css_stylesheet *s = sheet; const css_rule *rule = s->rule_list; uint32_t sp = 0; const css_rule *import_stack[IMPORT_STACK_SIZE]; - + do { /* Find first non-charset rule, if we're at the list head */ if (rule == s->rule_list) { while (rule != NULL && rule->type == CSS_RULE_CHARSET) rule = rule->next; } - + if (rule != NULL && rule->type == CSS_RULE_IMPORT) { /* Current rule is an import */ - const css_rule_import *import = + const css_rule_import *import = (const css_rule_import *) rule; - + if (import->sheet != NULL && (import->media & state->media) != 0) { /* It's applicable, so process it */ if (sp >= IMPORT_STACK_SIZE) return CSS_NOMEM; - + import_stack[sp++] = rule; - + s = import->sheet; rule = s->rule_list; } else { @@ -1991,15 +1991,15 @@ static css_error select_font_faces_from_sheet( } } else if (rule != NULL && rule->type == CSS_RULE_FONT_FACE) { css_error error; - + error = _select_font_face_from_rule( (const css_rule_font_face *) rule, origin, state); - + if (error != CSS_OK) return error; - + rule = rule->next; } else if (rule == NULL) { /* Find next sheet to process */ @@ -2014,7 +2014,7 @@ static css_error select_font_faces_from_sheet( rule = rule->next; } } while (s != NULL); - + return CSS_OK; } @@ -2039,7 +2039,7 @@ static inline bool _selectors_pending(const css_selector **node, return pending; } -static inline bool _selector_less_specific(const css_selector *ref, +static inline bool _selector_less_specific(const css_selector *ref, const css_selector *cand) { bool result = true; @@ -2103,7 +2103,7 @@ static const css_selector *_selector_next(const css_selector **node, return ret; } -css_error match_selectors_in_sheet(css_select_ctx *ctx, +css_error match_selectors_in_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, css_select_state *state) { static const css_selector *empty_selector = NULL; @@ -2128,7 +2128,7 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, /* Find hash chain that applies to current node */ req.qname = state->element; - error = css__selector_hash_find(sheet->selectors, + error = css__selector_hash_find(sheet->selectors, &req, &node_iterator, &node_selectors); if (error != CSS_OK) @@ -2155,7 +2155,7 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, if (state->id != NULL) { /* Find hash chain for node ID */ req.id = state->id; - error = css__selector_hash_find_by_id(sheet->selectors, + error = css__selector_hash_find_by_id(sheet->selectors, &req, &id_iterator, &id_selectors); if (error != CSS_OK) goto cleanup; @@ -2168,7 +2168,7 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, goto cleanup; /* Process matching selectors, if any */ - while (_selectors_pending(node_selectors, id_selectors, + while (_selectors_pending(node_selectors, id_selectors, class_selectors, n_classes, univ_selectors)) { const css_selector *selector; @@ -2190,7 +2190,7 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, if (error != CSS_OK) goto cleanup; - /* Advance to next selector in whichever chain we extracted + /* Advance to next selector in whichever chain we extracted * the processed selector from. */ switch (src.source) { case CSS_SELECT_RULE_SRC_ELEMENT: @@ -2227,7 +2227,7 @@ cleanup: return error; } -static void update_reject_cache(css_select_state *state, +static void update_reject_cache(css_select_state *state, css_combinator comb, const css_selector *s) { const css_selector_detail *detail = &s->data; @@ -2250,7 +2250,7 @@ static void update_reject_cache(css_select_state *state, state->next_reject--; } -css_error match_selector_chain(css_select_ctx *ctx, +css_error match_selector_chain(css_select_ctx *ctx, const css_selector *selector, css_select_state *state) { const css_selector *s = selector; @@ -2267,11 +2267,11 @@ css_error match_selector_chain(css_select_ctx *ctx, fprintf(stderr, "\n"); #endif - /* Match the details of the first selector in the chain. + /* Match the details of the first selector in the chain. * * Note that pseudo elements will only appear as details of * the first selector in the chain, as the parser will reject - * any selector chains containing pseudo elements anywhere + * any selector chains containing pseudo elements anywhere * else. */ error = match_details(ctx, node, detail, state, &match, &pseudo); @@ -2288,14 +2288,14 @@ css_error match_selector_chain(css_select_ctx *ctx, /* Consider any combinator on this selector */ if (s->data.comb != CSS_COMBINATOR_NONE && - s->combinator->data.qname.name != + s->combinator->data.qname.name != ctx->universal) { /* Named combinator */ - may_optimise &= - (s->data.comb == CSS_COMBINATOR_ANCESTOR || + may_optimise &= + (s->data.comb == CSS_COMBINATOR_ANCESTOR || s->data.comb == CSS_COMBINATOR_PARENT); - error = match_named_combinator(ctx, s->data.comb, + error = match_named_combinator(ctx, s->data.comb, s->combinator, state, node, &next_node); if (error != CSS_OK) return error; @@ -2305,12 +2305,12 @@ css_error match_selector_chain(css_select_ctx *ctx, return CSS_OK; } else if (s->data.comb != CSS_COMBINATOR_NONE) { /* Universal combinator */ - may_optimise &= - (s->data.comb == CSS_COMBINATOR_ANCESTOR || + may_optimise &= + (s->data.comb == CSS_COMBINATOR_ANCESTOR || s->data.comb == CSS_COMBINATOR_PARENT); - error = match_universal_combinator(ctx, s->data.comb, - s->combinator, state, node, + error = match_universal_combinator(ctx, s->data.comb, + s->combinator, state, node, may_optimise, &rejected_by_cache, &next_node); if (error != CSS_OK) @@ -2339,7 +2339,7 @@ css_error match_selector_chain(css_select_ctx *ctx, /* Ensure that the appropriate computed style exists */ if (state->results->styles[pseudo] == NULL) { error = css__computed_style_create( - &state->results->styles[pseudo]); + &state->results->styles[pseudo]); if (error != CSS_OK) return error; } @@ -2347,12 +2347,12 @@ css_error match_selector_chain(css_select_ctx *ctx, state->current_pseudo = pseudo; state->computed = state->results->styles[pseudo]; - return cascade_style(((css_rule_selector *) selector->rule)->style, + return cascade_style(((css_rule_selector *) selector->rule)->style, state); } css_error match_named_combinator(css_select_ctx *ctx, css_combinator type, - const css_selector *selector, css_select_state *state, + const css_selector *selector, css_select_state *state, void *node, void **next_node) { const css_selector_detail *detail = &selector->data; @@ -2365,19 +2365,19 @@ css_error match_named_combinator(css_select_ctx *ctx, css_combinator type, /* Find candidate node */ switch (type) { case CSS_COMBINATOR_ANCESTOR: - error = state->handler->named_ancestor_node(state->pw, + error = state->handler->named_ancestor_node(state->pw, n, &selector->data.qname, &n); if (error != CSS_OK) return error; break; case CSS_COMBINATOR_PARENT: - error = state->handler->named_parent_node(state->pw, + error = state->handler->named_parent_node(state->pw, n, &selector->data.qname, &n); if (error != CSS_OK) return error; break; case CSS_COMBINATOR_SIBLING: - error = state->handler->named_sibling_node(state->pw, + error = state->handler->named_sibling_node(state->pw, n, &selector->data.qname, &n); if (error != CSS_OK) return error; @@ -2402,7 +2402,7 @@ css_error match_named_combinator(css_select_ctx *ctx, css_combinator type, if (n != NULL) { /* Match its details */ - error = match_details(ctx, n, detail, state, + error = match_details(ctx, n, detail, state, &match, NULL); if (error != CSS_OK) return error; @@ -2411,8 +2411,8 @@ css_error match_named_combinator(css_select_ctx *ctx, css_combinator type, if (match == true) break; - /* For parent and sibling selectors, only adjacent - * nodes are valid. Thus, if we failed to match, + /* For parent and sibling selectors, only adjacent + * nodes are valid. Thus, if we failed to match, * give up. */ if (type == CSS_COMBINATOR_PARENT || type == CSS_COMBINATOR_SIBLING) @@ -2453,10 +2453,10 @@ css_error match_universal_combinator(css_select_ctx *ctx, css_combinator type, *rejected_by_cache = false; /* Consult reject cache first */ - if (may_optimise && (type == CSS_COMBINATOR_ANCESTOR || - type == CSS_COMBINATOR_PARENT) && + if (may_optimise && (type == CSS_COMBINATOR_ANCESTOR || + type == CSS_COMBINATOR_PARENT) && next_detail != NULL && - (next_detail->type == CSS_SELECTOR_CLASS || + (next_detail->type == CSS_SELECTOR_CLASS || next_detail->type == CSS_SELECTOR_ID)) { reject_item *reject = state->next_reject + 1; reject_item *last = state->reject_cache + @@ -2466,8 +2466,8 @@ css_error match_universal_combinator(css_select_ctx *ctx, css_combinator type, while (reject <= last) { /* Perform pessimistic matching (may hurt quirks) */ if (reject->type == next_detail->type && - lwc_string_isequal(reject->value, - next_detail->qname.name, + lwc_string_isequal(reject->value, + next_detail->qname.name, &match) == lwc_error_ok && match) { /* Found it: can't match */ @@ -2505,7 +2505,7 @@ css_error match_universal_combinator(css_select_ctx *ctx, css_combinator type, if (n != NULL) { /* Match its details */ - error = match_details(ctx, n, detail, state, + error = match_details(ctx, n, detail, state, &match, NULL); if (error != CSS_OK) return error; @@ -2528,8 +2528,8 @@ css_error match_universal_combinator(css_select_ctx *ctx, css_combinator type, return CSS_OK; } -css_error match_details(css_select_ctx *ctx, void *node, - const css_selector_detail *detail, css_select_state *state, +css_error match_details(css_select_ctx *ctx, void *node, + const css_selector_detail *detail, css_select_state *state, bool *match, css_pseudo_element *pseudo_element) { css_error error; @@ -2547,10 +2547,10 @@ css_error match_details(css_select_ctx *ctx, void *node, * selector, then we must match) */ *match = true; - /** \todo Some details are easier to test than others (e.g. dashmatch - * actually requires looking at data rather than simply comparing - * pointers). Should we consider sorting the detail list such that the - * simpler details come first (and thus the expensive match routines + /** \todo Some details are easier to test than others (e.g. dashmatch + * actually requires looking at data rather than simply comparing + * pointers). Should we consider sorting the detail list such that the + * simpler details come first (and thus the expensive match routines * can be avoided unless absolutely necessary)? */ while (detail != NULL) { @@ -2592,8 +2592,8 @@ static inline bool match_nth(int32_t a, int32_t b, int32_t count) } } -css_error match_detail(css_select_ctx *ctx, void *node, - const css_selector_detail *detail, css_select_state *state, +css_error match_detail(css_select_ctx *ctx, void *node, + const css_selector_detail *detail, css_select_state *state, bool *match, css_pseudo_element *pseudo_element) { bool is_root = false; @@ -2623,19 +2623,19 @@ css_error match_detail(css_select_ctx *ctx, void *node, if (error != CSS_OK) return error; - if (is_root == false && + if (is_root == false && detail->qname.name == ctx->first_child) { int32_t num_before = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, false, false, &num_before); if (error == CSS_OK) *match = (num_before == 0); - } else if (is_root == false && + } else if (is_root == false && detail->qname.name == ctx->nth_child) { int32_t num_before = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, false, false, &num_before); if (error == CSS_OK) { int32_t a = detail->value.nth.a; @@ -2643,11 +2643,11 @@ css_error match_detail(css_select_ctx *ctx, void *node, *match = match_nth(a, b, num_before + 1); } - } else if (is_root == false && + } else if (is_root == false && detail->qname.name == ctx->nth_last_child) { int32_t num_after = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, false, true, &num_after); if (error == CSS_OK) { int32_t a = detail->value.nth.a; @@ -2655,11 +2655,11 @@ css_error match_detail(css_select_ctx *ctx, void *node, *match = match_nth(a, b, num_after + 1); } - } else if (is_root == false && + } else if (is_root == false && detail->qname.name == ctx->nth_of_type) { int32_t num_before = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, true, false, &num_before); if (error == CSS_OK) { int32_t a = detail->value.nth.a; @@ -2667,11 +2667,11 @@ css_error match_detail(css_select_ctx *ctx, void *node, *match = match_nth(a, b, num_before + 1); } - } else if (is_root == false && + } else if (is_root == false && detail->qname.name == ctx->nth_last_of_type) { int32_t num_after = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, true, true, &num_after); if (error == CSS_OK) { int32_t a = detail->value.nth.a; @@ -2691,7 +2691,7 @@ css_error match_detail(css_select_ctx *ctx, void *node, detail->qname.name == ctx->first_of_type) { int32_t num_before = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, true, false, &num_before); if (error == CSS_OK) *match = (num_before == 0); @@ -2699,36 +2699,36 @@ css_error match_detail(css_select_ctx *ctx, void *node, detail->qname.name == ctx->last_of_type) { int32_t num_after = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, true, true, &num_after); if (error == CSS_OK) *match = (num_after == 0); - } else if (is_root == false && + } else if (is_root == false && detail->qname.name == ctx->only_child) { int32_t num_before = 0, num_after = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, false, false, &num_before); if (error == CSS_OK) { error = state->handler->node_count_siblings( state->pw, node, false, true, &num_after); if (error == CSS_OK) - *match = (num_before == 0) && + *match = (num_before == 0) && (num_after == 0); } - } else if (is_root == false && + } else if (is_root == false && detail->qname.name == ctx->only_of_type) { int32_t num_before = 0, num_after = 0; - error = state->handler->node_count_siblings(state->pw, + error = state->handler->node_count_siblings(state->pw, node, true, false, &num_before); if (error == CSS_OK) { error = state->handler->node_count_siblings( state->pw, node, true, true, &num_after); if (error == CSS_OK) - *match = (num_before == 0) && + *match = (num_before == 0) && (num_after == 0); } } else if (detail->qname.name == ctx->root) { @@ -2796,8 +2796,8 @@ css_error match_detail(css_select_ctx *ctx, void *node, add_node_flags(node, state, CSS_NODE_FLAGS_TAINT_ATTRIBUTE); break; case CSS_SELECTOR_ATTRIBUTE_EQUAL: - error = state->handler->node_has_attribute_equal(state->pw, - node, &detail->qname, detail->value.string, + error = state->handler->node_has_attribute_equal(state->pw, + node, &detail->qname, detail->value.string, match); add_node_flags(node, state, CSS_NODE_FLAGS_TAINT_ATTRIBUTE); break; @@ -2808,7 +2808,7 @@ css_error match_detail(css_select_ctx *ctx, void *node, add_node_flags(node, state, CSS_NODE_FLAGS_TAINT_ATTRIBUTE); break; case CSS_SELECTOR_ATTRIBUTE_INCLUDES: - error = state->handler->node_has_attribute_includes(state->pw, + error = state->handler->node_has_attribute_includes(state->pw, node, &detail->qname, detail->value.string, match); add_node_flags(node, state, CSS_NODE_FLAGS_TAINT_ATTRIBUTE); @@ -2868,7 +2868,7 @@ bool css__outranks_existing(uint16_t op, bool important, css_select_state *state bool outranks = false; /* Sorting on origin & importance gives the following: - * + * * | UA, - | UA, i | USER, - | USER, i | AUTHOR, - | AUTHOR, i * |---------------------------------------------------------- * UA , - | S S Y Y Y Y @@ -2878,8 +2878,8 @@ bool css__outranks_existing(uint16_t op, bool important, css_select_state *state * AUTHOR, - | - - - Y S Y * AUTHOR, i | - - - Y - S * - * Where the columns represent the origin/importance of the property - * being considered and the rows represent the origin/importance of + * Where the columns represent the origin/importance of the property + * being considered and the rows represent the origin/importance of * the existing property. * * - means that the existing property must be preserved @@ -2893,12 +2893,12 @@ bool css__outranks_existing(uint16_t op, bool important, css_select_state *state * the specificities are the same because: * * a) We process stylesheets in order - * b) The selector hash chains within a sheet are ordered such that + * b) The selector hash chains within a sheet are ordered such that * more specific rules come after less specific ones and, when * specificities are identical, rules defined later occur after * those defined earlier. * - * Therefore, where we consider specificity, below, the property + * Therefore, where we consider specificity, below, the property * currently being considered will always be applied if its specificity * is greater than or equal to that of the existing property. */ @@ -2912,15 +2912,15 @@ bool css__outranks_existing(uint16_t op, bool important, css_select_state *state if (existing->origin < state->current_origin) { /* New origin has more weight than existing one. - * Thus, new property wins, except when the existing + * Thus, new property wins, except when the existing * one is USER, i. */ if (existing->important == 0 || existing->origin != CSS_ORIGIN_USER) { outranks = true; } } else if (existing->origin == state->current_origin) { - /* Origins are identical, consider importance, except - * for UA stylesheets, when specificity is always + /* Origins are identical, consider importance, except + * for UA stylesheets, when specificity is always * considered (as importance is meaningless) */ if (existing->origin == CSS_ORIGIN_UA) { if (state->current_specificity >= @@ -2984,7 +2984,7 @@ void dump_chain(const css_selector *selector) do { switch (detail->type) { case CSS_SELECTOR_ELEMENT: - if (lwc_string_length(detail->name) == 1 && + if (lwc_string_length(detail->name) == 1 && lwc_string_data(detail->name)[0] == '*' && detail->next == 1) { break; diff --git a/src/stylesheet.c b/src/stylesheet.c index 0a281e7..7c6728b 100644 --- a/src/stylesheet.c +++ b/src/stylesheet.c @@ -39,33 +39,33 @@ css_error css__stylesheet_string_add(css_stylesheet *sheet, lwc_string *string, uint32_t new_string_number; /* The string number count */ /* search for the string in the existing vector */ - for (new_string_number = 0; + for (new_string_number = 0; new_string_number < sheet->string_vector_c; new_string_number++) { lwc_error res; bool isequal; - res = lwc_string_isequal(string, - sheet->string_vector[new_string_number], + res = lwc_string_isequal(string, + sheet->string_vector[new_string_number], &isequal); if (res != lwc_error_ok) { - lwc_string_unref(string); + lwc_string_unref(string); return css_error_from_lwc_error(res); } if (isequal) { - lwc_string_unref(string); + lwc_string_unref(string); *string_number = (new_string_number + 1); return CSS_OK; } - + } /* string does not exist in current vector, add a new one */ if (sheet->string_vector_c >= sheet->string_vector_l) { /* additional storage must be allocated to deal with - * this request. + * this request. */ lwc_string **new_vector; uint32_t new_vector_len; @@ -75,7 +75,7 @@ css_error css__stylesheet_string_add(css_stylesheet *sheet, lwc_string *string, new_vector_len * sizeof(lwc_string *)); if (new_vector == NULL) { - lwc_string_unref(string); + lwc_string_unref(string); return CSS_NOMEM; } sheet->string_vector = new_vector; @@ -128,7 +128,7 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, css_error error; css_stylesheet *sheet; - if (params == NULL || params->params_version != + if (params == NULL || params->params_version != CSS_STYLESHEET_PARAMS_VERSION_1 || params->url == NULL || params->resolve == NULL || stylesheet == NULL) @@ -143,11 +143,11 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, free(sheet); return error; } - + sheet->inline_style = params->inline_style; if (params->inline_style) { - error = css__parser_create_for_inline_style(params->charset, + error = css__parser_create_for_inline_style(params->charset, (params->charset != NULL) ? CSS_CHARSET_DICTATED : CSS_CHARSET_DEFAULT, &sheet->parser); @@ -255,12 +255,12 @@ css_error css_stylesheet_destroy(css_stylesheet *sheet) if (sheet == NULL) return CSS_BADPARM; - + if (sheet->title != NULL) free(sheet->title); free(sheet->url); - + for (r = sheet->rule_list; r != NULL; r = s) { s = r->next; @@ -286,14 +286,14 @@ css_error css_stylesheet_destroy(css_stylesheet *sheet) /* destroy string vector */ for (index = 0; index < sheet->string_vector_c; index++) { - lwc_string_unref(sheet->string_vector[index]); + lwc_string_unref(sheet->string_vector[index]); } if (sheet->string_vector != NULL) free(sheet->string_vector); css__propstrings_unref(); - + free(sheet); return CSS_OK; @@ -348,7 +348,7 @@ css_error css_stylesheet_data_done(css_stylesheet *sheet) sheet->parser_frontend = NULL; sheet->parser = NULL; - + /* If we have a cached style, drop it as we're done parsing. */ if (sheet->cached_style != NULL) { css__stylesheet_style_destroy(sheet->cached_style); @@ -375,7 +375,7 @@ 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 + * \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, @@ -427,7 +427,7 @@ css_error css_stylesheet_next_pending_import(css_stylesheet *parent, * * \param parent Parent stylesheet * \param import Imported sheet - * \return CSS_OK on success, + * \return CSS_OK on success, * CSS_INVALID if there are no outstanding imports, * appropriate error otherwise. * @@ -612,7 +612,7 @@ css_error css_stylesheet_size(css_stylesheet *sheet, size_t *size) bytes += hash_size; } - + *size = bytes; return CSS_OK; @@ -643,13 +643,13 @@ css_error css__stylesheet_style_create(css_stylesheet *sheet, css_style **style) if (sheet == NULL) return CSS_BADPARM; - + if (sheet->cached_style != NULL) { *style = sheet->cached_style; sheet->cached_style = NULL; return CSS_OK; } - + s = malloc(sizeof(css_style)); if (s == NULL) return CSS_NOMEM; @@ -658,7 +658,7 @@ css_error css__stylesheet_style_create(css_stylesheet *sheet, css_style **style) if (s->bytecode == NULL) { free(s); /* do not leak */ - + return CSS_NOMEM; } s->allocated = CSS_STYLE_DEFAULT_SIZE; @@ -679,7 +679,7 @@ css_error css__stylesheet_merge_style(css_style *target, css_style *style) return CSS_BADPARM; newcode_len = target->used + style->used ; - + if (newcode_len > target->allocated) { newcode_len += CSS_STYLE_DEFAULT_SIZE - 1; newcode_len &= ~(CSS_STYLE_DEFAULT_SIZE - 1); @@ -702,7 +702,7 @@ css_error css__stylesheet_merge_style(css_style *target, css_style *style) } -/** append one or more css code entries to a style */ +/** append one or more css code entries to a style */ css_error css__stylesheet_style_vappend(css_style *style, uint32_t style_count, ...) { va_list ap; @@ -721,7 +721,7 @@ css_error css__stylesheet_style_vappend(css_style *style, uint32_t style_count, return error; } -/** append a css code entry to a style */ +/** append a css code entry to a style */ css_error css__stylesheet_style_append(css_style *style, css_code_t css_code) { if (style == NULL) @@ -755,7 +755,7 @@ css_error css__stylesheet_style_append(css_style *style, css_code_t css_code) css_error css__stylesheet_style_destroy(css_style *style) { css_stylesheet *sheet; - + if (style == NULL) return CSS_BADPARM; @@ -773,7 +773,7 @@ css_error css__stylesheet_style_destroy(css_style *style) free(style->bytecode); free(style); } - + return CSS_OK; } @@ -792,7 +792,7 @@ css_error css__stylesheet_selector_create(css_stylesheet *sheet, { css_selector *sel; - if (sheet == NULL || qname == NULL || qname->name == NULL || + if (sheet == NULL || qname == NULL || qname->name == NULL || selector == NULL) return CSS_BADPARM; @@ -815,7 +815,7 @@ css_error css__stylesheet_selector_create(css_stylesheet *sheet, sel->specificity = CSS_SPECIFICITY_A; } else { /* Initial specificity -- 1 for an element, 0 for universal */ - if (lwc_string_length(qname->name) != 1 || + if (lwc_string_length(qname->name) != 1 || lwc_string_data(qname->name)[0] != '*') sel->specificity = CSS_SPECIFICITY_D; else @@ -857,8 +857,8 @@ css_error css__stylesheet_selector_destroy(css_stylesheet *sheet, lwc_string_unref(detail->qname.ns); lwc_string_unref(detail->qname.name); - if (detail->value_type == - CSS_SELECTOR_DETAIL_VALUE_STRING && + if (detail->value_type == + CSS_SELECTOR_DETAIL_VALUE_STRING && detail->value.string != NULL) { lwc_string_unref(detail->value.string); } @@ -868,16 +868,16 @@ css_error css__stylesheet_selector_destroy(css_stylesheet *sheet, else detail = NULL; } - + free(c); } - + for (detail = &selector->data; detail;) { if (detail->qname.ns != NULL) lwc_string_unref(detail->qname.ns); lwc_string_unref(detail->qname.name); - if (detail->value_type == CSS_SELECTOR_DETAIL_VALUE_STRING && + if (detail->value_type == CSS_SELECTOR_DETAIL_VALUE_STRING && detail->value.string != NULL) { lwc_string_unref(detail->value.string); } @@ -887,8 +887,8 @@ css_error css__stylesheet_selector_destroy(css_stylesheet *sheet, else detail = NULL; } - - + + /* Destroy this selector */ free(selector); @@ -908,16 +908,16 @@ css_error css__stylesheet_selector_destroy(css_stylesheet *sheet, * \return CSS_OK on success, * CSS_BADPARM on bad parameters * - * \note No strings are referenced at this point: they will be + * \note No strings are referenced at this point: they will be * referenced when appending the detail to a selector. */ css_error css__stylesheet_selector_detail_init(css_stylesheet *sheet, - css_selector_type type, css_qname *qname, - css_selector_detail_value value, + css_selector_type type, css_qname *qname, + css_selector_detail_value value, css_selector_detail_value_type value_type, bool negate, css_selector_detail *detail) { - if (sheet == NULL || qname == NULL || qname->name == NULL || + if (sheet == NULL || qname == NULL || qname->name == NULL || detail == NULL) return CSS_BADPARM; @@ -947,11 +947,11 @@ css_error css__stylesheet_selector_append_specific(css_stylesheet *sheet, css_selector_detail *d; size_t num_details = 0; - if (sheet == NULL || parent == NULL || + if (sheet == NULL || parent == NULL || *parent == NULL || detail == NULL) return CSS_BADPARM; - /** \todo this may want optimising -- counting blocks is O(n) + /** \todo this may want optimising -- counting blocks is O(n) * In practice, however, n isn't likely to be large, so may be fine */ @@ -969,7 +969,7 @@ css_error css__stylesheet_selector_append_specific(css_stylesheet *sheet, *(d = &(&temp->data)[num_details + 1]) = *detail; /* Flag that there's another block */ (&temp->data)[num_details].next = 1; - + /* Ref the strings */ if (detail->qname.ns != NULL) d->qname.ns = lwc_string_ref(detail->qname.ns); @@ -977,7 +977,7 @@ css_error css__stylesheet_selector_append_specific(css_stylesheet *sheet, if (detail->value_type == CSS_SELECTOR_DETAIL_VALUE_STRING && detail->value.string != NULL) d->value.string = lwc_string_ref(detail->value.string); - + (*parent) = temp; /* Update parent's specificity */ @@ -1014,7 +1014,7 @@ css_error css__stylesheet_selector_append_specific(css_stylesheet *sheet, * \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, + * For example, given A + B, the combinator field of B would point at A, * with a combinator type of CSS_COMBINATOR_SIBLING. Thus, given B, we can * find its combinator. It is not possible to find B given A. */ @@ -1115,7 +1115,7 @@ css_error css__stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule) return CSS_BADPARM; /* Must be detached from parent/siblings */ - assert(rule->parent == NULL && rule->next == NULL && + assert(rule->parent == NULL && rule->next == NULL && rule->prev == NULL); /* Destroy type-specific contents */ @@ -1152,9 +1152,9 @@ css_error css__stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule) case CSS_RULE_IMPORT: { css_rule_import *import = (css_rule_import *) rule; - + lwc_string_unref(import->url); - + /* Do not destroy imported sheet: it is owned by the client */ } break; @@ -1212,7 +1212,7 @@ css_error css__stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule) * \param selector The selector to add * \return CSS_OK on success, appropriate error otherwise */ -css_error css__stylesheet_rule_add_selector(css_stylesheet *sheet, +css_error css__stylesheet_rule_add_selector(css_stylesheet *sheet, css_rule *rule, css_selector *selector) { css_rule_selector *r = (css_rule_selector *) rule; @@ -1236,7 +1236,7 @@ css_error css__stylesheet_rule_add_selector(css_stylesheet *sheet, /* Set selector's rule field */ selector->rule = rule; - + return CSS_OK; } @@ -1310,7 +1310,7 @@ css_error css__stylesheet_rule_set_charset(css_stylesheet *sheet, /* Set rule's encoding field */ r->encoding = lwc_string_ref(charset); - + return CSS_OK; } @@ -1325,7 +1325,7 @@ css_error css__stylesheet_rule_set_charset(css_stylesheet *sheet, * \return CSS_OK on success, appropriate error otherwise */ css_error css__stylesheet_rule_set_nascent_import(css_stylesheet *sheet, - css_rule *rule, lwc_string *url, + css_rule *rule, lwc_string *url, uint64_t media) { css_rule_import *r = (css_rule_import *) rule; @@ -1505,9 +1505,9 @@ css_error css__stylesheet_remove_rule(css_stylesheet *sheet, css_rule *rule) rule->prev = NULL; rule->next = NULL; - /**\ todo renumber subsequent rules? may not be necessary, as there's - * only an expectation that rules which occur later in the stylesheet - * have a higher index than those that appear earlier. There's no + /**\ todo renumber subsequent rules? may not be necessary, as there's + * only an expectation that rules which occur later in the stylesheet + * have a higher index than those that appear earlier. There's no * guarantee that the number space is continuous. */ /** \todo needs to trigger some event announcing styles have changed */ @@ -1556,7 +1556,7 @@ css_error _add_selectors(css_stylesheet *sheet, css_rule *rule) css__selector_hash_remove( sheet->selectors, sel); } - + return error; } } @@ -1705,7 +1705,7 @@ size_t _rule_size(const css_rule *r) d++; } - s = s->combinator; + s = s->combinator; } if (rp->style != NULL) diff --git a/src/stylesheet.h b/src/stylesheet.h index a2b3fd5..18e077e 100644 --- a/src/stylesheet.h +++ b/src/stylesheet.h @@ -74,7 +74,7 @@ typedef struct css_selector_detail { unsigned int type : 4, /**< Type of selector */ comb : 3, /**< Type of combinator */ - next : 1, /**< Another selector detail + next : 1, /**< Another selector detail * follows */ value_type : 1, /**< Type of value field */ negate : 1; /**< Detail match is inverted */ @@ -110,7 +110,7 @@ typedef enum css_rule_parent_type { } css_rule_parent_type; struct css_rule { - void *parent; /**< containing rule or owning + void *parent; /**< containing rule or owning * stylesheet (defined by ptype) */ css_rule *next; /**< next in list */ @@ -173,7 +173,7 @@ struct css_stylesheet { css_rule *rule_list; /**< List of rules in sheet */ css_rule *last_rule; /**< Last rule in list */ - bool disabled; /**< Whether this sheet is + bool disabled; /**< Whether this sheet is * disabled */ char *url; /**< URL of this sheet */ @@ -201,19 +201,19 @@ struct css_stylesheet { void *color_pw; /**< Private word */ /** System font resolution function */ - css_font_resolution_fn font; + css_font_resolution_fn font; void *font_pw; /**< Private word */ - + css_style *cached_style; /**< Cache for style parsing */ - + lwc_string **string_vector; /**< Bytecode string vector */ uint32_t string_vector_l; /**< The string vector allocated * length in entries */ - uint32_t string_vector_c; /**< The number of string - * vector entries used */ + uint32_t string_vector_c; /**< The number of string + * vector entries used */ }; -css_error css__stylesheet_style_create(css_stylesheet *sheet, +css_error css__stylesheet_style_create(css_stylesheet *sheet, css_style **style); css_error css__stylesheet_style_append(css_style *style, css_code_t code); css_error css__stylesheet_style_vappend(css_style *style, uint32_t style_count, @@ -221,19 +221,19 @@ css_error css__stylesheet_style_vappend(css_style *style, uint32_t style_count, css_error css__stylesheet_style_destroy(css_style *style); css_error css__stylesheet_merge_style(css_style *target, css_style *style); -/** Helper function to avoid distinct buildOPV call */ -static inline css_error css__stylesheet_style_appendOPV(css_style *style, +/** Helper function to avoid distinct buildOPV call */ +static inline css_error css__stylesheet_style_appendOPV(css_style *style, opcode_t opcode, uint8_t flags, uint16_t value) { - return css__stylesheet_style_append(style, + return css__stylesheet_style_append(style, buildOPV(opcode, flags, value)); } -/** Helper function to set inherit flag */ -static inline css_error css_stylesheet_style_inherit(css_style *style, +/** Helper function to set inherit flag */ +static inline css_error css_stylesheet_style_inherit(css_style *style, opcode_t opcode) { - return css__stylesheet_style_append(style, + return css__stylesheet_style_append(style, buildOPV(opcode, FLAG_INHERIT, 0)); } @@ -244,7 +244,7 @@ css_error css__stylesheet_selector_destroy(css_stylesheet *sheet, css_error css__stylesheet_selector_detail_init(css_stylesheet *sheet, css_selector_type type, css_qname *qname, - css_selector_detail_value value, + css_selector_detail_value value, css_selector_detail_value_type value_type, bool negate, css_selector_detail *detail); @@ -258,7 +258,7 @@ css_error css__stylesheet_rule_create(css_stylesheet *sheet, css_rule_type type, css_rule **rule); css_error css__stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule); -css_error css__stylesheet_rule_add_selector(css_stylesheet *sheet, +css_error css__stylesheet_rule_add_selector(css_stylesheet *sheet, css_rule *rule, css_selector *selector); css_error css__stylesheet_rule_append_style(css_stylesheet *sheet, @@ -280,10 +280,10 @@ css_error css__stylesheet_add_rule(css_stylesheet *sheet, css_rule *rule, css_rule *parent); css_error css__stylesheet_remove_rule(css_stylesheet *sheet, css_rule *rule); -css_error css__stylesheet_string_get(css_stylesheet *sheet, +css_error css__stylesheet_string_get(css_stylesheet *sheet, uint32_t string_number, lwc_string **string); -css_error css__stylesheet_string_add(css_stylesheet *sheet, +css_error css__stylesheet_string_add(css_stylesheet *sheet, lwc_string *string, uint32_t *string_number); #endif diff --git a/src/utils/parserutilserror.h b/src/utils/parserutilserror.h index d2cffb6..2243b06 100644 --- a/src/utils/parserutilserror.h +++ b/src/utils/parserutilserror.h @@ -14,7 +14,7 @@ /** * Convert a ParserUtils error into a LibCSS error - * + * * \param error The ParserUtils error to convert * \return The corresponding LibCSS error */ diff --git a/src/utils/utils.c b/src/utils/utils.c index 1745ea0..4bd93f6 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -10,7 +10,7 @@ css_fixed css__number_from_lwc_string(lwc_string *string, bool int_only, size_t *consumed) { - if (string == NULL || lwc_string_length(string) == 0 || + if (string == NULL || lwc_string_length(string) == 0 || consumed == NULL) return 0; @@ -77,7 +77,7 @@ css_fixed css__number_from_string(const uint8_t *data, size_t len, } /* And fracpart, again, assuming base 10 */ - if (int_only == false && len > 1 && ptr[0] == '.' && + if (int_only == false && len > 1 && ptr[0] == '.' && ('0' <= ptr[1] && ptr[1] <= '9')) { ptr++; len--; diff --git a/test/README b/test/README index f408e72..557adf9 100644 --- a/test/README +++ b/test/README @@ -21,14 +21,14 @@ basis. Testcase output --------------- -Testcases may output anything at all to stdout. The final line of the -output must begin with either PASS or FAIL (case sensitive), indicating +Testcases may output anything at all to stdout. The final line of the +output must begin with either PASS or FAIL (case sensitive), indicating the success status of the test. Test Index ---------- -In the test sources directory, is a file, named INDEX, which provides an +In the test sources directory, is a file, named INDEX, which provides an index of all available test binaries. Any new test applications should be added to this index as they are created. @@ -49,20 +49,20 @@ The test index file format is as follows: non-newline = VCHAR / WSP non-reserved = VCHAR / SP -Each entry contains a mandatory binary name and description followed by -an optional data directory specifier. The data directory specifier is -used to state the name of the directory containing data files for the -test name. This directory will be searched for within the "data" -directory in the source tree. +Each entry contains a mandatory binary name and description followed by +an optional data directory specifier. The data directory specifier is +used to state the name of the directory containing data files for the +test name. This directory will be searched for within the "data" +directory in the source tree. If a data directory is specified, the test binary will be invoked for -each data file listed within the data directory INDEX, passing the +each data file listed within the data directory INDEX, passing the filename as the second parameter (<data_file>, above). Data Index ---------- -Each test data directory contains a file, named INDEX, which provides an +Each test data directory contains a file, named INDEX, which provides an index of all available test data files. The data index file format is as follows: diff --git a/test/css21.c b/test/css21.c index cc9acab..a29fae1 100644 --- a/test/css21.c +++ b/test/css21.c @@ -75,7 +75,7 @@ int main(int argc, char **argv) size_t read = fread(buf, 1, CHUNK_SIZE, fp); assert(read == CHUNK_SIZE); - error = css_stylesheet_append_data(sheet, buf, + error = css_stylesheet_append_data(sheet, buf, CHUNK_SIZE); assert(error == CSS_OK || error == CSS_NEEDDATA); @@ -109,7 +109,7 @@ int main(int argc, char **argv) css_stylesheet *import; char *buf = malloc(lwc_string_length(url) + 1); - memcpy(buf, lwc_string_data(url), + memcpy(buf, lwc_string_data(url), lwc_string_length(url)); buf[lwc_string_length(url)] = '\0'; @@ -118,7 +118,7 @@ int main(int argc, char **argv) assert(css_stylesheet_create(¶ms, &import) == CSS_OK); - assert(css_stylesheet_data_done(import) == + assert(css_stylesheet_data_done(import) == CSS_OK); assert(css_stylesheet_register_import(sheet, @@ -154,7 +154,7 @@ int main(int argc, char **argv) } printf("PASS\n"); - + return 0; } diff --git a/test/dump.h b/test/dump.h index 872c850..0159b19 100644 --- a/test/dump.h +++ b/test/dump.h @@ -13,13 +13,13 @@ #include "testutils.h" static void dump_sheet(css_stylesheet *sheet, char *buf, size_t *len); -static void dump_rule_selector(css_rule_selector *s, char **buf, +static void dump_rule_selector(css_rule_selector *s, char **buf, size_t *buflen, uint32_t depth); static void dump_rule_charset(css_rule_charset *s, char **buf, size_t *buflen); static void dump_rule_import(css_rule_import *s, char **buf, size_t *buflen); static void dump_rule_media(css_rule_media *s, char **buf, size_t *buflen); static void dump_rule_page(css_rule_page *s, char **buf, size_t *buflen); -static void dump_rule_font_face(css_rule_font_face *s, +static void dump_rule_font_face(css_rule_font_face *s, char **buf, size_t *buflen); static void dump_selector_list(css_selector *list, char **ptr); static void dump_selector(css_selector *selector, char **ptr); @@ -35,15 +35,15 @@ void dump_sheet(css_stylesheet *sheet, char *buf, size_t *buflen) for (rule = sheet->rule_list; rule != NULL; rule = rule->next) { switch (rule->type) { case CSS_RULE_SELECTOR: - dump_rule_selector((css_rule_selector *) rule, + dump_rule_selector((css_rule_selector *) rule, &buf, buflen, 1); break; case CSS_RULE_CHARSET: - dump_rule_charset((css_rule_charset *) rule, + dump_rule_charset((css_rule_charset *) rule, &buf, buflen); break; case CSS_RULE_IMPORT: - dump_rule_import((css_rule_import *) rule, + dump_rule_import((css_rule_import *) rule, &buf, buflen); break; case CSS_RULE_MEDIA: @@ -71,7 +71,7 @@ void dump_sheet(css_stylesheet *sheet, char *buf, size_t *buflen) } } -void dump_rule_selector(css_rule_selector *s, char **buf, size_t *buflen, +void dump_rule_selector(css_rule_selector *s, char **buf, size_t *buflen, uint32_t depth) { uint32_t i; @@ -115,7 +115,7 @@ void dump_rule_import(css_rule_import *s, char **buf, size_t *buflen) { char *ptr = *buf; - ptr += sprintf(ptr, "| @import url(\"%.*s\")", + ptr += sprintf(ptr, "| @import url(\"%.*s\")", (int) lwc_string_length(s->url), lwc_string_data(s->url)); /** \todo media list */ @@ -174,7 +174,7 @@ void dump_rule_font_face(css_rule_font_face *s, char **buf, size_t *buflen) if (s->font_face != NULL) { dump_font_face(s->font_face, &ptr); } - + *ptr++ = '\n'; *buflen -= ptr - *buf; @@ -233,7 +233,7 @@ void dump_selector_detail(css_selector_detail *detail, char **ptr) switch (detail->type) { case CSS_SELECTOR_ELEMENT: - if (lwc_string_length(detail->qname.name) == 1 && + if (lwc_string_length(detail->qname.name) == 1 && lwc_string_data(detail->qname.name)[0] == '*' && detail->next == 0) { dump_string(detail->qname.name, ptr); @@ -662,7 +662,7 @@ static void dump_counter(lwc_string *name, uint32_t value, static void dump_counters(lwc_string *name, lwc_string *separator, uint32_t value, char **ptr) { - *ptr += sprintf(*ptr, "counter(%.*s, %.*s", + *ptr += sprintf(*ptr, "counter(%.*s, %.*s", (int) lwc_string_length(name), lwc_string_data(name), (int) lwc_string_length(separator), @@ -748,7 +748,7 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) if (isInherit(opv)) { *ptr += sprintf(*ptr, "inherit"); - } else { + } else { value = getValue(opv); switch (op) { @@ -836,11 +836,11 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) break; case BACKGROUND_COLOR_SET: { - uint32_t colour = + uint32_t colour = *((uint32_t *) bytecode); ADVANCE(sizeof(colour)); *ptr += sprintf(*ptr, "#%08x", colour); - } + } break; } break; @@ -875,12 +875,12 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) { uint32_t snum = *((uint32_t *) bytecode); lwc_string *he; - css__stylesheet_string_get(style->sheet, - snum, + css__stylesheet_string_get(style->sheet, + snum, &he); ADVANCE(sizeof(snum)); - *ptr += sprintf(*ptr, "url('%.*s')", - (int) lwc_string_length(he), + *ptr += sprintf(*ptr, "url('%.*s')", + (int) lwc_string_length(he), lwc_string_data(he)); } break; @@ -1289,14 +1289,14 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) } break; case CSS_PROP_CLIP: - if ((value & CLIP_SHAPE_MASK) == + if ((value & CLIP_SHAPE_MASK) == CLIP_SHAPE_RECT) { *ptr += sprintf(*ptr, "rect("); if (value & CLIP_RECT_TOP_AUTO) { *ptr += sprintf(*ptr, "auto"); } else { uint32_t unit; - css_fixed val = + css_fixed val = *((css_fixed *) bytecode); ADVANCE(sizeof(val)); unit = *((uint32_t *) bytecode); @@ -1308,7 +1308,7 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) *ptr += sprintf(*ptr, "auto"); } else { uint32_t unit; - css_fixed val = + css_fixed val = *((css_fixed *) bytecode); ADVANCE(sizeof(val)); unit = *((uint32_t *) bytecode); @@ -1320,7 +1320,7 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) *ptr += sprintf(*ptr, "auto"); } else { uint32_t unit; - css_fixed val = + css_fixed val = *((css_fixed *) bytecode); ADVANCE(sizeof(val)); unit = *((uint32_t *) bytecode); @@ -1332,7 +1332,7 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) *ptr += sprintf(*ptr, "auto"); } else { uint32_t unit; - css_fixed val = + css_fixed val = *((css_fixed *) bytecode); ADVANCE(sizeof(val)); unit = *((uint32_t *) bytecode); @@ -1353,11 +1353,11 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) break; case COLOR_SET: { - uint32_t colour = + uint32_t colour = *((uint32_t *) bytecode); ADVANCE(sizeof(colour)); *ptr += sprintf(*ptr, "#%08x", colour); - } + } break; } break; @@ -1422,7 +1422,7 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) } while (value != CONTENT_NORMAL) { - uint32_t snum = *((uint32_t *) bytecode); + uint32_t snum = *((uint32_t *) bytecode); lwc_string *he; const char *end = ""; @@ -1448,10 +1448,10 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) break; case CONTENT_URI: - case CONTENT_ATTR: + case CONTENT_ATTR: case CONTENT_STRING: css__stylesheet_string_get(style->sheet, snum, &he); - if (value == CONTENT_URI) + if (value == CONTENT_URI) *ptr += sprintf(*ptr, "url("); if (value == CONTENT_ATTR) *ptr += sprintf(*ptr, "attr("); @@ -1504,11 +1504,11 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) while (value != COUNTER_INCREMENT_NONE) { css_fixed val; uint32_t snum = *((uint32_t *) bytecode); lwc_string *he; - css__stylesheet_string_get(style->sheet, - snum, + css__stylesheet_string_get(style->sheet, + snum, &he); ADVANCE(sizeof(snum)); - *ptr += sprintf(*ptr, "%.*s ", + *ptr += sprintf(*ptr, "%.*s ", (int)lwc_string_length(he), lwc_string_data(he)); val = *((css_fixed *) bytecode); @@ -1518,10 +1518,10 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) value = *((uint32_t *) bytecode); ADVANCE(sizeof(value)); - if (value != + if (value != COUNTER_INCREMENT_NONE) - *ptr += sprintf(*ptr, - " "); + *ptr += sprintf(*ptr, + " "); } break; case COUNTER_INCREMENT_NONE: @@ -1532,11 +1532,11 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) case CSS_PROP_CURSOR: while (value == CURSOR_URI) { uint32_t snum = *((uint32_t *) bytecode); lwc_string *he; - css__stylesheet_string_get(style->sheet, - snum, + css__stylesheet_string_get(style->sheet, + snum, &he); ADVANCE(sizeof(snum)); - *ptr += sprintf(*ptr, "url('%.*s'), ", + *ptr += sprintf(*ptr, "url('%.*s'), ", (int) lwc_string_length(he), lwc_string_data(he)); @@ -1718,12 +1718,12 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) case FONT_FAMILY_STRING: case FONT_FAMILY_IDENT_LIST: { - uint32_t snum = *((uint32_t *) bytecode); + uint32_t snum = *((uint32_t *) bytecode); lwc_string *he; css__stylesheet_string_get(style->sheet, snum, &he); ADVANCE(sizeof(snum)); - *ptr += sprintf(*ptr, "'%.*s'", - (int) lwc_string_length(he), + *ptr += sprintf(*ptr, "'%.*s'", + (int) lwc_string_length(he), lwc_string_data(he)); } break; @@ -2078,7 +2078,7 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) break; case OUTLINE_COLOR_SET: { - uint32_t colour = + uint32_t colour = *((uint32_t *) bytecode); ADVANCE(sizeof(colour)); *ptr += sprintf(*ptr, "#%08x", colour); @@ -2185,12 +2185,12 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) switch (value) { case PLAY_DURING_URI: { - uint32_t snum = *((uint32_t *) bytecode); + uint32_t snum = *((uint32_t *) bytecode); lwc_string *he; css__stylesheet_string_get(style->sheet, snum, &he); ADVANCE(sizeof(snum)); - *ptr += sprintf(*ptr, "'%.*s'", - (int) lwc_string_length(he), + *ptr += sprintf(*ptr, "'%.*s'", + (int) lwc_string_length(he), lwc_string_data(he)); } break; @@ -2227,18 +2227,18 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) switch (value) { case QUOTES_STRING: while (value != QUOTES_NONE) { - uint32_t snum = *((uint32_t *) bytecode); + uint32_t snum = *((uint32_t *) bytecode); lwc_string *he; css__stylesheet_string_get(style->sheet, snum, &he); ADVANCE(sizeof(snum)); - *ptr += sprintf(*ptr, " '%.*s' ", - (int) lwc_string_length(he), + *ptr += sprintf(*ptr, " '%.*s' ", + (int) lwc_string_length(he), lwc_string_data(he)); css__stylesheet_string_get(style->sheet, snum, &he); ADVANCE(sizeof(he)); - *ptr += sprintf(*ptr, " '%.*s' ", - (int) lwc_string_length(he), + *ptr += sprintf(*ptr, " '%.*s' ", + (int) lwc_string_length(he), lwc_string_data(he)); value = *((uint32_t *) bytecode); @@ -2459,11 +2459,11 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) case VOICE_FAMILY_STRING: case VOICE_FAMILY_IDENT_LIST: { - uint32_t snum = *((uint32_t *) bytecode); + uint32_t snum = *((uint32_t *) bytecode); lwc_string *he; css__stylesheet_string_get(style->sheet, snum, &he); ADVANCE(sizeof(snum)); - *ptr += sprintf(*ptr, "'%.*s'", + *ptr += sprintf(*ptr, "'%.*s'", (int) lwc_string_length(he), lwc_string_data(he)); } @@ -2589,7 +2589,7 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) void dump_string(lwc_string *string, char **ptr) { - *ptr += sprintf(*ptr, "%.*s", + *ptr += sprintf(*ptr, "%.*s", (int) lwc_string_length(string), lwc_string_data(string)); } @@ -2604,7 +2604,7 @@ void dump_font_face(css_font_face *font_face, char **ptr) (int) lwc_string_length(font_face->font_family), lwc_string_data(font_face->font_family)); } - + *ptr += sprintf(*ptr, "\n| font-style: "); style = css_font_face_font_style(font_face); switch (style) { @@ -2666,18 +2666,18 @@ void dump_font_face(css_font_face *font_face, char **ptr) break; } - + if (font_face->srcs != NULL) { uint32_t i; css_font_face_src *srcs = font_face->srcs; for (i = 0; i < font_face->n_srcs; ++i) { css_font_face_format format; *ptr += sprintf(*ptr, "\n| src: "); - + format = css_font_face_src_format(&srcs[i]); - + *ptr += sprintf(*ptr, "\n| format: "); - + switch (format) { case CSS_FONT_FACE_FORMAT_UNSPECIFIED: *ptr += sprintf(*ptr, "unspecified"); @@ -2717,10 +2717,10 @@ void dump_font_face(css_font_face *font_face, char **ptr) *ptr += sprintf(*ptr, "UNKNOWN"); break; } - + *ptr += sprintf(*ptr, "(%.*s)", (int) lwc_string_length( - srcs[i].location), + srcs[i].location), lwc_string_data(srcs[i].location)); } } diff --git a/test/dump_computed.h b/test/dump_computed.h index eb9d522..c9d699d 100644 --- a/test/dump_computed.h +++ b/test/dump_computed.h @@ -194,7 +194,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf, wrote = snprintf(ptr, *len, "background-image: inherit\n"); } else if (val == CSS_BACKGROUND_IMAGE_IMAGE && url != NULL) { wrote = snprintf(ptr, *len, "background-image: url('%.*s')\n", - (int) lwc_string_length(url), + (int) lwc_string_length(url), lwc_string_data(url)); } else if (val == CSS_BACKGROUND_IMAGE_NONE) { wrote = snprintf(ptr, *len, "background-image: none\n"); @@ -1176,7 +1176,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf, switch (content->type) { case CSS_COMPUTED_CONTENT_STRING: - wrote += snprintf(ptr + wrote, + wrote += snprintf(ptr + wrote, *len - wrote, "\"%.*s\"", (int) lwc_string_length( @@ -1185,7 +1185,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf, content->data.string)); break; case CSS_COMPUTED_CONTENT_URI: - wrote += snprintf(ptr + wrote, + wrote += snprintf(ptr + wrote, *len - wrote, "uri(\"%.*s\")", (int) lwc_string_length( @@ -1194,7 +1194,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf, content->data.uri)); break; case CSS_COMPUTED_CONTENT_COUNTER: - wrote += snprintf(ptr + wrote, + wrote += snprintf(ptr + wrote, *len - wrote, "counter(%.*s)", (int) lwc_string_length( @@ -1203,7 +1203,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf, content->data.counter.name)); break; case CSS_COMPUTED_CONTENT_COUNTERS: - wrote += snprintf(ptr + wrote, + wrote += snprintf(ptr + wrote, *len - wrote, "counters(%.*s, " "\"%.*s\")", @@ -1217,7 +1217,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf, content->data.counters.sep)); break; case CSS_COMPUTED_CONTENT_ATTR: - wrote += snprintf(ptr + wrote, + wrote += snprintf(ptr + wrote, *len - wrote, "attr(%.*s)", (int) lwc_string_length( @@ -1834,7 +1834,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf, wrote = snprintf(ptr, *len, "list-style-image: inherit\n"); } else if (url != NULL) { wrote = snprintf(ptr, *len, "list-style-image: url('%.*s')\n", - (int) lwc_string_length(url), + (int) lwc_string_length(url), lwc_string_data(url)); } else if (val == CSS_LIST_STYLE_IMAGE_NONE) { wrote = snprintf(ptr, *len, "list-style-image: none\n"); @@ -1882,7 +1882,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf, wrote = snprintf(ptr, *len, "list-style-type: decimal\n"); break; case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO: - wrote = snprintf(ptr, *len, + wrote = snprintf(ptr, *len, "list-style-type: decimal-leading-zero\n"); break; case CSS_LIST_STYLE_TYPE_LOWER_ROMAN: diff --git a/test/lex-auto.c b/test/lex-auto.c index f2f6007..f4afec3 100644 --- a/test/lex-auto.c +++ b/test/lex-auto.c @@ -39,7 +39,7 @@ static bool handle_line(const char *data, size_t datalen, void *pw); static void css__parse_expected(line_ctx *ctx, const char *data, size_t len); static const char *string_from_type(css_token_type type); static css_token_type string_to_type(const char *data, size_t len); -static void run_test(const uint8_t *data, size_t len, +static void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen); int main(int argc, char **argv) @@ -92,7 +92,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) if (ctx->inexp) { /* This marks end of testcase, so run it */ - run_test(ctx->buf, ctx->bufused, + run_test(ctx->buf, ctx->bufused, ctx->exp, ctx->expused); ctx->buf[0] = '\0'; @@ -141,7 +141,7 @@ void css__parse_expected(line_ctx *ctx, const char *data, size_t len) if (ctx->expused == ctx->explen) { size_t num = ctx->explen == 0 ? 4 : ctx->explen; - exp_entry *temp = realloc(ctx->exp, + exp_entry *temp = realloc(ctx->exp, num * 2 * sizeof(exp_entry)); if (temp == NULL) { assert(0 && "No memory for expected tokens"); @@ -188,7 +188,7 @@ void css__parse_expected(line_ctx *ctx, const char *data, size_t len) ctx->exp[ctx->expused].textLen] = c; ctx->exp[ctx->expused].textLen++; - assert(ctx->exp[ctx->expused].textLen < + assert(ctx->exp[ctx->expused].textLen < EXP_ENTRY_TEXT_LEN); } } @@ -201,7 +201,7 @@ const char *string_from_type(css_token_type type) { "IDENT", "ATKEYWORD", "HASH", "FUNCTION", "STRING", "INVALID", "URI", "UNICODE-RANGE", "CHAR", "NUMBER", "PERCENTAGE", - "DIMENSION", "last_intern", "CDO", "CDC", "S", "COMMENT", + "DIMENSION", "last_intern", "CDO", "CDC", "S", "COMMENT", "INCLUDES", "DASHMATCH", "PREFIXMATCH", "SUFFIXMATCH", "SUBSTRINGMATCH", "EOF" }; @@ -271,10 +271,10 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen) assert(css__lexer_create(input, &lexer) == CSS_OK); - assert(parserutils_inputstream_append(input, data, len) == + assert(parserutils_inputstream_append(input, data, len) == PARSERUTILS_OK); - assert(parserutils_inputstream_append(input, NULL, 0) == + assert(parserutils_inputstream_append(input, NULL, 0) == PARSERUTILS_OK); e = 0; @@ -283,7 +283,7 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen) while ((error = css__lexer_get_token(lexer, &tok)) == CSS_OK) { if (tok->type != exp[e].type) { printf("%d: Got token %s, Expected %s [%d, %d]\n", - testnum, string_from_type(tok->type), + testnum, string_from_type(tok->type), string_from_type(exp[e].type), tok->line, tok->col); assert(0 && "Types differ"); @@ -292,15 +292,15 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen) if (exp[e].hasText) { if (tok->data.len != exp[e].textLen) { printf("%d: Got length %d, Expected %d\n", - testnum, (int) tok->data.len, + testnum, (int) tok->data.len, (int) exp[e].textLen); assert(0 && "Text lengths differ"); } - if (strncmp((char *) tok->data.data, exp[e].text, + if (strncmp((char *) tok->data.data, exp[e].text, tok->data.len) != 0) { printf("%d: Got data '%.*s', Expected '%.*s'\n", - testnum, + testnum, (int) tok->data.len, tok->data.data, (int) exp[e].textLen, exp[e].text); assert(0 && "Text differs"); @@ -25,42 +25,42 @@ static void printToken(const css_token *token) switch (token->type) { case CSS_TOKEN_IDENT: - printf("IDENT(%.*s)", + printf("IDENT(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_ATKEYWORD: - printf("ATKEYWORD(%.*s)", + printf("ATKEYWORD(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_STRING: - printf("STRING(%.*s)", + printf("STRING(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_INVALID_STRING: - printf("INVALID(%.*s)", + printf("INVALID(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_HASH: - printf("HASH(%.*s)", + printf("HASH(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_NUMBER: - printf("NUMBER(%.*s)", + printf("NUMBER(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_PERCENTAGE: - printf("PERCENTAGE(%.*s)", + printf("PERCENTAGE(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_DIMENSION: - printf("DIMENSION(%.*s)", + printf("DIMENSION(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_URI: printf("URI(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_UNICODE_RANGE: - printf("UNICODE-RANGE(%.*s)", + printf("UNICODE-RANGE(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_CDO: @@ -76,7 +76,7 @@ static void printToken(const css_token *token) printf("COMMENT(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_FUNCTION: - printf("FUNCTION(%.*s)", + printf("FUNCTION(%.*s)", (int) token->data.len, token->data.data); break; case CSS_TOKEN_INCLUDES: @@ -128,11 +128,11 @@ int main(int argc, char **argv) } for (i = 0; i < ITERATIONS; i++) { - assert(parserutils_inputstream_create("UTF-8", - CSS_CHARSET_DICTATED,css__charset_extract, + assert(parserutils_inputstream_create("UTF-8", + CSS_CHARSET_DICTATED,css__charset_extract, &stream) == PARSERUTILS_OK); - assert(css__lexer_create(stream, &lexer) == + assert(css__lexer_create(stream, &lexer) == CSS_OK); fp = fopen(argv[1], "rb"); @@ -154,7 +154,7 @@ int main(int argc, char **argv) len -= CHUNK_SIZE; - while ((error = css__lexer_get_token(lexer, &tok)) == + while ((error = css__lexer_get_token(lexer, &tok)) == CSS_OK) { printToken(tok); @@ -175,7 +175,7 @@ int main(int argc, char **argv) fclose(fp); - assert(parserutils_inputstream_append(stream, NULL, 0) == + assert(parserutils_inputstream_append(stream, NULL, 0) == PARSERUTILS_OK); while ((error = css__lexer_get_token(lexer, &tok)) == CSS_OK) { diff --git a/test/number.c b/test/number.c index 12728fb..d255f4c 100644 --- a/test/number.c +++ b/test/number.c @@ -21,7 +21,7 @@ typedef struct line_ctx { } line_ctx; static bool handle_line(const char *data, size_t datalen, void *pw); -static void run_test(const uint8_t *data, size_t len, +static void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen); static void print_css_fixed(char *buf, size_t len, css_fixed f); @@ -72,7 +72,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) if (ctx->inexp) { /* This marks end of testcase, so run it */ - run_test(ctx->buf, ctx->bufused - 1, + run_test(ctx->buf, ctx->bufused - 1, ctx->exp, ctx->explen); ctx->buf[0] = '\0'; @@ -117,9 +117,9 @@ void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen) UNUSED(exp); UNUSED(explen); - + assert(lwc_intern_string((const char *)data, len, &in) == lwc_error_ok); - + result = css__number_from_lwc_string(in, false, &consumed); print_css_fixed(buf, sizeof(buf), result); diff --git a/test/parse-auto.c b/test/parse-auto.c index a332a5b..58ccf9a 100644 --- a/test/parse-auto.c +++ b/test/parse-auto.c @@ -47,12 +47,12 @@ typedef struct line_ctx { static bool handle_line(const char *data, size_t datalen, void *pw); static void css__parse_expected(line_ctx *ctx, const char *data, size_t len); -static void run_test(const uint8_t *data, size_t len, +static void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen); static bool validate_rule_selector(css_rule_selector *s, exp_entry *e); -static void validate_rule_charset(css_rule_charset *s, exp_entry *e, +static void validate_rule_charset(css_rule_charset *s, exp_entry *e, int testnum); -static void validate_rule_import(css_rule_import *s, exp_entry *e, +static void validate_rule_import(css_rule_import *s, exp_entry *e, int testnum); static void dump_selector_list(css_selector *list, char **ptr); @@ -78,7 +78,7 @@ static void printing_lwc_iterator(lwc_string *str, void *pw) { UNUSED(pw); - + printf(" DICT: %*s\n", (int)(lwc_string_length(str)), lwc_string_data(str)); fail_because_lwc_leaked = true; } @@ -140,9 +140,9 @@ int main(int argc, char **argv) free(ctx.exp); lwc_iterate_strings(printing_lwc_iterator, NULL); - + assert(fail_because_lwc_leaked == false); - + printf("PASS\n"); return 0; @@ -156,7 +156,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) if (ctx->inexp) { /* This marks end of testcase, so run it */ - run_test(ctx->buf, ctx->bufused, + run_test(ctx->buf, ctx->bufused, ctx->exp, ctx->expused); ctx->buf[0] = '\0'; @@ -169,7 +169,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) ctx->indata = false; ctx->inerrors = true; ctx->inexp = false; - } else if (ctx->inerrors && + } else if (ctx->inerrors && strncasecmp(data+1, "expected", 8) == 0) { ctx->indata = false; ctx->inerrors = false; @@ -212,7 +212,7 @@ void css__parse_expected(line_ctx *ctx, const char *data, size_t len) if (ctx->inrule == false) { char *name; int type; - + start_rule: type = strtol(data + 1, &name, 10); @@ -223,7 +223,7 @@ start_rule: if (ctx->expused == ctx->explen) { size_t num = ctx->explen == 0 ? 4 : ctx->explen; - exp_entry *temp = realloc(ctx->exp, + exp_entry *temp = realloc(ctx->exp, num * 2 * sizeof(exp_entry)); if (temp == NULL) { assert(0 && "No memory for expected rules"); @@ -234,9 +234,9 @@ start_rule: } ctx->exp[ctx->expused].type = type; - memcpy(ctx->exp[ctx->expused].name, name, + memcpy(ctx->exp[ctx->expused].name, name, min(len - (name - data), MAX_RULE_NAME_LEN)); - ctx->exp[ctx->expused].name[min(len - (name - data), + ctx->exp[ctx->expused].name[min(len - (name - data), MAX_RULE_NAME_LEN - 1)] = '\0'; ctx->exp[ctx->expused].bclen = 0; ctx->exp[ctx->expused].bcused = 0; @@ -246,7 +246,7 @@ start_rule: ctx->exp[ctx->expused].stringtab = NULL; ctx->expused++; - + ctx->inrule = true; } else { char *next = (char *) data + 1; @@ -266,7 +266,7 @@ start_rule: break; if (rule->bcused >= rule->bclen) { - size_t num = rule->bcused == 0 ? 4 : + size_t num = rule->bcused == 0 ? 4 : rule->bcused; uint8_t *temp = realloc(rule->bytecode, @@ -295,10 +295,10 @@ start_rule: rule->stused; struct stentry *temp = realloc( - rule->stringtab, + rule->stringtab, num * 2 * sizeof(struct stentry)); if (temp == NULL) { - assert(0 && + assert(0 && "No memory for string table"); } @@ -306,11 +306,11 @@ start_rule: rule->stlen = num * 2; } - rule->stringtab[rule->stused].off = + rule->stringtab[rule->stused].off = rule->bcused; rule->stringtab[rule->stused].string = malloc(next - str); - assert(rule->stringtab[rule->stused].string != + assert(rule->stringtab[rule->stused].string != NULL); memcpy(rule->stringtab[rule->stused].string, str, next - str - 1); @@ -324,7 +324,7 @@ start_rule: uint32_t val = strtoul(next, &next, 16); /* Append to bytecode */ - memcpy(rule->bytecode + rule->bcused, + memcpy(rule->bytecode + rule->bcused, &val, sizeof(val)); rule->bcused += sizeof(val); } @@ -405,7 +405,7 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen) css_stylesheet *import; char *buf = malloc(lwc_string_length(url) + 1); - memcpy(buf, lwc_string_data(url), + memcpy(buf, lwc_string_data(url), lwc_string_length(url)); buf[lwc_string_length(url)] = '\0'; @@ -437,7 +437,7 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen) for (rule = sheet->rule_list; rule != NULL; rule = rule->next, e++) { if (rule->type != exp[e].type) { - printf("%d: Got type %d. Expected %d\n", + printf("%d: Got type %d. Expected %d\n", testnum, rule->type, exp[e].type); assert(0 && "Types differ"); } @@ -535,28 +535,28 @@ bool validate_rule_selector(css_rule_selector *s, exp_entry *e) css__stylesheet_string_get(s->style->sheet, (s->style->bytecode[i / sizeof(css_code_t)]), &p); - if (lwc_string_length(p) != + if (lwc_string_length(p) != strlen(e->stringtab[j].string) || - memcmp(lwc_string_data(p), + memcmp(lwc_string_data(p), e->stringtab[j].string, lwc_string_length(p)) != 0) { printf("FAIL Strings differ\n" " Got string '%.*s'. " "Expected '%s'\n", - (int) lwc_string_length(p), - lwc_string_data(p), + (int) lwc_string_length(p), + lwc_string_data(p), e->stringtab[j].string); return true; } i += sizeof (css_code_t) - 1; - } else if (((uint8_t *) s->style->bytecode)[i] != + } else if (((uint8_t *) s->style->bytecode)[i] != e->bytecode[i]) { printf("FAIL Bytecode differs\n" " Bytecode differs at %u\n ", (int) i); while (i < e->bcused) { - printf("%.2x ", + printf("%.2x ", ((uint8_t *) s->style->bytecode)[i]); i++; } @@ -588,7 +588,7 @@ void validate_rule_import(css_rule_import *s, exp_entry *e, int testnum) if (strncmp(lwc_string_data(s->url), e->name, lwc_string_length(s->url)) != 0) { printf("%d: Got URL '%.*s'. Expected '%s'\n", - testnum, (int) lwc_string_length(s->url), + testnum, (int) lwc_string_length(s->url), lwc_string_data(s->url), e->name); assert(0 && "Mismatched URLs"); @@ -648,7 +648,7 @@ void dump_selector_detail(css_selector_detail *detail, char **ptr) switch (detail->type) { case CSS_SELECTOR_ELEMENT: - if (lwc_string_length(detail->qname.name) == 1 && + if (lwc_string_length(detail->qname.name) == 1 && lwc_string_data(detail->qname.name)[0] == '*' && detail->next == 0) { dump_string(detail->qname.name, ptr); @@ -778,6 +778,6 @@ void dump_selector_detail(css_selector_detail *detail, char **ptr) void dump_string(lwc_string *string, char **ptr) { - *ptr += sprintf(*ptr, "%.*s", (int) lwc_string_length(string), + *ptr += sprintf(*ptr, "%.*s", (int) lwc_string_length(string), lwc_string_data(string)); } diff --git a/test/parse.c b/test/parse.c index dbbf91f..0692fc7 100644 --- a/test/parse.c +++ b/test/parse.c @@ -29,7 +29,7 @@ static const char *event_names[] = { }; #endif -static css_error event_handler(css_parser_event type, +static css_error event_handler(css_parser_event type, const parserutils_vector *tokens, void *pw) { #if !DUMP_EVENTS @@ -88,7 +88,7 @@ int main(int argc, char **argv) params.event_handler.handler = event_handler; params.event_handler.pw = NULL; - assert(css__parser_setopt(parser, CSS_PARSER_EVENT_HANDLER, + assert(css__parser_setopt(parser, CSS_PARSER_EVENT_HANDLER, ¶ms) == CSS_OK); fp = fopen(argv[1], "rb"); @@ -130,7 +130,7 @@ int main(int argc, char **argv) } printf("PASS\n"); - + return 0; } diff --git a/test/parse2-auto.c b/test/parse2-auto.c index 1d5ba57..ee717c3 100644 --- a/test/parse2-auto.c +++ b/test/parse2-auto.c @@ -31,7 +31,7 @@ typedef struct line_ctx { static bool handle_line(const char *data, size_t datalen, void *pw); static void css__parse_expected(line_ctx *ctx, const char *data, size_t len); -static void run_test(const uint8_t *data, size_t len, +static void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen); static css_error resolve_url(void *pw, @@ -52,7 +52,7 @@ static void printing_lwc_iterator(lwc_string *str, void *pw) { UNUSED(pw); - + printf(" DICT: %*s\n", (int)(lwc_string_length(str)), lwc_string_data(str)); fail_because_lwc_leaked = true; } @@ -60,7 +60,7 @@ printing_lwc_iterator(lwc_string *str, void *pw) int main(int argc, char **argv) { line_ctx ctx; - + if (argc != 2) { printf("Usage: %s <filename>\n", argv[0]); return 1; @@ -96,9 +96,9 @@ int main(int argc, char **argv) free(ctx.exp); lwc_iterate_strings(printing_lwc_iterator, NULL); - + assert(fail_because_lwc_leaked == false); - + printf("PASS\n"); return 0; @@ -112,7 +112,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) if (ctx->inexp) { /* This marks end of testcase, so run it */ - run_test(ctx->buf, ctx->bufused, + run_test(ctx->buf, ctx->bufused, ctx->exp, ctx->expused); ctx->buf[0] = '\0'; @@ -125,7 +125,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) ctx->indata = false; ctx->inerrors = true; ctx->inexp = false; - } else if (ctx->inerrors && + } else if (ctx->inerrors && strncasecmp(data+1, "expected", 8) == 0) { ctx->indata = false; ctx->inerrors = false; @@ -188,7 +188,7 @@ void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen) assert(0 && "No memory for result data"); } buflen = 2 * explen; - + params.params_version = CSS_STYLESHEET_PARAMS_VERSION_1; params.level = CSS_LEVEL_21; params.charset = "UTF-8"; @@ -220,7 +220,7 @@ void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen) dump_sheet(sheet, buf, &buflen); if (2 * explen - buflen != explen || memcmp(buf, exp, explen) != 0) { - printf("Expected (%u):\n%.*s\n", + printf("Expected (%u):\n%.*s\n", (int) explen, (int) explen, exp); printf("Result (%u):\n%.*s\n", (int) (2 * explen - buflen), (int) (2 * explen - buflen), buf); diff --git a/test/select.c b/test/select.c index 4146355..d317696 100644 --- a/test/select.c +++ b/test/select.c @@ -65,7 +65,7 @@ typedef struct line_ctx { uint64_t media; uint32_t pseudo_element; node *target; - + lwc_string *attr_class; lwc_string *attr_id; } line_ctx; @@ -78,7 +78,7 @@ static void css__parse_tree(line_ctx *ctx, const char *data, size_t len); static void css__parse_tree_data(line_ctx *ctx, const char *data, size_t len); static void css__parse_sheet(line_ctx *ctx, const char *data, size_t len); static void css__parse_media_list(const char **data, size_t *len, uint64_t *media); -static void css__parse_pseudo_list(const char **data, size_t *len, +static void css__parse_pseudo_list(const char **data, size_t *len, uint32_t *element); static void css__parse_expected(line_ctx *ctx, const char *data, size_t len); static void run_test(line_ctx *ctx, const char *exp, size_t explen); @@ -104,8 +104,8 @@ static css_error named_generic_sibling_node(void *pw, void *node, void **sibling); static css_error parent_node(void *pw, void *node, void **parent); static css_error sibling_node(void *pw, void *node, void **sibling); -static css_error node_has_name(void *pw, void *node, - const css_qname *qname, +static css_error node_has_name(void *pw, void *node, + const css_qname *qname, bool *match); static css_error node_has_class(void *pw, void *node, lwc_string *name, @@ -226,7 +226,7 @@ static void printing_lwc_iterator(lwc_string *str, void *pw) { UNUSED(pw); - + printf(" DICT: %*s\n", (int)(lwc_string_length(str)), lwc_string_data(str)); fail_because_lwc_leaked = true; } @@ -234,7 +234,7 @@ printing_lwc_iterator(lwc_string *str, void *pw) int main(int argc, char **argv) { line_ctx ctx; - + if (argc != 2) { printf("Usage: %s <filename>\n", argv[0]); return 1; @@ -245,22 +245,22 @@ int main(int argc, char **argv) lwc_intern_string("class", SLEN("class"), &ctx.attr_class); lwc_intern_string("id", SLEN("id"), &ctx.attr_id); - + assert(css__parse_testfile(argv[1], handle_line, &ctx) == true); - + /* and run final test */ if (ctx.tree != NULL) run_test(&ctx, ctx.exp, ctx.expused); free(ctx.exp); - + lwc_string_unref(ctx.attr_class); lwc_string_unref(ctx.attr_id); - + lwc_iterate_strings(printing_lwc_iterator, NULL); - + assert(fail_because_lwc_leaked == false); - + printf("PASS\n"); return 0; } @@ -289,7 +289,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) } else if (ctx->insheet) { if (strncasecmp(data+1, "errors", 6) == 0) { assert(css_stylesheet_data_done( - ctx->sheets[ctx->n_sheets - 1].sheet) + ctx->sheets[ctx->n_sheets - 1].sheet) == CSS_OK); ctx->intree = false; @@ -306,10 +306,10 @@ bool handle_line(const char *data, size_t datalen, void *pw) css__parse_sheet(ctx, data + 1, datalen - 1); } else { error = css_stylesheet_append_data( - ctx->sheets[ctx->n_sheets - 1].sheet, - (const uint8_t *) data, + ctx->sheets[ctx->n_sheets - 1].sheet, + (const uint8_t *) data, datalen); - assert(error == CSS_OK || + assert(error == CSS_OK || error == CSS_NEEDDATA); } } else if (ctx->inerrors) { @@ -344,7 +344,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) css__parse_tree_data(ctx, data + 1, datalen - 1); } else if (ctx->insheet) { error = css_stylesheet_append_data( - ctx->sheets[ctx->n_sheets - 1].sheet, + ctx->sheets[ctx->n_sheets - 1].sheet, (const uint8_t *) data, datalen); assert(error == CSS_OK || error == CSS_NEEDDATA); } else if (ctx->inexp) { @@ -397,7 +397,7 @@ void css__parse_tree_data(line_ctx *ctx, const char *data, size_t len) bool target = false; /* ' '{depth+1} [ <element> '*'? | <attr> ] - * + * * <element> ::= [^=*[:space:]]+ * <attr> ::= [^=*[:space:]]+ '=' [^[:space:]]* */ @@ -440,7 +440,7 @@ void css__parse_tree_data(line_ctx *ctx, const char *data, size_t len) assert(n != NULL); memset(n, 0, sizeof(node)); - + lwc_intern_string(name, namelen, &n->name); /* Insert it into tree */ @@ -488,7 +488,7 @@ void css__parse_tree_data(line_ctx *ctx, const char *data, size_t len) n->attrs = temp; attr = &n->attrs[n->n_attrs]; - + lwc_intern_string(name, namelen, &attr->name); lwc_intern_string(value, valuelen, &attr->value); @@ -566,7 +566,7 @@ void css__parse_sheet(line_ctx *ctx, const char *data, size_t len) assert(css_stylesheet_create(¶ms, &sheet) == CSS_OK); /* Extend array of sheets and append new sheet to it */ - temp = realloc(ctx->sheets, + temp = realloc(ctx->sheets, (ctx->n_sheets + 1) * sizeof(sheet_ctx)); assert(temp != NULL); @@ -594,7 +594,7 @@ void css__parse_media_list(const char **data, size_t *len, uint64_t *media) while (isspace(*p) == false && *p != ',') p++; - if (p - start == 10 && + if (p - start == 10 && strncasecmp(start, "projection", 10) == 0) result |= CSS_MEDIA_PROJECTION; else if (p - start == 8 && @@ -765,7 +765,7 @@ static void run_test_select_tree(css_select_ctx *select, css_select_results *sr; struct node *n = NULL; - assert(css_select_style(select, node, ctx->media, NULL, + assert(css_select_style(select, node, ctx->media, NULL, &select_handler, ctx, &sr) == CSS_OK); if (node->parent != NULL) { @@ -812,7 +812,7 @@ void run_test(line_ctx *ctx, const char *exp, size_t explen) assert(css_select_ctx_create(&select) == CSS_OK); for (i = 0; i < ctx->n_sheets; i++) { - assert(css_select_ctx_append_sheet(select, + assert(css_select_ctx_append_sheet(select, ctx->sheets[i].sheet, ctx->sheets[i].origin, ctx->sheets[i].media) == CSS_OK); } @@ -826,7 +826,7 @@ void run_test(line_ctx *ctx, const char *exp, size_t explen) if (8192 - buflen != explen || memcmp(buf, exp, explen) != 0) { size_t len = 8192 - buflen < explen ? 8192 - buflen : explen; - printf("Expected (%u):\n%.*s\n", + printf("Expected (%u):\n%.*s\n", (int) explen, (int) explen, exp); printf("Result (%u):\n%.*s\n", (int) (8192 - buflen), (int) (8192 - buflen), buf); @@ -868,7 +868,7 @@ void destroy_tree(node *root) } css_select_results_destroy(root->sr); - + for (i = 0; i < root->n_attrs; ++i) { lwc_string_unref(root->attrs[i].name); lwc_string_unref(root->attrs[i].value); @@ -897,9 +897,9 @@ css_error node_name(void *pw, void *n, css_qname *qname) node *node = n; UNUSED(pw); - + qname->name = lwc_string_ref(node->name); - + return CSS_OK; } @@ -930,7 +930,7 @@ css_error node_id(void *pw, void *n, for (i = 0; i < node->n_attrs; i++) { bool amatch = false; assert(lwc_string_caseless_isequal( - node->attrs[i].name, lc->attr_id, &amatch) == + node->attrs[i].name, lc->attr_id, &amatch) == lwc_error_ok); if (amatch == true) break; @@ -954,7 +954,7 @@ css_error named_ancestor_node(void *pw, void *n, for (node = node->parent; node != NULL; node = node->parent) { bool match = false; assert(lwc_string_caseless_isequal( - qname->name, node->name, + qname->name, node->name, &match) == lwc_error_ok); if (match == true) break; @@ -976,7 +976,7 @@ css_error named_parent_node(void *pw, void *n, if (node->parent != NULL) { bool match = false; assert(lwc_string_caseless_isequal( - qname->name, node->parent->name, &match) == + qname->name, node->parent->name, &match) == lwc_error_ok); if (match == true) *parent = (void *) node->parent; @@ -996,7 +996,7 @@ css_error named_sibling_node(void *pw, void *n, if (node->prev != NULL) { bool match = false; assert(lwc_string_caseless_isequal( - qname->name, node->prev->name, &match) == + qname->name, node->prev->name, &match) == lwc_error_ok); if (match == true) *sibling = (void *) node->prev; @@ -1015,7 +1015,7 @@ css_error named_generic_sibling_node(void *pw, void *n, for (node = node->prev; node != NULL; node = node->prev) { bool match = false; assert(lwc_string_caseless_isequal( - qname->name, node->name, + qname->name, node->name, &match) == lwc_error_ok); if (match == true) break; @@ -1059,7 +1059,7 @@ css_error node_has_name(void *pw, void *n, lwc_string_data(qname->name)[0] == '*') *match = true; else - assert(lwc_string_caseless_isequal(node->name, + assert(lwc_string_caseless_isequal(node->name, qname->name, match) == lwc_error_ok); return CSS_OK; @@ -1076,7 +1076,7 @@ css_error node_has_class(void *pw, void *n, for (i = 0; i < node->n_attrs; i++) { bool amatch = false; assert(lwc_string_caseless_isequal( - node->attrs[i].name, ctx->attr_class, + node->attrs[i].name, ctx->attr_class, &amatch) == lwc_error_ok); if (amatch == true) break; @@ -1102,7 +1102,7 @@ css_error node_has_id(void *pw, void *n, for (i = 0; i < node->n_attrs; i++) { bool amatch = false; assert(lwc_string_caseless_isequal( - node->attrs[i].name, ctx->attr_id, &amatch) == + node->attrs[i].name, ctx->attr_id, &amatch) == lwc_error_ok); if (amatch == true) break; @@ -1124,11 +1124,11 @@ css_error node_has_attribute(void *pw, void *n, node *node = n; uint32_t i; UNUSED(pw); - + *match = false; for (i = 0; i < node->n_attrs; i++) { assert(lwc_string_caseless_isequal( - node->attrs[i].name, qname->name, match) == + node->attrs[i].name, qname->name, match) == lwc_error_ok); if (*match == true) break; @@ -1147,21 +1147,21 @@ css_error node_has_attribute_equal(void *pw, void *n, UNUSED(pw); *match = false; - + for (i = 0; i < node->n_attrs; i++) { assert(lwc_string_caseless_isequal( - node->attrs[i].name, qname->name, match) == + node->attrs[i].name, qname->name, match) == lwc_error_ok); if (*match == true) break; } - + if (*match == true) { assert(lwc_string_caseless_isequal( - node->attrs[i].name, value, match) == + node->attrs[i].name, value, match) == lwc_error_ok); } - + return CSS_OK; } @@ -1176,10 +1176,10 @@ css_error node_has_attribute_includes(void *pw, void *n, UNUSED(pw); *match = false; - + for (i = 0; i < node->n_attrs; i++) { assert(lwc_string_caseless_isequal( - node->attrs[i].name, qname->name, match) == + node->attrs[i].name, qname->name, match) == lwc_error_ok); if (*match == true) break; @@ -1188,14 +1188,14 @@ css_error node_has_attribute_includes(void *pw, void *n, if (*match == true) { const char *p; const char *start = lwc_string_data(node->attrs[i].value); - const char *end = start + + const char *end = start + lwc_string_length(node->attrs[i].value); - + *match = false; - + for (p = start; p < end; p++) { if (*p == ' ') { - if ((size_t) (p - start) == vlen && + if ((size_t) (p - start) == vlen && strncasecmp(start, lwc_string_data(value), vlen) == 0) { @@ -1222,10 +1222,10 @@ css_error node_has_attribute_dashmatch(void *pw, void *n, UNUSED(pw); *match = false; - + for (i = 0; i < node->n_attrs; i++) { assert(lwc_string_caseless_isequal( - node->attrs[i].name, qname->name, match) == + node->attrs[i].name, qname->name, match) == lwc_error_ok); if (*match == true) break; @@ -1234,16 +1234,16 @@ css_error node_has_attribute_dashmatch(void *pw, void *n, if (*match == true) { const char *p; const char *start = lwc_string_data(node->attrs[i].value); - const char *end = start + + const char *end = start + lwc_string_length(node->attrs[i].value); - + *match = false; - + for (p = start; p < end; p++) { if (*p == '-') { - if ((size_t) (p - start) == vlen && + if ((size_t) (p - start) == vlen && strncasecmp(start, - lwc_string_data(value), + lwc_string_data(value), vlen) == 0) { *match = true; break; @@ -1267,15 +1267,15 @@ css_error node_has_attribute_prefix(void *pw, void *n, UNUSED(pw); *match = false; - + for (i = 0; i < node->n_attrs; i++) { assert(lwc_string_caseless_isequal( - node->attrs[i].name, qname->name, match) == + node->attrs[i].name, qname->name, match) == lwc_error_ok); if (*match == true) break; } - + if (*match == true) { size_t len = lwc_string_length(node->attrs[i].value); const char *data = lwc_string_data(node->attrs[i].value); @@ -1288,7 +1288,7 @@ css_error node_has_attribute_prefix(void *pw, void *n, else *match = (strncasecmp(data, vdata, vlen) == 0); } - + return CSS_OK; } @@ -1302,15 +1302,15 @@ css_error node_has_attribute_suffix(void *pw, void *n, UNUSED(pw); *match = false; - + for (i = 0; i < node->n_attrs; i++) { assert(lwc_string_caseless_isequal( - node->attrs[i].name, qname->name, match) == + node->attrs[i].name, qname->name, match) == lwc_error_ok); if (*match == true) break; } - + if (*match == true) { size_t len = lwc_string_length(node->attrs[i].value); const char *data = lwc_string_data(node->attrs[i].value); @@ -1323,7 +1323,7 @@ css_error node_has_attribute_suffix(void *pw, void *n, if (len < vlen) *match = false; else { - *match = (strncasecmp(data + suffix_start, + *match = (strncasecmp(data + suffix_start, vdata, vlen) == 0); } } @@ -1341,15 +1341,15 @@ css_error node_has_attribute_substring(void *pw, void *n, UNUSED(pw); *match = false; - + for (i = 0; i < node->n_attrs; i++) { assert(lwc_string_caseless_isequal( - node->attrs[i].name, qname->name, match) == + node->attrs[i].name, qname->name, match) == lwc_error_ok); if (*match == true) break; } - + if (*match == true) { size_t len = lwc_string_length(node->attrs[i].value); const char *data = lwc_string_data(node->attrs[i].value); @@ -1637,17 +1637,17 @@ css_error compute_font_size(void *pw, const css_hint *parent, css_hint *size) size->data.length = sizes[size->status - 1]; } else if (size->status == CSS_FONT_SIZE_LARGER) { /** \todo Step within table, if appropriate */ - size->data.length.value = + size->data.length.value = FMUL(parent_size->value, FLTTOFIX(1.2)); size->data.length.unit = parent_size->unit; } else if (size->status == CSS_FONT_SIZE_SMALLER) { /** \todo Step within table, if appropriate */ - size->data.length.value = + size->data.length.value = FMUL(parent_size->value, FLTTOFIX(1.2)); size->data.length.unit = parent_size->unit; } else if (size->data.length.unit == CSS_UNIT_EM || size->data.length.unit == CSS_UNIT_EX) { - size->data.length.value = + size->data.length.value = FMUL(size->data.length.value, parent_size->value); if (size->data.length.unit == CSS_UNIT_EX) { |