2 #ifndef EL__DOCUMENT_CSS_PROPERTY_H
3 #define EL__DOCUMENT_CSS_PROPERTY_H
5 #include "document/html/parser.h"
6 #include "util/color.h"
7 #include "util/lists.h"
9 /* The {struct css_property} describes one CSS declaration in a rule, therefore
10 * being basically a parsed instance of {struct css_property_info}. One list of
11 * these contains all the declarations contained in one rule. */
14 LIST_HEAD(struct css_property
);
16 /* Declared property. The enum item name is derived from the property
17 * name, just uppercase it and tr/-/_/. */
19 enum css_property_type
{
22 CSS_PT_BACKGROUND_COLOR
,
28 CSS_PT_TEXT_DECORATION
,
33 /* Property value. If it is a pointer, it points always to a memory
34 * to be free()d together with this structure. */
36 enum css_property_value_type
{
40 CSS_VT_FONT_ATTRIBUTE
,
44 union css_property_value
{
52 enum format_attr add
, rem
;
54 enum format_align text_align
;
59 * Align (struct format_align) */
60 /* TODO: The size units will be fun yet. --pasky */
64 /* The {struct css_property_info} describes what values the properties can
65 * have and what internal type they have. */
67 struct css_property_info
;
69 typedef int (*css_property_value_parser_T
)(struct css_property_info
*propinfo
,
70 union css_property_value
*value
,
71 struct scanner
*scanner
);
73 struct css_property_info
{
75 enum css_property_type type
;
77 /* This is the storage type, basically describing what to save to
78 * css_property.value. Many properties can share the same valtype.
79 * The value is basically output of the value parser. */
80 enum css_property_value_type value_type
;
82 /* This is the property value parser, processing the written form of a
83 * property value. Its job is to take the value string (or scanner's
84 * token list in the future) and transform it to a @value form
85 * according to the property's @value_type. Although some properties
86 * can share a parser, it is expected that most properties will either
87 * use a custom one or use a generic parser with property-specific
88 * backend specified in @parser_data. */
89 css_property_value_parser_T parser
;
91 /* In case you use a generic @parser, it can be useful to still give
92 * it some specific data. You can do so through @parser_data. The
93 * content is @parser-specific. */
97 /* This table contains info about all the known CSS properties. */
98 extern struct css_property_info css_property_info
[];