Subversion Repositories Kolibri OS

Rev

Rev 8491 | Rev 8499 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8491 Rev 8492
Line 44... Line 44...
44
	dword bufpointer;
44
	dword bufpointer;
45
	dword bufsize;
45
	dword bufsize;
46
	dword is_html;
46
	dword is_html;
47
	collection img_url;
47
	collection img_url;
48
	char header[150];
48
	char header[150];
49
	char line[500];
49
	char linebuf[500];
50
	char redirect[URL_SIZE];
50
	char redirect[URL_SIZE];
Line 51... Line 51...
51
 
51
 
52
	void SetStyle();
52
	void SetStyle();
53
	void RenderTextbuf();
53
	void RenderTextbuf();
Line 74... Line 74...
74
	void tag_meta_xml();
74
	void tag_meta_xml();
75
	void tag_body();
75
	void tag_body();
76
	void tag_iframe();
76
	void tag_iframe();
77
	void tag_title();
77
	void tag_title();
78
	void tag_font();
78
	void tag_font();
-
 
79
	void tag_table_reset();
79
	void tag_table();
80
	void tag_table();
80
	void tag_td();
81
	void tag_td();
81
	void tag_tr();
82
	void tag_tr();
82
};
83
};
Line 98... Line 99...
98
	text_colors.add(0);
99
	text_colors.add(0);
99
	bg_colors.drop();
100
	bg_colors.drop();
100
	bg_colors.add(DEFAULT_BG_COL);
101
	bg_colors.add(DEFAULT_BG_COL);
101
	canvas.Fill(0, DEFAULT_BG_COL);
102
	canvas.Fill(0, DEFAULT_BG_COL);
102
	header = NULL;
103
	header = NULL;
103
	cur_encoding = CH_CP866;
-
 
104
	draw_y = BODY_MARGIN;
104
	draw_y = BODY_MARGIN;
105
	draw_x = left_gap = BODY_MARGIN;
105
	draw_x = left_gap = BODY_MARGIN;
106
	draw_w = list.w - BODY_MARGIN;
106
	draw_w = list.w - BODY_MARGIN;
107
	line = 0;
107
	linebuf = 0;
108
	redirect = '\0';
108
	redirect = '\0';
109
	//hold original buffer
-
 
110
	if (o_bufpointer) o_bufpointer=free(o_bufpointer);
-
 
111
	o_bufpointer = malloc(bufsize);
-
 
112
	memmov(o_bufpointer, bufpointer, bufsize);
-
 
113
	if (custom_encoding != -1) {
-
 
114
		cur_encoding = custom_encoding;
-
 
115
		bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
-
 
116
	}
-
 
117
	list.SetFont(8, 14, 10011000b);
109
	list.SetFont(8, 14, 10011000b);
-
 
110
	tag_table_reset();
118
}
111
}
119
//============================================================================================
112
//============================================================================================
120
void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
113
void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
121
	int tab_len;
114
	int tab_len;
122
	dword bufpos;
115
	dword bufpos;
123
	bufsize = _bufsize;
116
	bufsize = _bufsize;
Line 124... Line 117...
124
 
117
 
Line 125... Line 118...
125
	if (list.w!=canvas.bufw) canvas.Init(list.x, list.y, list.w, 400*20);
118
	if (list.w!=canvas.bufw) canvas.Init(list.x, list.y, list.w, 400*20);
-
 
119
 
-
 
120
	if (bufpointer == _bufpointer) {
126
 
121
		custom_encoding = cur_encoding;	
127
	if (bufpointer != _bufpointer) {
122
	} else {
-
 
123
		bufpointer = malloc(bufsize);
128
		bufpointer = malloc(bufsize);
124
		memmov(bufpointer, _bufpointer, bufsize);
-
 
125
 
-
 
126
		//hold original buffer
-
 
127
		o_bufpointer = malloc(bufsize);
129
		memmov(bufpointer, _bufpointer, bufsize);
128
		memmov(o_bufpointer, bufpointer, bufsize);
-
 
129
 
-
 
130
		cur_encoding = CH_CP866;
-
 
131
		if (custom_encoding != -1) {
-
 
132
			cur_encoding = custom_encoding;
-
 
133
			bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
130
	} else {
134
			bufsize = strlen(bufpointer);
-
 
135
		}
-
 
136
	}
131
		custom_encoding = CH_CP866;	
137
 
132
	}
138
 
133
	SetPageDefaults();
139
	SetPageDefaults();
134
	is_html = true;
140
	is_html = true;
135
	if (!strstri(bufpointer, "
141
	if (!strstri(bufpointer, "
Line 151... Line 157...
151
				goto _DEFAULT;
157
				goto _DEFAULT;
152
			}
158
			}
153
			break;
159
			break;
154
		case 0x09:
160
		case 0x09:
155
			if (style.pre) {
161
			if (style.pre) {
156
				tab_len = draw_x - left_gap / list.font_w + strlen(#line) % 4;
162
				tab_len = draw_x - left_gap / list.font_w + strlen(#linebuf) % 4;
157
				if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len;
163
				if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len;
158
				while (tab_len) {chrcat(#line,' '); tab_len--;}
164
				while (tab_len) {chrcat(#linebuf,' '); tab_len--;}
159
			} else {
165
			} else {
160
				goto _DEFAULT;
166
				goto _DEFAULT;
161
			}
167
			}
162
			break;
168
			break;
163
		case '&': //  and so on
169
		case '&': //  and so on
164
			bufpos = GetUnicodeSymbol(#line, sizeof(TWebBrowser.line), bufpos+1, bufpointer+bufsize);
170
			bufpos = GetUnicodeSymbol(#linebuf, sizeof(TWebBrowser.linebuf), bufpos+1, bufpointer+bufsize);
165
			break;
171
			break;
166
		case '<':
172
		case '<':
167
			if (!is_html) goto _DEFAULT;
173
			if (!is_html) goto _DEFAULT;
168
			if (!strchr("!/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", ESBYTE[bufpos+1])) goto _DEFAULT;
174
			if (!strchr("!/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", ESBYTE[bufpos+1])) goto _DEFAULT;
169
			bufpos++;
175
			bufpos++;
Line 174... Line 180...
174
				$pop eax
180
				$pop eax
175
				// The thing is that UTF if longer than other encodings.
181
				// The thing is that UTF if longer than other encodings.
176
				// So if encoding was changed from UTF to DOS than $bufpos position got wrong,
182
				// So if encoding was changed from UTF to DOS than $bufpos position got wrong,
177
				// and we have to start parse from the very beginning
183
				// and we have to start parse from the very beginning
178
				if (EAX != cur_encoding) && (cur_encoding == CH_UTF8) {
184
				if (EAX != cur_encoding) && (cur_encoding == CH_UTF8) {
179
					ParseHtml(bufpointer, bufsize);
185
					ParseHtml(bufpointer, strlen(bufpointer));
180
					return;
186
					return;
181
				}
187
				}
182
			}
188
			}
183
			break;
189
			break;
184
		default:
190
		default:
Line 192... Line 198...
192
	canvas.bufh = math.max(list.visible, list.count);
198
	canvas.bufh = math.max(list.visible, list.count);
193
	buf_data = realloc(buf_data, canvas.bufh * canvas.bufw * 4 + 8);
199
	buf_data = realloc(buf_data, canvas.bufh * canvas.bufw * 4 + 8);
Line 194... Line 200...
194
 
200
 
195
	list.CheckDoesValuesOkey();
201
	list.CheckDoesValuesOkey();
196
	anchors.current = NULL;
-
 
197
	custom_encoding = -1;
202
	anchors.current = NULL;
198
	if (!header) {
203
	if (!header) {
199
		strncpy(#header, #version, sizeof(TWebBrowser.header)-1);
204
		strncpy(#header, #version, sizeof(TWebBrowser.header)-1);
200
		DrawTitle(#header);
205
		DrawTitle(#header);
201
	}
206
	}
202
}
207
}
203
//============================================================================================
208
//============================================================================================
204
void TWebBrowser::AddCharToTheLine(unsigned char _char)
209
void TWebBrowser::AddCharToTheLine(unsigned char _char)
205
{
210
{
206
	dword line_len = strlen(#line);
211
	dword line_len = strlen(#linebuf);
207
	if (_char<=15) _char=' ';
212
	if (_char<=15) _char=' ';
208
	if (!style.pre) && (_char == ' ')
213
	if (!style.pre) && (_char == ' ')
209
	{
214
	{
210
		if (line[line_len-1]==' ') return; //no double spaces
215
		if (linebuf[line_len-1]==' ') return; //no double spaces
211
		if (draw_x==left_gap) && (!line) return; //no paces at the beginning of the line
216
		if (draw_x==left_gap) && (!linebuf) return; //no paces at the beginning of the line
212
		if (link) && (line_len==0) return;
217
		if (link) && (line_len==0) return;
213
	}
218
	}
214
	if (line_len < sizeof(TWebBrowser.line)) chrcat(#line+line_len, _char);
219
	if (line_len < sizeof(TWebBrowser.linebuf)) chrcat(#linebuf+line_len, _char);
215
	if (line_len+1 * list.font_w + draw_x >= draw_w) RenderTextbuf();
220
	if (line_len+1 * list.font_w + draw_x >= draw_w) RenderTextbuf();
216
}
221
}
217
//============================================================================================
222
//============================================================================================
218
void TWebBrowser::NewLine()
223
void TWebBrowser::NewLine()