Subversion Repositories Kolibri OS

Rev

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

Rev 8365 Rev 8396
Line 1... Line 1...
1
#include "TWB\colors.h"
1
#include "TWB\colors.h"
2
#include "TWB\anchors.h"
2
#include "TWB\anchors.h"
3
#include "TWB\parse_tag.h"
3
#include "TWB\parse_tag.h"
4
#include "TWB\special.h"
4
#include "TWB\special.h"
5
#include "TWB\img.h"
-
 
6
#include "TWB\tag_list.h"
5
#include "TWB\tag_list.h"
7
dword page_bg;
6
dword page_bg;
8
dword link_color_default;
7
dword link_color_default;
9
dword link_color_active;
8
dword link_color_active;
10
#include "TWB\links.h"
9
#include "TWB\links.h"
Line 29... Line 28...
29
};
28
};
Line 30... Line 29...
30
 
29
 
31
struct TWebBrowser {
30
struct TWebBrowser {
32
	llist list;
31
	llist list;
33
	_style style;
-
 
34
	_img img;
32
	_style style;
35
	dword draw_y, stolbec;
33
	dword draw_y, stolbec;
36
	int zoom;
34
	int zoom;
37
	dword o_bufpointer;
35
	dword o_bufpointer;
38
	int cur_encoding, custom_encoding;
36
	int cur_encoding, custom_encoding;
39
	bool link, t_html, t_body;
37
	bool link, t_html, t_body;
40
	dword bufpointer;
38
	dword bufpointer;
41
	dword bufsize;
39
	dword bufsize;
-
 
40
	dword is_html;
Line 42... Line 41...
42
	dword is_html;
41
	collection img_url;
43
 
42
 
44
	void Paint();
43
	void Paint();
45
	void SetPageDefaults();
44
	void SetPageDefaults();
Line 122... Line 121...
122
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
121
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
123
	link = style.tag_title = style.font = false;
122
	link = style.tag_title = style.font = false;
124
	style.tag_list.reset();
123
	style.tag_list.reset();
125
	link_color_default = 0x0000FF;
124
	link_color_default = 0x0000FF;
126
	link_color_active = 0xFF0000;
125
	link_color_active = 0xFF0000;
127
	page_bg = 0xEBE8E9; //E0E3E3 EBE8E9
126
	page_bg = 0xffEBE8E9; //E0E3E3 EBE8E9
128
	style.bg_color = page_bg;
127
	style.bg_color = page_bg;
129
	DrawBuf.Fill(0, page_bg);
128
	DrawBuf.Fill(0, page_bg);
130
	links.clear();
129
	links.clear();
131
	anchors.clear();
130
	anchors.clear();
132
	img.clear();
131
	img_url.drop();
133
	text_colors.drop();
132
	text_colors.drop();
134
	text_colors.add(0);
133
	text_colors.add(0);
135
	header = NULL;
134
	header = NULL;
136
	cur_encoding = CH_CP866;
135
	cur_encoding = CH_CP866;
137
	draw_y = BODY_MARGIN;
136
	draw_y = BODY_MARGIN;
Line 331... Line 330...
331
	return true;
330
	return true;
332
}
331
}
333
//============================================================================================
332
//============================================================================================
334
void TWebBrowser::SetStyle() {
333
void TWebBrowser::SetStyle() {
335
	char img_path[4096]=0;
334
	char img_path[4096]=0;
-
 
335
	dword imgbuf[44];
-
 
336
	dword cur_img;
-
 
337
	int img_x, img_y, img_w, img_h;
Line 336... Line 338...
336
 
338
 
Line 337... Line 339...
337
	dword value;
339
	dword value;
338
 
340
 
Line 450... Line 452...
450
		if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;
452
		if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;
451
		style.pre = tag.opened; return; 
453
		style.pre = tag.opened; return; 
452
	}
454
	}
453
	if (tag.is("img")) {
455
	if (tag.is("img")) {
454
		value = tag.get_value_of("src=");
456
		value = tag.get_value_of("src=");
455
		if (!value) value = tag.get_value_of("data-src=");
-
 
456
		if (!value) goto NOIMG;
457
		if (!value) goto NOIMG;
Line 457... Line 458...
457
 
458
 
Line -... Line 459...
-
 
459
		if (!strcmp(value + strrchr(value, '.'), "svg")) goto NOIMG;
-
 
460
 
-
 
461
		if (streqrp(value, "data:")) {
-
 
462
			if (!strstr(value, "base64,")) goto NOIMG;
-
 
463
			value = EAX+7;
-
 
464
			if (ESBYTE[value]==' ') value++;
-
 
465
			cur_img = malloc(strlen(value));
-
 
466
			base64_decode stdcall (value, cur_img, strlen(value));
-
 
467
			img_decode stdcall (cur_img, EAX, 0);
-
 
468
			$push eax
-
 
469
			free(cur_img);
-
 
470
			$pop eax
-
 
471
			if (EAX) goto IMGOK; else goto NOIMG;
458
		if (!strcmp(value + strrchr(value, '.'), "svg")) goto NOIMG;
472
		} 
459
 
473
 
Line 460... Line 474...
460
		strlcpy(#img_path, value, sizeof(img_path)-1);
474
		strlcpy(#img_path, value, sizeof(img_path)-1);
-
 
475
		get_absolute_url(#img_path, history.current());
-
 
476
 
-
 
477
		if (check_is_the_adress_local(#img_path)) {
-
 
478
			img_from_file stdcall(#img_path);
461
		get_absolute_url(#img_path, history.current());
479
			if (EAX) goto IMGOK; else goto NOIMG;
462
 
480
		}
463
		//if (check_is_the_adress_local(#img_path)) <== load local files
481
 
464
		if (cache.has(#img_path)) && (cache.current_size)
482
		if (cache.has(#img_path)) && (cache.current_size)
-
 
483
		{
Line 465... Line 484...
465
		{
484
			img_decode stdcall (cache.current_buf, cache.current_size, 0);
466
			img_decode stdcall (cache.current_buf, cache.current_size, 0);
485
			if (!EAX) goto NOIMG;
467
			if (!EAX) goto NOIMG;
486
			IMGOK:
468
 
-
 
469
			EDI = EAX;
-
 
470
			img.w.add(ESDWORD[EDI+4]);
-
 
Line 471... Line 487...
471
			img.h.add(ESDWORD[EDI+8]);
487
 
472
			img_destroy stdcall(EDI);
488
			cur_img = EAX;
473
 
489
			img_h = ESDWORD[cur_img+8];
474
			img.url.add(#img_path);
490
			img_w = ESDWORD[cur_img+4];
475
 
491
 
Line -... Line 492...
-
 
492
			if (img_w / 6 + stolbec > list.column_max) {
-
 
493
				NewLine();
476
			if (img.w.get_last() / 6 + stolbec > list.column_max) {
494
			} 
477
				NewLine();
495
			img_x = stolbec*list.font_w+3;
Line 478... Line 496...
478
			} 
496
			img_y = draw_y;
479
			img.x.add(stolbec*list.font_w+3);
497
 
480
			img.y.add(draw_y);
498
			img_w = math.min(img_w, DrawBuf.bufw - img_x);
481
 
499
 
Line 482... Line 500...
482
			stolbec += img.w.get_last() / 6;
500
			stolbec += img_w / 6;
483
			if (stolbec > list.column_max) NewLine();
-
 
484
 
-
 
485
			if (img.h.get_last() > list.item_h) {
-
 
486
				draw_y += img.h.get_last() - list.item_h; 
-
 
487
				NewLine();
-
 
Line -... Line 501...
-
 
501
			if (stolbec > list.column_max) NewLine();
Line -... Line 502...
-
 
502
 
-
 
503
			if (img_h > list.item_h + 5) {
-
 
504
				draw_y += img_h - list.item_h; 
-
 
505
				NewLine();
-
 
506
			}
-
 
507
 
-
 
508
			if (link) links.add_text(img_x + list.x, img_y + list.y, img_w, img_h, 0);
-
 
509
 
-
 
510
			if (img_y + img_h >= DrawBuf.bufh) DrawBuf.IncreaseBufSize();
-
 
511
 
-
 
512
			if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
-
 
513
				img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
-
 
514
				$push eax
-
 
515
				img_destroy stdcall(cur_img);
488
			}
516
				$pop eax
489
 
517
				cur_img = EAX;
490
			if (link) links.add_text(
518
				if (!EAX) goto NOIMG;
491
				img.x.get_last() + list.x,
519
			}
492
				img.y.get_last() + list.y, 
520
			imgbuf[04] = DrawBuf.bufw;
Line 493... Line -...
493
				img.w.get_last(), 
-
 
494
				img.h.get_last(), 
-
 
495
				0);
-
 
496
 
-
 
497
 
-
 
498
			return;
-
 
499
		} else {
-
 
500
			img.url.add(#img_path);
-
 
501
		}
-
 
502
		NOIMG:
-
 
503
 
521
			imgbuf[08] = DrawBuf.bufh;
504
		/*
522
			imgbuf[20] = IMAGE_BPP32;
505
		if (streqrp(value, "data:")) {
523
			imgbuf[24] = buf_data+8;
506
			EAX = strstr(value, "base64,");
524
			img_blend stdcall(#imgbuf, cur_img, img_x, img_y, 0, 0, img_w, img_h);
507
			if (value == EAX) return;
525
			img_destroy stdcall(cur_img);
Line 673... Line 691...
673
	if (debug_mode) debugln(NULL);
691
	if (debug_mode) debugln(NULL);
674
}
692
}
675
//============================================================================================
693
//============================================================================================
676
void TWebBrowser::DrawPage()
694
void TWebBrowser::DrawPage()
677
{
695
{
678
	int i, img_y;
696
	DrawBuf.Show(list.first, list.h);
679
	PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);
-
 
680
	DrawScroller();
697
	DrawScroller();
681
	//img.draw_all(list.x, list.y, list.w, list.h, list.first);
-
 
682
 
-
 
683
	for (i=0; i
-
 
684
	{
-
 
685
		img_y = img.y.get(i);
-
 
686
 
-
 
687
		if (img_y + img.h.get(i) > list.first) && (img_y - list.h < list.first) 
-
 
688
		&& (cache.has(img.url.get(i))) img.draw(list.x, list.y, list.w, list.h, list.first, i);
-
 
689
	}
-
 
690
}
698
}
691
>
699
>