2 #ifndef EL__DOCUMENT_CSS_PROPERTY_H
3 #define EL__DOCUMENT_CSS_PROPERTY_H
5 #include "document/format.h"
6 #include "document/html/parser.h"
7 #include "util/align.h"
8 #include "util/color.h"
9 #include "util/lists.h"
11 /** The struct css_property describes one CSS declaration in a rule, therefore
12 * being basically a parsed instance of struct css_property_info. One list of
13 * these contains all the declarations contained in one rule. */
15 LIST_HEAD(struct css_property
);
17 /** Declared property. The enum item name is derived from the
18 * property name, just uppercase it and tr/-/_/. */
19 enum css_property_type
{
22 CSS_PT_BACKGROUND_COLOR
,
29 CSS_PT_TEXT_DECORATION
,
34 /** Type of the property value. Discriminates the #value union. */
35 enum css_property_value_type
{
39 CSS_VT_FONT_ATTRIBUTE
,
45 /** Property value. If it is a pointer, it points always to a
46 * memory to be free()d together with this structure. */
47 union css_property_value
{
56 enum text_style_format add
, rem
;
58 enum format_align text_align
;
64 CSS_LIST_ORDINAL
, /* Marker value */
66 CSS_LIST_DECIMAL_LEADING_ZERO
,
77 CSS_LIST_CJK_IDEOGRAPHIC
,
80 CSS_LIST_HIRAGANA_IROHA
,
81 CSS_LIST_KATAKANA_IROHA
,
87 * Align (struct format_align) */
88 /* TODO: The size units will be fun yet. --pasky */
92 struct css_property_info
;
94 typedef int (*css_property_value_parser_T
)(struct css_property_info
*propinfo
,
95 union css_property_value
*value
,
96 struct scanner
*scanner
);
98 /** The struct css_property_info describes what values the properties can
99 * have and what internal type they have. */
100 struct css_property_info
{
102 enum css_property_type type
;
104 /** This is the storage type, basically describing what to save to
105 * css_property.value. Many properties can share the same valtype.
106 * The value is basically output of the value parser. */
107 enum css_property_value_type value_type
;
109 /** This is the property value parser, processing the written
110 * form of a property value. Its job is to take the value
111 * string (or scanner's token list in the future) and
112 * transform it to a union css_property_value according to the
113 * property's #value_type. Although some properties can share
114 * a parser, it is expected that most properties will either
115 * use a custom one or use a generic parser with
116 * property-specific backend specified in #parser_data. */
117 css_property_value_parser_T parser
;
119 /** In case you use a generic #parser, it can be useful to still give
120 * it some specific data. You can do so through @c parser_data. The
121 * content is #parser-specific. */
125 /** This table contains info about all the known CSS properties. */
126 extern struct css_property_info css_property_info
[];