Merge pull request #75 from aygulsalahli/collation-fixes

Change the way background is parsed and serialized; One node can have…
This commit is contained in:
Alexander 2019-11-14 12:41:48 +03:00 committed by GitHub
commit 4c03bfc2a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 315 additions and 222 deletions

View File

@ -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" */

View File

@ -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,

View File

@ -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);

View File

@ -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;
@ -472,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;
@ -518,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

View File

@ -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);
}
}

View File

@ -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" */

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}
@ -307,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;
@ -346,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;
@ -404,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);
@ -423,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;
@ -444,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;
}
@ -466,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));
@ -504,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));
@ -529,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)) {
@ -548,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));
@ -569,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));
@ -591,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;
@ -615,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));
@ -638,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));

View File

@ -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;
}

View File

@ -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);

View File

@ -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) ];
}

View File

@ -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;
@ -472,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;
@ -518,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