2 #ifndef EL__DOCUMENT_CSS_PROPERTY_H
3 #define EL__DOCUMENT_CSS_PROPERTY_H
5 #include "document/format.h"
6 #include "util/align.h"
7 #include "util/color.h"
8 #include "util/lists.h"
10 /** The struct css_property describes one CSS declaration in a rule, therefore
11 * being basically a parsed instance of struct css_property_info. One list of
12 * 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
17 * property name, just uppercase it and tr/-/_/. */
18 enum css_property_type
{
21 CSS_PT_BACKGROUND_COLOR
,
27 CSS_PT_TEXT_DECORATION
,
32 /** Type of the property value. Discriminates the #value union. */
33 enum css_property_value_type
{
37 CSS_VT_FONT_ATTRIBUTE
,
42 /** Property value. If it is a pointer, it points always to a
43 * memory to be free()d together with this structure. */
44 union css_property_value
{
53 enum text_style_format add
, rem
;
55 enum format_align text_align
;
60 * Align (struct format_align) */
61 /* TODO: The size units will be fun yet. --pasky */
65 struct css_property_info
;
67 typedef int (*css_property_value_parser_T
)(struct css_property_info
*propinfo
,
68 union css_property_value
*value
,
69 struct scanner
*scanner
);
71 /** The struct css_property_info describes what values the properties can
72 * have and what internal type they have. */
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
83 * form of a property value. Its job is to take the value
84 * string (or scanner's token list in the future) and
85 * transform it to a union css_property_value according to the
86 * property's #value_type. Although some properties can share
87 * a parser, it is expected that most properties will either
88 * use a custom one or use a generic parser with
89 * property-specific backend specified in #parser_data. */
90 css_property_value_parser_T parser
;
92 /** In case you use a generic #parser, it can be useful to still give
93 * it some specific data. You can do so through @c parser_data. The
94 * content is #parser-specific. */
98 /** This table contains info about all the known CSS properties. */
99 extern struct css_property_info css_property_info
[];