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/values/color_parser.h" |
22
|
|
|
|
|
|
|
#include "mycore/utils/resources.h" |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_undef(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
|
|
|
return mycss_property_shared_switch_to_parse_error(entry); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
static void mycss_values_color_parser_switch_parser(mycss_entry_t* entry) |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
|
|
|
mycss_stack_entry_t *stack_entry = mycss_stack_pop(entry->declaration->stack); |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if(stack_entry->value) |
34
|
0
|
|
|
|
|
|
entry->declaration->entry_last->value = stack_entry->value; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
entry->parser = stack_entry->parser; |
37
|
0
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
static bool mycss_values_color_parser_find_end(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
42
|
0
|
|
|
|
|
|
return true; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS) |
47
|
0
|
|
|
|
|
|
return true; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return false; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
static void mycss_values_color_parser_set_percentage_value(mycss_entry_t* entry, mycss_token_t* token, mycss_values_percentage_t *color_rgb) |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
|
|
|
mycore_string_t str = {0}; |
55
|
0
|
|
|
|
|
|
mycss_token_data_to_string(entry, token, &str, true, false); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
double return_num; |
58
|
0
|
|
|
|
|
|
mycss_convert_data_to_double(str.data, str.length, &return_num, &color_rgb->is_float); |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if(color_rgb->is_float) |
61
|
0
|
|
|
|
|
|
color_rgb->value.f = (float)return_num; |
62
|
|
|
|
|
|
|
else |
63
|
0
|
|
|
|
|
|
color_rgb->value.i = (int)return_num; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
mycore_string_destroy(&str, false); |
66
|
0
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
static void mycss_values_color_parser_set_number_value(mycss_entry_t* entry, mycss_token_t* token, mycss_values_number_t *color_rgb) |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
|
|
|
|
|
mycore_string_t str = {0}; |
71
|
0
|
|
|
|
|
|
mycss_token_data_to_string(entry, token, &str, true, false); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
double return_num; |
74
|
0
|
|
|
|
|
|
mycss_convert_data_to_double(str.data, str.length, &return_num, &color_rgb->is_float); |
75
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
if(color_rgb->is_float) |
77
|
0
|
|
|
|
|
|
color_rgb->value.f = (float)return_num; |
78
|
|
|
|
|
|
|
else |
79
|
0
|
|
|
|
|
|
color_rgb->value.i = (int)return_num; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
mycore_string_destroy(&str, false); |
82
|
0
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
static bool mycss_values_color_parser_set_angle_value(mycss_entry_t* entry, mycss_token_t* token, mycss_values_angle_t *angle) |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
|
|
|
mycore_string_t str = {0}; |
87
|
0
|
|
|
|
|
|
mycss_token_data_to_string(entry, token, &str, true, false); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
bool is_float; |
90
|
|
|
|
|
|
|
double return_num; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
size_t consume_length = mycss_convert_data_to_double(str.data, str.length, &return_num, &is_float); |
93
|
0
|
|
|
|
|
|
mycss_units_type_t type = mycss_units_type_by_name(&str.data[consume_length], (str.length - consume_length)); |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
mycore_string_destroy(&str, false); |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
switch (type) { |
98
|
|
|
|
|
|
|
case MyCSS_UNIT_TYPE_DEG: |
99
|
|
|
|
|
|
|
case MyCSS_UNIT_TYPE_GRAD: |
100
|
|
|
|
|
|
|
case MyCSS_UNIT_TYPE_RAD: |
101
|
|
|
|
|
|
|
case MyCSS_UNIT_TYPE_TURN: |
102
|
0
|
|
|
|
|
|
break; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
default: |
105
|
0
|
|
|
|
|
|
return false; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
if(is_float) |
109
|
0
|
|
|
|
|
|
angle->value.f = (float)return_num; |
110
|
|
|
|
|
|
|
else |
111
|
0
|
|
|
|
|
|
angle->value.i = (int)return_num; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
angle->is_float = is_float; |
114
|
0
|
|
|
|
|
|
angle->type = type; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return true; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
static bool mycss_values_color_parser_rgb_full(mycss_entry_t* entry, mycss_token_t* token, mycss_values_color_t *color) |
120
|
|
|
|
|
|
|
{ |
121
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) |
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_percentage.r); |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE; |
126
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_before_g_percentage; |
127
|
|
|
|
|
|
|
} |
128
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) |
129
|
|
|
|
|
|
|
{ |
130
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_number.r); |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
133
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_before_g_number; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
else { |
136
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
137
|
0
|
|
|
|
|
|
return false; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return true; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
144
|
|
|
|
|
|
|
{ |
145
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
146
|
0
|
|
|
|
|
|
return true; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
149
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
151
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
152
|
0
|
|
|
|
|
|
return false; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
156
|
0
|
|
|
|
|
|
color->type = MyCSS_VALUES_COLOR_TYPE_RGB; |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
return mycss_values_color_parser_rgb_full(entry, token, color); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgba(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
162
|
|
|
|
|
|
|
{ |
163
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
164
|
0
|
|
|
|
|
|
return true; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
167
|
|
|
|
|
|
|
|
168
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
169
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
170
|
0
|
|
|
|
|
|
return false; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
174
|
0
|
|
|
|
|
|
color->type = MyCSS_VALUES_COLOR_TYPE_RGBA; |
175
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
return mycss_values_color_parser_rgb_full(entry, token, color); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
/* |
180
|
|
|
|
|
|
|
* For percentage type |
181
|
|
|
|
|
|
|
*/ |
182
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_before_g_percentage(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
183
|
|
|
|
|
|
|
{ |
184
|
0
|
|
|
|
|
|
switch (token->type) { |
185
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
186
|
0
|
|
|
|
|
|
return true; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
189
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_g_percentage; |
190
|
0
|
|
|
|
|
|
return true; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_PERCENTAGE: |
193
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_g_percentage; |
194
|
0
|
|
|
|
|
|
return false; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
default: |
197
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
198
|
0
|
|
|
|
|
|
return false; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_g_percentage(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
203
|
|
|
|
|
|
|
{ |
204
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
205
|
0
|
|
|
|
|
|
return true; |
206
|
|
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_PERCENTAGE) { |
208
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
209
|
0
|
|
|
|
|
|
return false; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
213
|
|
|
|
|
|
|
|
214
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
215
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
216
|
0
|
|
|
|
|
|
return false; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
220
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_percentage.g); |
221
|
|
|
|
|
|
|
|
222
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_before_b_percentage; |
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
return true; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_before_b_percentage(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
228
|
|
|
|
|
|
|
{ |
229
|
0
|
|
|
|
|
|
switch (token->type) { |
230
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
231
|
0
|
|
|
|
|
|
return true; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
234
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_b_percentage; |
235
|
0
|
|
|
|
|
|
return true; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_PERCENTAGE: |
238
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_b_percentage; |
239
|
0
|
|
|
|
|
|
return false; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
default: |
242
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
243
|
0
|
|
|
|
|
|
return false; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_b_percentage(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
248
|
|
|
|
|
|
|
{ |
249
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
250
|
0
|
|
|
|
|
|
return true; |
251
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_PERCENTAGE) |
252
|
0
|
|
|
|
|
|
return mycss_property_shared_switch_to_parse_error(entry); |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
255
|
|
|
|
|
|
|
|
256
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
257
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
258
|
0
|
|
|
|
|
|
return false; |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
262
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_percentage.b); |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_before_alpha_percentage; |
265
|
0
|
|
|
|
|
|
return true; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_before_alpha_percentage(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
269
|
|
|
|
|
|
|
{ |
270
|
0
|
|
|
|
|
|
switch (token->type) { |
271
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
272
|
0
|
|
|
|
|
|
return true; |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
275
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_alpha_percentage; |
276
|
0
|
|
|
|
|
|
return true; |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS: |
279
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
280
|
0
|
|
|
|
|
|
return true; |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_DELIM: |
283
|
0
|
0
|
|
|
|
|
if(*token->data == '/') { |
284
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_alpha_percentage; |
285
|
0
|
|
|
|
|
|
return true; |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
/* fall through */ |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
default: |
290
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
291
|
0
|
|
|
|
|
|
return false; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
|
295
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_alpha_percentage(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
296
|
|
|
|
|
|
|
{ |
297
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
298
|
0
|
|
|
|
|
|
return true; |
299
|
|
|
|
|
|
|
|
300
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
301
|
|
|
|
|
|
|
|
302
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
303
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
304
|
0
|
|
|
|
|
|
return false; |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
308
|
|
|
|
|
|
|
|
309
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) { |
310
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_percentage.alpha.value.percentage); |
311
|
0
|
|
|
|
|
|
color->value.rgba_percentage.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE; |
312
|
|
|
|
|
|
|
} |
313
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) { |
314
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_percentage.alpha.value.number); |
315
|
0
|
|
|
|
|
|
color->value.rgba_percentage.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
else { |
318
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
319
|
0
|
|
|
|
|
|
return false; |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_find_end; |
323
|
0
|
|
|
|
|
|
return true; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
/* |
327
|
|
|
|
|
|
|
* For number type |
328
|
|
|
|
|
|
|
*/ |
329
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_before_g_number(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
330
|
|
|
|
|
|
|
{ |
331
|
0
|
|
|
|
|
|
switch (token->type) { |
332
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
333
|
0
|
|
|
|
|
|
return true; |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
336
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_g_number; |
337
|
0
|
|
|
|
|
|
return true; |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_NUMBER: |
340
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_g_number; |
341
|
0
|
|
|
|
|
|
return false; |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
default: |
344
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
345
|
0
|
|
|
|
|
|
return false; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_g_number(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
350
|
|
|
|
|
|
|
{ |
351
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
352
|
0
|
|
|
|
|
|
return true; |
353
|
|
|
|
|
|
|
|
354
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_NUMBER) { |
355
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
356
|
0
|
|
|
|
|
|
return false; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
|
359
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
360
|
|
|
|
|
|
|
|
361
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
362
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
363
|
0
|
|
|
|
|
|
return false; |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
367
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_number.g); |
368
|
|
|
|
|
|
|
|
369
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_before_b_number; |
370
|
0
|
|
|
|
|
|
return true; |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
|
373
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_before_b_number(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
374
|
|
|
|
|
|
|
{ |
375
|
0
|
|
|
|
|
|
switch (token->type) { |
376
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
377
|
0
|
|
|
|
|
|
return true; |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
380
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_b_number; |
381
|
0
|
|
|
|
|
|
return true; |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_NUMBER: |
384
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_b_number; |
385
|
0
|
|
|
|
|
|
return false; |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
default: |
388
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
389
|
0
|
|
|
|
|
|
return false; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_b_number(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
394
|
|
|
|
|
|
|
{ |
395
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
396
|
0
|
|
|
|
|
|
return true; |
397
|
|
|
|
|
|
|
|
398
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_NUMBER) { |
399
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
400
|
0
|
|
|
|
|
|
return false; |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
404
|
|
|
|
|
|
|
|
405
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
406
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
407
|
0
|
|
|
|
|
|
return false; |
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
|
410
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
411
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_number.b); |
412
|
|
|
|
|
|
|
|
413
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_before_alpha_number; |
414
|
0
|
|
|
|
|
|
return true; |
415
|
|
|
|
|
|
|
} |
416
|
|
|
|
|
|
|
|
417
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_before_alpha_number(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
418
|
|
|
|
|
|
|
{ |
419
|
0
|
|
|
|
|
|
switch (token->type) { |
420
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
421
|
0
|
|
|
|
|
|
return true; |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
424
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_alpha_number; |
425
|
0
|
|
|
|
|
|
return true; |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS: |
428
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
429
|
0
|
|
|
|
|
|
return true; |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_DELIM: |
432
|
0
|
0
|
|
|
|
|
if(*token->data == '/') { |
433
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_rgb_alpha_number; |
434
|
0
|
|
|
|
|
|
return true; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
/* fall through */ |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
default: |
439
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
440
|
0
|
|
|
|
|
|
return false; |
441
|
|
|
|
|
|
|
} |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_rgb_alpha_number(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
445
|
|
|
|
|
|
|
{ |
446
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
447
|
0
|
|
|
|
|
|
return true; |
448
|
|
|
|
|
|
|
|
449
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
450
|
|
|
|
|
|
|
|
451
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
452
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
453
|
0
|
|
|
|
|
|
return false; |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
|
456
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
457
|
|
|
|
|
|
|
|
458
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) { |
459
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_number.alpha.value.percentage); |
460
|
0
|
|
|
|
|
|
color->value.rgba_number.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE; |
461
|
|
|
|
|
|
|
} |
462
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) { |
463
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_number.alpha.value.number); |
464
|
0
|
|
|
|
|
|
color->value.rgba_number.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
else { |
467
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
468
|
0
|
|
|
|
|
|
return false; |
469
|
|
|
|
|
|
|
} |
470
|
|
|
|
|
|
|
|
471
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_find_end; |
472
|
0
|
|
|
|
|
|
return true; |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
/* |
476
|
|
|
|
|
|
|
* HSL and HSLA |
477
|
|
|
|
|
|
|
*/ |
478
|
0
|
|
|
|
|
|
static bool mycss_values_color_parser_hsla_full(mycss_entry_t* entry, mycss_token_t* token, mycss_values_color_t *color) |
479
|
|
|
|
|
|
|
{ |
480
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_DIMENSION) { |
481
|
0
|
0
|
|
|
|
|
if(mycss_values_color_parser_set_angle_value(entry, token, &color->value.hsla.hue.value.angle) == false) { |
482
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
483
|
0
|
|
|
|
|
|
return false; |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
|
486
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_ANGLE; |
487
|
|
|
|
|
|
|
} |
488
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) |
489
|
|
|
|
|
|
|
{ |
490
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.hsla.hue.value.number); |
491
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
else { |
494
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
495
|
0
|
|
|
|
|
|
return false; |
496
|
|
|
|
|
|
|
} |
497
|
|
|
|
|
|
|
|
498
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_before_saturation; |
499
|
0
|
|
|
|
|
|
return true; |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
|
502
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hsl(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
503
|
|
|
|
|
|
|
{ |
504
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
505
|
0
|
|
|
|
|
|
return true; |
506
|
|
|
|
|
|
|
|
507
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
508
|
|
|
|
|
|
|
|
509
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
510
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
511
|
0
|
|
|
|
|
|
return false; |
512
|
|
|
|
|
|
|
} |
513
|
|
|
|
|
|
|
|
514
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
515
|
0
|
|
|
|
|
|
color->type = MyCSS_VALUES_COLOR_TYPE_HSL; |
516
|
|
|
|
|
|
|
|
517
|
0
|
|
|
|
|
|
return mycss_values_color_parser_hsla_full(entry, token, color); |
518
|
|
|
|
|
|
|
} |
519
|
|
|
|
|
|
|
|
520
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hsla(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
521
|
|
|
|
|
|
|
{ |
522
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
523
|
0
|
|
|
|
|
|
return true; |
524
|
|
|
|
|
|
|
|
525
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
526
|
|
|
|
|
|
|
|
527
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
528
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
529
|
0
|
|
|
|
|
|
return false; |
530
|
|
|
|
|
|
|
} |
531
|
|
|
|
|
|
|
|
532
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
533
|
0
|
|
|
|
|
|
color->type = MyCSS_VALUES_COLOR_TYPE_HSLA; |
534
|
|
|
|
|
|
|
|
535
|
0
|
|
|
|
|
|
return mycss_values_color_parser_hsla_full(entry, token, color); |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
|
538
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hsl_before_saturation(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
539
|
|
|
|
|
|
|
{ |
540
|
0
|
|
|
|
|
|
switch (token->type) { |
541
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
542
|
0
|
|
|
|
|
|
return true; |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
545
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_saturation; |
546
|
0
|
|
|
|
|
|
return true; |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_PERCENTAGE: |
549
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_saturation; |
550
|
0
|
|
|
|
|
|
return false; |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
default: |
553
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
554
|
0
|
|
|
|
|
|
return false; |
555
|
|
|
|
|
|
|
} |
556
|
|
|
|
|
|
|
} |
557
|
|
|
|
|
|
|
|
558
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hsl_saturation(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
559
|
|
|
|
|
|
|
{ |
560
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
561
|
0
|
|
|
|
|
|
return true; |
562
|
|
|
|
|
|
|
|
563
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_PERCENTAGE) { |
564
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
565
|
0
|
|
|
|
|
|
return false; |
566
|
|
|
|
|
|
|
} |
567
|
|
|
|
|
|
|
|
568
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
569
|
|
|
|
|
|
|
|
570
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
571
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
572
|
0
|
|
|
|
|
|
return false; |
573
|
|
|
|
|
|
|
} |
574
|
|
|
|
|
|
|
|
575
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
576
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hsla.saturation); |
577
|
|
|
|
|
|
|
|
578
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_before_lightness; |
579
|
0
|
|
|
|
|
|
return true; |
580
|
|
|
|
|
|
|
} |
581
|
|
|
|
|
|
|
|
582
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hsl_before_lightness(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
583
|
|
|
|
|
|
|
{ |
584
|
0
|
|
|
|
|
|
switch (token->type) { |
585
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
586
|
0
|
|
|
|
|
|
return true; |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
589
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_lightness; |
590
|
0
|
|
|
|
|
|
return true; |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_PERCENTAGE: |
593
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_lightness; |
594
|
0
|
|
|
|
|
|
return false; |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
default: |
597
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
598
|
0
|
|
|
|
|
|
return false; |
599
|
|
|
|
|
|
|
} |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
|
602
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hsl_lightness(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
603
|
|
|
|
|
|
|
{ |
604
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
605
|
0
|
|
|
|
|
|
return true; |
606
|
|
|
|
|
|
|
|
607
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_PERCENTAGE) { |
608
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
609
|
0
|
|
|
|
|
|
return false; |
610
|
|
|
|
|
|
|
} |
611
|
|
|
|
|
|
|
|
612
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
613
|
|
|
|
|
|
|
|
614
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
615
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
616
|
0
|
|
|
|
|
|
return false; |
617
|
|
|
|
|
|
|
} |
618
|
|
|
|
|
|
|
|
619
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
620
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hsla.lightness); |
621
|
|
|
|
|
|
|
|
622
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_before_alpha; |
623
|
0
|
|
|
|
|
|
return true; |
624
|
|
|
|
|
|
|
} |
625
|
|
|
|
|
|
|
|
626
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hsl_before_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
627
|
|
|
|
|
|
|
{ |
628
|
0
|
|
|
|
|
|
switch (token->type) { |
629
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
630
|
0
|
|
|
|
|
|
return true; |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
633
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_alpha; |
634
|
0
|
|
|
|
|
|
return true; |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS: |
637
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
638
|
0
|
|
|
|
|
|
return true; |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_DELIM: |
641
|
0
|
0
|
|
|
|
|
if(*token->data == '/') { |
642
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hsl_alpha; |
643
|
0
|
|
|
|
|
|
return true; |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
/* fall through */ |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
default: |
648
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
649
|
0
|
|
|
|
|
|
return false; |
650
|
|
|
|
|
|
|
} |
651
|
|
|
|
|
|
|
} |
652
|
|
|
|
|
|
|
|
653
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hsl_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
654
|
|
|
|
|
|
|
{ |
655
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
656
|
0
|
|
|
|
|
|
return true; |
657
|
|
|
|
|
|
|
|
658
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
659
|
|
|
|
|
|
|
|
660
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
661
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
662
|
0
|
|
|
|
|
|
return false; |
663
|
|
|
|
|
|
|
} |
664
|
|
|
|
|
|
|
|
665
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
666
|
|
|
|
|
|
|
|
667
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) { |
668
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hsla.alpha.value.percentage); |
669
|
0
|
|
|
|
|
|
color->value.hsla.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE; |
670
|
|
|
|
|
|
|
} |
671
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) { |
672
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.hsla.alpha.value.number); |
673
|
0
|
|
|
|
|
|
color->value.hsla.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
else { |
676
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
677
|
0
|
|
|
|
|
|
return false; |
678
|
|
|
|
|
|
|
} |
679
|
|
|
|
|
|
|
|
680
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_find_end; |
681
|
0
|
|
|
|
|
|
return true; |
682
|
|
|
|
|
|
|
} |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
/* |
685
|
|
|
|
|
|
|
* HEX |
686
|
|
|
|
|
|
|
*/ |
687
|
0
|
|
|
|
|
|
static unsigned int mycss_values_color_parser_hex_get_by_two(unsigned char* u_data) |
688
|
|
|
|
|
|
|
{ |
689
|
0
|
|
|
|
|
|
return (mycore_string_chars_hex_map[ u_data[0] ] << 4) | mycore_string_chars_hex_map[ u_data[1] ]; |
690
|
|
|
|
|
|
|
} |
691
|
|
|
|
|
|
|
|
692
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str) |
693
|
|
|
|
|
|
|
{ |
694
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_HASH) |
695
|
0
|
|
|
|
|
|
return true; |
696
|
|
|
|
|
|
|
|
697
|
0
|
0
|
|
|
|
|
if(str->data == NULL) |
698
|
0
|
|
|
|
|
|
mycss_token_data_to_string(entry, token, str, true, false); |
699
|
|
|
|
|
|
|
|
700
|
0
|
|
|
|
|
|
unsigned char *u_data = (unsigned char*)str->data; |
701
|
0
|
|
|
|
|
|
mycss_values_color_t *color = (mycss_values_color_t*)mycss_values_create(entry, sizeof(mycss_values_color_t)); |
702
|
|
|
|
|
|
|
|
703
|
0
|
|
|
|
|
|
switch (str->length) { |
704
|
|
|
|
|
|
|
case 6: |
705
|
0
|
|
|
|
|
|
color->value.hex.r.value.i = (int)mycss_values_color_parser_hex_get_by_two(u_data); |
706
|
0
|
|
|
|
|
|
color->value.hex.g.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[2]); |
707
|
0
|
|
|
|
|
|
color->value.hex.b.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[4]); |
708
|
0
|
|
|
|
|
|
color->value.hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_UNDEF; |
709
|
|
|
|
|
|
|
|
710
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_6; |
711
|
0
|
|
|
|
|
|
break; |
712
|
|
|
|
|
|
|
case 8: |
713
|
0
|
|
|
|
|
|
color->value.hex.r.value.i = (int)mycss_values_color_parser_hex_get_by_two(u_data); |
714
|
0
|
|
|
|
|
|
color->value.hex.g.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[2]); |
715
|
0
|
|
|
|
|
|
color->value.hex.b.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[4]); |
716
|
|
|
|
|
|
|
|
717
|
0
|
|
|
|
|
|
color->value.hex.alpha.value.number.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[6]); |
718
|
0
|
|
|
|
|
|
color->value.hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
719
|
|
|
|
|
|
|
|
720
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_8; |
721
|
0
|
|
|
|
|
|
break; |
722
|
|
|
|
|
|
|
case 3: |
723
|
0
|
|
|
|
|
|
color->value.hex.r.value.i = (int)(mycore_string_chars_hex_map[ u_data[0] ]); |
724
|
0
|
|
|
|
|
|
color->value.hex.r.value.i = (color->value.hex.r.value.i << 4) | color->value.hex.r.value.i; |
725
|
|
|
|
|
|
|
|
726
|
0
|
|
|
|
|
|
color->value.hex.g.value.i = (int)(mycore_string_chars_hex_map[ u_data[1] ]); |
727
|
0
|
|
|
|
|
|
color->value.hex.g.value.i = (color->value.hex.g.value.i << 4) | color->value.hex.g.value.i; |
728
|
|
|
|
|
|
|
|
729
|
0
|
|
|
|
|
|
color->value.hex.b.value.i = (int)(mycore_string_chars_hex_map[ u_data[2] ]); |
730
|
0
|
|
|
|
|
|
color->value.hex.b.value.i = (color->value.hex.b.value.i << 4) | color->value.hex.b.value.i; |
731
|
|
|
|
|
|
|
|
732
|
0
|
|
|
|
|
|
color->value.hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_UNDEF; |
733
|
|
|
|
|
|
|
|
734
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_3; |
735
|
0
|
|
|
|
|
|
break; |
736
|
|
|
|
|
|
|
case 4: |
737
|
0
|
|
|
|
|
|
color->value.hex.r.value.i = (int)(mycore_string_chars_hex_map[ u_data[0] ]); |
738
|
0
|
|
|
|
|
|
color->value.hex.r.value.i = (color->value.hex.r.value.i << 4) | color->value.hex.r.value.i; |
739
|
|
|
|
|
|
|
|
740
|
0
|
|
|
|
|
|
color->value.hex.g.value.i = (int)(mycore_string_chars_hex_map[ u_data[1] ]); |
741
|
0
|
|
|
|
|
|
color->value.hex.g.value.i = (color->value.hex.g.value.i << 4) | color->value.hex.g.value.i; |
742
|
|
|
|
|
|
|
|
743
|
0
|
|
|
|
|
|
color->value.hex.b.value.i = (int)(mycore_string_chars_hex_map[ u_data[2] ]); |
744
|
0
|
|
|
|
|
|
color->value.hex.b.value.i = (color->value.hex.b.value.i << 4) | color->value.hex.b.value.i; |
745
|
|
|
|
|
|
|
|
746
|
0
|
|
|
|
|
|
color->value.hex.alpha.value.number.value.i = (int)(mycore_string_chars_hex_map[ u_data[3] ]); |
747
|
0
|
|
|
|
|
|
color->value.hex.alpha.value.number.value.i = (color->value.hex.alpha.value.number.value.i << 4) | color->value.hex.alpha.value.number.value.i; |
748
|
0
|
|
|
|
|
|
color->value.hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
749
|
|
|
|
|
|
|
|
750
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_4; |
751
|
0
|
|
|
|
|
|
break; |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
default: |
754
|
0
|
|
|
|
|
|
mycss_values_destroy(entry, (void*)color); |
755
|
|
|
|
|
|
|
|
756
|
0
|
|
|
|
|
|
*value_type = MyCSS_PROPERTY_VALUE_UNDEF; |
757
|
0
|
|
|
|
|
|
return false; |
758
|
|
|
|
|
|
|
} |
759
|
|
|
|
|
|
|
|
760
|
0
|
|
|
|
|
|
color->type = MyCSS_VALUES_COLOR_TYPE_HEX; |
761
|
|
|
|
|
|
|
|
762
|
0
|
|
|
|
|
|
*value = color; |
763
|
0
|
|
|
|
|
|
*value_type = MyCSS_PROPERTY_VALUE__COLOR; |
764
|
|
|
|
|
|
|
|
765
|
0
|
|
|
|
|
|
return true; |
766
|
|
|
|
|
|
|
} |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
/* |
769
|
|
|
|
|
|
|
* HWB |
770
|
|
|
|
|
|
|
*/ |
771
|
0
|
|
|
|
|
|
static bool mycss_values_color_parser_hwb_hue(mycss_entry_t* entry, mycss_token_t* token, mycss_values_color_t *color) |
772
|
|
|
|
|
|
|
{ |
773
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_DIMENSION) { |
774
|
0
|
0
|
|
|
|
|
if(mycss_values_color_parser_set_angle_value(entry, token, &color->value.hwb.hue.value.angle) == false) { |
775
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
776
|
0
|
|
|
|
|
|
return false; |
777
|
|
|
|
|
|
|
} |
778
|
|
|
|
|
|
|
|
779
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_ANGLE; |
780
|
|
|
|
|
|
|
} |
781
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) |
782
|
|
|
|
|
|
|
{ |
783
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.hwb.hue.value.number); |
784
|
0
|
|
|
|
|
|
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
785
|
|
|
|
|
|
|
} |
786
|
|
|
|
|
|
|
else { |
787
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
788
|
0
|
|
|
|
|
|
return false; |
789
|
|
|
|
|
|
|
} |
790
|
|
|
|
|
|
|
|
791
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_before_whiteness; |
792
|
0
|
|
|
|
|
|
return true; |
793
|
|
|
|
|
|
|
} |
794
|
|
|
|
|
|
|
|
795
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hwb(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
796
|
|
|
|
|
|
|
{ |
797
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
798
|
0
|
|
|
|
|
|
return true; |
799
|
|
|
|
|
|
|
|
800
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
801
|
|
|
|
|
|
|
|
802
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
803
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
804
|
0
|
|
|
|
|
|
return false; |
805
|
|
|
|
|
|
|
} |
806
|
|
|
|
|
|
|
|
807
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
808
|
0
|
|
|
|
|
|
color->type = MyCSS_VALUES_COLOR_TYPE_HWB; |
809
|
|
|
|
|
|
|
|
810
|
0
|
|
|
|
|
|
return mycss_values_color_parser_hwb_hue(entry, token, color); |
811
|
|
|
|
|
|
|
} |
812
|
|
|
|
|
|
|
|
813
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hwb_before_whiteness(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
814
|
|
|
|
|
|
|
{ |
815
|
0
|
|
|
|
|
|
switch (token->type) { |
816
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
817
|
0
|
|
|
|
|
|
return true; |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
820
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_whiteness; |
821
|
0
|
|
|
|
|
|
return true; |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_PERCENTAGE: |
824
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_whiteness; |
825
|
0
|
|
|
|
|
|
return false; |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
default: |
828
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
829
|
0
|
|
|
|
|
|
return false; |
830
|
|
|
|
|
|
|
} |
831
|
|
|
|
|
|
|
} |
832
|
|
|
|
|
|
|
|
833
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hwb_whiteness(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
834
|
|
|
|
|
|
|
{ |
835
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
836
|
0
|
|
|
|
|
|
return true; |
837
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_PERCENTAGE) |
838
|
0
|
|
|
|
|
|
return mycss_property_shared_switch_to_parse_error(entry); |
839
|
|
|
|
|
|
|
|
840
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
841
|
|
|
|
|
|
|
|
842
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
843
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
844
|
0
|
|
|
|
|
|
return false; |
845
|
|
|
|
|
|
|
} |
846
|
|
|
|
|
|
|
|
847
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
848
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hwb.saturation); |
849
|
|
|
|
|
|
|
|
850
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_before_blackness; |
851
|
0
|
|
|
|
|
|
return true; |
852
|
|
|
|
|
|
|
} |
853
|
|
|
|
|
|
|
|
854
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hwb_before_blackness(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
855
|
|
|
|
|
|
|
{ |
856
|
0
|
|
|
|
|
|
switch (token->type) { |
857
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
858
|
0
|
|
|
|
|
|
return true; |
859
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
861
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_blackness; |
862
|
0
|
|
|
|
|
|
return true; |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_PERCENTAGE: |
865
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_blackness; |
866
|
0
|
|
|
|
|
|
return false; |
867
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
default: |
869
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
870
|
0
|
|
|
|
|
|
return false; |
871
|
|
|
|
|
|
|
} |
872
|
|
|
|
|
|
|
} |
873
|
|
|
|
|
|
|
|
874
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hwb_blackness(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
875
|
|
|
|
|
|
|
{ |
876
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
877
|
0
|
|
|
|
|
|
return true; |
878
|
|
|
|
|
|
|
|
879
|
0
|
0
|
|
|
|
|
if(token->type != MyCSS_TOKEN_TYPE_PERCENTAGE) { |
880
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
881
|
0
|
|
|
|
|
|
return false; |
882
|
|
|
|
|
|
|
} |
883
|
|
|
|
|
|
|
|
884
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
885
|
|
|
|
|
|
|
|
886
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
887
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
888
|
0
|
|
|
|
|
|
return false; |
889
|
|
|
|
|
|
|
} |
890
|
|
|
|
|
|
|
|
891
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
892
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hwb.lightness); |
893
|
|
|
|
|
|
|
|
894
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_before_alpha; |
895
|
0
|
|
|
|
|
|
return true; |
896
|
|
|
|
|
|
|
} |
897
|
|
|
|
|
|
|
|
898
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hwb_before_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
899
|
|
|
|
|
|
|
{ |
900
|
0
|
|
|
|
|
|
switch (token->type) { |
901
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
902
|
0
|
|
|
|
|
|
return true; |
903
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
905
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_alpha; |
906
|
0
|
|
|
|
|
|
return true; |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS: |
909
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
910
|
0
|
|
|
|
|
|
return true; |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_DELIM: |
913
|
0
|
0
|
|
|
|
|
if(*token->data == '/') { |
914
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_hwb_alpha; |
915
|
0
|
|
|
|
|
|
return true; |
916
|
|
|
|
|
|
|
} |
917
|
|
|
|
|
|
|
/* fall through */ |
918
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
default: |
920
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
921
|
0
|
|
|
|
|
|
return false; |
922
|
|
|
|
|
|
|
} |
923
|
|
|
|
|
|
|
} |
924
|
|
|
|
|
|
|
|
925
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_hwb_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
926
|
|
|
|
|
|
|
{ |
927
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
928
|
0
|
|
|
|
|
|
return true; |
929
|
|
|
|
|
|
|
|
930
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
931
|
|
|
|
|
|
|
|
932
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
933
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
934
|
0
|
|
|
|
|
|
return false; |
935
|
|
|
|
|
|
|
} |
936
|
|
|
|
|
|
|
|
937
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
938
|
|
|
|
|
|
|
|
939
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) { |
940
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hwb.alpha.value.percentage); |
941
|
0
|
|
|
|
|
|
color->value.hwb.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE; |
942
|
|
|
|
|
|
|
} |
943
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) { |
944
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.hwb.alpha.value.number); |
945
|
0
|
|
|
|
|
|
color->value.hwb.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
946
|
|
|
|
|
|
|
} |
947
|
|
|
|
|
|
|
else { |
948
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
949
|
0
|
|
|
|
|
|
return false; |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
|
952
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_find_end; |
953
|
0
|
|
|
|
|
|
return true; |
954
|
|
|
|
|
|
|
} |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
/* |
957
|
|
|
|
|
|
|
* Gray |
958
|
|
|
|
|
|
|
*/ |
959
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_gray(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
960
|
|
|
|
|
|
|
{ |
961
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
962
|
0
|
|
|
|
|
|
return true; |
963
|
|
|
|
|
|
|
|
964
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
965
|
|
|
|
|
|
|
|
966
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
967
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
968
|
0
|
|
|
|
|
|
return false; |
969
|
|
|
|
|
|
|
} |
970
|
|
|
|
|
|
|
|
971
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
972
|
|
|
|
|
|
|
|
973
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_NUMBER) |
974
|
|
|
|
|
|
|
{ |
975
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.gray.number); |
976
|
0
|
|
|
|
|
|
color->type = MyCSS_VALUES_COLOR_TYPE_GRAY; |
977
|
|
|
|
|
|
|
|
978
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_gray_before_alpha; |
979
|
|
|
|
|
|
|
} |
980
|
|
|
|
|
|
|
else { |
981
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
982
|
0
|
|
|
|
|
|
return false; |
983
|
|
|
|
|
|
|
} |
984
|
|
|
|
|
|
|
|
985
|
0
|
|
|
|
|
|
return true; |
986
|
|
|
|
|
|
|
} |
987
|
|
|
|
|
|
|
|
988
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_gray_before_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
989
|
|
|
|
|
|
|
{ |
990
|
0
|
|
|
|
|
|
switch (token->type) { |
991
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
992
|
0
|
|
|
|
|
|
return true; |
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_COMMA: |
995
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_gray_alpha; |
996
|
0
|
|
|
|
|
|
return true; |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS: |
999
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
1000
|
0
|
|
|
|
|
|
return true; |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_DELIM: |
1003
|
0
|
0
|
|
|
|
|
if(*token->data == '/') { |
1004
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_gray_alpha; |
1005
|
0
|
|
|
|
|
|
return true; |
1006
|
|
|
|
|
|
|
} |
1007
|
|
|
|
|
|
|
/* fall through */ |
1008
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
default: |
1010
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
1011
|
0
|
|
|
|
|
|
return false; |
1012
|
|
|
|
|
|
|
} |
1013
|
|
|
|
|
|
|
} |
1014
|
|
|
|
|
|
|
|
1015
|
0
|
|
|
|
|
|
bool mycss_values_color_parser_gray_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
1016
|
|
|
|
|
|
|
{ |
1017
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
1018
|
0
|
|
|
|
|
|
return true; |
1019
|
|
|
|
|
|
|
|
1020
|
0
|
|
|
|
|
|
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last; |
1021
|
|
|
|
|
|
|
|
1022
|
0
|
0
|
|
|
|
|
if(declr_entry->value == NULL) { |
1023
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
1024
|
0
|
|
|
|
|
|
return false; |
1025
|
|
|
|
|
|
|
} |
1026
|
|
|
|
|
|
|
|
1027
|
0
|
|
|
|
|
|
mycss_values_color_t *color = declr_entry->value; |
1028
|
|
|
|
|
|
|
|
1029
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) { |
1030
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_percentage_value(entry, token, &color->value.gray.alpha.value.percentage); |
1031
|
0
|
|
|
|
|
|
color->value.gray.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE; |
1032
|
|
|
|
|
|
|
} |
1033
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) { |
1034
|
0
|
|
|
|
|
|
mycss_values_color_parser_set_number_value(entry, token, &color->value.gray.alpha.value.number); |
1035
|
0
|
|
|
|
|
|
color->value.gray.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER; |
1036
|
|
|
|
|
|
|
} |
1037
|
|
|
|
|
|
|
else { |
1038
|
0
|
|
|
|
|
|
mycss_values_color_parser_switch_parser(entry); |
1039
|
0
|
|
|
|
|
|
return false; |
1040
|
|
|
|
|
|
|
} |
1041
|
|
|
|
|
|
|
|
1042
|
0
|
|
|
|
|
|
entry->parser = mycss_values_color_parser_find_end; |
1043
|
0
|
|
|
|
|
|
return true; |
1044
|
|
|
|
|
|
|
} |
1045
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
|