grafthistory: support curl
[elinks/elinks-j605.git] / src / document / css / property.h
blob0801026e2752c2042c3ba192f2bae622b67958b2
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. */
13 struct css_property {
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 {
20 CSS_PT_NONE,
21 CSS_PT_BACKGROUND,
22 CSS_PT_BACKGROUND_COLOR,
23 CSS_PT_COLOR,
24 CSS_PT_DISPLAY,
25 CSS_PT_FONT_STYLE,
26 CSS_PT_FONT_WEIGHT,
27 CSS_PT_TEXT_ALIGN,
28 CSS_PT_TEXT_DECORATION,
29 CSS_PT_WHITE_SPACE,
30 CSS_PT_LAST,
31 } type;
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 {
37 CSS_VT_NONE,
38 CSS_VT_COLOR,
39 CSS_VT_DISPLAY,
40 CSS_VT_FONT_ATTRIBUTE,
41 CSS_VT_TEXT_ALIGN,
42 CSS_VT_LAST,
43 } value_type;
44 union css_property_value {
45 void *none;
46 color_T color;
47 enum css_display {
48 CSS_DISP_INLINE,
49 CSS_DISP_BLOCK,
50 } display;
51 struct {
52 enum format_attr add, rem;
53 } font_attribute;
54 enum format_align text_align;
55 /* TODO:
56 * Generic numbers
57 * Percentages
58 * URL
59 * Align (struct format_align) */
60 /* TODO: The size units will be fun yet. --pasky */
61 } value;
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;
68 struct scanner;
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 {
74 unsigned char *name;
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. */
94 void *parser_data;
97 /* This table contains info about all the known CSS properties. */
98 extern struct css_property_info css_property_info[];
100 #endif