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 102... Line 102...
102
 
102
 
103
void TWebBrowser::tag_iframe()
103
void TWebBrowser::tag_iframe()
104
{
104
{
105
	if (tag.get_value_of("src")) {
105
	if (tag.get_value_of("src")) {
106
		NewLine();
106
		NewLine();
107
		strcpy(#line, "IFRAME: ");
107
		strcpy(#linebuf, "IFRAME: ");
108
		RenderTextbuf();
108
		RenderTextbuf();
109
		link=true;
109
		link=true;
110
		links.add_link(tag.value);
110
		links.add_link(tag.value);
111
		strncpy(#line, tag.value, sizeof(TWebBrowser.line)-1);
111
		strncpy(#linebuf, tag.value, sizeof(TWebBrowser.linebuf)-1);
112
		RenderTextbuf();
112
		RenderTextbuf();
113
		link=false;
113
		link=false;
114
		NewLine();
114
		NewLine();
115
	}
115
	}
Line 135... Line 135...
135
	|| (tag.get_value_of("content")) || (tag.get_value_of("encoding"))
135
	|| (tag.get_value_of("content")) || (tag.get_value_of("encoding"))
136
	{
136
	{
137
		EDX = strrchr(tag.value, '=') + tag.value; //search in content=
137
		EDX = strrchr(tag.value, '=') + tag.value; //search in content=
138
		if (ESBYTE[EDX] == '"') EDX++;
138
		if (ESBYTE[EDX] == '"') EDX++;
139
		strlwr(EDX);
139
		strlwr(EDX);
140
		if      (streqrp(EDX,"utf-8"))        || (streqrp(EDX,"utf8"))        ChangeEncoding(CH_UTF8);
-
 
141
		else if (streqrp(EDX,"windows-1251")) || (streqrp(EDX,"windows1251")) ChangeEncoding(CH_CP1251);
140
		EAX = get_encoding_type_by_name(EDX);
142
		else if (streqrp(EDX,"dos"))          || (streqrp(EDX,"cp-866"))      ChangeEncoding(CH_CP866);
-
 
143
		else if (streqrp(EDX,"iso-8859-5"))   || (streqrp(EDX,"iso8859-5"))   ChangeEncoding(CH_ISO8859_5);
-
 
144
		else if (streqrp(EDX,"koi8-r"))       || (streqrp(EDX,"koi8-u"))      ChangeEncoding(CH_KOI8);
141
		if (EAX!=-1) ChangeEncoding(EAX);
145
	}
142
	}
146
	if (streq(tag.get_value_of("http-equiv"), "refresh")) && (tag.get_value_of("content")) {
143
	if (streq(tag.get_value_of("http-equiv"), "refresh")) && (tag.get_value_of("content")) {
147
		if (tag.value = strstri(tag.value, "url")) strcpy(#redirect, tag.value);
144
		if (tag.value = strstri(tag.value, "url")) strcpy(#redirect, tag.value);
148
	}
145
	}
149
}
146
}
Line -... Line 147...
-
 
147
 
-
 
148
signed int get_encoding_type_by_name(dword name)
-
 
149
{
-
 
150
	EDX = name;
-
 
151
	if      (streqrp(EDX,"utf-8"))        || (streqrp(EDX,"utf8"))        return CH_UTF8;
-
 
152
	else if (streqrp(EDX,"windows-1251")) || (streqrp(EDX,"windows1251")) return CH_CP1251;
-
 
153
	else if (streqrp(EDX,"dos"))          || (streqrp(EDX,"cp-866"))      return CH_CP866;
-
 
154
	else if (streqrp(EDX,"iso-8859-5"))   || (streqrp(EDX,"iso8859-5"))   return CH_ISO8859_5;
-
 
155
	else if (streqrp(EDX,"koi8-r"))       || (streqrp(EDX,"koi8-u"))      return CH_KOI8;
-
 
156
	return -1;
-
 
157
}
150
 
158
 
151
void TWebBrowser::tag_code()
159
void TWebBrowser::tag_code()
152
{
160
{
153
	if (style.pre = tag.opened) {
161
	if (style.pre = tag.opened) {
154
		bg_colors.add(0xe4ffcb);
162
		bg_colors.add(0xe4ffcb);
Line 176... Line 184...
176
{
184
{
177
	if (tag.opened) {
185
	if (tag.opened) {
178
		if (!style.tag_list.level) style.tag_list.upd_level(1, 'u');
186
		if (!style.tag_list.level) style.tag_list.upd_level(1, 'u');
179
		if (!style.pre) NewLine();
187
		if (!style.pre) NewLine();
180
		if (style.tag_list.order_type() == 'u') {
188
		if (style.tag_list.order_type() == 'u') {
181
			strcpy(#line, "\31 ");
189
			strcpy(#linebuf, "\31 ");
182
			draw_x = style.tag_list.level * 5 - 2 * list.font_w + left_gap;
190
			draw_x = style.tag_list.level * 5 - 2 * list.font_w + left_gap;
183
		} 
191
		} 
184
		if (style.tag_list.order_type() == 'o') {
192
		if (style.tag_list.order_type() == 'o') {
185
			sprintf(#line, "%i. ", style.tag_list.inc_counter());
193
			sprintf(#linebuf, "%i. ", style.tag_list.inc_counter());
186
			draw_x = style.tag_list.level * 5 - 1 - strlen(#line) * list.font_w + left_gap;
194
			draw_x = style.tag_list.level * 5 - 1 - strlen(#linebuf) * list.font_w + left_gap;
187
		}
195
		}
188
	}
196
	}
189
}
197
}
Line 190... Line 198...
190
 
198
 
Line 215... Line 223...
215
	}
223
	}
216
}
224
}
Line 217... Line 225...
217
 
225
 
218
void TWebBrowser::tag_q()
226
void TWebBrowser::tag_q()
219
{
227
{
220
	chrncat(#line, '\"', sizeof(TWebBrowser.line));
228
	chrncat(#linebuf, '\"', sizeof(TWebBrowser.linebuf));
Line 221... Line 229...
221
}
229
}
222
 
230
 
223
void TWebBrowser::tag_h1234_caption()
231
void TWebBrowser::tag_h1234_caption()
Line 290... Line 298...
290
IMGOK:
298
IMGOK:
291
	if (RenderImage(EAX)) return;
299
	if (RenderImage(EAX)) return;
Line 292... Line 300...
292
 
300
 
293
NOIMG:
301
NOIMG:
294
	if (tag.get_value_of("title")) || (tag.get_value_of("alt")) {
302
	if (tag.get_value_of("title")) || (tag.get_value_of("alt")) {
295
		strncpy(#img_path, tag.value, sizeof(TWebBrowser.line)-3);
303
		strncpy(#img_path, tag.value, sizeof(TWebBrowser.linebuf)-3);
296
		sprintf(#line, "[%s]", #img_path);
304
		sprintf(#linebuf, "[%s]", #img_path);
297
	} else {
305
	} else {
298
		if (streqrp(#img_path, "data:")) img_path=0;
306
		if (streqrp(#img_path, "data:")) img_path=0;
299
		replace_char(#img_path, '?', NULL, strlen(#img_path));
307
		replace_char(#img_path, '?', NULL, strlen(#img_path));
300
		img_path[sizeof(TWebBrowser.line)-3] = '\0'; //prevent overflow in sprintf
308
		img_path[sizeof(TWebBrowser.linebuf)-3] = '\0'; //prevent overflow in sprintf
301
		sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
309
		sprintf(#linebuf, "[%s]", #img_path+strrchr(#img_path, '/'));
302
		line[50]= NULL;
310
		linebuf[50]= NULL;
303
	}
311
	}
304
	text_colors.add(0x9A6F29);
312
	text_colors.add(0x9A6F29);
305
	style.image = true;
313
	style.image = true;
306
	RenderTextbuf();
314
	RenderTextbuf();
307
	style.image = false;
315
	style.image = false;
308
	text_colors.pop();
316
	text_colors.pop();
Line -... Line 317...
-
 
317
}
-
 
318
 
-
 
319
 
-
 
320
 
-
 
321
 
309
}
322
 
310
 
323
 
311
 
324
struct TABLE {
312
 
325
	int count;
-
 
326
	int col;
-
 
327
	collection_int cx;
-
 
328
	int row_y, next_row_y;
-
 
329
} table;
-
 
330
 
-
 
331
void TWebBrowser::tag_table_reset()
-
 
332
{
-
 
333
	table.count = 0;
Line 313... Line 334...
313
unsigned tr_y;
334
	table.cx.drop();
314
unsigned td_x, td_w;
335
	table.row_y = 0;
315
unsigned highest_td;
336
	table.next_row_y = 0;
316
int table_c=0;
337
}
-
 
338
 
-
 
339
void TWebBrowser::tag_table()
-
 
340
{
-
 
341
	if (tag.opened) {
-
 
342
		if (!table.count) {
-
 
343
			table.next_row_y = table.row_y = draw_y;
-
 
344
		}
-
 
345
		table.count++;
-
 
346
	} else {
-
 
347
		table.count--;
317
 
348
		if (!table.count) {
Line 318... Line 349...
318
void TWebBrowser::tag_table()
349
			draw_y = math.max(draw_y + style.cur_line_h, table.next_row_y);
319
{
350
			left_gap = BODY_MARGIN;
320
	if (tag.opened) table_c++; else table_c--;
-
 
321
	if (!tag.opened) NewLine();
-
 
322
}
-
 
323
 
-
 
324
void TWebBrowser::tag_tr()
-
 
325
{
-
 
326
	if (table_c>1) return;
351
		}
-
 
352
	} 
327
	//style.tr = tag.opened;
353
}
328
	NewLine();
354
 
-
 
355
void TWebBrowser::tag_tr()
-
 
356
{
329
	draw_w = list.w - left_gap;
357
	if (tag.opened) {
-
 
358
		if (table.count>1) {
-
 
359
			NewLine();
330
	left_gap = BODY_MARGIN;
360
		} else {
331
	td_w = 0;
361
			table.col = 0;
Line 332... Line 362...
332
	if (tag.opened) {
362
			table.row_y = math.max(draw_y + style.cur_line_h, table.next_row_y);
333
		tr_y = draw_y;
363
			left_gap = BODY_MARGIN;
334
	} else {
364
			NewLine();	
335
		//draw_y = highest_td;
365
		}		
-
 
366
	}
-
 
367
}
-
 
368
 
-
 
369
void TWebBrowser::tag_td()
-
 
370
{
-
 
371
	if (table.count>1) return;
-
 
372
	if (tag.opened) {
-
 
373
		table.next_row_y = math.max(draw_y + style.cur_line_h, table.next_row_y);
-
 
374
		draw_y = table.row_y;
-
 
375
		table.cx.set(table.col, math.max(draw_x,table.cx.get(table.col)) );
-
 
376
		draw_x = left_gap = table.cx.get(table.col);
-
 
377
		table.col++;
-
 
378
		if (tag.get_value_of("width")) {
-
 
379
			draw_w = EAX;
-
 
380
			//debugval("draw_w", atoi(tag.value));
-
 
381
			table.cx.set(table.col, draw_x + atoi(tag.value));
-
 
382
		}
-
 
383
		//if (tag.get_value_of("height")) table.next_row_y = draw_y + atoi(tag.value);
336
	}
384
	} 
337
}
-
 
338
 
-
 
339
void TWebBrowser::tag_td()
-
 
340
{
-
 
341
	if (table_c>1) return;
-
 
342
	if (tag.opened) {
-
 
343
		NewLine();
-
 
344
		//highest_td = math.max(draw_y, tr_y);
-
 
345
		if (tag.get_value_of("width")) td_w = atoi(tag.value);
-
 
346
		draw_y = tr_y;
-
 
347
		draw_x = left_gap;
-
 
348
		debugval("td_w", td_w);
-
 
349
		if (td_w > 20) draw_w = td_w; else draw_w = list.w - left_gap;
-
 
350
	} else {
-
 
351
		left_gap += td_w;
-
 
352
		draw_w = list.w - left_gap;
385
 
-
 
386
	if (left_gap >= list.w - list.font_w - 10) {
-
 
387
		notify("left_gap overflow");
-
 
388
		draw_x = left_gap = BODY_MARGIN;
-
 
389
		table.cx.drop();
353
		/*
390
		table.count = 999;
354
		draw_w -= left_gap;
391
		NewLine();
355
		if (left_gap < 0) left_gap = BODY_MARGIN;
392
	}
356
		if (draw_w < 0) {
-
 
357
			left_gap = BODY_MARGIN;
-
 
358
			draw_w = list.w - left_gap;
393
 
359
		}
394
	if (draw_w < 0) || (draw_w >= list.w) {