-
Notifications
You must be signed in to change notification settings - Fork 65
New CSS selector ":contains(text)" #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lexborisov
merged 26 commits into
lexborisov:master
from
f34nk:support-for-pseudo-class-contains
Mar 26, 2018
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ee1578e
Added new pseudo-clas type 'contains'; Added placeholder function for…
f34nk 97fc234
Marked function as TODO and added default return
f34nk d6e9727
Added _contains declaration
f34nk f2bd21d
Incremented xy_LAST_ENTRY
f34nk bfdc22b
Added missing functions
f34nk f5e7360
In Progress...
f34nk b97bce9
Removed binaries
f34nk 6322e2c
Added more debugging prints
f34nk 6b7c2c4
Generated new 'mycss_selectors_function_begin_map_index' with 'perl u…
f34nk 3ef1c28
Removed some debug printing
f34nk bfc5256
In progress
f34nk aed3e3d
Prepared for serialization...
f34nk 5883615
modest_finder_selector_sub_type_pseudo_class_function_contains in pro…
f34nk bec0bc8
Implemented modest_finder_selector_sub_type_pseudo_class_function_con…
f34nk b4e4e45
Some cleanup...
f34nk a3040f2
Removed all dev printing
f34nk 11bddf6
Minor change
f34nk 5feb533
Merge branch 'master' into support-for-pseudo-class-contains
f34nk 8b947b6
Cleanup
f34nk 8dc0c4c
Cleanup
f34nk bee75d5
Added parser for 'contains'
f34nk 2f65f50
Removed concat function; Refactored 'modest_finder_selector_sub_type_…
f34nk f8076d9
Added comma separated arguments test
f34nk 76b1839
Added failed allocation check
f34nk d650d01
Removed memory leak in case mycore_realloc failes
f34nk 412ba67
Cleaned formatting
f34nk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,72 @@ bool modest_finder_selector_sub_type_pseudo_class_function_has(modest_finder_t* | |
return false; | ||
} | ||
|
||
bool modest_finder_selector_sub_type_pseudo_class_function_contains(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | ||
{ | ||
if(base_node == NULL) | ||
return false; | ||
|
||
myhtml_tree_node_t *text_node = myhtml_node_child(base_node); | ||
if(text_node == NULL) | ||
return false; | ||
|
||
const char* text = myhtml_node_text(text_node, NULL); | ||
if(text == NULL) | ||
return false; | ||
|
||
mycss_selectors_list_t *list = (mycss_selectors_list_t*)selector->value; | ||
for(size_t i = 0; i < list->entries_list_length; i++) { | ||
char *data = NULL; | ||
data = mycore_malloc(0); | ||
if(data == NULL) { | ||
return false; | ||
} | ||
|
||
mycss_selectors_entry_t *sel_entry = list->entries_list[i].entry; | ||
if(sel_entry->key->data){ | ||
const char *str = sel_entry->key->data; | ||
int length = strlen(str) + 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add new line after this |
||
|
||
char *new_data = mycore_realloc(data, length); | ||
if(new_data == NULL) { | ||
mycore_free(data); | ||
return false; | ||
} | ||
|
||
snprintf(new_data, length, "%s", str); | ||
data = new_data; | ||
} | ||
|
||
mycss_selectors_entry_t *next = sel_entry->next; | ||
while(next) { | ||
if(next->key->data) { | ||
int prev = strlen(data); | ||
const char *whitespace = (prev > 0) ? " " : ""; | ||
const char *str = next->key->data; | ||
int length = strlen(whitespace) + strlen(str) + 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new line after |
||
|
||
char *new_data = mycore_realloc(data, prev + length); | ||
if(new_data == NULL) { | ||
mycore_free(data); | ||
return false; | ||
} | ||
|
||
snprintf(&new_data[prev], length, "%s%s", whitespace, str); | ||
data = new_data; | ||
} | ||
next = next->next; | ||
} | ||
|
||
if(strstr(text, data) != NULL) { | ||
mycore_free(data); | ||
return true; | ||
} | ||
mycore_free(data); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool modest_finder_selector_sub_type_pseudo_class_function_lang(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | ||
{ | ||
return false; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.