« third_party/modest/source/mycss/selectors/list.c
↑ Summary
third_party/modest/source/mycss/selectors/value.c »
| 1 | /* | ||||||||||
| 2 | Copyright (C) 2016-2017 Alexander Borisov | ||||||||||
| 3 | |||||||||||
| 4 | This library is free software; you can redistribute it and/or | ||||||||||
| 5 | modify it under the terms of the GNU Lesser General Public | ||||||||||
| 6 | License as published by the Free Software Foundation; either | ||||||||||
| 7 | version 2.1 of the License, or (at your option) any later version. | ||||||||||
| 8 | |||||||||||
| 9 | This library is distributed in the hope that it will be useful, | ||||||||||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||
| 12 | Lesser General Public License for more details. | ||||||||||
| 13 | |||||||||||
| 14 | You should have received a copy of the GNU Lesser General Public | ||||||||||
| 15 | License along with this library; if not, write to the Free Software | ||||||||||
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||||||||
| 17 | |||||||||||
| 18 | Author: lex.borisov@gmail.com (Alexander Borisov) | ||||||||||
| 19 | */ | ||||||||||
| 20 | |||||||||||
| 21 | #include "mycss/selectors/pseudo.h" | ||||||||||
| 22 | #include "mycss/selectors/pseudo_resource.h" | ||||||||||
| 23 | #include "mycore/utils/resources.h" | ||||||||||
| 24 | |||||||||||
| 25 | ///////////////////////////////////////////////////////// | ||||||||||
| 26 | //// Functions for a find Begin Function | ||||||||||
| 27 | //// | ||||||||||
| 28 | ///////////////////////////////////////////////////////// | ||||||||||
| 29 | 0 | const mycss_selectots_pseudo_begin_entry_t * mycss_pseudo_begin_entry_by_name(const char* name, size_t length, size_t static_size, const mycss_selectots_pseudo_begin_entry_t* pseudo) | |||||||||
| 30 | { | ||||||||||
| 31 | 0 | size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] * | |||||||||
| 32 | 0 | mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] * | |||||||||
| 33 | length) | ||||||||||
| 34 | 0 | % static_size) + 1; | |||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | while (pseudo[idx].name) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | { | ||||||||||
| 38 | 0 | ▶ | if(pseudo[idx].length == length) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | ▶ | if(mycore_strncasecmp(pseudo[idx].name, name, length) == 0) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | return &pseudo[idx]; | |||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | if(pseudo[idx].next) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | idx = pseudo[idx].next; | |||||||||
| 44 | else | ||||||||||
| 45 | 0 | return NULL; | |||||||||
| 46 | } | ||||||||||
| 47 | 0 | ▶ | else if(pseudo[idx].length > length) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | return NULL; | |||||||||
| 49 | } | ||||||||||
| 50 | else { | ||||||||||
| 51 | 0 | idx = pseudo[idx].next; | |||||||||
| 52 | } | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 0 | return NULL; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 0 | mycss_selectors_sub_type_pseudo_class_t mycss_pseudo_class_by_name(const char *name, size_t length) | |||||||||
| 59 | { | ||||||||||
| 60 | 0 | const mycss_selectots_pseudo_begin_entry_t *entry = mycss_pseudo_begin_entry_by_name(name, length, MyCSS_SELECTORS_PSEUDO_CLASS_NAME_STATIC_SIZE, mycss_selectors_pseudo_class_begin_map_index); | |||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | if(entry) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | return entry->sub_type; | |||||||||
| 64 | |||||||||||
| 65 | 0 | return MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_UNKNOWN; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 0 | mycss_selectors_sub_type_pseudo_element_t mycss_pseudo_element_by_name(const char *name, size_t length) | |||||||||
| 69 | { | ||||||||||
| 70 | 0 | const mycss_selectots_pseudo_begin_entry_t *entry = mycss_pseudo_begin_entry_by_name(name, length, MyCSS_SELECTORS_PSEUDO_ELEMENT_NAME_STATIC_SIZE, mycss_selectors_pseudo_element_begin_map_index); | |||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | if(entry) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 0 | return entry->sub_type; | |||||||||
| 74 | |||||||||||
| 75 | 0 | return MyCSS_SELECTORS_SUB_TYPE_PSEUDO_ELEMENT_UNKNOWN; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | |||||||||||