1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* This file is part of LibCSS.
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2016 John-Mark Bell <jmb@netsurf-browser.org>
*/
/* https://drafts.csswg.org/mediaqueries/ */
#include "parse/mq.h"
css_error css__mq_parse_media_list(css_language *c,
const parserutils_vector *vector, int *ctx,
css_mq_query **media)
{
css_mq_query *ret = NULL;
const css_token *token;
/* (IDENT ws (',' ws IDENT ws)* )? */
UNUSED(c);
token = parserutils_vector_iterate(vector, ctx);
while (token != NULL) {
if (token->type != CSS_TOKEN_IDENT)
return CSS_INVALID;
#if 0
if (lwc_string_caseless_isequal(token->idata, c->strings[AURAL],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_AURAL;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[BRAILLE],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_BRAILLE;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[EMBOSSED],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_EMBOSSED;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[HANDHELD],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_HANDHELD;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[PRINT],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_PRINT;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[PROJECTION],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_PROJECTION;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[SCREEN],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_SCREEN;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[SPEECH],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_SPEECH;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[TTY],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_TTY;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[TV],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_TV;
} else if (lwc_string_caseless_isequal(
token->idata, c->strings[ALL],
&match) == lwc_error_ok && match) {
ret |= CSS_MEDIA_ALL;
} else
return CSS_INVALID;
#endif
consumeWhitespace(vector, ctx);
token = parserutils_vector_iterate(vector, ctx);
if (token != NULL && tokenIsChar(token, ',') == false)
return CSS_INVALID;
consumeWhitespace(vector, ctx);
}
#if 0
/* If, after parsing the media list, we still have no media,
* then it must be ALL. */
if (ret == 0)
ret = CSS_MEDIA_ALL;
#endif
*media = ret;
return CSS_OK;
}
|