diff --git a/include/mycss/values/values.h b/include/mycss/values/values.h index 50a97e0..3cbffae 100644 --- a/include/mycss/values/values.h +++ b/include/mycss/values/values.h @@ -471,10 +471,6 @@ struct mycss_values_background { mycss_declaration_entry_t* color; }; -struct mycss_values_background_list { - mycss_values_background_t* entries; - size_t entries_length; -}; struct mycss_values_background_repeat { mycss_property_background_t horizontal; @@ -517,9 +513,6 @@ mycss_values_image_t * mycss_values_image_list_add_entry(mycss_entry_t* entry, m mycss_values_background_repeat_t * mycss_values_background_repeat_list_add_entry(mycss_entry_t* entry, mycss_values_background_repeat_list_t *list); mycss_values_background_size_entry_t * mycss_values_background_size_list_add_entry(mycss_entry_t* entry, mycss_values_background_size_list_t *list); -mycss_values_background_t * mycss_values_background_list_add_entry(mycss_entry_t* entry, mycss_values_background_list_t *list); -mycss_values_background_t * mycss_values_background_list_current_entry(mycss_values_background_list_t *list); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/source/mycss/property/parser_background.c b/source/mycss/property/parser_background.c index d582905..b744208 100644 --- a/source/mycss/property/parser_background.c +++ b/source/mycss/property/parser_background.c @@ -306,7 +306,7 @@ static bool mycss_property_parser_background_step_size_height(mycss_entry_t* ent mycore_string_t str = {0}; mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last; - mycss_values_background_t *background = mycss_values_background_list_current_entry(dec_entry->value); + mycss_values_background_t *background = dec_entry->value; void *value = NULL; unsigned int value_type = 0; @@ -345,7 +345,7 @@ bool mycss_property_parser_background_step_size(mycss_entry_t* entry, mycss_toke mycore_string_t str = {0}; mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last; - mycss_values_background_t *background = mycss_values_background_list_current_entry(dec_entry->value); + mycss_values_background_t *background = dec_entry->value; void *value = NULL; unsigned int value_type = 0; @@ -403,7 +403,7 @@ static bool mycss_property_parser_background_step_position(mycss_entry_t* entry, if(mycss_property_shared_background_position(entry, token, &value, &value_type, &str)) { - mycss_values_background_t *background = mycss_values_background_list_current_entry(dec_entry->value); + mycss_values_background_t *background = dec_entry->value; if(mycss_property_parser_background_check_position(entry, background, value, value_type)) return mycss_property_parser_destroy_string(&str, true); @@ -422,7 +422,7 @@ static bool mycss_property_parser_background_step_repeat_wait_two(mycss_entry_t* mycore_string_t str = {0}; mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last; - mycss_values_background_t *background = mycss_values_background_list_current_entry(dec_entry->value); + mycss_values_background_t *background = dec_entry->value; unsigned int value_type = 0; @@ -443,11 +443,8 @@ static bool mycss_property_parser_background_step_repeat_wait_two(mycss_entry_t* mycss_values_background_t * mycss_property_parser_background_check_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry) { - mycss_values_background_t *background = mycss_values_background_list_current_entry(dec_entry->value); - - if(background == NULL) - return mycss_values_background_list_add_entry(entry, dec_entry->value); - + mycss_values_background_t *background = dec_entry->value; + return background; } @@ -465,18 +462,16 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token bool parser_changed = false; if(dec_entry->value == NULL) - dec_entry->value = mycss_values_create(entry, sizeof(mycss_values_background_list_t)); - + dec_entry->value = mycss_values_create(entry, sizeof(mycss_values_background_t)); + /* Image */ if(mycss_property_shared_image(entry, token, &value, &value_type, &str, &parser_changed)) { - mycss_values_background_t *background = mycss_property_parser_background_check_entry(entry, dec_entry); - - if(background->image) - return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry)); - - background->image = mycss_declaration_entry_create(entry->declaration, NULL); + mycss_values_background_t *background = dec_entry->value; + if(background->image == NULL) + background->image = mycss_declaration_entry_create(entry->declaration, NULL); + if(background->image->value == NULL) background->image->value = mycss_values_create(entry, sizeof(mycss_values_image_list_t)); @@ -503,10 +498,8 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token { mycss_values_background_t *background = mycss_property_parser_background_check_entry(entry, dec_entry); - if(background->image) - return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry)); - - background->image = mycss_declaration_entry_create(entry->declaration, NULL); + if(background->image == NULL) + background->image = mycss_declaration_entry_create(entry->declaration, NULL); if(background->image->value == NULL) background->image->value = mycss_values_create(entry, sizeof(mycss_values_image_list_t)); @@ -528,10 +521,9 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token { mycss_values_background_t *background = mycss_property_parser_background_check_entry(entry, dec_entry); - if(background->position) - return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry)); - - background->position = mycss_declaration_entry_create(entry->declaration, NULL); + if(background->position == NULL) + background->position = mycss_declaration_entry_create(entry->declaration, NULL); + background->position->type = MyCSS_PROPERTY_TYPE_BACKGROUND_POSITION; if(mycss_property_parser_background_check_position(entry, background, value, value_type)) { @@ -547,10 +539,8 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token { mycss_values_background_t *background = mycss_property_parser_background_check_entry(entry, dec_entry); - if(background->repeat) - return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry)); - - background->repeat = mycss_declaration_entry_create(entry->declaration, NULL); + if(background->repeat == NULL) + background->repeat = mycss_declaration_entry_create(entry->declaration, NULL); if(background->repeat->value == NULL) background->repeat->value = mycss_values_create(entry, sizeof(mycss_values_background_repeat_list_t)); @@ -568,10 +558,8 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token { mycss_values_background_t *background = mycss_property_parser_background_check_entry(entry, dec_entry); - if(background->repeat) - return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry)); - - background->repeat = mycss_declaration_entry_create(entry->declaration, NULL); + if(background->repeat == NULL) + background->repeat = mycss_declaration_entry_create(entry->declaration, NULL); if(background->repeat->value == NULL) background->repeat->value = mycss_values_create(entry, sizeof(mycss_values_background_repeat_list_t)); @@ -590,10 +578,8 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token { mycss_values_background_t *background = mycss_property_parser_background_check_entry(entry, dec_entry); - if(background->color) - return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry)); - - background->color = mycss_declaration_entry_create(entry->declaration, NULL); + if(background->color == NULL) + background->color = mycss_declaration_entry_create(entry->declaration, NULL); background->color->type = MyCSS_PROPERTY_TYPE_BACKGROUND_COLOR; background->color->value = value; background->color->value_type = value_type; @@ -614,10 +600,8 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token { mycss_values_background_t *background = mycss_property_parser_background_check_entry(entry, dec_entry); - if(background->attachment) - return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry)); - - background->attachment = mycss_declaration_entry_create(entry->declaration, NULL); + if(background->attachment == NULL) + background->attachment = mycss_declaration_entry_create(entry->declaration, NULL); if(background->attachment->value == NULL) background->attachment->value = mycss_values_create(entry, sizeof(mycss_values_type_list_t)); @@ -637,10 +621,8 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token mycss_values_background_t *background = mycss_property_parser_background_check_entry(entry, dec_entry); if(background->clip) { - if(background->origin) - return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry)); - - background->origin = mycss_declaration_entry_create(entry->declaration, NULL); + if(background->origin == NULL) + background->origin = mycss_declaration_entry_create(entry->declaration, NULL); if(background->origin->value == NULL) background->origin->value = mycss_values_create(entry, sizeof(mycss_values_type_list_t)); diff --git a/source/mycss/values/values.c b/source/mycss/values/values.c index dd39480..dd52aa4 100644 --- a/source/mycss/values/values.c +++ b/source/mycss/values/values.c @@ -102,39 +102,3 @@ mycss_values_image_t * mycss_values_image_list_add_entry(mycss_entry_t* entry, m return image; } -mycss_values_background_repeat_t * mycss_values_background_repeat_list_add_entry(mycss_entry_t* entry, mycss_values_background_repeat_list_t *list) -{ - if(list->entries == NULL) { - list->entries = mycss_values_create(entry, sizeof(mycss_values_background_repeat_t)); - list->entries_length = 0; - } - else { - list->entries = mycss_values_realloc(entry, list->entries, - list->entries_length * sizeof(mycss_values_background_repeat_t), - sizeof(mycss_values_background_repeat_t)); - } - - mycss_values_background_repeat_t *repeat = &list->entries[ list->entries_length ]; - list->entries_length++; - - return repeat; -} - -mycss_values_background_size_entry_t * mycss_values_background_size_list_add_entry(mycss_entry_t* entry, mycss_values_background_size_list_t *list) -{ - if(list->entries == NULL) { - list->entries = mycss_values_create(entry, sizeof(mycss_values_background_size_entry_t)); - list->entries_length = 0; - } - else { - list->entries = mycss_values_realloc(entry, list->entries, - list->entries_length * sizeof(mycss_values_background_size_entry_t), - sizeof(mycss_values_background_size_entry_t)); - } - - mycss_values_background_size_entry_t *size_entry = &list->entries[ list->entries_length ]; - list->entries_length++; - - return size_entry; -} - diff --git a/source/mycss/values/values.h b/source/mycss/values/values.h index 3cb098d..0fceafe 100644 --- a/source/mycss/values/values.h +++ b/source/mycss/values/values.h @@ -471,10 +471,6 @@ struct mycss_values_background { mycss_declaration_entry_t* color; }; -struct mycss_values_background_list { - mycss_values_background_t* entries; - size_t entries_length; -}; struct mycss_values_background_repeat { mycss_property_background_t horizontal; @@ -517,9 +513,6 @@ mycss_values_image_t * mycss_values_image_list_add_entry(mycss_entry_t* entry, m mycss_values_background_repeat_t * mycss_values_background_repeat_list_add_entry(mycss_entry_t* entry, mycss_values_background_repeat_list_t *list); mycss_values_background_size_entry_t * mycss_values_background_size_list_add_entry(mycss_entry_t* entry, mycss_values_background_size_list_t *list); -mycss_values_background_t * mycss_values_background_list_add_entry(mycss_entry_t* entry, mycss_values_background_list_t *list); -mycss_values_background_t * mycss_values_background_list_current_entry(mycss_values_background_list_t *list); - #ifdef __cplusplus } /* extern "C" */ #endif