annotate src/html_common.hh @ 263:af0161ff58ec

- html.cc cleanup (in progress): source split.
author jcid
date Sat, 07 Jun 2008 15:29:01 +0200
parents bb0694ce4e6b
children f97319b762d2
rev   line source
262
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
1 #ifndef __HTML_COMMON_HH__
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
2 #define __HTML_COMMON_HH__
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
3
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
4 #include "url.h"
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
5 #include "bw.h"
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
6
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
7 #include "lout/misc.hh"
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
8 #include "dw/core.hh"
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
9 #include "dw/image.hh"
263
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
10 #include "dw/style.hh"
262
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
11
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
12 #include "image.hh"
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
13
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
14 #include "form.hh"
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
15
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
16 /*
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
17 * Macros
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
18 */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
19
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
20 // Dw to Textblock
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
21 #define DW2TB(dw) ((Textblock*)dw)
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
22 // "html struct" to "Layout"
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
23 #define HT2LT(html) ((Layout*)html->bw->render_layout)
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
24 // "Image" to "Dw Widget"
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
25 #define IM2DW(Image) ((Widget*)Image->dw)
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
26 // Top of the parsing stack
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
27 #define S_TOP(html) (html->stack->getRef(html->stack->size()-1))
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
28
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
29 // Add a bug-meter message.
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
30 #define BUG_MSG(...) \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
31 D_STMT_START { \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
32 html->bugMessage(__VA_ARGS__); \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
33 } D_STMT_END
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
34
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
35 /*
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
36 * Change one toplevel attribute. var should be an identifier. val is
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
37 * only evaluated once, so you can safely use a function call for it.
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
38 */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
39 #define HTML_SET_TOP_ATTR(html, var, val) \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
40 do { \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
41 StyleAttrs style_attrs; \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
42 Style *old_style; \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
43 \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
44 old_style = S_TOP(html)->style; \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
45 style_attrs = *old_style; \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
46 style_attrs.var = (val); \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
47 S_TOP(html)->style = \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
48 Style::create (HT2LT(html), &style_attrs); \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
49 old_style->unref (); \
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
50 } while (FALSE)
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
51
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
52 /*
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
53 * Typedefs
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
54 */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
55
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
56 typedef struct _DilloLinkImage DilloLinkImage;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
57 typedef struct _DilloHtmlState DilloHtmlState;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
58
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
59 typedef enum {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
60 DT_NONE,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
61 DT_HTML,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
62 DT_XHTML
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
63 } DilloHtmlDocumentType;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
64
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
65 typedef enum {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
66 DILLO_HTML_PARSE_MODE_INIT = 0,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
67 DILLO_HTML_PARSE_MODE_STASH,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
68 DILLO_HTML_PARSE_MODE_STASH_AND_BODY,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
69 DILLO_HTML_PARSE_MODE_VERBATIM,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
70 DILLO_HTML_PARSE_MODE_BODY,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
71 DILLO_HTML_PARSE_MODE_PRE
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
72 } DilloHtmlParseMode;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
73
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
74 typedef enum {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
75 DILLO_HTML_TABLE_MODE_NONE, /* no table at all */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
76 DILLO_HTML_TABLE_MODE_TOP, /* outside of <tr> */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
77 DILLO_HTML_TABLE_MODE_TR, /* inside of <tr>, outside of <td> */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
78 DILLO_HTML_TABLE_MODE_TD /* inside of <td> */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
79 } DilloHtmlTableMode;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
80
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
81 typedef enum {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
82 HTML_LIST_NONE,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
83 HTML_LIST_UNORDERED,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
84 HTML_LIST_ORDERED
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
85 } DilloHtmlListMode;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
86
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
87 typedef enum {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
88 IN_NONE = 0,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
89 IN_HTML = 1 << 0,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
90 IN_HEAD = 1 << 1,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
91 IN_BODY = 1 << 2,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
92 IN_FORM = 1 << 3,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
93 IN_SELECT = 1 << 4,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
94 IN_OPTION = 1 << 5,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
95 IN_TEXTAREA = 1 << 6,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
96 IN_MAP = 1 << 7,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
97 IN_PRE = 1 << 8,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
98 IN_BUTTON = 1 << 9,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
99 IN_LI = 1 << 10,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
100 } DilloHtmlProcessingState;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
101
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
102 /*
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
103 * Data Structures
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
104 */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
105
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
106 struct _DilloLinkImage {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
107 DilloUrl *url;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
108 DilloImage *image;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
109 };
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
110
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
111 struct _DilloHtmlState {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
112 dw::core::style::Style *style, *table_cell_style;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
113 DilloHtmlParseMode parse_mode;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
114 DilloHtmlTableMode table_mode;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
115 bool_t cell_text_align_set;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
116 DilloHtmlListMode list_type;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
117 int list_number;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
118
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
119 /* TagInfo index for the tag that's being processed */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
120 int tag_idx;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
121
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
122 dw::core::Widget *textblock, *table;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
123
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
124 /* This is used to align list items (especially in enumerated lists) */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
125 dw::core::Widget *ref_list_item;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
126
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
127 /* This is used for list items etc; if it is set to TRUE, breaks
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
128 have to be "handed over" (see Html_add_indented and
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
129 Html_eventually_pop_dw). */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
130 bool_t hand_over_break;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
131 };
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
132
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
133 /*
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
134 * Classes
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
135 */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
136
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
137 class DilloHtml {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
138 private:
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
139 class HtmlLinkReceiver: public dw::core::Widget::LinkReceiver {
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
140 public:
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
141 DilloHtml *html;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
142
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
143 bool enter (dw::core::Widget *widget, int link, int img, int x, int y);
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
144 bool press (dw::core::Widget *widget, int link, int img, int x, int y,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
145 dw::core::EventButton *event);
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
146 bool click (dw::core::Widget *widget, int link, int img, int x, int y,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
147 dw::core::EventButton *event);
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
148 };
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
149 HtmlLinkReceiver linkReceiver;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
150
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
151 public: //BUG: for now everything is public
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
152
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
153 BrowserWindow *bw;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
154 DilloUrl *page_url, *base_url;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
155 dw::core::Widget *dw; /* this is duplicated in the stack */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
156
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
157 /* -------------------------------------------------------------------*/
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
158 /* Variables required at parsing time */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
159 /* -------------------------------------------------------------------*/
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
160 size_t Buf_Consumed; /* amount of source from cache consumed */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
161 char *Start_Buf;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
162 int Start_Ofs;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
163 char *content_type, *charset;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
164 bool stop_parser;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
165
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
166 size_t CurrTagOfs;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
167 size_t OldTagOfs, OldTagLine;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
168
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
169 DilloHtmlDocumentType DocType; /* as given by DOCTYPE tag */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
170 float DocTypeVersion; /* HTML or XHTML version number */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
171
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
172 lout::misc::SimpleVector<DilloHtmlState> *stack;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
173
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
174 int InFlags; /* tracks which elements we are in */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
175
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
176 Dstr *Stash;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
177 bool_t StashSpace;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
178
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
179 int pre_column; /* current column, used in PRE tags with tabs */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
180 bool_t PreFirstChar; /* used to skip the first CR or CRLF in PRE tags */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
181 bool_t PrevWasCR; /* Flag to help parsing of "\r\n" in PRE tags */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
182 bool_t PrevWasOpenTag; /* Flag to help deferred parsing of white space */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
183 bool_t SPCPending; /* Flag to help deferred parsing of white space */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
184 bool_t PrevWasSPC; /* Flag to help handling collapsing white space */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
185 bool_t InVisitedLink; /* used to 'contrast_visited_colors' */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
186 bool_t ReqTagClose; /* Flag to help handling bad-formed HTML */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
187 bool_t CloseOneTag; /* Flag to help Html_tag_cleanup_at_close() */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
188 bool_t WordAfterLI; /* Flag to help ignoring the 1st <P> after <LI> */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
189 bool_t TagSoup; /* Flag to enable the parser's cleanup functions */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
190 char *NameVal; /* used for validation of "NAME" and "ID" in <A> */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
191
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
192 /* element counters: used for validation purposes */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
193 uchar_t Num_HTML, Num_HEAD, Num_BODY, Num_TITLE;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
194
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
195 Dstr *attr_data; /* Buffer for attribute value */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
196
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
197 /* -------------------------------------------------------------------*/
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
198 /* Variables required after parsing (for page functionality) */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
199 /* -------------------------------------------------------------------*/
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
200 lout::misc::SimpleVector<DilloHtmlForm*> *forms;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
201 lout::misc::SimpleVector<DilloUrl*> *links;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
202 lout::misc::SimpleVector<DilloLinkImage*> *images;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
203 dw::ImageMapsList maps;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
204
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
205 int32_t link_color;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
206 int32_t visited_color;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
207
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
208 private:
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
209 bool_t parse_finished;
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
210 void freeParseData();
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
211 void initDw(); /* Used by the constructor */
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
212
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
213 public:
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
214 DilloHtml(BrowserWindow *bw, const DilloUrl *url, const char *content_type);
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
215 ~DilloHtml();
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
216 void bugMessage(const char *format, ... );
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
217 void connectSignals(dw::core::Widget *dw);
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
218 void write(char *Buf, int BufSize, int Eof);
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
219 int getCurTagLineNumber();
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
220 void finishParsing(int ClientKey);
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
221 int formNew(DilloHtmlMethod method, const DilloUrl *action,
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
222 DilloHtmlEnc enc, const char *charset);
263
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
223 DilloHtmlForm *getCurrentForm ();
262
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
224 void loadImages (const DilloUrl *pattern);
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
225 };
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
226
263
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
227 /*
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
228 * Parser functions
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
229 */
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
230
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
231 const char *a_Html_get_attr(DilloHtml *html,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
232 const char *tag,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
233 int tagsize,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
234 const char *attrname);
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
235
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
236 char *a_Html_get_attr_wdef(DilloHtml *html,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
237 const char *tag,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
238 int tagsize,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
239 const char *attrname,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
240 const char *def);
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
241
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
242 DilloUrl *a_Html_url_new(DilloHtml *html,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
243 const char *url_str, const char *base_url,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
244 int flags, int32_t posx, int32_t posy,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
245 int use_base_url);
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
246
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
247 DilloImage *a_Html_add_new_image(DilloHtml *html, const char *tag,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
248 int tagsize, DilloUrl *url,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
249 dw::core::style::StyleAttrs *style_attrs,
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
250 bool_t add);
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
251
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
252 char *a_Html_parse_entities(DilloHtml *html, const char *token, int toksize);
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
253 void a_Html_pop_tag(DilloHtml *html, int TagIdx);
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
254 void a_Html_stash_init(DilloHtml *html);
af0161ff58ec - html.cc cleanup (in progress): source split.
jcid
parents: 262
diff changeset
255
262
bb0694ce4e6b - html.cc cleanup (in progress). Source split.
jcid
parents:
diff changeset
256 #endif /* __HTML_COMMON_HH__ */