mirror of
https://github.com/lexborisov/Modest
synced 2024-11-22 05:41:32 +03:00
modest_finder_selector_sub_type_pseudo_class_function_contains in progress...
This commit is contained in:
parent
aed3e3d105
commit
58836153d9
Binary file not shown.
@ -1 +0,0 @@
|
||||
libmodest-0.0.6.so
|
@ -1 +0,0 @@
|
||||
libmodest-0.0.6.so
|
@ -1 +0,0 @@
|
||||
libmodest-0.0.6.so
|
Binary file not shown.
@ -187,23 +187,29 @@ myhtml_tree_node_t * modest_finder_node_combinator_begin(modest_finder_t* finder
|
||||
myhtml_tree_node_t *node = base_node;
|
||||
|
||||
// FRANK
|
||||
printf("\nmodest_finder_node_combinator_begin()\n\t%s\n", (node)?"has node":"no node");
|
||||
printf("\nmodest_finder_node_combinator_begin()\n");
|
||||
printf("\t%s\n", (node)?"has node":"no node");
|
||||
printf("\tselector->type = %d\n", (int)selector->type);
|
||||
|
||||
while(node) {
|
||||
if(node->tag_id != MyHTML_TAG__TEXT && node->tag_id != MyHTML_TAG__COMMENT &&
|
||||
modest_finder_static_selector_type_map[selector->type](finder, node, selector, spec))
|
||||
{
|
||||
printf("\t%s\n", (selector->next != NULL)?"has next":"no next");
|
||||
// printf("\nmodest_finder_node_combinator_begin()\n");
|
||||
// printf("\t%s\n", (selector->next != NULL)?"has next":"no next");
|
||||
if(selector->next == NULL) {
|
||||
printf("\t%s\n", (callback_found)?"callback_found":"no callback_found");
|
||||
// printf("\t%s\n", (callback_found)?"callback_found":"no callback_found");
|
||||
if(callback_found)
|
||||
callback_found(finder, node, selector_list, selector, spec, ctx);
|
||||
}
|
||||
else {
|
||||
printf("\tselector->next->combinator = %d\n", (int)selector->next->combinator);
|
||||
// printf("\nmodest_finder_node_combinator_begin()\n");
|
||||
// printf("\tselector->next->combinator = %d\n", (int)selector->next->combinator);
|
||||
|
||||
myhtml_tree_node_t *find_node = modest_finder_static_selector_combinator_map[selector->next->combinator](finder, node, selector_list, selector->next, spec, callback_found, ctx);
|
||||
printf("\t%s\n", (find_node)?"find_node":"no find_node");
|
||||
|
||||
// printf("\nmodest_finder_node_combinator_begin()\n");
|
||||
// printf("\t%s\n", (find_node)?"find_node":"no find_node");
|
||||
|
||||
if(find_node == NULL) {
|
||||
while(node != base_node && node->next == NULL)
|
||||
|
@ -82,23 +82,57 @@ bool modest_finder_selector_sub_type_pseudo_class_function_contains(modest_finde
|
||||
// FRANK
|
||||
// TODO: implemenet
|
||||
printf("\nmodest_finder_selector_sub_type_pseudo_class_function_contains()\n");
|
||||
// mycss_selectors_list_t *list = selector->value;
|
||||
// bool i_found;
|
||||
printf("\t%s\n", (base_node) ? "has base_node" : "no base_node");
|
||||
printf("\t%s\n", (selector->value) ? "selector->value exists" : "selector->value does not exist");
|
||||
|
||||
if(base_node){
|
||||
const char *tag_name = myhtml_tag_name_by_id(base_node->tree, myhtml_node_tag_id(base_node), NULL);
|
||||
printf("\ttag_name = %s\n", tag_name);
|
||||
myhtml_position_t pos = myhtml_node_raw_position(base_node);
|
||||
printf("\tpos = %d -> %d\n", (int)pos.begin, (int)pos.length);
|
||||
|
||||
myhtml_tree_node_t *text_node = myhtml_node_child(base_node);
|
||||
if(text_node) {
|
||||
const char* text = myhtml_node_text(text_node, NULL);
|
||||
if(text){
|
||||
printf("\ttext = %s\n", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for(size_t i = 0; i < list->entries_list_length; i++)
|
||||
// {
|
||||
// i_found = false;
|
||||
mycss_selectors_list_t *list = selector->value;
|
||||
bool i_found;
|
||||
|
||||
for(size_t i = 0; i < list->entries_list_length; i++)
|
||||
{
|
||||
i_found = false;
|
||||
|
||||
// mycss_selectors_entry_t *sel_entry = list->entries_list[i].entry;
|
||||
mycss_selectors_entry_t *sel_entry = list->entries_list[i].entry;
|
||||
// printf("\tsel_entry->value = %s\n", (char*)sel_entry->value);
|
||||
printf("\tsel_entry->key->data = %s\n", (char*)sel_entry->key->data);
|
||||
// printf("\tsel_entry->key->size = %d\n", (int)sel_entry->key->size);
|
||||
// printf("\tsel_entry->key->length = %d\n", (int)sel_entry->key->length);
|
||||
|
||||
printf("\t%s\n", (sel_entry->next) ? "has sel_entry->next" : "no sel_entry->next");
|
||||
|
||||
mycss_selectors_entry_t *next = sel_entry->next;
|
||||
while(next){
|
||||
printf("\tnext->key->data = %s\n", (char*)next->key->data);
|
||||
next = next->next;
|
||||
}
|
||||
|
||||
// printf("\tsel_entry->combinator = %d\n", (int)sel_entry->combinator);
|
||||
|
||||
// if(sel_entry->combinator == MyCSS_SELECTORS_COMBINATOR_UNDEF){
|
||||
// printf("\tMyCSS_SELECTORS_COMBINATOR_UNDEF\n");
|
||||
// modest_finder_node_combinator_descendant(finder, base_node, NULL, sel_entry, spec, modest_finder_callback_found_with_bool, &i_found);
|
||||
// }
|
||||
// else
|
||||
// modest_finder_static_selector_combinator_map[sel_entry->combinator](finder, base_node, NULL, sel_entry, spec, modest_finder_callback_found_with_bool, &i_found);
|
||||
|
||||
// if(sel_entry->combinator == MyCSS_SELECTORS_COMBINATOR_UNDEF)
|
||||
// modest_finder_node_combinator_descendant(finder, base_node, NULL, sel_entry, spec, modest_finder_callback_found_with_bool, &i_found);
|
||||
// else
|
||||
// modest_finder_static_selector_combinator_map[sel_entry->combinator](finder, base_node, NULL, sel_entry, spec, modest_finder_callback_found_with_bool, &i_found);
|
||||
|
||||
// if(i_found == true)
|
||||
// return true;
|
||||
// }
|
||||
if(i_found == true)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -113,7 +113,8 @@ bool modest_finder_selector_type_attribute(modest_finder_t* finder, myhtml_tree_
|
||||
bool modest_finder_selector_type_pseudo_class_function(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
|
||||
{
|
||||
// FRANK
|
||||
printf("\nmodest_finder_selector_type_pseudo_class_function()\n\tselector->sub_type = %d\n", (int)selector->sub_type);
|
||||
printf("\nmodest_finder_selector_type_pseudo_class_function()\n");
|
||||
printf("\tselector->sub_type = %d\n", (int)selector->sub_type);
|
||||
|
||||
if(selector->sub_type < MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_LAST_ENTRY)
|
||||
return modest_finder_static_selector_sub_type_pseudo_class_function_map[selector->sub_type](finder, node, selector, spec);
|
||||
|
@ -113,14 +113,28 @@ void mycss_selectors_function_begin_has(mycss_entry_t* entry, mycss_selectors_en
|
||||
void mycss_selectors_function_begin_contains(mycss_entry_t* entry, mycss_selectors_entry_t* selector)
|
||||
{
|
||||
selector->sub_type = MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_CONTAINS;
|
||||
selector->value = NULL;
|
||||
entry->parser = mycss_selectors_function_parser_contains;
|
||||
// selector->value = NULL;
|
||||
// entry->parser = mycss_selectors_function_parser_contains;
|
||||
|
||||
// FRANK
|
||||
// TODO: implement
|
||||
printf("\nmycss_selectors_function_begin_contains()\n");
|
||||
printf("\tselector->sub_type = %d\n", (int)selector->sub_type);
|
||||
// printf("\tselector->sub_type = %d\n", (int)selector->sub_type);
|
||||
|
||||
mycss_selectors_t *selectors = entry->selectors;
|
||||
mycss_selectors_list_t **new_list = (mycss_selectors_list_t**)(&selectors->entry_last->value);
|
||||
mycss_selectors_list_t *current_list = selectors->list_last;
|
||||
|
||||
selectors->list = new_list;
|
||||
selectors->list_last = NULL;
|
||||
selectors->ending_token = entry->parser_ending_token;
|
||||
|
||||
mycss_selectors_state_relative_selector_list(entry, NULL, true);
|
||||
|
||||
(*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)
|
||||
|
@ -241,9 +241,9 @@ bool mycss_selectors_function_parser_contains(mycss_entry_t* entry, mycss_token_
|
||||
printf("\nmycss_selectors_function_parser_contains()\n");
|
||||
// printf("\ttoken->type = %d\n\tentry->parser_ending_token = %d\n\tlast_response = %d\n", (int)token->type, entry->parser_ending_token, (int)last_response);
|
||||
|
||||
// mycss_selectors_t *selectors = entry->selectors;
|
||||
// mycss_selectors_entry_t *selector = selectors->entry_last;
|
||||
// printf("\t%s\n", (selector->value) ? "selector->value exists" : "selector->value does not exist");
|
||||
mycss_selectors_t *selectors = entry->selectors;
|
||||
mycss_selectors_entry_t *selector = selectors->entry_last;
|
||||
printf("\t%s\n", (selector->value) ? "selector->value exists" : "selector->value does not exist");
|
||||
|
||||
if(token){
|
||||
|
||||
|
@ -142,7 +142,9 @@ mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* se
|
||||
|
||||
status = mycss_tokenizer_end(entry);
|
||||
|
||||
printf("\nmycss_selectors_parse_by_function()\n\tstatus = %d %s\n", (int)status, ((int)status == MyHTML_STATUS_OK)?"MyHTML_STATUS_OK":"not OK");
|
||||
// FRANK
|
||||
// printf("\nmycss_selectors_parse_by_function()\n");
|
||||
// printf("\tstatus = %d %s\n", (int)status, ((int)status == MyHTML_STATUS_OK)?"MyHTML_STATUS_OK":"not OK");
|
||||
|
||||
if(out_status)
|
||||
*out_status = status;
|
||||
@ -150,7 +152,8 @@ mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* se
|
||||
if(list)
|
||||
return list;
|
||||
|
||||
printf("\n\tmissing list, return NULL\n");
|
||||
// FRANK
|
||||
// printf("\n\tmissing list, return NULL\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -274,7 +274,8 @@ void mycss_selectors_parser_selector_pseudo_class_function(mycss_entry_t* entry,
|
||||
mycss_selectors_function_begin_f to_func = mycss_function_begin_by_name(str->data, str->length);
|
||||
|
||||
// FRANK
|
||||
printf("\nmycss_selectors_parser_selector_pseudo_class_function()\n\tbegin_by_name = '%s'\n\t%s\n", str->data, (to_func) ? "exists" : "does not exist");
|
||||
// printf("\nmycss_selectors_parser_selector_pseudo_class_function()\n");
|
||||
// printf("\tbegin_by_name = '%s'\n\t%s\n", str->data, (to_func) ? "exists" : "does not exist");
|
||||
|
||||
if(to_func) {
|
||||
to_func(entry, selector);
|
||||
|
@ -51,6 +51,8 @@ bool mycss_selectors_serialization_contains(mycss_selectors_t* selectors, void *
|
||||
// TODO: implement
|
||||
// FRANK
|
||||
printf("\nmycss_selectors_serialization_contains()\n");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -60,8 +62,8 @@ bool mycss_selectors_serialization_list(mycss_selectors_t* selectors, mycss_sele
|
||||
while(selectors_list) {
|
||||
|
||||
// FRANK
|
||||
printf("\nmycss_selectors_serialization_list()\n");
|
||||
printf("\tselectors_list->entries_list_length = %d\n", (int)selectors_list->entries_list_length);
|
||||
// printf("\nmycss_selectors_serialization_list()\n");
|
||||
// printf("\tselectors_list->entries_list_length = %d\n", (int)selectors_list->entries_list_length);
|
||||
|
||||
for(size_t i = 0; i < selectors_list->entries_list_length; i++)
|
||||
{
|
||||
@ -94,6 +96,11 @@ bool mycss_selectors_serialization_list(mycss_selectors_t* selectors, mycss_sele
|
||||
bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector,
|
||||
mycore_callback_serialize_f callback, void* context)
|
||||
{
|
||||
// FRANK
|
||||
// printf("\nmycss_selectors_serialization_selector()\n");
|
||||
// printf("\tselector->type = %d\n", (int)selector->type);
|
||||
// printf("\tselector->sub_type = %d\n", (int)selector->sub_type);
|
||||
|
||||
switch(selector->type) {
|
||||
case MyCSS_SELECTORS_TYPE_ELEMENT: {
|
||||
if(selector->ns_entry)
|
||||
@ -163,19 +170,16 @@ bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_
|
||||
}
|
||||
|
||||
callback("(", 1, context);
|
||||
|
||||
// FRANK
|
||||
printf("\nmycss_selectors_serialization_selector()\n\tselector->sub_type = %d\n", (int)selector->sub_type);
|
||||
|
||||
switch (selector->sub_type) {
|
||||
case MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_CONTAINS:
|
||||
// TODO: implement
|
||||
// FRANK
|
||||
printf("\tMyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_CONTAINS\n");
|
||||
printf("\t%s\n", (selector->value) ? "selector value exists" : "selector value does not exist");
|
||||
// printf("\n\tMyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_CONTAINS\n");
|
||||
// printf("\t%s\n", (selector->value) ? "selector value exists" : "selector value does not exist");
|
||||
|
||||
// if(selector->value)
|
||||
// mycss_selectors_serialization_contains(selectors, selector->value, callback, context);
|
||||
if(selector->value)
|
||||
mycss_selectors_serialization_list(selectors, selector->value, callback, context);
|
||||
break;
|
||||
|
||||
// case MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_CONTAINS:
|
||||
|
@ -152,7 +152,7 @@ void * mycss_selectors_value_pseudo_class_function_contains_create(mycss_entry_t
|
||||
// TODO: implement
|
||||
// FRANK
|
||||
printf("\nmycss_selectors_value_pseudo_class_function_contains_create()\n");
|
||||
return NULL;
|
||||
return mycss_selectors_list_create(entry->selectors);
|
||||
}
|
||||
|
||||
void * mycss_selectors_value_pseudo_class_function_lang_create(mycss_entry_t* entry, bool set_clean)
|
||||
@ -253,6 +253,23 @@ void * mycss_selectors_value_pseudo_class_function_has_destroy(mycss_entry_t* en
|
||||
return mycss_selectors_list_destroy(entry->selectors, value, self_destroy);
|
||||
}
|
||||
|
||||
void * mycss_selectors_value_pseudo_class_function_contains_destroy(mycss_entry_t* entry, void* value, bool self_destroy)
|
||||
{
|
||||
// FRANK
|
||||
// TODO: implement
|
||||
printf("\nmycss_selectors_value_pseudo_class_function_contains_destroy()\n");
|
||||
|
||||
if(value == NULL)
|
||||
return NULL;
|
||||
|
||||
if(self_destroy) {
|
||||
mchar_async_free(entry->mchar, entry->mchar_value_node_id, value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void * mycss_selectors_value_pseudo_class_function_lang_destroy(mycss_entry_t* entry, void* value, bool self_destroy)
|
||||
{
|
||||
if(value == NULL)
|
||||
@ -373,20 +390,5 @@ void * mycss_selectors_value_pseudo_class_function_nth_of_type_destroy(mycss_ent
|
||||
return value;
|
||||
}
|
||||
|
||||
void * mycss_selectors_value_pseudo_class_function_contains_destroy(mycss_entry_t* entry, void* value, bool self_destroy)
|
||||
{
|
||||
// FRANK
|
||||
// TODO: implement
|
||||
printf("\nmycss_selectors_value_pseudo_class_function_contains_destroy()\n");
|
||||
|
||||
if(value == NULL)
|
||||
return NULL;
|
||||
|
||||
if(self_destroy) {
|
||||
mchar_async_free(entry->mchar, entry->mchar_value_node_id, value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -86,8 +86,10 @@ mycss_selectors_list_t * prepare_selector(mycss_entry_t *css_entry, const char*
|
||||
MyENCODING_UTF_8,
|
||||
selector, selector_size,
|
||||
&out_status);
|
||||
printf("\nprepare_selector()\n\t%s\n", (list != NULL)?"has list":"no list");
|
||||
printf("\tlist->flags = %d\n", (int)list->flags);
|
||||
|
||||
// printf("\nprepare_selector()\n");
|
||||
// printf("\t%s\n", (list != NULL)?"has list":"no list");
|
||||
// printf("\tlist->flags = %d\n", (int)list->flags);
|
||||
|
||||
/* check parsing errors */
|
||||
if(list == NULL || (list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD)) {
|
||||
@ -102,7 +104,7 @@ mycss_selectors_list_t * prepare_selector(mycss_entry_t *css_entry, const char*
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("\treturn list\n");
|
||||
// printf("\treturn list\n");
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -123,7 +125,7 @@ void print_found_result(myhtml_tree_t* html_tree, myhtml_collection_t *collectio
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
const char *html = "<div>Another <p>Hello World</p></div>";
|
||||
const char *html = "<div>Another<p>Hello World</p><p>Something Else</p></div>";
|
||||
// const char *selector = ":has(p)";
|
||||
const char *selector = "p:contains(Hello World)";
|
||||
|
||||
|
BIN
test/myurl/url
BIN
test/myurl/url
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user