1 2 #ifndef EL__DOCUMENT_HTML_INTERNAL_H 3 #define EL__DOCUMENT_HTML_INTERNAL_H 4 5 #include "document/css/stylesheet.h" 6 #include "document/html/parser.h" 7 #include "util/lists.h" 8 9 struct document_options; 10 struct uri; 11 12 /* For parser/parse.c: */ 13 14 void process_head(struct html_context *html_context, unsigned char *head); 15 void put_chrs(struct html_context *html_context, unsigned char *start, int len); 16 17 enum html_whitespace_state { 18 /* Either we are starting a new "block" or the last segment of the 19 * current "block" is ending with whitespace and we should eat any 20 * leading whitespace of the next segment passed to put_chrs(). 21 * This prevents HTML whitespace from indenting new blocks by one 22 * or creating two consecutive segments of whitespace in the middle 23 * of a block. */ 24 HTML_SPACE_SUPPRESS, 25 26 /* Do not do anything special. */ 27 HTML_SPACE_NORMAL, 28 29 /* We should add a space when we start the next segment if it doesn't 30 * already start with whitespace. This is used in an "x </y> z" 31 * scenario when the parser hits </y>: it renders "x" and sets this, 32 * so that it will then render " z". XXX: Then we could of course 33 * render "x " and set -1. But we test for this value in parse_html() 34 * if we hit an opening tag of an element and potentially 35 * put_chrs(" "). That needs more investigation yet. --pasky */ 36 HTML_SPACE_ADD, 37 }; 38 39 struct html_context { 40 #ifdef CONFIG_CSS 41 /* The default stylesheet is initially merged into it. When parsing CSS 42 * from <style>-tags and external stylesheets if enabled is merged 43 * added to it. */ 44 struct css_stylesheet css_styles; 45 #endif 46 47 /* These are global per-document base values, alterable by the <base> 48 * element. */ 49 struct uri *base_href; 50 unsigned char *base_target; 51 52 struct document_options *options; 53 54 /* For: 55 * html/parser/parse.c 56 * html/parser/stack.c 57 * html/parser.c */ 58 struct list_head stack; 59 60 /* For parser/parse.c: */ 61 unsigned char *eoff; /* For parser/forms.c too */ 62 int line_breax; /* This is for ln_break. */ 63 int position; 64 enum html_whitespace_state putsp; /* This is for the put_chrs 65 * state-machine. */ 66 int was_li; 67 68 unsigned int was_br:1; 69 unsigned int was_xmp:1; 70 unsigned int was_style:1; 71 unsigned int has_link_lines:1; 72 unsigned int was_body:1; /* For META refresh inside <body>. */ 73 unsigned int was_body_background:1; /* For <HTML> with style. */ 74 75 /* For html/parser.c, html/renderer.c */ 76 int margin; 77 78 /* For parser/forms.c: */ 79 unsigned char *startf; 80 81 /* For: 82 * html/parser/parse.c 83 * html/parser.c 84 * html/renderer.c 85 * html/tables.c */ 86 int table_level; 87 88 /* For: 89 * html/parser/forms.c 90 * html/parser/link.c 91 * html/parser/parse.c 92 * html/parser/stack.c 93 * html/parser.c */ 94 struct part *part; 95 96 /* For: 97 * html/parser/forms.c 98 * html/parser/link.c 99 * html/parser/parse.c 100 * html/parser.c */ 101 void (*put_chars_f)(struct html_context *, unsigned char *, int); 102 103 /* For: 104 * html/parser/forms.c 105 * html/parser/link.c 106 * html/parser/parse.c 107 * html/parser/stack.c 108 * html/parser.c */ 109 void (*line_break_f)(struct html_context *); 110 111 /* For: 112 * html/parser/forms.c 113 * html/parser/parse.c 114 * html/parser.c */ 115 void *(*special_f)(struct html_context *, enum html_special_type, ...); 116 }; 117 118 #define format (((struct html_element *) html_context->stack.next)->attr) 119 #define par_format (((struct html_element *) html_context->stack.next)->parattr) 120 #define html_top (*(struct html_element *) html_context->stack.next) 121 122 #define html_is_preformatted() (format.style.attr & AT_PREFORMATTED) 123 124 #define get_html_max_width() \ 125 int_max(par_format.width - (par_format.leftmargin + par_format.rightmargin), 0) 126 127 /* For parser/link.c: */ 128 129 void html_focusable(struct html_context *html_context, unsigned char *a); 130 void html_skip(struct html_context *html_context, unsigned char *a); 131 unsigned char *get_target(struct document_options *options, unsigned char *a); 132 133 void 134 import_css_stylesheet(struct css_stylesheet *css, struct uri *base_uri, 135 unsigned char *url, int len); 136 137 #endif 138