line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
7
|
|
|
|
|
|
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
|
21
|
|
|
|
|
|
size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] * |
32
|
14
|
|
|
|
|
|
mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] * |
33
|
|
|
|
|
|
|
length) |
34
|
7
|
|
|
|
|
|
% static_size) + 1; |
35
|
|
|
|
|
|
|
|
36
|
7
|
100
|
|
|
|
|
while (pseudo[idx].name) |
37
|
|
|
|
|
|
|
{ |
38
|
5
|
50
|
|
|
|
|
if(pseudo[idx].length == length) { |
39
|
5
|
50
|
|
|
|
|
if(mycore_strncasecmp(pseudo[idx].name, name, length) == 0) |
40
|
5
|
|
|
|
|
|
return &pseudo[idx]; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if(pseudo[idx].next) |
43
|
0
|
|
|
|
|
|
idx = pseudo[idx].next; |
44
|
|
|
|
|
|
|
else |
45
|
0
|
|
|
|
|
|
return NULL; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
0
|
|
|
|
|
else if(pseudo[idx].length > length) { |
48
|
0
|
|
|
|
|
|
return NULL; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else { |
51
|
0
|
|
|
|
|
|
idx = pseudo[idx].next; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
|
return NULL; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
4
|
|
|
|
|
|
mycss_selectors_sub_type_pseudo_class_t mycss_pseudo_class_by_name(const char *name, size_t length) |
59
|
|
|
|
|
|
|
{ |
60
|
4
|
|
|
|
|
|
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
|
4
|
100
|
|
|
|
|
if(entry) |
63
|
2
|
|
|
|
|
|
return entry->sub_type; |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
|
return MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_UNKNOWN; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
|
mycss_selectors_sub_type_pseudo_element_t mycss_pseudo_element_by_name(const char *name, size_t length) |
69
|
|
|
|
|
|
|
{ |
70
|
3
|
|
|
|
|
|
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
|
3
|
50
|
|
|
|
|
if(entry) |
73
|
3
|
|
|
|
|
|
return entry->sub_type; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return MyCSS_SELECTORS_SUB_TYPE_PSEUDO_ELEMENT_UNKNOWN; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|