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
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
2003-04-04 19:19:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_CSS_CSS_H_
|
|
|
|
#define _NETSURF_CSS_CSS_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"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* structures and typedefs
|
|
|
|
*/
|
|
|
|
|
|
|
|
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
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
struct css_length {
|
|
|
|
float value;
|
|
|
|
css_unit unit;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct css_style {
|
|
|
|
colour background_color;
|
|
|
|
css_clear clear;
|
|
|
|
colour color;
|
|
|
|
css_display display;
|
|
|
|
css_float float_;
|
|
|
|
|
|
|
|
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_weight font_weight;
|
|
|
|
css_font_style font_style;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
enum { CSS_HEIGHT_INHERIT,
|
|
|
|
CSS_HEIGHT_AUTO,
|
|
|
|
CSS_HEIGHT_LENGTH } height;
|
|
|
|
struct css_length length;
|
|
|
|
} height;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
css_text_align text_align;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
enum { CSS_WIDTH_INHERIT,
|
|
|
|
CSS_WIDTH_AUTO,
|
|
|
|
CSS_WIDTH_LENGTH,
|
|
|
|
CSS_WIDTH_PERCENT } width;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} width;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct css_stylesheet;
|
|
|
|
|
|
|
|
struct css_selector {
|
|
|
|
const char *element;
|
|
|
|
char *class;
|
|
|
|
char *id;
|
|
|
|
};
|
|
|
|
|
2003-09-08 01:08:13 +04:00
|
|
|
struct content_css_data {
|
|
|
|
struct css_stylesheet *css;
|
|
|
|
unsigned int import_count;
|
|
|
|
char **import_url;
|
|
|
|
struct content **import_content;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
NODE_BLOCK,
|
|
|
|
NODE_DECLARATION,
|
|
|
|
NODE_IDENT,
|
|
|
|
NODE_NUMBER,
|
|
|
|
NODE_PERCENTAGE,
|
|
|
|
NODE_DIMENSION,
|
|
|
|
NODE_STRING,
|
|
|
|
NODE_DELIM,
|
|
|
|
NODE_URI,
|
|
|
|
NODE_HASH,
|
|
|
|
NODE_UNICODE_RANGE,
|
|
|
|
NODE_INCLUDES,
|
|
|
|
NODE_FUNCTION,
|
|
|
|
NODE_DASHMATCH,
|
|
|
|
NODE_COLON,
|
|
|
|
NODE_COMMA,
|
|
|
|
NODE_PLUS,
|
|
|
|
NODE_GT,
|
|
|
|
NODE_PAREN,
|
|
|
|
NODE_BRAC,
|
|
|
|
NODE_SELECTOR,
|
|
|
|
NODE_ID,
|
|
|
|
NODE_CLASS,
|
2003-09-28 03:36:34 +04:00
|
|
|
NODE_ATTRIB,
|
|
|
|
NODE_ATTRIB_EQ,
|
|
|
|
NODE_ATTRIB_INC,
|
|
|
|
NODE_ATTRIB_DM,
|
2003-04-04 19:19:32 +04:00
|
|
|
} node_type;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
COMB_NONE,
|
|
|
|
COMB_ANCESTOR,
|
|
|
|
COMB_PARENT,
|
|
|
|
COMB_PRECEDED,
|
|
|
|
} combinator;
|
|
|
|
|
|
|
|
struct node {
|
|
|
|
node_type type;
|
|
|
|
char *data;
|
2003-09-28 03:36:34 +04:00
|
|
|
char *data2;
|
2003-04-04 19:19:32 +04:00
|
|
|
struct node *left;
|
|
|
|
struct node *right;
|
|
|
|
struct node *next;
|
|
|
|
combinator comb;
|
|
|
|
struct css_style *style;
|
2003-09-28 21:37:43 +04:00
|
|
|
unsigned long specificity;
|
2003-04-04 19:19:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#include "netsurf/css/scanner.h"
|
|
|
|
|
2003-04-06 01:38:06 +04:00
|
|
|
#define HASH_SIZE (47 + 1)
|
2003-04-05 19:35:55 +04:00
|
|
|
|
2003-04-04 19:19:32 +04:00
|
|
|
struct css_stylesheet {
|
|
|
|
yyscan_t lexer;
|
|
|
|
void *parser;
|
2003-04-05 19:35:55 +04:00
|
|
|
struct node *rule[HASH_SIZE];
|
2003-04-04 19:19:32 +04:00
|
|
|
};
|
|
|
|
|
2003-04-05 20:24:43 +04:00
|
|
|
struct parse_params {
|
|
|
|
int ruleset_only;
|
2003-04-06 22:09:34 +04:00
|
|
|
struct content *stylesheet;
|
2003-04-05 20:24:43 +04:00
|
|
|
struct node *declaration;
|
|
|
|
};
|
|
|
|
|
2003-04-04 19:19:32 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* interface
|
|
|
|
*/
|
|
|
|
|
2003-07-15 02:57:45 +04:00
|
|
|
struct content;
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
void css_create(struct content *c);
|
|
|
|
void css_process_data(struct content *c, char *data, unsigned long size);
|
|
|
|
int css_convert(struct content *c, unsigned int width, unsigned int height);
|
|
|
|
void css_revive(struct content *c, unsigned int width, unsigned int height);
|
|
|
|
void css_reformat(struct content *c, unsigned int width, unsigned int height);
|
|
|
|
void css_destroy(struct content *c);
|
|
|
|
|
|
|
|
#ifdef CSS_INTERNALS
|
|
|
|
|
|
|
|
struct node * css_new_node(node_type type, char *data,
|
|
|
|
struct node *left, struct node *right);
|
|
|
|
void css_free_node(struct node *node);
|
2003-09-28 21:37:43 +04:00
|
|
|
char *css_unquote(char *s);
|
2003-04-06 22:09:34 +04:00
|
|
|
void css_atimport(struct content *c, struct node *node);
|
|
|
|
void css_add_ruleset(struct content *c,
|
2003-04-04 19:19:32 +04:00
|
|
|
struct node *selector,
|
|
|
|
struct node *declaration);
|
2003-04-05 20:24:43 +04:00
|
|
|
void css_add_declarations(struct css_style *style, struct node *declaration);
|
2003-04-05 19:35:55 +04:00
|
|
|
unsigned int css_hash(const char *s);
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
void css_parser_Trace(FILE *TraceFILE, char *zTracePrompt);
|
|
|
|
void *css_parser_Alloc(void *(*mallocProc)(int));
|
|
|
|
void css_parser_Free(void *p, void (*freeProc)(void*));
|
2003-04-05 20:24:43 +04:00
|
|
|
void css_parser_(void *yyp, int yymajor, char* yyminor,
|
|
|
|
struct parse_params *param);
|
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);
|
2003-04-04 19:19:32 +04:00
|
|
|
void css_cascade(struct css_style * const style, const struct css_style * const apply);
|
2003-04-06 01:38:06 +04:00
|
|
|
void css_merge(struct css_style * const style, const struct css_style * const apply);
|
2003-04-04 19:19:32 +04:00
|
|
|
void css_parse_property_list(struct css_style * style, 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-07-10 01:33:01 +04:00
|
|
|
signed long len(struct css_length * length, struct css_style * style);
|
2003-04-04 19:19:32 +04:00
|
|
|
|
|
|
|
#endif
|