From ff60ef8eb1f4f4388ee7c4668c0289d1bfce173f Mon Sep 17 00:00:00 2001 From: Aygul Salahli Date: Fri, 1 Nov 2019 15:31:46 +0200 Subject: [PATCH] Change the way background is parsed and serialized; One node can have only one background with multiple background-properties. Removed unused mycss_values_background_list_t and all related functions. Collate function changed accordingly. Added collation for border and border-sides. --- include/modest/style/map.h | 6 + include/modest/style/map_resource.h | 50 +++---- include/mycss/values/destroy.h | 2 +- include/mycss/values/values.h | 1 - source/modest/style/map.c | 157 ++++++++++++++++++++++ source/modest/style/map.h | 6 + source/modest/style/map_resource.h | 50 +++---- source/mycss/declaration/serialization.c | 96 +++++++------ source/mycss/property/parser_background.c | 5 +- source/mycss/values/destroy.c | 48 +++---- source/mycss/values/destroy.h | 2 +- source/mycss/values/values.c | 27 ---- source/mycss/values/values.h | 1 - 13 files changed, 288 insertions(+), 163 deletions(-) diff --git a/include/modest/style/map.h b/include/modest/style/map.h index 086495a..36d7ef3 100644 --- a/include/modest/style/map.h +++ b/include/modest/style/map.h @@ -41,6 +41,12 @@ void modest_style_map_collate_declaration_padding(modest_t* modest, myhtml_tree_ void modest_style_map_collate_declaration_margin(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); void modest_style_map_collate_declaration_border_width(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); void modest_style_map_collate_declaration_border_style(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_background(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border_top(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border_bottom(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border_left(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border_right(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); #ifdef __cplusplus } /* extern "C" */ diff --git a/include/modest/style/map_resource.h b/include/modest/style/map_resource.h index 9938dd8..0e31e0c 100644 --- a/include/modest/style/map_resource.h +++ b/include/modest/style/map_resource.h @@ -39,6 +39,28 @@ static const modest_style_map_collate_f modest_style_map_static_collate_declarat modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_background, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border_bottom, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, @@ -59,40 +81,18 @@ static const modest_style_map_collate_f modest_style_map_static_collate_declarat modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border_left, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border_right, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_border_style, - modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border_top, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, diff --git a/include/mycss/values/destroy.h b/include/mycss/values/destroy.h index 651ec76..5cd6dae 100644 --- a/include/mycss/values/destroy.h +++ b/include/mycss/values/destroy.h @@ -66,7 +66,7 @@ mycss_values_cross_fade_t * mycss_values_destroy_cross_fade(mycss_entry_t* entry mycss_values_image_list_t * mycss_values_destroy_image_list(mycss_entry_t* entry, mycss_values_image_list_t* value, bool self_destroy); /* Background */ -mycss_values_background_list_t * mycss_values_destroy_background(mycss_entry_t* entry, mycss_values_background_list_t* value, bool self_destroy); +mycss_values_background_t * mycss_values_destroy_background(mycss_entry_t* entry, mycss_values_background_t* value, bool self_destroy); mycss_values_background_repeat_list_t * mycss_values_destroy_background_repeat(mycss_entry_t* entry, mycss_values_background_repeat_list_t* value, bool self_destroy); mycss_values_background_position_t * mycss_values_destroy_background_position(mycss_entry_t* entry, mycss_values_background_position_t* value, bool self_destroy); mycss_values_background_size_list_t * mycss_values_destroy_background_size(mycss_entry_t* entry, mycss_values_background_size_list_t* value, bool self_destroy); diff --git a/include/mycss/values/values.h b/include/mycss/values/values.h index d05cc9f..50a97e0 100644 --- a/include/mycss/values/values.h +++ b/include/mycss/values/values.h @@ -67,7 +67,6 @@ typedef struct mycss_values_background_position mycss_values_background_position typedef struct mycss_values_background_size_list mycss_values_background_size_list_t; typedef struct mycss_values_background_size_entry mycss_values_background_size_entry_t; typedef struct mycss_values_background mycss_values_background_t; -typedef struct mycss_values_background_list mycss_values_background_list_t; typedef struct mycss_values_border mycss_values_border_t; diff --git a/source/modest/style/map.c b/source/modest/style/map.c index 778ae91..0168fc9 100644 --- a/source/modest/style/map.c +++ b/source/modest/style/map.c @@ -186,4 +186,161 @@ void modest_style_map_collate_declaration_border_style(modest_t* modest, myhtml_ } } +/* background */ +void modest_style_map_collate_declaration_background(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec) +{ + if(node->data == NULL || decl->value == NULL) + return; + + mycss_values_background_t* background = decl->value; + if(background == NULL) + return; + + if(background->image) { + modest_style_map_collate_declaration_for_all(modest, node, background->image, MyCSS_PROPERTY_TYPE_BACKGROUND_IMAGE, spec); + } + if(background->color) { + modest_style_map_collate_declaration_for_all(modest, node, background->color, MyCSS_PROPERTY_TYPE_BACKGROUND_COLOR, spec); + } + if(background->attachment) { + modest_style_map_collate_declaration_for_all(modest, node, background->attachment, MyCSS_PROPERTY_TYPE_BACKGROUND_ATTACHMENT, spec); + } + if(background->position) { + modest_style_map_collate_declaration_for_all(modest, node, background->position, MyCSS_PROPERTY_TYPE_BACKGROUND_POSITION, spec); + } + if(background->size) { + modest_style_map_collate_declaration_for_all(modest, node, background->size, MyCSS_PROPERTY_TYPE_BACKGROUND_SIZE, spec); + } + if(background->repeat) { + modest_style_map_collate_declaration_for_all(modest, node, background->repeat, MyCSS_PROPERTY_TYPE_BACKGROUND_REPEAT, spec); + } + if(background->size) { + modest_style_map_collate_declaration_for_all(modest, node, background->size, MyCSS_PROPERTY_TYPE_BACKGROUND_SIZE, spec); + } + if(background->origin) { + modest_style_map_collate_declaration_for_all(modest, node, background->origin, MyCSS_PROPERTY_TYPE_BACKGROUND_ORIGIN, spec); + } + if(background->clip) { + modest_style_map_collate_declaration_for_all(modest, node, background->clip, MyCSS_PROPERTY_TYPE_BACKGROUND_CLIP, spec); + } +} + +/* border */ +void modest_style_map_collate_declaration_border(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec) +{ + if(node->data == NULL || decl->value == NULL) + return; + + mycss_values_border_t *border = decl->value; + + if(border == NULL) + return; + + if(border->width) { + modest_style_map_collate_declaration_for_all(modest, node, border->width, MyCSS_PROPERTY_TYPE_BORDER_TOP_WIDTH, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->width, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_WIDTH, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->width, MyCSS_PROPERTY_TYPE_BORDER_LEFT_WIDTH, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->width, MyCSS_PROPERTY_TYPE_BORDER_RIGHT_WIDTH, spec); + } + if(border->style) { + modest_style_map_collate_declaration_for_all(modest, node, border->style, MyCSS_PROPERTY_TYPE_BORDER_TOP_STYLE, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->style, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_STYLE, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->style, MyCSS_PROPERTY_TYPE_BORDER_LEFT_STYLE, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->style, MyCSS_PROPERTY_TYPE_BORDER_RIGHT_STYLE, spec); + } + if(border->color) { + modest_style_map_collate_declaration_for_all(modest, node, border->color, MyCSS_PROPERTY_TYPE_BORDER_TOP_COLOR, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->color, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_COLOR, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->color, MyCSS_PROPERTY_TYPE_BORDER_LEFT_COLOR, spec); + modest_style_map_collate_declaration_for_all(modest, node, border->color, MyCSS_PROPERTY_TYPE_BORDER_RIGHT_COLOR, spec); + } +} + +/* border-top */ +void modest_style_map_collate_declaration_border_top(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec) +{ + if(node->data == NULL || decl->value == NULL) + return; + + mycss_values_border_t *border = decl->value; + + if(border == NULL) + return; + + if(border->width) { + modest_style_map_collate_declaration_for_all(modest, node, border->width, MyCSS_PROPERTY_TYPE_BORDER_TOP_WIDTH, spec); + } + if(border->style) { + modest_style_map_collate_declaration_for_all(modest, node, border->style, MyCSS_PROPERTY_TYPE_BORDER_TOP_STYLE, spec); + } + if(border->color) { + modest_style_map_collate_declaration_for_all(modest, node, border->color, MyCSS_PROPERTY_TYPE_BORDER_TOP_COLOR, spec); + } +} + +/* border-bottom */ +void modest_style_map_collate_declaration_border_bottom(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec) +{ + if(node->data == NULL || decl->value == NULL) + return; + + mycss_values_border_t *border = decl->value; + + if(border == NULL) + return; + + if(border->width) { + modest_style_map_collate_declaration_for_all(modest, node, border->width, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_WIDTH, spec); + } + if(border->style) { + modest_style_map_collate_declaration_for_all(modest, node, border->style, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_STYLE, spec); + } + if(border->color) { + modest_style_map_collate_declaration_for_all(modest, node, border->color, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_COLOR, spec); + } +} + +/* border-left */ +void modest_style_map_collate_declaration_border_left(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec) +{ + if(node->data == NULL || decl->value == NULL) + return; + + mycss_values_border_t *border = decl->value; + + if(border == NULL) + return; + + if(border->width) { + modest_style_map_collate_declaration_for_all(modest, node, border->width, MyCSS_PROPERTY_TYPE_BORDER_LEFT_WIDTH, spec); + } + if(border->style) { + modest_style_map_collate_declaration_for_all(modest, node, border->style, MyCSS_PROPERTY_TYPE_BORDER_LEFT_STYLE, spec); + } + if(border->color) { + modest_style_map_collate_declaration_for_all(modest, node, border->color, MyCSS_PROPERTY_TYPE_BORDER_LEFT_COLOR, spec); + } +} + +/* border-right */ +void modest_style_map_collate_declaration_border_right(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec) +{ + if(node->data == NULL || decl->value == NULL) + return; + + mycss_values_border_t *border = decl->value; + + if(border == NULL) + return; + + if(border->width) { + modest_style_map_collate_declaration_for_all(modest, node, border->width, MyCSS_PROPERTY_TYPE_BORDER_RIGHT_WIDTH, spec); + } + if(border->style) { + modest_style_map_collate_declaration_for_all(modest, node, border->style, MyCSS_PROPERTY_TYPE_BORDER_RIGHT_STYLE, spec); + } + if(border->color) { + modest_style_map_collate_declaration_for_all(modest, node, border->color, MyCSS_PROPERTY_TYPE_BORDER_RIGHT_COLOR, spec); + } +} diff --git a/source/modest/style/map.h b/source/modest/style/map.h index aad706c..68b8e9a 100644 --- a/source/modest/style/map.h +++ b/source/modest/style/map.h @@ -41,6 +41,12 @@ void modest_style_map_collate_declaration_padding(modest_t* modest, myhtml_tree_ void modest_style_map_collate_declaration_margin(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); void modest_style_map_collate_declaration_border_width(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); void modest_style_map_collate_declaration_border_style(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_background(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border_top(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border_bottom(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border_left(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); +void modest_style_map_collate_declaration_border_right(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, mycss_property_type_t type, modest_style_raw_specificity_t* spec); #ifdef __cplusplus } /* extern "C" */ diff --git a/source/modest/style/map_resource.h b/source/modest/style/map_resource.h index 9938dd8..0e31e0c 100644 --- a/source/modest/style/map_resource.h +++ b/source/modest/style/map_resource.h @@ -39,6 +39,28 @@ static const modest_style_map_collate_f modest_style_map_static_collate_declarat modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_background, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border_bottom, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, @@ -59,40 +81,18 @@ static const modest_style_map_collate_f modest_style_map_static_collate_declarat modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border_left, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, - modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border_right, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_border_style, - modest_style_map_collate_declaration_for_all, + modest_style_map_collate_declaration_border_top, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, modest_style_map_collate_declaration_for_all, diff --git a/source/mycss/declaration/serialization.c b/source/mycss/declaration/serialization.c index 5f29ec7..1da606c 100644 --- a/source/mycss/declaration/serialization.c +++ b/source/mycss/declaration/serialization.c @@ -461,62 +461,56 @@ bool mycss_declaration_serialization_background(mycss_entry_t* entry, mycss_decl { if(dec_entry == NULL) return false; - + if(dec_entry->value == NULL) return mycss_declaration_serialization_undef(entry, dec_entry, callback, context); - - mycss_values_background_list_t *list = dec_entry->value; - - for(size_t i = 0; i < list->entries_length; i++) { - if(i) - callback(", ", 2, context); - - mycss_values_background_t* bg = &list->entries[i]; - bool o_e = false; - - if(bg->color) { - o_e = true; - mycss_property_serialization_value(bg->color->value_type, bg->color->value, callback, context); - } - - if(bg->image) { - if(o_e) callback(" ", 1, context); else o_e = true; - mycss_declaration_serialization_background_image(entry, bg->image, callback, context); - } - - if(bg->position) { - if(o_e) callback(" ", 1, context); else o_e = true; - mycss_declaration_serialization_background_position(entry, bg->position, callback, context); - - if(bg->size) { - callback(" / ", 3, context); - mycss_declaration_serialization_background_size(entry, bg->size, callback, context); - } - } - - if(bg->repeat) { - if(o_e) callback(" ", 1, context); else o_e = true; - mycss_declaration_serialization_background_repeat(entry, bg->repeat, callback, context); - } - - if(bg->attachment) { - if(o_e) callback(" ", 1, context); else o_e = true; - mycss_declaration_serialization_type_list(entry, bg->attachment, callback, context); - } - - if(bg->clip) { - if(o_e) callback(" ", 1, context); else o_e = true; - mycss_declaration_serialization_type_list(entry, bg->clip, callback, context); - } - - if(bg->origin) { - if(o_e) callback(" ", 1, context); - mycss_declaration_serialization_type_list(entry, bg->origin, callback, context); + + mycss_values_background_t* bg = dec_entry->value; + + bool o_e = false; + + if(bg->color) { + o_e = true; + mycss_property_serialization_value(bg->color->value_type, bg->color->value, callback, context); + } + + if(bg->image) { + if(o_e) callback(" ", 1, context); else o_e = true; + mycss_declaration_serialization_background_image(entry, bg->image, callback, context); + } + + if(bg->position) { + if(o_e) callback(" ", 1, context); else o_e = true; + mycss_declaration_serialization_background_position(entry, bg->position, callback, context); + + if(bg->size) { + callback(" / ", 3, context); + mycss_declaration_serialization_background_size(entry, bg->size, callback, context); } } - + + if(bg->repeat) { + if(o_e) callback(" ", 1, context); else o_e = true; + mycss_declaration_serialization_background_repeat(entry, bg->repeat, callback, context); + } + + if(bg->attachment) { + if(o_e) callback(" ", 1, context); else o_e = true; + mycss_declaration_serialization_type_list(entry, bg->attachment, callback, context); + } + + if(bg->clip) { + if(o_e) callback(" ", 1, context); else o_e = true; + mycss_declaration_serialization_type_list(entry, bg->clip, callback, context); + } + + if(bg->origin) { + if(o_e) callback(" ", 1, context); + mycss_declaration_serialization_type_list(entry, bg->origin, callback, context); + } + mycss_declaration_serialization_important_if_need(dec_entry, callback, context); - + return true; } diff --git a/source/mycss/property/parser_background.c b/source/mycss/property/parser_background.c index 0900ca7..d582905 100644 --- a/source/mycss/property/parser_background.c +++ b/source/mycss/property/parser_background.c @@ -255,12 +255,11 @@ static bool mycss_property_parser_background_step_end(mycss_entry_t* entry, mycs entry->parser = mycss_property_parser_background; if(token->type == MyCSS_TOKEN_TYPE_COMMA) { - mycss_values_background_t *background = mycss_values_background_list_current_entry(entry->declaration->entry_last->value); + mycss_values_background_t *background = entry->declaration->entry_last->value; if(background->color) return mycss_property_shared_switch_to_parse_error(entry); - - mycss_values_background_list_add_entry(entry, entry->declaration->entry_last->value); + return true; } diff --git a/source/mycss/values/destroy.c b/source/mycss/values/destroy.c index ebf0268..86ff72c 100644 --- a/source/mycss/values/destroy.c +++ b/source/mycss/values/destroy.c @@ -598,41 +598,33 @@ mycss_values_background_size_list_t * mycss_values_destroy_background_size(mycss return value; } -mycss_values_background_list_t * mycss_values_destroy_background(mycss_entry_t* entry, mycss_values_background_list_t* value, bool self_destroy) +mycss_values_background_t * mycss_values_destroy_background(mycss_entry_t* entry, mycss_values_background_t* value, bool self_destroy) { if(value == NULL) return NULL; - - mycss_values_background_t* bg_entry; - - for(size_t i = 0; i < value->entries_length; i++) { - bg_entry = &value->entries[i]; - - if(bg_entry->color) - mycss_values_destroy_color(entry, bg_entry->color->value, true); - if(bg_entry->image) - mycss_values_destroy_image(entry, bg_entry->image->value, true); - if(bg_entry->position) - mycss_values_destroy_background_position(entry, bg_entry->position->value, true); - if(bg_entry->size) - mycss_values_destroy_background_size(entry, bg_entry->size->value, true); - if(bg_entry->repeat) - mycss_values_destroy_background_repeat(entry, bg_entry->repeat->value, true); - if(bg_entry->attachment) - mycss_values_destroy_type_list(entry, bg_entry->attachment->value, true); - if(bg_entry->clip) - mycss_values_destroy_type_list(entry, bg_entry->clip->value, true); - if(bg_entry->origin) - mycss_values_destroy_type_list(entry, bg_entry->origin->value, true); - } - - mycss_values_destroy(entry, (void*)value->entries); - + + if(value->color) + mycss_values_destroy_color(entry, value->color->value, true); + if(value->image) + mycss_values_destroy_image(entry, value->image->value, true); + if(value->position) + mycss_values_destroy_background_position(entry, value->position->value, true); + if(value->size) + mycss_values_destroy_background_size(entry, value->size->value, true); + if(value->repeat) + mycss_values_destroy_background_repeat(entry, value->repeat->value, true); + if(value->attachment) + mycss_values_destroy_type_list(entry, value->attachment->value, true); + if(value->clip) + mycss_values_destroy_type_list(entry, value->clip->value, true); + if(value->origin) + mycss_values_destroy_type_list(entry, value->origin->value, true); + if(self_destroy) { mycss_values_destroy(entry, (void*)value); return NULL; } - + return value; } diff --git a/source/mycss/values/destroy.h b/source/mycss/values/destroy.h index 67d6a32..86fda09 100644 --- a/source/mycss/values/destroy.h +++ b/source/mycss/values/destroy.h @@ -66,7 +66,7 @@ mycss_values_cross_fade_t * mycss_values_destroy_cross_fade(mycss_entry_t* entry mycss_values_image_list_t * mycss_values_destroy_image_list(mycss_entry_t* entry, mycss_values_image_list_t* value, bool self_destroy); /* Background */ -mycss_values_background_list_t * mycss_values_destroy_background(mycss_entry_t* entry, mycss_values_background_list_t* value, bool self_destroy); +mycss_values_background_t * mycss_values_destroy_background(mycss_entry_t* entry, mycss_values_background_t* value, bool self_destroy); mycss_values_background_repeat_list_t * mycss_values_destroy_background_repeat(mycss_entry_t* entry, mycss_values_background_repeat_list_t* value, bool self_destroy); mycss_values_background_position_t * mycss_values_destroy_background_position(mycss_entry_t* entry, mycss_values_background_position_t* value, bool self_destroy); mycss_values_background_size_list_t * mycss_values_destroy_background_size(mycss_entry_t* entry, mycss_values_background_size_list_t* value, bool self_destroy); diff --git a/source/mycss/values/values.c b/source/mycss/values/values.c index 8f18f6e..dd39480 100644 --- a/source/mycss/values/values.c +++ b/source/mycss/values/values.c @@ -138,30 +138,3 @@ mycss_values_background_size_entry_t * mycss_values_background_size_list_add_ent return size_entry; } -mycss_values_background_t * mycss_values_background_list_add_entry(mycss_entry_t* entry, mycss_values_background_list_t *list) -{ - if(list->entries == NULL) { - list->entries = mycss_values_create(entry, sizeof(mycss_values_background_t)); - list->entries_length = 0; - } - else { - list->entries = mycss_values_realloc(entry, list->entries, - list->entries_length * sizeof(mycss_values_background_t), - sizeof(mycss_values_background_t)); - } - - mycss_values_background_t *bg = &list->entries[ list->entries_length ]; - list->entries_length++; - - return bg; -} - -mycss_values_background_t * mycss_values_background_list_current_entry(mycss_values_background_list_t *list) -{ - if(list->entries_length == 0) - return NULL; - - return &list->entries[ (list->entries_length - 1) ]; -} - - diff --git a/source/mycss/values/values.h b/source/mycss/values/values.h index b1cc84f..3cb098d 100644 --- a/source/mycss/values/values.h +++ b/source/mycss/values/values.h @@ -67,7 +67,6 @@ typedef struct mycss_values_background_position mycss_values_background_position typedef struct mycss_values_background_size_list mycss_values_background_size_list_t; typedef struct mycss_values_background_size_entry mycss_values_background_size_entry_t; typedef struct mycss_values_background mycss_values_background_t; -typedef struct mycss_values_background_list mycss_values_background_list_t; typedef struct mycss_values_border mycss_values_border_t;