2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2004-02-14 02:07:42 +03:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2004-08-02 01:56:47 +04:00
|
|
|
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
2003-04-04 19:19:32 +04:00
|
|
|
*/
|
|
|
|
|
2003-12-27 23:15:23 +03:00
|
|
|
/** \file
|
|
|
|
* CSS handling (interface).
|
|
|
|
*
|
|
|
|
* This module aims to implement CSS 2.1.
|
|
|
|
*
|
|
|
|
* CSS stylesheets are held in a struct ::content with type CONTENT_CSS.
|
|
|
|
* Creation and parsing should be carried out via the content_* functions.
|
|
|
|
*
|
|
|
|
* Styles are stored in a struct ::css_style, which can be retrieved from a
|
|
|
|
* content using css_get_style().
|
|
|
|
*
|
|
|
|
* css_parse_property_list() constructs a struct ::css_style from a CSS
|
|
|
|
* property list, as found in HTML style attributes.
|
|
|
|
*/
|
|
|
|
|
2003-04-04 19:19:32 +04:00
|
|
|
#ifndef _NETSURF_CSS_CSS_H_
|
|
|
|
#define _NETSURF_CSS_CSS_H_
|
|
|
|
|
2003-10-17 21:39:29 +04:00
|
|
|
#include <stdbool.h>
|
2003-09-28 03:36:34 +04:00
|
|
|
#include "libxml/HTMLparser.h"
|
2003-04-04 19:19:32 +04:00
|
|
|
#include "css_enum.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef unsigned long colour; /* 0xbbggrr */
|
|
|
|
#define TRANSPARENT 0x1000000
|
|
|
|
#define CSS_COLOR_INHERIT 0x2000000
|
2003-10-01 00:34:35 +04:00
|
|
|
#define CSS_COLOR_NONE 0x3000000
|
2004-02-02 03:22:59 +03:00
|
|
|
#define TOP 0
|
|
|
|
#define RIGHT 1
|
|
|
|
#define BOTTOM 2
|
|
|
|
#define LEFT 3
|
2003-04-04 19:19:32 +04:00
|
|
|
|
2003-12-27 23:15:23 +03:00
|
|
|
/** Representation of a CSS 2 length. */
|
2003-04-04 19:19:32 +04:00
|
|
|
struct css_length {
|
|
|
|
float value;
|
|
|
|
css_unit unit;
|
|
|
|
};
|
|
|
|
|
2003-11-05 19:25:35 +03:00
|
|
|
typedef enum {
|
|
|
|
CSS_TEXT_DECORATION_NONE = 0x0,
|
|
|
|
CSS_TEXT_DECORATION_INHERIT = 0x1,
|
|
|
|
CSS_TEXT_DECORATION_UNDERLINE = 0x2,
|
|
|
|
CSS_TEXT_DECORATION_BLINK = 0x4,
|
|
|
|
CSS_TEXT_DECORATION_LINE_THROUGH = 0x8,
|
|
|
|
CSS_TEXT_DECORATION_OVERLINE = 0x10,
|
|
|
|
CSS_TEXT_DECORATION_UNKNOWN = 0x1000
|
|
|
|
} css_text_decoration;
|
|
|
|
|
2004-06-09 23:55:06 +04:00
|
|
|
typedef enum {
|
2004-06-25 18:28:29 +04:00
|
|
|
CSS_BACKGROUND_IMAGE_NONE,
|
|
|
|
CSS_BACKGROUND_IMAGE_INHERIT,
|
|
|
|
CSS_BACKGROUND_IMAGE_URI
|
|
|
|
} css_background_image_type;
|
|
|
|
|
|
|
|
/** Part of struct css_style, for convenience. */
|
|
|
|
struct css_background_position {
|
|
|
|
enum {
|
|
|
|
CSS_BACKGROUND_POSITION_LENGTH,
|
|
|
|
CSS_BACKGROUND_POSITION_PERCENT,
|
|
|
|
CSS_BACKGROUND_POSITION_INHERIT
|
|
|
|
} pos;
|
|
|
|
union {
|
|
|
|
float percent;
|
|
|
|
struct css_length length;
|
|
|
|
} value;
|
|
|
|
};
|
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
struct css_border_width {
|
|
|
|
enum { CSS_BORDER_WIDTH_INHERIT,
|
|
|
|
CSS_BORDER_WIDTH_LENGTH } width;
|
|
|
|
struct css_length value;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CSS_LIST_STYLE_IMAGE_INHERIT,
|
|
|
|
CSS_LIST_STYLE_IMAGE_NONE,
|
|
|
|
CSS_LIST_STYLE_IMAGE_URI
|
|
|
|
} css_list_style_image_type;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CSS_OUTLINE_COLOR_INHERIT,
|
|
|
|
CSS_OUTLINE_COLOR_COLOR,
|
|
|
|
CSS_OUTLINE_COLOR_INVERT
|
|
|
|
} css_outline_color_type;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CSS_VERTICAL_ALIGN_INHERIT,
|
|
|
|
CSS_VERTICAL_ALIGN_BASELINE,
|
|
|
|
CSS_VERTICAL_ALIGN_SUB,
|
|
|
|
CSS_VERTICAL_ALIGN_SUPER,
|
|
|
|
CSS_VERTICAL_ALIGN_TOP,
|
|
|
|
CSS_VERTICAL_ALIGN_TEXT_TOP,
|
|
|
|
CSS_VERTICAL_ALIGN_MIDDLE,
|
|
|
|
CSS_VERTICAL_ALIGN_BOTTOM,
|
|
|
|
CSS_VERTICAL_ALIGN_TEXT_BOTTOM,
|
|
|
|
CSS_VERTICAL_ALIGN_LENGTH,
|
|
|
|
CSS_VERTICAL_ALIGN_PERCENT
|
|
|
|
} css_vertical_align_type;
|
|
|
|
|
2004-06-09 23:55:06 +04:00
|
|
|
|
2003-12-27 23:15:23 +03:00
|
|
|
/** Representation of a complete CSS 2 style. */
|
2003-04-04 19:19:32 +04:00
|
|
|
struct css_style {
|
2004-08-01 18:13:47 +04:00
|
|
|
/* background properties */
|
2004-06-25 18:28:29 +04:00
|
|
|
css_background_attachment background_attachment;
|
2004-08-01 18:13:47 +04:00
|
|
|
colour background_color;
|
2004-06-09 23:55:06 +04:00
|
|
|
struct {
|
2004-06-25 18:28:29 +04:00
|
|
|
css_background_image_type type;
|
|
|
|
char *uri;
|
2004-06-09 23:55:06 +04:00
|
|
|
} background_image;
|
2004-06-25 18:28:29 +04:00
|
|
|
struct {
|
|
|
|
struct css_background_position horz;
|
|
|
|
struct css_background_position vert;
|
|
|
|
} background_position;
|
|
|
|
css_background_repeat background_repeat;
|
2004-06-09 23:55:06 +04:00
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
/* borders */
|
2004-02-02 03:22:59 +03:00
|
|
|
struct {
|
|
|
|
colour color;
|
2004-08-01 18:13:47 +04:00
|
|
|
struct css_border_width width;
|
2004-02-02 03:22:59 +03:00
|
|
|
css_border_style style;
|
|
|
|
} border[4]; /**< top, right, bottom, left */
|
2004-08-01 18:13:47 +04:00
|
|
|
css_border_collapse border_collapse;
|
|
|
|
struct {
|
|
|
|
enum { CSS_BORDER_SPACING_INHERIT,
|
|
|
|
CSS_BORDER_SPACING_LENGTH } border_spacing;
|
|
|
|
struct css_length horz;
|
|
|
|
struct css_length vert;
|
|
|
|
} border_spacing;
|
2004-02-02 03:22:59 +03:00
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
css_caption_side caption_side;
|
2003-04-04 19:19:32 +04:00
|
|
|
css_clear clear;
|
2004-08-01 18:13:47 +04:00
|
|
|
|
|
|
|
struct {
|
|
|
|
enum { CSS_CLIP_INHERIT,
|
|
|
|
CSS_CLIP_AUTO,
|
|
|
|
CSS_CLIP_RECT } clip;
|
|
|
|
struct {
|
|
|
|
enum { CSS_CLIP_RECT_AUTO,
|
|
|
|
CSS_CLIP_RECT_LENGTH } rect;
|
|
|
|
struct css_length value;
|
|
|
|
} rect[4]; /**< top, right, bottom, left */
|
|
|
|
} clip;
|
|
|
|
|
2003-04-04 19:19:32 +04:00
|
|
|
colour color;
|
2004-08-01 18:13:47 +04:00
|
|
|
|
|
|
|
/** \todo content and counters */
|
|
|
|
|
2004-04-03 03:12:26 +04:00
|
|
|
css_cursor cursor;
|
2004-08-01 18:13:47 +04:00
|
|
|
css_direction direction;
|
2003-04-04 19:19:32 +04:00
|
|
|
css_display display;
|
2004-08-01 18:13:47 +04:00
|
|
|
css_empty_cells empty_cells;
|
2003-04-04 19:19:32 +04:00
|
|
|
css_float float_;
|
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
/* font properties */
|
|
|
|
css_font_family font_family;
|
2003-04-04 19:19:32 +04:00
|
|
|
struct {
|
|
|
|
enum { CSS_FONT_SIZE_INHERIT,
|
|
|
|
CSS_FONT_SIZE_ABSOLUTE,
|
|
|
|
CSS_FONT_SIZE_LENGTH,
|
|
|
|
CSS_FONT_SIZE_PERCENT } size;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float absolute;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} font_size;
|
|
|
|
css_font_style font_style;
|
2004-01-31 01:28:32 +03:00
|
|
|
css_font_variant font_variant;
|
2004-08-01 18:13:47 +04:00
|
|
|
css_font_weight font_weight;
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
struct {
|
|
|
|
enum { CSS_HEIGHT_INHERIT,
|
|
|
|
CSS_HEIGHT_AUTO,
|
|
|
|
CSS_HEIGHT_LENGTH } height;
|
|
|
|
struct css_length length;
|
|
|
|
} height;
|
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
struct {
|
|
|
|
enum { CSS_LETTER_SPACING_INHERIT,
|
|
|
|
CSS_LETTER_SPACING_NORMAL,
|
|
|
|
CSS_LETTER_SPACING_LENGTH } letter_spacing;
|
|
|
|
struct css_length length;
|
|
|
|
} letter_spacing;
|
|
|
|
|
2003-04-04 19:19:32 +04:00
|
|
|
struct {
|
|
|
|
enum { CSS_LINE_HEIGHT_INHERIT,
|
|
|
|
CSS_LINE_HEIGHT_ABSOLUTE,
|
|
|
|
CSS_LINE_HEIGHT_LENGTH,
|
|
|
|
CSS_LINE_HEIGHT_PERCENT } size;
|
|
|
|
union {
|
|
|
|
float absolute;
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} line_height;
|
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
/* list properties */
|
|
|
|
struct {
|
|
|
|
css_list_style_image_type type;
|
|
|
|
char *uri;
|
|
|
|
} list_style_image;
|
|
|
|
css_list_style_position list_style_position;
|
|
|
|
css_list_style_type list_style_type;
|
|
|
|
|
|
|
|
/* margins */
|
2004-02-02 03:22:59 +03:00
|
|
|
struct {
|
|
|
|
enum { CSS_MARGIN_INHERIT,
|
|
|
|
CSS_MARGIN_LENGTH,
|
|
|
|
CSS_MARGIN_PERCENT,
|
|
|
|
CSS_MARGIN_AUTO } margin;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} margin[4]; /**< top, right, bottom, left */
|
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
/* min/max width/height */
|
|
|
|
struct {
|
|
|
|
enum { CSS_MAX_HEIGHT_INHERIT,
|
|
|
|
CSS_MAX_HEIGHT_NONE,
|
|
|
|
CSS_MAX_HEIGHT_LENGTH,
|
|
|
|
CSS_MAX_HEIGHT_PERCENT } max_height;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} max_height;
|
|
|
|
struct {
|
|
|
|
enum { CSS_MAX_WIDTH_INHERIT,
|
|
|
|
CSS_MAX_WIDTH_NONE,
|
|
|
|
CSS_MAX_WIDTH_LENGTH,
|
|
|
|
CSS_MAX_WIDTH_PERCENT } max_width;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} max_width;
|
|
|
|
struct {
|
|
|
|
enum { CSS_MIN_HEIGHT_INHERIT,
|
|
|
|
CSS_MIN_HEIGHT_LENGTH,
|
|
|
|
CSS_MIN_HEIGHT_PERCENT } min_height;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} min_height;
|
|
|
|
struct {
|
|
|
|
enum { CSS_MIN_WIDTH_INHERIT,
|
|
|
|
CSS_MIN_WIDTH_LENGTH,
|
|
|
|
CSS_MIN_WIDTH_PERCENT } min_width;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} min_width;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
enum { CSS_ORPHANS_INHERIT,
|
|
|
|
CSS_ORPHANS_INTEGER } orphans;
|
|
|
|
int value;
|
|
|
|
} orphans;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
css_outline_color_type color;
|
|
|
|
colour value;
|
|
|
|
} color;
|
|
|
|
struct css_border_width width;
|
|
|
|
css_border_style style;
|
|
|
|
} outline;
|
|
|
|
|
2004-07-17 00:22:31 +04:00
|
|
|
css_overflow overflow;
|
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
/* padding */
|
2004-02-02 03:22:59 +03:00
|
|
|
struct {
|
|
|
|
enum { CSS_PADDING_INHERIT,
|
|
|
|
CSS_PADDING_LENGTH,
|
|
|
|
CSS_PADDING_PERCENT } padding;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} padding[4]; /**< top, right, bottom, left */
|
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
css_page_break_after page_break_after;
|
|
|
|
css_page_break_before page_break_before;
|
|
|
|
css_page_break_inside page_break_inside;
|
|
|
|
|
|
|
|
struct {
|
2004-08-02 01:56:47 +04:00
|
|
|
enum { CSS_POS_INHERIT,
|
|
|
|
CSS_POS_AUTO,
|
|
|
|
CSS_POS_PERCENT,
|
|
|
|
CSS_POS_LENGTH } pos;
|
2004-08-01 18:13:47 +04:00
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
2004-08-02 01:56:47 +04:00
|
|
|
} pos[4]; /**< top, right, bottom, left */
|
|
|
|
|
|
|
|
css_position position;
|
|
|
|
|
|
|
|
/** \todo quotes */
|
2004-08-01 18:13:47 +04:00
|
|
|
|
|
|
|
css_table_layout table_layout;
|
|
|
|
|
|
|
|
/* text properties */
|
2003-04-04 19:19:32 +04:00
|
|
|
css_text_align text_align;
|
2003-10-18 03:47:13 +04:00
|
|
|
css_text_decoration text_decoration;
|
2004-02-02 01:42:40 +03:00
|
|
|
struct {
|
2004-06-25 18:28:29 +04:00
|
|
|
enum { CSS_TEXT_INDENT_INHERIT,
|
|
|
|
CSS_TEXT_INDENT_LENGTH,
|
|
|
|
CSS_TEXT_INDENT_PERCENT } size;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value ;
|
|
|
|
} text_indent;
|
2004-02-01 00:18:44 +03:00
|
|
|
css_text_transform text_transform;
|
2003-04-04 19:19:32 +04:00
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
css_unicode_bidi unicode_bidi;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
css_vertical_align_type type;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} vertical_align;
|
|
|
|
|
2003-10-10 22:13:36 +04:00
|
|
|
css_visibility visibility;
|
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
css_white_space white_space;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
enum { CSS_WIDOWS_INHERIT,
|
|
|
|
CSS_WIDOWS_INTEGER } widows;
|
|
|
|
int value;
|
|
|
|
} widows;
|
|
|
|
|
2003-04-04 19:19:32 +04:00
|
|
|
struct {
|
|
|
|
enum { CSS_WIDTH_INHERIT,
|
|
|
|
CSS_WIDTH_AUTO,
|
|
|
|
CSS_WIDTH_LENGTH,
|
|
|
|
CSS_WIDTH_PERCENT } width;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} width;
|
2003-10-08 01:34:27 +04:00
|
|
|
|
2004-08-01 18:13:47 +04:00
|
|
|
struct {
|
|
|
|
enum { CSS_WORD_SPACING_INHERIT,
|
|
|
|
CSS_WORD_SPACING_NORMAL,
|
|
|
|
CSS_WORD_SPACING_LENGTH } word_spacing;
|
|
|
|
struct css_length length;
|
|
|
|
} word_spacing;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
enum { CSS_Z_INDEX_INHERIT,
|
|
|
|
CSS_Z_INDEX_AUTO,
|
|
|
|
CSS_Z_INDEX_INTEGER } z_index;
|
|
|
|
int value;
|
|
|
|
} z_index;
|
2003-04-04 19:19:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct css_stylesheet;
|
|
|
|
|
2003-12-27 23:15:23 +03:00
|
|
|
/** Data specific to CONTENT_CSS. */
|
2003-09-08 01:08:13 +04:00
|
|
|
struct content_css_data {
|
2003-12-27 23:15:23 +03:00
|
|
|
struct css_stylesheet *css; /**< Opaque stylesheet data. */
|
|
|
|
unsigned int import_count; /**< Number of entries in import_url. */
|
|
|
|
char **import_url; /**< Imported stylesheet urls. */
|
|
|
|
struct content **import_content; /**< Imported stylesheet contents. */
|
2003-09-08 01:08:13 +04:00
|
|
|
};
|
|
|
|
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
extern const struct css_style css_base_style;
|
|
|
|
extern const struct css_style css_empty_style;
|
|
|
|
extern const struct css_style css_blank_style;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CSS_INTERNALS
|
|
|
|
|
2004-05-01 21:48:38 +04:00
|
|
|
/** Type of a css_selector. */
|
|
|
|
typedef enum {
|
|
|
|
CSS_SELECTOR_ELEMENT,
|
|
|
|
CSS_SELECTOR_ID,
|
|
|
|
CSS_SELECTOR_CLASS,
|
|
|
|
CSS_SELECTOR_ATTRIB,
|
|
|
|
CSS_SELECTOR_ATTRIB_EQ,
|
|
|
|
CSS_SELECTOR_ATTRIB_INC,
|
|
|
|
CSS_SELECTOR_ATTRIB_DM,
|
2004-07-31 01:53:52 +04:00
|
|
|
CSS_SELECTOR_ATTRIB_PRE,
|
|
|
|
CSS_SELECTOR_ATTRIB_SUF,
|
|
|
|
CSS_SELECTOR_ATTRIB_SUB,
|
2004-05-01 21:48:38 +04:00
|
|
|
CSS_SELECTOR_PSEUDO,
|
|
|
|
} css_selector_type;
|
|
|
|
|
|
|
|
/** Relationship to combiner in a css_selector. */
|
|
|
|
typedef enum {
|
|
|
|
CSS_COMB_NONE,
|
|
|
|
CSS_COMB_ANCESTOR,
|
|
|
|
CSS_COMB_PARENT,
|
|
|
|
CSS_COMB_PRECEDED,
|
|
|
|
} css_combinator;
|
|
|
|
|
|
|
|
/** Representation of a CSS selector. */
|
|
|
|
struct css_selector {
|
|
|
|
css_selector_type type;
|
|
|
|
const char *data;
|
|
|
|
unsigned int data_length;
|
|
|
|
const char *data2;
|
|
|
|
unsigned int data2_length;
|
|
|
|
struct css_selector *detail;
|
|
|
|
struct css_selector *combiner;
|
|
|
|
struct css_selector *next;
|
|
|
|
css_combinator comb;
|
|
|
|
struct css_style *style;
|
|
|
|
unsigned long specificity;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Type of a css_node. */
|
2003-04-04 19:19:32 +04:00
|
|
|
typedef enum {
|
2003-10-08 01:34:27 +04:00
|
|
|
CSS_NODE_DECLARATION,
|
|
|
|
CSS_NODE_IDENT,
|
|
|
|
CSS_NODE_NUMBER,
|
|
|
|
CSS_NODE_PERCENTAGE,
|
|
|
|
CSS_NODE_DIMENSION,
|
|
|
|
CSS_NODE_STRING,
|
|
|
|
CSS_NODE_DELIM,
|
|
|
|
CSS_NODE_URI,
|
|
|
|
CSS_NODE_HASH,
|
|
|
|
CSS_NODE_UNICODE_RANGE,
|
|
|
|
CSS_NODE_INCLUDES,
|
|
|
|
CSS_NODE_FUNCTION,
|
|
|
|
CSS_NODE_DASHMATCH,
|
2004-07-31 01:53:52 +04:00
|
|
|
CSS_NODE_PREFIX,
|
|
|
|
CSS_NODE_SUFFIX,
|
|
|
|
CSS_NODE_SUBSTR,
|
2003-10-08 01:34:27 +04:00
|
|
|
CSS_NODE_COLON,
|
|
|
|
CSS_NODE_COMMA,
|
2003-10-17 21:39:29 +04:00
|
|
|
CSS_NODE_DOT,
|
2003-10-08 01:34:27 +04:00
|
|
|
CSS_NODE_PLUS,
|
|
|
|
CSS_NODE_GT,
|
|
|
|
CSS_NODE_PAREN,
|
|
|
|
CSS_NODE_BRAC,
|
|
|
|
} css_node_type;
|
2003-04-04 19:19:32 +04:00
|
|
|
|
2004-05-01 21:48:38 +04:00
|
|
|
/** A node in a CSS parse tree. */
|
2003-10-08 01:34:27 +04:00
|
|
|
struct css_node {
|
|
|
|
css_node_type type;
|
2004-05-01 21:48:38 +04:00
|
|
|
const char *data;
|
|
|
|
unsigned int data_length;
|
|
|
|
struct css_node *value;
|
2003-10-08 01:34:27 +04:00
|
|
|
struct css_node *next;
|
|
|
|
css_combinator comb;
|
2003-04-04 19:19:32 +04:00
|
|
|
struct css_style *style;
|
2003-09-28 21:37:43 +04:00
|
|
|
unsigned long specificity;
|
2004-06-09 23:55:06 +04:00
|
|
|
struct content *stylesheet;
|
2003-04-04 19:19:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-04-06 01:38:06 +04:00
|
|
|
#define HASH_SIZE (47 + 1)
|
2003-04-05 19:35:55 +04:00
|
|
|
|
2004-05-01 21:48:38 +04:00
|
|
|
/** Representation of a CSS 2 style sheet. */
|
2003-04-04 19:19:32 +04:00
|
|
|
struct css_stylesheet {
|
2004-05-01 21:48:38 +04:00
|
|
|
struct css_selector *rule[HASH_SIZE];
|
2003-04-04 19:19:32 +04:00
|
|
|
};
|
|
|
|
|
2004-05-01 21:48:38 +04:00
|
|
|
/** Parameters to and results from the CSS parser. */
|
|
|
|
struct css_parser_params {
|
|
|
|
bool ruleset_only;
|
2003-04-06 22:09:34 +04:00
|
|
|
struct content *stylesheet;
|
2003-10-08 01:34:27 +04:00
|
|
|
struct css_node *declaration;
|
2003-10-17 21:39:29 +04:00
|
|
|
bool syntax_error;
|
2004-05-01 21:48:38 +04:00
|
|
|
bool memory_error;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Token type for the CSS parser. */
|
|
|
|
struct css_parser_token {
|
|
|
|
const char *text;
|
|
|
|
unsigned int length;
|
2003-04-05 20:24:43 +04:00
|
|
|
};
|
|
|
|
|
2003-04-04 19:19:32 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-07-15 02:57:45 +04:00
|
|
|
struct content;
|
2003-04-04 19:19:32 +04:00
|
|
|
|
2004-06-11 00:41:26 +04:00
|
|
|
bool css_convert(struct content *c, int width, int height);
|
2003-04-04 19:19:32 +04:00
|
|
|
void css_destroy(struct content *c);
|
|
|
|
|
|
|
|
#ifdef CSS_INTERNALS
|
|
|
|
|
2004-06-09 23:55:06 +04:00
|
|
|
struct css_node * css_new_node(struct content *stylesheet,
|
2004-06-25 18:28:29 +04:00
|
|
|
css_node_type type,
|
2004-05-01 21:48:38 +04:00
|
|
|
const char *data, unsigned int data_length);
|
2003-10-08 01:34:27 +04:00
|
|
|
void css_free_node(struct css_node *node);
|
2004-05-01 21:48:38 +04:00
|
|
|
struct css_selector * css_new_selector(css_selector_type type,
|
|
|
|
const char *data, unsigned int data_length);
|
|
|
|
void css_free_selector(struct css_selector *node);
|
2003-10-08 01:34:27 +04:00
|
|
|
void css_atimport(struct content *c, struct css_node *node);
|
2003-04-06 22:09:34 +04:00
|
|
|
void css_add_ruleset(struct content *c,
|
2004-05-01 21:48:38 +04:00
|
|
|
struct css_selector *selector,
|
|
|
|
struct css_node *declaration);
|
|
|
|
void css_add_declarations(struct css_style *style,
|
2003-10-08 01:34:27 +04:00
|
|
|
struct css_node *declaration);
|
2004-05-01 21:48:38 +04:00
|
|
|
unsigned int css_hash(const char *s, int length);
|
|
|
|
|
|
|
|
int css_tokenise(unsigned char **buffer, unsigned char *end,
|
|
|
|
unsigned char **token_text);
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
void css_parser_Trace(FILE *TraceFILE, char *zTracePrompt);
|
2004-05-21 14:17:55 +04:00
|
|
|
void *css_parser_Alloc(void *(*mallocProc)(/*size_t*/ int));
|
2003-04-04 19:19:32 +04:00
|
|
|
void css_parser_Free(void *p, void (*freeProc)(void*));
|
2004-05-01 21:48:38 +04:00
|
|
|
void css_parser_(void *yyp, int yymajor, struct css_parser_token yyminor,
|
|
|
|
struct css_parser_params *param);
|
2004-06-11 00:41:26 +04:00
|
|
|
const char *css_parser_TokenName(int tokenType);
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2003-09-28 03:36:34 +04:00
|
|
|
void css_get_style(struct content *c, xmlNode *n, struct css_style * style);
|
2004-05-01 21:48:38 +04:00
|
|
|
void css_cascade(struct css_style * const style,
|
|
|
|
const struct css_style * const apply);
|
|
|
|
void css_merge(struct css_style * const style,
|
|
|
|
const struct css_style * const apply);
|
2004-06-11 16:51:40 +04:00
|
|
|
void css_parse_property_list(struct content *c, struct css_style * style,
|
2004-06-25 18:28:29 +04:00
|
|
|
char * str);
|
2003-04-13 16:50:10 +04:00
|
|
|
colour named_colour(const char *name);
|
2003-07-05 01:18:24 +04:00
|
|
|
void css_dump_style(const struct css_style * const style);
|
2003-12-27 03:11:57 +03:00
|
|
|
void css_dump_stylesheet(const struct css_stylesheet * stylesheet);
|
2003-07-05 01:18:24 +04:00
|
|
|
|
2004-08-14 19:07:21 +04:00
|
|
|
float css_len2px(struct css_length * length, struct css_style * style);
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
#endif
|