diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2018-08-01 15:38:49 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2019-03-10 13:42:03 +0000 |
commit | 3342c8e3bafba86ff1154db940891a3405cb1c30 (patch) | |
tree | fb1b24398bbe01ee4932aecf86acfa1efa644d41 /src/parse | |
parent | 9eea40513329fbd10d494f5a2d29664847043c4c (diff) | |
download | libcss-3342c8e3bafba86ff1154db940891a3405cb1c30.tar.gz libcss-3342c8e3bafba86ff1154db940891a3405cb1c30.tar.bz2 |
HACKS for testing Media Queries parsing.
Top level stylesheets need to have their media query passed in.
So we need a way to parse standalone media queries.
This was hacked together to explore doing that.
However, it encounteded an issue where it seems the parseAtRule()
function in src/parse/parse.c doesn't handle the full grammar for
media queries.
Diffstat (limited to 'src/parse')
-rw-r--r-- | src/parse/language.c | 1 | ||||
-rw-r--r-- | src/parse/parse.c | 19 | ||||
-rw-r--r-- | src/parse/parse.h | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/parse/language.c b/src/parse/language.c index faafcfd..54fac9a 100644 --- a/src/parse/language.c +++ b/src/parse/language.c @@ -532,7 +532,6 @@ css_error handleStartAtRule(css_language *c, const parserutils_vector *vector) css_mq_query *media = NULL; /* any0 = media query */ - error = css__mq_parse_media_list( c->strings, vector, &ctx, &media); if (error != CSS_OK) diff --git a/src/parse/parse.c b/src/parse/parse.c index 4cc1c98..d58e328 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -220,6 +220,25 @@ css_error css__parser_create_for_inline_style(const char *charset, } /** + * Create a CSS parser for a media query + * + * \param charset Charset of data, if known, or NULL + * \param cs_source Source of charset information, or CSS_CHARSET_DEFAULT + * \param parser Pointer to location to receive parser instance + * \return CSS_OK on success, + * CSS_BADPARM on bad parameters, + * CSS_NOMEM on memory exhaustion + */ +css_error css__parser_create_for_media_query(const char *charset, + css_charset_source cs_source, css_parser **parser) +{ + parser_state initial = { sAtRule, 0 }; + + return css__parser_create_internal(charset, cs_source, + initial, parser); +} + +/** * Destroy a CSS parser * * \param parser The parser instance to destroy diff --git a/src/parse/parse.h b/src/parse/parse.h index 833aa51..e65f055 100644 --- a/src/parse/parse.h +++ b/src/parse/parse.h @@ -61,6 +61,8 @@ css_error css__parser_create(const char *charset, css_charset_source cs_source, css_parser **parser); css_error css__parser_create_for_inline_style(const char *charset, css_charset_source cs_source, css_parser **parser); +css_error css__parser_create_for_media_query(const char *charset, + css_charset_source cs_source, css_parser **parser); css_error css__parser_destroy(css_parser *parser); css_error css__parser_setopt(css_parser *parser, css_parser_opttype type, |