Added parser for 'contains'

This commit is contained in:
frank 2018-03-26 14:24:12 +02:00
parent 8dc0c4c2b5
commit bee75d5d36
2 changed files with 63 additions and 2 deletions

View File

@ -34,7 +34,7 @@ const mycss_selectots_function_begin_entry_t * mycss_function_begin_entry_by_nam
% MyCSS_SELECTORS_FUNCTION_NAME_STATIC_SIZE) + 1;
while (mycss_selectors_function_begin_map_index[idx].name)
{
{
if(mycss_selectors_function_begin_map_index[idx].length == length) {
if(mycore_strncasecmp(mycss_selectors_function_begin_map_index[idx].name, name, length) == 0)
return &mycss_selectors_function_begin_map_index[idx];
@ -126,7 +126,7 @@ void mycss_selectors_function_begin_contains(mycss_entry_t* entry, mycss_selecto
(*new_list)->parent = current_list;
mycss_entry_parser_list_push(entry, mycss_selectors_function_parser_has, entry->parser_switch, entry->parser_ending_token, false);
mycss_entry_parser_list_push(entry, mycss_selectors_function_parser_contains, entry->parser_switch, entry->parser_ending_token, false);
}
void mycss_selectors_function_begin_nth_last_child(mycss_entry_t* entry, mycss_selectors_entry_t* selector)

View File

@ -223,6 +223,67 @@ bool mycss_selectors_function_parser_has(mycss_entry_t* entry, mycss_token_t* to
return false;
}
///////////////////////////////////////////////////////////
////// CONTAINS
//////
///////////////////////////////////////////////////////////
void mycss_selectors_function_parser_contains_find_bad_selector(mycss_selectors_list_t* selectors_list)
{
for(size_t i = 0; i < selectors_list->entries_list_length; i++) {
mycss_selectors_entry_t* selector = selectors_list->entries_list[i].entry;
while(selector) {
if(selector->type == MyCSS_SELECTORS_TYPE_PSEUDO_ELEMENT) {
if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
return;
}
selector = selector->next;
}
}
}
bool mycss_selectors_function_parser_contains(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
{
mycss_selectors_t *selectors = entry->selectors;
mycss_selectors_list_t *selectors_list = selectors->list_last;
mycss_selectors_list_t *parent_list = selectors->list_last->parent;
selectors->entry_last = mycss_selectors_list_last_entry(parent_list);
selectors->list_last = parent_list;
selectors->specificity = &parent_list->entries_list[ (parent_list->entries_list_length - 1) ].specificity;
mycss_selectors_function_parser_contains_find_bad_selector(selectors_list);
selectors_list = mycss_selectors_parser_check_selector_list(selectors, selectors_list);
if(selectors_list == NULL) {
if(selectors->entry_last) {
selectors->entry_last->value = NULL;
selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
}
}
else if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) && selectors->entry_last) {
selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
}
if(token->type == entry->parser_ending_token) {
mycss_entry_parser_list_pop(entry);
return false;
}
if(selectors_list)
selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
if(selectors->entry_last)
selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
entry->parser = mycss_selectors_function_parser_state_drop_component_value;
return false;
}
///////////////////////////////////////////////////////////
////// NTH OF SELECTORS
//////