File Coverage

third_party/modest/source/mycss/property/parser_text_decoration.c
Criterion Covered Total %
statement 0 203 0.0
branch 0 116 0.0
condition n/a
subroutine n/a
pod n/a
total 0 319 0.0


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/property/parser.h"
22              
23 0           static void mycss_property_parser_text_decoration_parser_switch(mycss_entry_t* entry)
24             {
25 0           mycss_stack_entry_t *stack_entry = mycss_stack_pop(entry->declaration->stack);
26            
27 0 0         if(stack_entry->value)
28 0           entry->declaration->entry_last = stack_entry->value;
29            
30 0           entry->parser = stack_entry->parser;
31 0           }
32              
33 0           void * mycss_property_destroy_text_decoration(mycss_entry_t* entry, void* value)
34             {
35 0 0         if(value == NULL)
36 0           return NULL;
37            
38 0           mycss_values_text_decoration_t *text_decoration = (mycss_values_text_decoration_t*)value;
39            
40 0 0         if(text_decoration->color)
41 0           text_decoration->color = mycss_declaration_entry_destroy(entry->declaration, text_decoration->color, true);
42            
43 0 0         if(text_decoration->line)
44 0           text_decoration->color = mycss_declaration_entry_destroy(entry->declaration, text_decoration->line, true);
45            
46 0 0         if(text_decoration->style)
47 0           text_decoration->color = mycss_declaration_entry_destroy(entry->declaration, text_decoration->style, true);
48            
49 0           return mycss_values_destroy(entry, text_decoration);
50             }
51              
52 0           bool mycss_property_parser_text_decoration(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
53             {
54 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
55 0           return true;
56            
57 0           mycore_string_t str = {0};
58 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
59             mycss_values_text_decoration_t *text_decoration;
60            
61 0 0         if(dec_entry->value == NULL) {
62 0           text_decoration = (mycss_values_text_decoration_t*)mycss_values_create(entry, sizeof(mycss_values_text_decoration_t));
63 0           dec_entry->value = text_decoration;
64            
65 0 0         if(text_decoration == NULL)
66 0           return mycss_property_shared_switch_to_parse_error(entry);
67             }
68             else {
69 0           text_decoration = (mycss_values_text_decoration_t*)dec_entry->value;
70             }
71            
72 0 0         if(mycss_property_shared_check_declaration_end(entry, token)) {
73 0 0         if(text_decoration &&
    0          
74 0 0         text_decoration->color == NULL &&
75 0 0         text_decoration->style == NULL &&
76 0           text_decoration->line == NULL)
77             {
78 0           dec_entry->value = mycss_property_destroy_text_decoration(entry, text_decoration);
79 0           return mycss_property_shared_switch_to_parse_error(entry);
80             }
81            
82 0           return true;
83             }
84            
85 0 0         if(text_decoration == NULL)
86 0           return mycss_property_shared_switch_to_parse_error(entry);
87            
88 0           dec_entry->value = text_decoration;
89            
90 0           void *value = NULL;
91 0           unsigned int line_value = 0;
92 0           unsigned int value_type = 0;
93 0           bool parser_changed = false;
94            
95 0 0         if(mycss_property_shared_text_decoration_style(entry, token, &value_type, &str))
96             {
97 0 0         if(text_decoration->style) {
98 0           mycss_property_destroy_text_decoration(entry, text_decoration);
99 0           return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
100             }
101            
102 0           text_decoration->style = mycss_declaration_entry_create(entry->declaration, NULL);
103            
104 0           text_decoration->style->type = MyCSS_PROPERTY_TYPE_TEXT_DECORATION_STYLE;
105 0           text_decoration->style->value_type = value_type;
106            
107 0           return mycss_property_parser_destroy_string(&str, true);
108             }
109 0 0         else if(mycss_property_shared_color(entry, token, &value, &value_type, &str, &parser_changed))
110             {
111 0 0         if(text_decoration->color) {
112 0           mycss_property_destroy_text_decoration(entry, text_decoration);
113 0           return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
114             }
115            
116 0           text_decoration->color = mycss_declaration_entry_create(entry->declaration, NULL);
117            
118 0 0         if(parser_changed) {
119 0           mycss_stack_push(entry->declaration->stack, dec_entry->value, mycss_property_parser_text_decoration_after_color);
120 0           entry->declaration->entry_last->value = text_decoration->color->value;
121             }
122            
123 0           text_decoration->color->value = value;
124 0           text_decoration->color->type = MyCSS_PROPERTY_TYPE_TEXT_DECORATION_COLOR;
125 0           text_decoration->color->value_type = value_type;
126            
127 0           return mycss_property_parser_destroy_string(&str, true);
128             }
129 0 0         else if(mycss_property_shared_text_decoration_line(entry, token, &line_value, &value_type, &str, true))
130             {
131 0 0         if(text_decoration->line) {
132 0           mycss_property_destroy_text_decoration(entry, text_decoration);
133 0           return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
134             }
135            
136 0           text_decoration->line = mycss_declaration_entry_create(entry->declaration, NULL);
137 0           text_decoration->line->type = MyCSS_PROPERTY_TYPE_TEXT_DECORATION_LINE;
138            
139 0 0         if(line_value) {
140 0           unsigned int *new_value = mycss_values_create(entry, sizeof(unsigned int));
141 0           *new_value = line_value;
142            
143 0           text_decoration->line->value = new_value;
144            
145 0           mycss_stack_push(entry->declaration->stack, dec_entry, mycss_property_parser_text_decoration_after_line);
146 0           entry->declaration->entry_last = text_decoration->line;
147             }
148             else {
149 0           text_decoration->line->value_type = value_type;
150             }
151            
152 0           return mycss_property_parser_destroy_string(&str, true);
153             }
154            
155 0           return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
156             }
157              
158 0           bool mycss_property_parser_text_decoration_after_color(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
159             {
160 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
161            
162 0 0         if(mycss_property_shared_check_declaration_end(entry, token))
163             {
164 0           mycss_values_text_decoration_t *text_decoration = (mycss_values_text_decoration_t*)dec_entry->value;
165            
166 0 0         if(text_decoration &&
    0          
167 0 0         text_decoration->color == NULL &&
168 0 0         text_decoration->style == NULL &&
169 0           text_decoration->line == NULL)
170             {
171 0           dec_entry->value = mycss_property_destroy_text_decoration(entry, text_decoration);
172 0           return mycss_property_shared_switch_to_parse_error(entry);
173             }
174            
175 0           return true;
176             }
177            
178 0           entry->parser = mycss_property_parser_text_decoration;
179 0           return false;
180             }
181              
182 0           bool mycss_property_parser_text_decoration_after_line(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
183             {
184 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
185            
186 0 0         if(mycss_property_shared_check_declaration_end(entry, token))
187             {
188 0           mycss_values_text_decoration_t *text_decoration = (mycss_values_text_decoration_t*)dec_entry->value;
189            
190 0 0         if(text_decoration &&
    0          
191 0 0         text_decoration->color == NULL &&
192 0 0         text_decoration->style == NULL &&
193 0           text_decoration->line == NULL)
194             {
195 0           dec_entry->value = mycss_property_destroy_text_decoration(entry, text_decoration);
196 0           return mycss_property_shared_switch_to_parse_error(entry);
197             }
198            
199 0           return true;
200             }
201            
202 0           entry->parser = mycss_property_parser_text_decoration;
203 0           return false;
204             }
205              
206 0           bool mycss_property_parser_text_decoration_color(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
207             {
208 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
209 0           return true;
210            
211 0           mycore_string_t str = {0};
212 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
213            
214 0           bool parser_changed = false;
215            
216 0 0         if(mycss_property_shared_color(entry, token, &dec_entry->value, &dec_entry->value_type, &str, &parser_changed))
217             {
218 0 0         if(parser_changed)
219 0           mycss_stack_push(entry->declaration->stack, NULL, mycss_property_parser_text_decoration_color_after);
220            
221 0           return mycss_property_parser_destroy_string(&str, true);
222             }
223            
224 0           return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
225             }
226              
227 0           bool mycss_property_parser_text_decoration_color_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
228             {
229 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
230 0           return true;
231            
232 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
233            
234 0 0         if(mycss_property_shared_check_declaration_end(entry, token))
235 0           return true;
236            
237 0           dec_entry->value = mycss_values_destroy(entry, dec_entry->value);
238            
239 0           return mycss_property_shared_switch_to_parse_error(entry);
240             }
241              
242 0           bool mycss_property_parser_text_decoration_skip(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
243             {
244 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
245 0           return true;
246            
247 0 0         if(token->type != MyCSS_TOKEN_TYPE_IDENT)
248 0           return mycss_property_shared_switch_to_parse_error(entry);
249            
250 0           mycore_string_t str = {0};
251 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
252            
253 0           unsigned int value = 0;
254            
255 0 0         if(mycss_property_shared_text_decoration_skip(entry, token, &value, &dec_entry->value_type, &str, true)) {
256 0 0         if(value) {
257 0           unsigned int *new_value = mycss_values_create(entry, sizeof(unsigned int));
258 0           *new_value = value;
259            
260 0           dec_entry->value = new_value;
261            
262 0           mycss_stack_push(entry->declaration->stack, dec_entry, mycss_property_parser_text_decoration_skip_after);
263             }
264            
265 0           return mycss_property_parser_destroy_string(&str, true);
266             }
267            
268 0           return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
269             }
270              
271 0           bool mycss_property_parser_text_decoration_skip_not_none(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
272             {
273 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
274 0           return true;
275            
276 0 0         if(token->type != MyCSS_TOKEN_TYPE_IDENT) {
277 0           mycss_property_parser_text_decoration_parser_switch(entry);
278 0           return false;
279             }
280            
281 0           mycore_string_t str = {0};
282 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
283            
284 0 0         if(mycss_property_shared_text_decoration_skip(entry, token, (unsigned int*)dec_entry->value, &dec_entry->value_type, &str, false))
285 0           return mycss_property_parser_destroy_string(&str, true);
286            
287 0           mycss_property_parser_text_decoration_parser_switch(entry);
288 0           return mycss_property_parser_destroy_string(&str, false);
289             }
290              
291 0           bool mycss_property_parser_text_decoration_skip_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
292             {
293 0 0         if(mycss_property_shared_check_declaration_end(entry, token))
294 0           return true;
295            
296 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
297            
298 0 0         if(dec_entry->value)
299 0           dec_entry->value = mycss_values_destroy(entry, dec_entry->value);
300            
301 0           return mycss_property_shared_switch_to_parse_error(entry);
302             }
303              
304 0           bool mycss_property_parser_text_decoration_style(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
305             {
306 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
307 0           return true;
308            
309 0 0         if(token->type != MyCSS_TOKEN_TYPE_IDENT)
310 0           return mycss_property_shared_switch_to_parse_error(entry);
311            
312 0           mycore_string_t str = {0};
313 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
314            
315 0 0         if(mycss_property_shared_text_decoration_style(entry, token, &dec_entry->value_type, &str))
316 0           mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_find_important(entry));
317            
318 0           return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
319             }
320              
321 0           bool mycss_property_parser_text_decoration_line(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
322             {
323 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
324 0           return true;
325            
326 0 0         if(token->type != MyCSS_TOKEN_TYPE_IDENT)
327 0           return mycss_property_shared_switch_to_parse_error(entry);
328            
329 0           mycore_string_t str = {0};
330 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
331            
332 0           unsigned int value = 0;
333            
334 0 0         if(mycss_property_shared_text_decoration_line(entry, token, &value, &dec_entry->value_type, &str, true))
335             {
336 0 0         if(value) {
337 0           unsigned int *new_value = mycss_values_create(entry, sizeof(unsigned int));
338 0           *new_value = value;
339            
340 0           dec_entry->value = new_value;
341            
342 0           mycss_stack_push(entry->declaration->stack, dec_entry, mycss_property_parser_text_decoration_line_after);
343             }
344            
345 0           return mycss_property_parser_destroy_string(&str, true);
346             }
347            
348 0           return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));
349             }
350              
351 0           bool mycss_property_parser_text_decoration_line_not_none(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
352             {
353 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
354 0           return true;
355            
356 0 0         if(token->type != MyCSS_TOKEN_TYPE_IDENT) {
357 0           mycss_property_parser_text_decoration_parser_switch(entry);
358 0           return false;
359             }
360            
361 0           mycore_string_t str = {0};
362 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
363            
364 0 0         if(mycss_property_shared_text_decoration_line(entry, token, (unsigned int*)dec_entry->value, &dec_entry->value_type, &str, false))
365 0           return mycss_property_parser_destroy_string(&str, true);
366            
367 0           mycss_property_parser_text_decoration_parser_switch(entry);
368 0           return mycss_property_parser_destroy_string(&str, false);
369             }
370              
371 0           bool mycss_property_parser_text_decoration_line_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
372             {
373 0 0         if(mycss_property_shared_check_declaration_end(entry, token))
374 0           return true;
375            
376 0           mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
377            
378 0 0         if(dec_entry->value)
379 0           dec_entry->value = mycss_values_destroy(entry, dec_entry->value);
380            
381 0           return mycss_property_shared_switch_to_parse_error(entry);
382             }
383              
384