2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
#ifndef EL__DOCUMENT_CSS_PROPERTY_H
|
|
|
|
#define EL__DOCUMENT_CSS_PROPERTY_H
|
|
|
|
|
2007-08-28 15:05:00 -04:00
|
|
|
#include "document/format.h"
|
2011-10-27 17:15:53 -04:00
|
|
|
#include "document/html/parser.h"
|
2007-08-28 15:05:00 -04:00
|
|
|
#include "util/align.h"
|
2005-09-15 09:58:31 -04:00
|
|
|
#include "util/color.h"
|
|
|
|
#include "util/lists.h"
|
|
|
|
|
2020-10-05 14:14:55 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-04-20 15:23:55 -04:00
|
|
|
enum css_property_type {
|
|
|
|
CSS_PT_NONE,
|
|
|
|
CSS_PT_BACKGROUND,
|
|
|
|
CSS_PT_BACKGROUND_COLOR,
|
|
|
|
CSS_PT_COLOR,
|
|
|
|
CSS_PT_DISPLAY,
|
|
|
|
CSS_PT_FONT_STYLE,
|
|
|
|
CSS_PT_FONT_WEIGHT,
|
|
|
|
CSS_PT_LIST_STYLE,
|
|
|
|
CSS_PT_LIST_STYLE_TYPE,
|
|
|
|
CSS_PT_TEXT_ALIGN,
|
|
|
|
CSS_PT_TEXT_DECORATION,
|
|
|
|
CSS_PT_WHITE_SPACE,
|
|
|
|
CSS_PT_LAST,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum css_property_value_type {
|
|
|
|
CSS_VT_NONE,
|
|
|
|
CSS_VT_COLOR,
|
|
|
|
CSS_VT_DISPLAY,
|
|
|
|
CSS_VT_FONT_ATTRIBUTE,
|
|
|
|
CSS_VT_LIST_STYLE,
|
|
|
|
CSS_VT_TEXT_ALIGN,
|
|
|
|
CSS_VT_LAST,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum css_display {
|
|
|
|
CSS_DISP_INLINE,
|
|
|
|
CSS_DISP_BLOCK,
|
|
|
|
CSS_DISP_NONE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum css_list_style {
|
|
|
|
CSS_LIST_NONE,
|
|
|
|
CSS_LIST_DISC,
|
|
|
|
CSS_LIST_CIRCLE,
|
|
|
|
CSS_LIST_SQUARE,
|
|
|
|
CSS_LIST_ORDINAL, /* Marker value */
|
|
|
|
CSS_LIST_DECIMAL,
|
|
|
|
CSS_LIST_DECIMAL_LEADING_ZERO,
|
|
|
|
CSS_LIST_LOWER_ROMAN,
|
|
|
|
CSS_LIST_UPPER_ROMAN,
|
|
|
|
CSS_LIST_LOWER_ALPHA,
|
|
|
|
CSS_LIST_UPPER_ALPHA,
|
|
|
|
CSS_LIST_LOWER_GREEK,
|
|
|
|
CSS_LIST_LOWER_LATIN,
|
|
|
|
CSS_LIST_UPPER_LATIN,
|
|
|
|
CSS_LIST_HEBREW,
|
|
|
|
CSS_LIST_ARMENIAN,
|
|
|
|
CSS_LIST_GEORGIAN,
|
|
|
|
CSS_LIST_CJK_IDEOGRAPHIC,
|
|
|
|
CSS_LIST_HIRAGANA,
|
|
|
|
CSS_LIST_KATAKANA,
|
|
|
|
CSS_LIST_HIRAGANA_IROHA,
|
|
|
|
CSS_LIST_KATAKANA_IROHA,
|
|
|
|
};
|
|
|
|
|
|
|
|
union css_property_value {
|
|
|
|
void *none;
|
|
|
|
color_T color;
|
|
|
|
enum css_display display;
|
|
|
|
struct {
|
|
|
|
enum text_style_format add, rem;
|
|
|
|
} font_attribute;
|
|
|
|
enum format_align text_align;
|
|
|
|
enum css_list_style list_style;
|
|
|
|
/* TODO:
|
|
|
|
* Generic numbers
|
|
|
|
* Percentages
|
|
|
|
* URL
|
|
|
|
* Align (struct format_align) */
|
|
|
|
/* TODO: The size units will be fun yet. --pasky */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-07-27 19:31:58 -04:00
|
|
|
/** The struct css_property describes one CSS declaration in a rule, therefore
|
|
|
|
* being basically a parsed instance of struct css_property_info. One list of
|
2005-09-15 09:58:31 -04:00
|
|
|
* these contains all the declarations contained in one rule. */
|
|
|
|
struct css_property {
|
|
|
|
LIST_HEAD(struct css_property);
|
|
|
|
|
2007-07-27 19:31:58 -04:00
|
|
|
/** Declared property. The enum item name is derived from the
|
|
|
|
* property name, just uppercase it and tr/-/_/. */
|
2016-04-20 15:23:55 -04:00
|
|
|
enum css_property_type type;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
2007-07-27 19:31:58 -04:00
|
|
|
/** Type of the property value. Discriminates the #value union. */
|
2016-04-20 15:23:55 -04:00
|
|
|
enum css_property_value_type value_type;
|
2007-07-27 19:31:58 -04:00
|
|
|
|
|
|
|
/** Property value. If it is a pointer, it points always to a
|
|
|
|
* memory to be free()d together with this structure. */
|
2016-04-20 15:23:55 -04:00
|
|
|
union css_property_value value;
|
2005-09-15 09:58:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct css_property_info;
|
|
|
|
struct scanner;
|
|
|
|
typedef int (*css_property_value_parser_T)(struct css_property_info *propinfo,
|
|
|
|
union css_property_value *value,
|
|
|
|
struct scanner *scanner);
|
|
|
|
|
2007-07-27 19:31:58 -04:00
|
|
|
/** The struct css_property_info describes what values the properties can
|
|
|
|
* have and what internal type they have. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct css_property_info {
|
|
|
|
unsigned char *name;
|
|
|
|
enum css_property_type type;
|
|
|
|
|
2007-07-27 19:31:58 -04:00
|
|
|
/** This is the storage type, basically describing what to save to
|
2005-09-15 09:58:31 -04:00
|
|
|
* css_property.value. Many properties can share the same valtype.
|
|
|
|
* The value is basically output of the value parser. */
|
|
|
|
enum css_property_value_type value_type;
|
|
|
|
|
2007-07-27 19:31:58 -04:00
|
|
|
/** This is the property value parser, processing the written
|
|
|
|
* form of a property value. Its job is to take the value
|
|
|
|
* string (or scanner's token list in the future) and
|
|
|
|
* transform it to a union css_property_value according to the
|
|
|
|
* property's #value_type. Although some properties can share
|
|
|
|
* a parser, it is expected that most properties will either
|
|
|
|
* use a custom one or use a generic parser with
|
|
|
|
* property-specific backend specified in #parser_data. */
|
2005-09-15 09:58:31 -04:00
|
|
|
css_property_value_parser_T parser;
|
|
|
|
|
2007-07-27 19:31:58 -04:00
|
|
|
/** In case you use a generic #parser, it can be useful to still give
|
|
|
|
* it some specific data. You can do so through @c parser_data. The
|
|
|
|
* content is #parser-specific. */
|
2005-09-15 09:58:31 -04:00
|
|
|
void *parser_data;
|
|
|
|
};
|
|
|
|
|
2007-07-27 19:31:58 -04:00
|
|
|
/** This table contains info about all the known CSS properties. */
|
2005-09-15 09:58:31 -04:00
|
|
|
extern struct css_property_info css_property_info[];
|
|
|
|
|
2020-10-05 14:14:55 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
#endif
|