libcss
Loading...
Searching...
No Matches
mq.h
Go to the documentation of this file.
1/*
2 * This file is part of LibCSS.
3 * Licensed under the MIT License,
4 * http://www.opensource.org/licenses/mit-license.php
5 * Copyright 2016 John-Mark Bell <jmb@netsurf-browser.org>
6 */
7
8#ifndef css_parse_mq_h_
9#define css_parse_mq_h_
10
11#include <parserutils/utils/vector.h>
12#include "parse/language.h"
13
14typedef struct {
15 enum {
19 CSS_MQ_VALUE_TYPE_RATIO
20 } type;
21 union {
22 css_fixed num_or_ratio; /* Where ratio is the result of a/b */
23 struct {
25 uint32_t unit;
26 } dim;
27 lwc_string *ident;
28 } data;
30
31/*
32 * "name : value" is encoded as "name = value"
33 * "name" is encoded by setting the operator to "bool"
34 * "value op name" is encoded verbatim (with op2 set to "unused")
35 * "name op value" inverts the operator to encode (i.e < becomes >=) (and sets op2 to "unused")
36 * "value op name op value" is encoded using op2 and value2
37 */
48
56
58
59typedef struct {
60 uint32_t negate : 1, /* set if "not" */
61 op : 1; /* clear if "and", set if "or" */
62 uint32_t nparts;
65
76
77typedef struct css_mq_query {
79
80 uint32_t negate_type : 1; /* set if "not type" */
81 uint64_t type; /* or NULL */
82
85
86css_error css_parse_media_query(lwc_string **strings,
87 const uint8_t *mq, size_t len,
88 css_mq_query **media_out);
89
90css_error css__mq_parse_media_list(lwc_string **strings,
91 const parserutils_vector *vector, int32_t *ctx,
92 css_mq_query **media);
93
95
96#endif
css_error
Definition errors.h:18
int32_t css_fixed
Definition fpmath.h:23
void css__mq_query_destroy(css_mq_query *media)
Definition mq.c:69
css_mq_feature_op
Definition mq.h:38
@ CSS_MQ_FEATURE_OP_EQ
Definition mq.h:44
@ CSS_MQ_FEATURE_OP_GTE
Definition mq.h:45
@ CSS_MQ_FEATURE_OP_BOOL
Definition mq.h:39
@ CSS_MQ_FEATURE_OP_UNUSED
Definition mq.h:40
@ CSS_MQ_FEATURE_OP_LT
Definition mq.h:42
@ CSS_MQ_FEATURE_OP_GT
Definition mq.h:46
@ CSS_MQ_FEATURE_OP_LTE
Definition mq.h:43
css_error css__mq_parse_media_list(lwc_string **strings, const parserutils_vector *vector, int32_t *ctx, css_mq_query **media)
Definition mq.c:1102
css_error css_parse_media_query(lwc_string **strings, const uint8_t *mq, size_t len, css_mq_query **media_out)
Definition mq.c:1193
Definition mq.h:66
css_mq_feature * feat
Definition mq.h:73
union css_mq_cond_or_feature::@15 data
@ CSS_MQ_FEATURE
Definition mq.h:68
@ CSS_MQ_COND
Definition mq.h:69
css_mq_cond * cond
Definition mq.h:72
enum css_mq_cond_or_feature::@14 type
Definition mq.h:59
css_mq_cond_or_feature ** parts
Definition mq.h:63
uint32_t op
Definition mq.h:61
uint32_t negate
Definition mq.h:60
uint32_t nparts
Definition mq.h:62
Definition mq.h:49
css_mq_value value2
Definition mq.h:54
css_mq_feature_op op2
Definition mq.h:52
css_mq_feature_op op
Definition mq.h:51
lwc_string * name
Definition mq.h:50
css_mq_value value
Definition mq.h:53
Definition mq.h:77
uint64_t type
Definition mq.h:81
struct css_mq_query * next
Definition mq.h:78
css_mq_cond * cond
Definition mq.h:83
uint32_t negate_type
Definition mq.h:80
Definition mq.h:14
uint32_t unit
Definition mq.h:25
lwc_string * ident
Definition mq.h:27
@ CSS_MQ_VALUE_TYPE_NUM
Definition mq.h:16
@ CSS_MQ_VALUE_TYPE_DIM
Definition mq.h:17
@ CSS_MQ_VALUE_TYPE_IDENT
Definition mq.h:18
css_fixed len
Definition mq.h:24
css_fixed num_or_ratio
Definition mq.h:22