summaryrefslogtreecommitdiff
path: root/docs/Representation
blob: 3eb63ebceb8fc5aec75691881f1459a66ba9d09d (plain)
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
97
98
LibCSS internal stylesheet representation
=========================================

Selector:

struct selector {
	selector_type type;			/**< Type of selector */

	struct {
		const uint8_t *name;
		size_t name_len;

		const uint8_t *value;
		size_t value_len;
	} data;					/**< Selector data */

	struct selector *specifics;		/**< Selector specifics */

	combinator combinator_type;		/**< Type of combinator */
	struct selector *combinator;		/**< Combining selector */

	struct rule *rule;			/**< Owning rule */

	struct style *style;			/**< Applicable style */

	struct selector *next;			/**< Next selector in list */
	struct selector *prev;			/**< Previous selector */
};

Rule:

struct rule {
	rule_type type;				/**< Type of rule */

	union {
		struct {
			uint32_t selector_count;
			struct selector **selectors;
		} selector;
		struct {
			uint32_t media;
			uint32_t rule_count;
			struct rule **rules;
		} media;
		struct {
			struct style *style;
		} font_face;
		struct {
			uint32_t selector_count;
			struct selector **selectors;
			struct style *style;
		} page;
		struct {
			struct stylesheet *sheet;
		} import;
		struct {
			char *encoding;
		} charset;
	} data;					/**< Rule data */

	uint32_t index;				/**< Index of rule in sheet */

	struct stylesheet *owner;		/**< Owning sheet */

	struct rule *parent;			/**< Parent rule */
	struct rule *first_child;		/**< First in child list */
	struct rule *last_child;		/**< Last in child list */
	struct rule *next;			/**< Next rule */
	struct rule *prev;			/**< Previous rule */
};

Stylesheet:

struct stylesheet {
#define HASH_SIZE (37)
	struct selector *selectors[HASH_SIZE];	/**< Hashtable of selectors */

	uint32_t rule_count;			/**< Number of rules in sheet */
	struct rule *rule_list;			/**< List of rules in sheet */

	bool disabled;				/**< Whether this sheet is 
						 * disabled */

	char *url;				/**< URL of this sheet */
	char *title;				/**< Title of this sheet */

	uint32_t media;				/**< Bitfield of media types */

	void *ownerNode;			/**< Owning node in document */
	struct rule *ownerRule;			/**< Owning rule in parent */

	struct stylesheet *parent;		/**< Parent sheet */
	struct stylesheet *first_child;		/**< First in child list */
	struct stylesheet *last_child;		/**< Last in child list */
	struct stylesheet *next;		/**< Next in sibling list */
	struct stylesheet *prev;		/**< Previous in sibling list */
};