Changes for api function modest_finder_by_selectors_list

This commit is contained in:
lexborisov 2016-11-22 14:30:38 +03:00
parent 11bcf850bc
commit a7621943de
4 changed files with 16 additions and 15 deletions

View File

@ -82,7 +82,8 @@ int main(int argc, const char * argv[])
mycss_selectors_list_t *list = mycss_selectors_parse(mycss_entry_selectors(css_entry), MyHTML_ENCODING_UTF_8, selector, strlen(selector), &out_status); mycss_selectors_list_t *list = mycss_selectors_parse(mycss_entry_selectors(css_entry), MyHTML_ENCODING_UTF_8, selector, strlen(selector), &out_status);
myhtml_collection_t *collection = modest_finder_by_selectors_list(finder, list, html_tree->node_html, NULL); myhtml_collection_t *collection = NULL;
modest_finder_by_selectors_list(finder, list, html_tree->node_html, &collection);
/* print result */ /* print result */
fprintf(stdout, "HTML Tree:\n"); fprintf(stdout, "HTML Tree:\n");

View File

@ -61,8 +61,8 @@ void modest_finder_begin(modest_finder_t* finder, myhtml_tree_node_t* base_node,
modest_finder_t * modest_finder_by_stylesheet(myhtml_tree_t* myhtml_tree, mycss_stylesheet_t *stylesheet, modest_finder_t * modest_finder_by_stylesheet(myhtml_tree_t* myhtml_tree, mycss_stylesheet_t *stylesheet,
myhtml_collection_t** collection, myhtml_tree_node_t* base_node, mycss_selectors_list_t* selector_list); myhtml_collection_t** collection, myhtml_tree_node_t* base_node, mycss_selectors_list_t* selector_list);
myhtml_collection_t * modest_finder_by_selectors_list(modest_finder_t* finder, mycss_selectors_list_t *sel_list, modest_status_t modest_finder_by_selectors_list(modest_finder_t* finder, mycss_selectors_list_t* selector_list,
myhtml_tree_node_t* base_node, myhtml_collection_t* collection); myhtml_tree_node_t* scope_node, myhtml_collection_t** collection);
/* process */ /* process */
myhtml_tree_node_t * modest_finder_node_combinator_begin(modest_finder_t* finder, myhtml_tree_node_t* base_node, myhtml_tree_node_t * modest_finder_node_combinator_begin(modest_finder_t* finder, myhtml_tree_node_t* base_node,

View File

@ -165,28 +165,28 @@ modest_finder_t * modest_finder_by_stylesheet(myhtml_tree_t* myhtml_tree, mycss_
return finder; return finder;
} }
myhtml_collection_t * modest_finder_by_selectors_list(modest_finder_t* finder, mycss_selectors_list_t *selector_list, modest_status_t modest_finder_by_selectors_list(modest_finder_t* finder, mycss_selectors_list_t* selector_list,
myhtml_tree_node_t* base_node, myhtml_collection_t* collection) myhtml_tree_node_t* scope_node, myhtml_collection_t** collection)
{ {
if(finder == NULL || selector_list == NULL || base_node == NULL) if(finder == NULL || selector_list == NULL || scope_node == NULL || collection == NULL)
return NULL; return MODEST_STATUS_ERROR;
if(collection == NULL) { if(*collection == NULL) {
myhtml_status_t status; myhtml_status_t status;
collection = myhtml_collection_create(4096, &status); *collection = myhtml_collection_create(4096, &status);
if(status) if(status)
return NULL; return MODEST_STATUS_ERROR_MEMORY_ALLOCATION;
} }
for(size_t i = 0; i < selector_list->entries_list_length; i++) { for(size_t i = 0; i < selector_list->entries_list_length; i++) {
mycss_selectors_specificity_t spec = selector_list->entries_list[i].specificity; mycss_selectors_specificity_t spec = selector_list->entries_list[i].specificity;
modest_finder_node_combinator_begin(finder, base_node, selector_list, selector_list->entries_list[i].entry, &spec, modest_finder_node_combinator_begin(finder, scope_node, selector_list, selector_list->entries_list[i].entry, &spec,
modest_finder_callback_found_with_collection, collection); modest_finder_callback_found_with_collection, *collection);
} }
return collection; return MODEST_STATUS_OK;
} }
void modest_finder_begin(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector) void modest_finder_begin(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector)

View File

@ -61,8 +61,8 @@ void modest_finder_begin(modest_finder_t* finder, myhtml_tree_node_t* base_node,
modest_finder_t * modest_finder_by_stylesheet(myhtml_tree_t* myhtml_tree, mycss_stylesheet_t *stylesheet, modest_finder_t * modest_finder_by_stylesheet(myhtml_tree_t* myhtml_tree, mycss_stylesheet_t *stylesheet,
myhtml_collection_t** collection, myhtml_tree_node_t* base_node, mycss_selectors_list_t* selector_list); myhtml_collection_t** collection, myhtml_tree_node_t* base_node, mycss_selectors_list_t* selector_list);
myhtml_collection_t * modest_finder_by_selectors_list(modest_finder_t* finder, mycss_selectors_list_t *sel_list, modest_status_t modest_finder_by_selectors_list(modest_finder_t* finder, mycss_selectors_list_t* selector_list,
myhtml_tree_node_t* base_node, myhtml_collection_t* collection); myhtml_tree_node_t* scope_node, myhtml_collection_t** collection);
/* process */ /* process */
myhtml_tree_node_t * modest_finder_node_combinator_begin(modest_finder_t* finder, myhtml_tree_node_t* base_node, myhtml_tree_node_t * modest_finder_node_combinator_begin(modest_finder_t* finder, myhtml_tree_node_t* base_node,