[wip] show_image(): Introduce struct screen_image with complete but abstract on-scree...
[elinks/images.git] / src / document / css / property.h
blob995f460e2f06485dd48f8c5aa0d947ef31ce69a1
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. */
13 struct css_property {
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 {
19 CSS_PT_NONE,
20 CSS_PT_BACKGROUND,
21 CSS_PT_BACKGROUND_COLOR,
22 CSS_PT_COLOR,
23 CSS_PT_DISPLAY,
24 CSS_PT_FONT_STYLE,
25 CSS_PT_FONT_WEIGHT,
26 CSS_PT_TEXT_ALIGN,
27 CSS_PT_TEXT_DECORATION,
28 CSS_PT_WHITE_SPACE,
29 CSS_PT_LAST,
30 } type;
32 /** Type of the property value. Discriminates the #value union. */
33 enum css_property_value_type {
34 CSS_VT_NONE,
35 CSS_VT_COLOR,
36 CSS_VT_DISPLAY,
37 CSS_VT_FONT_ATTRIBUTE,
38 CSS_VT_TEXT_ALIGN,
39 CSS_VT_LAST,
40 } value_type;
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 {
45 void *none;
46 color_T color;
47 enum css_display {
48 CSS_DISP_INLINE,
49 CSS_DISP_BLOCK,
50 CSS_DISP_NONE,
51 } display;
52 struct {
53 enum text_style_format add, rem;
54 } font_attribute;
55 enum format_align text_align;
56 /* TODO:
57 * Generic numbers
58 * Percentages
59 * URL
60 * Align (struct format_align) */
61 /* TODO: The size units will be fun yet. --pasky */
62 } value;
65 struct css_property_info;
66 struct scanner;
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 {
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
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. */
95 void *parser_data;
98 /** This table contains info about all the known CSS properties. */
99 extern struct css_property_info css_property_info[];
101 #endif