iconv: Bail out of the loop when an illegal sequence of bytes occurs.
[elinks/elinks-j605.git] / src / document / css / property.h
blob3d96e66db2772b9a3110c788a9871edf3d35900a
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. */
14 struct css_property {
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 {
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_LIST_STYLE,
28 CSS_PT_TEXT_ALIGN,
29 CSS_PT_TEXT_DECORATION,
30 CSS_PT_WHITE_SPACE,
31 CSS_PT_LAST,
32 } type;
34 /** Type of the property value. Discriminates the #value union. */
35 enum css_property_value_type {
36 CSS_VT_NONE,
37 CSS_VT_COLOR,
38 CSS_VT_DISPLAY,
39 CSS_VT_FONT_ATTRIBUTE,
40 CSS_VT_LIST_STYLE,
41 CSS_VT_TEXT_ALIGN,
42 CSS_VT_LAST,
43 } value_type;
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 {
48 void *none;
49 color_T color;
50 enum css_display {
51 CSS_DISP_INLINE,
52 CSS_DISP_BLOCK,
53 CSS_DISP_NONE,
54 } display;
55 struct {
56 enum text_style_format add, rem;
57 } font_attribute;
58 enum format_align text_align;
59 enum css_list_style {
60 CSS_LIST_NONE,
61 CSS_LIST_DISC,
62 CSS_LIST_CIRCLE,
63 CSS_LIST_SQUARE,
64 CSS_LIST_ORDINAL, /* Marker value */
65 CSS_LIST_DECIMAL,
66 CSS_LIST_DECIMAL_LEADING_ZERO,
67 CSS_LIST_LOWER_ROMAN,
68 CSS_LIST_UPPER_ROMAN,
69 CSS_LIST_LOWER_ALPHA,
70 CSS_LIST_UPPER_ALPHA,
71 CSS_LIST_LOWER_GREEK,
72 CSS_LIST_LOWER_LATIN,
73 CSS_LIST_UPPER_LATIN,
74 CSS_LIST_HEBREW,
75 CSS_LIST_ARMENIAN,
76 CSS_LIST_GEORGIAN,
77 CSS_LIST_CJK_IDEOGRAPHIC,
78 CSS_LIST_HIRAGANA,
79 CSS_LIST_KATAKANA,
80 CSS_LIST_HIRAGANA_IROHA,
81 CSS_LIST_KATAKANA_IROHA,
82 } list_style;
83 /* TODO:
84 * Generic numbers
85 * Percentages
86 * URL
87 * Align (struct format_align) */
88 /* TODO: The size units will be fun yet. --pasky */
89 } value;
92 struct css_property_info;
93 struct scanner;
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 {
101 unsigned char *name;
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. */
122 void *parser_data;
125 /** This table contains info about all the known CSS properties. */
126 extern struct css_property_info css_property_info[];
128 #endif