2 #ifndef EL__DOCUMENT_HTML_INTERNAL_H
3 #define EL__DOCUMENT_HTML_INTERNAL_H
5 #include "document/css/stylesheet.h"
6 #include "document/html/parser.h"
7 #include "util/lists.h"
9 struct document_options
;
12 /* For parser/parse.c: */
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
);
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
26 /* Do not do anything special. */
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 */
41 /* The default stylesheet is initially merged into it. When parsing CSS
42 * from <style>-tags and external stylesheets if enabled is merged
44 struct css_stylesheet css_styles
;
47 /* These are global per-document base values, alterable by the <base>
49 struct uri
*base_href
;
50 unsigned char *base_target
;
52 struct document_options
*options
;
54 /* doc_cp is the charset of the document, i.e. part->document->cp.
55 * It is copied here because part->document is NULL sometimes. */
62 struct list_head stack
;
64 /* For parser/parse.c: */
65 unsigned char *eoff
; /* For parser/forms.c too */
66 int line_breax
; /* This is for ln_break. */
67 int position
; /* This is the position on the document canvas relative
68 * to the current line and is maintained by put_chrs. */
69 enum html_whitespace_state putsp
; /* This is for the put_chrs
73 unsigned int quote_level
; /* Nesting level of <q> tags. See @html_quote
74 * for why this is unsigned. */
76 unsigned int was_br
:1;
77 unsigned int was_xmp
:1;
78 unsigned int was_style
:1;
79 unsigned int has_link_lines
:1;
80 unsigned int was_body
:1; /* For META refresh inside <body>. */
81 unsigned int was_body_background
:1; /* For <HTML> with style. */
83 /* For html/parser.c, html/renderer.c */
86 /* For parser/forms.c: */
87 unsigned char *startf
;
100 * html/parser/stack.c
105 * html/parser/forms.c
107 * html/parser/parse.c
109 /* Note that this is for usage by put_chrs only; anywhere else in
110 * the parser, one should use put_chrs. */
111 void (*put_chars_f
)(struct html_context
*, unsigned char *, int);
114 * html/parser/forms.c
116 * html/parser/parse.c
117 * html/parser/stack.c
119 void (*line_break_f
)(struct html_context
*);
122 * html/parser/forms.c
123 * html/parser/parse.c
125 void *(*special_f
)(struct html_context
*, enum html_special_type
, ...);
128 #define html_top ((struct html_element *) html_context->stack.next)
129 #define html_bottom ((struct html_element *) html_context->stack.prev)
130 #define format (html_top->attr)
131 #define par_format (html_top->parattr)
133 #define html_is_preformatted() (format.style.attr & AT_PREFORMATTED)
135 #define get_html_max_width() \
136 int_max(par_format.width - (par_format.leftmargin + par_format.rightmargin), 0)
138 /* For parser/link.c: */
140 void html_focusable(struct html_context
*html_context
, unsigned char *a
);
141 void html_skip(struct html_context
*html_context
, unsigned char *a
);
142 unsigned char *get_target(struct document_options
*options
, unsigned char *a
);
145 import_css_stylesheet(struct css_stylesheet
*css
, struct uri
*base_uri
,
146 unsigned char *url
, int len
);