2020-12-18 00:01:09 +01:00
|
|
|
void TWebBrowser::SetStyle()
|
|
|
|
{
|
2020-12-18 13:55:55 +01:00
|
|
|
if (tag.get_value_of("name")) || (tag.get_value_of("id")) {
|
2020-12-18 00:01:09 +01:00
|
|
|
anchors.add(tag.value, draw_y);
|
|
|
|
if (anchors.current) && (streq(tag.value, #anchors.current+1)) {
|
|
|
|
list.first = draw_y;
|
|
|
|
anchors.current = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tag.is("a")) { tag_a(); return; }
|
|
|
|
if (tag.is("p")) { tag_p(); return; }
|
|
|
|
if (tag.is("img")) { tag_img(); return; }
|
|
|
|
if (tag.is("div")) { tag_div(); return; }
|
2021-01-02 13:45:42 +01:00
|
|
|
if (tag.is("br")) { /*draw_x++;*/NewLine(); return; }
|
2021-11-22 19:30:51 +01:00
|
|
|
if (tag.is("nav")) { style.nav = tag.opened; return; }
|
2020-12-18 00:01:09 +01:00
|
|
|
if (tag.is("header")) { NewLine(); return; }
|
|
|
|
if (tag.is("article")) { NewLine(); return; }
|
|
|
|
if (tag.is("footer")) { NewLine(); return; }
|
|
|
|
if (tag.is("figure")) { NewLine(); return; }
|
|
|
|
if (tag.is("w:p")) { NewLine(); return; }
|
2020-12-21 02:59:34 +01:00
|
|
|
if (tag.is("b")) { style.b = tag.opened; return; }
|
|
|
|
if (tag.is("strong")) { style.b = tag.opened; return; }
|
|
|
|
if (tag.is("big")) { style.b = tag.opened; return; }
|
|
|
|
if (tag.is("w:b")) { style.b = tag.opened; return; }
|
|
|
|
if (tag.is("u")) { style.u = tag.opened; return; }
|
|
|
|
if (tag.is("ins")) { style.u = tag.opened; return; }
|
|
|
|
if (tag.is("s")) { style.s = tag.opened; return; }
|
|
|
|
if (tag.is("strike")) { style.s = tag.opened; return; }
|
|
|
|
if (tag.is("del")) { style.s = tag.opened; return; }
|
|
|
|
if (tag.is("pre")) { style.pre = tag.opened; return; }
|
|
|
|
if (tag.is("blockquote")) { style.blq = tag.opened; return; }
|
|
|
|
if (tag.is("button")) { style.button = tag.opened; return; }
|
2020-12-18 00:01:09 +01:00
|
|
|
if (tag.is("dl")) { if (tag.opened) NewLine(); return; }
|
|
|
|
if (tag.is("w:r")) { if (!tag.opened) style.b = false; return; }
|
|
|
|
if (tag.is("h1")) { tag_h1234_caption(); return; }
|
|
|
|
if (tag.is("h2")) { tag_h1234_caption(); return; }
|
|
|
|
if (tag.is("h3")) { tag_h1234_caption(); return; }
|
|
|
|
if (tag.is("h4")) { tag_h1234_caption(); return; }
|
|
|
|
if (tag.is("font")) { tag_font(); return; }
|
|
|
|
if (tag.is("dt")) { tag_ol_ul_dt(); return; }
|
2021-11-13 18:21:44 +01:00
|
|
|
if (tag.is("dd")) { tag_ol_ul_dt(); return; }
|
2020-12-18 00:01:09 +01:00
|
|
|
if (tag.is("ul")) { tag_ol_ul_dt(); return; }
|
|
|
|
if (tag.is("ol")) { tag_ol_ul_dt(); return; }
|
|
|
|
if (tag.is("li")) { tag_li(); return; }
|
|
|
|
if (tag.is("q")) { tag_q(); return; }
|
|
|
|
if (tag.is("hr")) { tag_hr(); return; }
|
|
|
|
if (tag.is("meta")) { tag_meta_xml(); return; }
|
|
|
|
if (tag.is("?xml")) { tag_meta_xml(); return; }
|
|
|
|
if (tag.is("code")) { tag_code(); return; }
|
|
|
|
if (tag.is("iframe")) { tag_iframe(); return; }
|
|
|
|
if (tag.is("caption")) { tag_h1234_caption(); return; }
|
|
|
|
if (tag.is("title")) { tag_title(); return; }
|
|
|
|
if (tag.is("body")) { tag_body(); return; }
|
|
|
|
if (tag.is("html")) { t_html = tag.opened; return; }
|
2021-11-21 12:42:21 +01:00
|
|
|
if (tag.is("table")) { tag_table(); return; }
|
|
|
|
if (tag.is("tr")) { tag_table(); return; }
|
|
|
|
if (tag.is("th")) { tag_table(); return; }
|
|
|
|
if (tag.is("td")) { tag_table(); return; }
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_p()
|
|
|
|
{
|
|
|
|
IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return;
|
|
|
|
NewLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_title()
|
|
|
|
{
|
|
|
|
style.title = tag.opened;
|
|
|
|
if (!tag.opened) DrawTitle(#header);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_font()
|
|
|
|
{
|
|
|
|
style.font = tag.opened;
|
|
|
|
if (tag.opened)
|
|
|
|
{
|
2020-12-19 01:50:55 +01:00
|
|
|
if (tag.get_value_of("bg")) {
|
|
|
|
bg_colors.add(GetColor(tag.value));
|
|
|
|
} else {
|
|
|
|
bg_colors.add(bg_colors.get_last());
|
|
|
|
}
|
2020-12-18 13:55:55 +01:00
|
|
|
if (tag.get_value_of("color")) {
|
2020-12-18 00:01:09 +01:00
|
|
|
text_colors.add(GetColor(tag.value));
|
|
|
|
} else {
|
|
|
|
text_colors.add(text_colors.get_last());
|
|
|
|
}
|
|
|
|
}
|
2020-12-19 01:50:55 +01:00
|
|
|
else {
|
2021-11-28 00:03:47 +01:00
|
|
|
if (bg_colors.count>1) text_colors.pop();
|
2020-12-31 03:03:58 +01:00
|
|
|
if (bg_colors.count>1) bg_colors.pop(); //never pop the last color
|
2020-12-19 01:50:55 +01:00
|
|
|
}
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_div()
|
|
|
|
{
|
2020-12-31 03:03:58 +01:00
|
|
|
//if (streq(#tag.prior,"div")) && (tag.opened) return;
|
2020-12-28 20:20:59 +01:00
|
|
|
if (streq(#tag.prior,"td")) return;
|
2020-12-31 03:03:58 +01:00
|
|
|
if (streq(#tag.prior,"div")) return;
|
2020-12-18 00:01:09 +01:00
|
|
|
if (!tag.opened) && (style.font) text_colors.pop();
|
|
|
|
NewLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_iframe()
|
|
|
|
{
|
2020-12-18 13:55:55 +01:00
|
|
|
if (tag.get_value_of("src")) {
|
2020-12-18 00:01:09 +01:00
|
|
|
NewLine();
|
2020-12-29 11:31:45 +01:00
|
|
|
strcpy(#linebuf, "IFRAME: ");
|
2020-12-28 22:43:46 +01:00
|
|
|
RenderTextbuf();
|
2020-12-18 00:01:09 +01:00
|
|
|
link=true;
|
|
|
|
links.add_link(tag.value);
|
2020-12-29 11:31:45 +01:00
|
|
|
strncpy(#linebuf, tag.value, sizeof(TWebBrowser.linebuf)-1);
|
2020-12-28 22:43:46 +01:00
|
|
|
RenderTextbuf();
|
2020-12-18 00:01:09 +01:00
|
|
|
link=false;
|
|
|
|
NewLine();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_a()
|
|
|
|
{
|
|
|
|
if (tag.opened)
|
|
|
|
{
|
2020-12-18 13:55:55 +01:00
|
|
|
if (tag.get_value_of("href")) && (!strstr(tag.value,"javascript:"))
|
2020-12-18 00:01:09 +01:00
|
|
|
{
|
|
|
|
link = true;
|
|
|
|
links.add_link(tag.value);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
link = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_meta_xml()
|
|
|
|
{
|
2020-12-18 13:55:55 +01:00
|
|
|
if (custom_encoding == -1) if (tag.get_value_of("charset"))
|
|
|
|
|| (tag.get_value_of("content")) || (tag.get_value_of("encoding"))
|
2020-12-18 00:01:09 +01:00
|
|
|
{
|
|
|
|
EDX = strrchr(tag.value, '=') + tag.value; //search in content=
|
|
|
|
if (ESBYTE[EDX] == '"') EDX++;
|
|
|
|
strlwr(EDX);
|
2020-12-29 11:31:45 +01:00
|
|
|
EAX = get_encoding_type_by_name(EDX);
|
|
|
|
if (EAX!=-1) ChangeEncoding(EAX);
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
2020-12-18 13:55:55 +01:00
|
|
|
if (streq(tag.get_value_of("http-equiv"), "refresh")) && (tag.get_value_of("content")) {
|
|
|
|
if (tag.value = strstri(tag.value, "url")) strcpy(#redirect, tag.value);
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-29 11:31:45 +01:00
|
|
|
signed int get_encoding_type_by_name(dword name)
|
|
|
|
{
|
|
|
|
EDX = name;
|
|
|
|
if (streqrp(EDX,"utf-8")) || (streqrp(EDX,"utf8")) return CH_UTF8;
|
|
|
|
else if (streqrp(EDX,"windows-1251")) || (streqrp(EDX,"windows1251")) return CH_CP1251;
|
|
|
|
else if (streqrp(EDX,"dos")) || (streqrp(EDX,"cp-866")) return CH_CP866;
|
|
|
|
else if (streqrp(EDX,"iso-8859-5")) || (streqrp(EDX,"iso8859-5")) return CH_ISO8859_5;
|
|
|
|
else if (streqrp(EDX,"koi8-r")) || (streqrp(EDX,"koi8-u")) return CH_KOI8;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-12-18 00:01:09 +01:00
|
|
|
void TWebBrowser::tag_code()
|
|
|
|
{
|
|
|
|
if (style.pre = tag.opened) {
|
2020-12-19 01:50:55 +01:00
|
|
|
bg_colors.add(0xe4ffcb);
|
2020-12-18 00:01:09 +01:00
|
|
|
} else {
|
2020-12-31 03:03:58 +01:00
|
|
|
if (bg_colors.count>1) bg_colors.pop(); //never pop the last color
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_ol_ul_dt()
|
|
|
|
{
|
|
|
|
char type = ESBYTE[#tag.name];
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case 'd':
|
2021-11-13 18:21:44 +01:00
|
|
|
if (ESBYTE[#tag.name+1]=='d') style.tag_list.upd_level(tag.opened, type);
|
|
|
|
if (ESBYTE[#tag.name+1]=='t') style.tag_list.upd_level(false, 'd');
|
2020-12-18 00:01:09 +01:00
|
|
|
if (tag.opened) NewLine();
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
case 'o':
|
2021-11-22 19:30:51 +01:00
|
|
|
if (style.nav) && (style.tag_list.level) NewLine();
|
2021-11-13 18:21:44 +01:00
|
|
|
style.tag_list.upd_level(tag.opened, type);
|
2020-12-18 00:01:09 +01:00
|
|
|
if (!tag.opened) && (!style.pre) NewLine();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_li()
|
|
|
|
{
|
2021-11-22 19:30:51 +01:00
|
|
|
if (style.nav) return;
|
2020-12-18 00:01:09 +01:00
|
|
|
if (tag.opened) {
|
|
|
|
if (!style.tag_list.level) style.tag_list.upd_level(1, 'u');
|
|
|
|
if (!style.pre) NewLine();
|
|
|
|
if (style.tag_list.order_type() == 'u') {
|
2020-12-29 11:31:45 +01:00
|
|
|
strcpy(#linebuf, "\31 ");
|
2020-12-21 02:59:34 +01:00
|
|
|
draw_x = style.tag_list.level * 5 - 2 * list.font_w + left_gap;
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
if (style.tag_list.order_type() == 'o') {
|
2020-12-29 11:31:45 +01:00
|
|
|
sprintf(#linebuf, "%i. ", style.tag_list.inc_counter());
|
|
|
|
draw_x = style.tag_list.level * 5 - 1 - strlen(#linebuf) * list.font_w + left_gap;
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_hr()
|
|
|
|
{
|
2021-08-02 16:08:12 +02:00
|
|
|
dword hrcol = 0x00777777;
|
2020-12-28 22:43:46 +01:00
|
|
|
if (tag.get_value_of("color")) hrcol = GetColor(tag.value);
|
|
|
|
if (draw_x != left_gap) NewLine();
|
2021-11-21 04:19:08 +01:00
|
|
|
if (secondrun) canvas.DrawBar(5+left_gap, style.cur_line_h / 2 + draw_y - 1, draw_w-10, 1, hrcol);
|
2021-01-02 13:45:42 +01:00
|
|
|
draw_x++;
|
2020-12-18 00:01:09 +01:00
|
|
|
NewLine();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_body()
|
|
|
|
{
|
|
|
|
t_body = tag.opened;
|
2020-12-18 13:55:55 +01:00
|
|
|
if (tag.get_value_of("link")) link_color_default = GetColor(tag.value);
|
|
|
|
if (tag.get_value_of("alink")) link_color_active = GetColor(tag.value);
|
|
|
|
if (tag.get_value_of("text")) text_colors.set(0, GetColor(tag.value));
|
|
|
|
if (tag.get_value_of("bgcolor")) {
|
2020-12-19 01:50:55 +01:00
|
|
|
bg_colors.set(0, GetColor(tag.value));
|
|
|
|
canvas.Fill(0, bg_colors.get(0));
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
// Autodetecting encoding if no encoding was set
|
|
|
|
if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) {
|
|
|
|
if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8);
|
|
|
|
else if (chrnum(bufpointer, '\246')>5) ChangeEncoding(CH_CP1251);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_q()
|
|
|
|
{
|
2020-12-29 11:31:45 +01:00
|
|
|
chrncat(#linebuf, '\"', sizeof(TWebBrowser.linebuf));
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::tag_h1234_caption()
|
|
|
|
{
|
|
|
|
if (ESBYTE[#tag.name+1]=='4') {
|
|
|
|
NewLine();
|
|
|
|
NewLine();
|
|
|
|
style.h = tag.opened;
|
|
|
|
style.b = tag.opened;
|
|
|
|
} else {
|
|
|
|
style.h = tag.opened;
|
|
|
|
if (tag.opened) {
|
|
|
|
if (!style.pre) NewLine();
|
|
|
|
draw_y += 10;
|
2020-12-20 14:28:50 +01:00
|
|
|
list.SetFont(BASIC_CHAR_W*2, 14*2, 10011001b);
|
2020-12-18 00:01:09 +01:00
|
|
|
list.item_h = BASIC_LINE_H * 2 - 2;
|
|
|
|
if (tag.is("h1")) style.b = true;
|
|
|
|
} else {
|
|
|
|
if (tag.is("h1")) style.b = false;
|
|
|
|
NewLine();
|
2020-12-20 14:28:50 +01:00
|
|
|
list.SetFont(BASIC_CHAR_W, 14, 10011000b);
|
2020-12-19 01:50:55 +01:00
|
|
|
style.cur_line_h = list.item_h = BASIC_LINE_H;
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TWebBrowser::tag_img()
|
|
|
|
{
|
|
|
|
char img_path[4096]=0;
|
2020-12-21 02:59:34 +01:00
|
|
|
dword base64img;
|
2020-12-18 00:01:09 +01:00
|
|
|
|
2020-12-19 23:43:46 +01:00
|
|
|
if (!tag.get_value_of("data-large-image"))
|
|
|
|
if (!tag.get_value_of("data-src"))
|
|
|
|
if (!tag.get_value_of("src")) return;
|
2020-12-18 00:01:09 +01:00
|
|
|
|
|
|
|
if (streqrp(tag.value, "data:")) {
|
|
|
|
if (!strstr(tag.value, "base64,")) goto NOIMG;
|
|
|
|
EDX = EAX+7;
|
|
|
|
if (ESBYTE[EDX]==' ') EDX++;
|
2020-12-21 02:59:34 +01:00
|
|
|
base64img = malloc(strlen(EDX));
|
|
|
|
base64_decode stdcall (EDX, base64img, strlen(EDX));
|
|
|
|
img_decode stdcall (base64img, EAX, 0);
|
2020-12-18 00:01:09 +01:00
|
|
|
$push eax
|
2020-12-21 02:59:34 +01:00
|
|
|
free(base64img);
|
2020-12-18 00:01:09 +01:00
|
|
|
$pop eax
|
|
|
|
if (EAX) goto IMGOK; else goto NOIMG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(tag.value + strrchr(tag.value, '.'), "svg")) goto NOIMG;
|
2020-12-19 23:43:46 +01:00
|
|
|
if (!strcmp(tag.value + strrchr(tag.value, '.'), "webp")) goto NOIMG;
|
|
|
|
|
2020-12-18 00:01:09 +01:00
|
|
|
strlcpy(#img_path, tag.value, sizeof(img_path)-1);
|
2020-12-28 20:20:59 +01:00
|
|
|
replace_char(#img_path, ' ', '\0', sizeof(img_path));
|
2020-12-18 00:01:09 +01:00
|
|
|
get_absolute_url(#img_path, history.current());
|
|
|
|
|
|
|
|
if (check_is_the_adress_local(#img_path)) {
|
|
|
|
img_from_file stdcall(#img_path);
|
|
|
|
if (EAX) goto IMGOK; else goto NOIMG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cache.has(#img_path)) {
|
|
|
|
img_decode stdcall (cache.current_buf, cache.current_size, 0);
|
|
|
|
if (EAX) goto IMGOK; else goto NOIMG;
|
|
|
|
} else {
|
|
|
|
img_url.add(#img_path);
|
|
|
|
goto NOIMG;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMGOK:
|
2020-12-21 02:59:34 +01:00
|
|
|
if (RenderImage(EAX)) return;
|
2020-12-18 00:01:09 +01:00
|
|
|
|
|
|
|
NOIMG:
|
2020-12-18 13:55:55 +01:00
|
|
|
if (tag.get_value_of("title")) || (tag.get_value_of("alt")) {
|
2020-12-29 11:31:45 +01:00
|
|
|
strncpy(#img_path, tag.value, sizeof(TWebBrowser.linebuf)-3);
|
|
|
|
sprintf(#linebuf, "[%s]", #img_path);
|
2020-12-18 00:01:09 +01:00
|
|
|
} else {
|
|
|
|
if (streqrp(#img_path, "data:")) img_path=0;
|
|
|
|
replace_char(#img_path, '?', NULL, strlen(#img_path));
|
2020-12-29 11:31:45 +01:00
|
|
|
img_path[sizeof(TWebBrowser.linebuf)-3] = '\0'; //prevent overflow in sprintf
|
|
|
|
sprintf(#linebuf, "[%s]", #img_path+strrchr(#img_path, '/'));
|
|
|
|
linebuf[50]= NULL;
|
2020-12-18 00:01:09 +01:00
|
|
|
}
|
|
|
|
text_colors.add(0x9A6F29);
|
|
|
|
style.image = true;
|
2020-12-28 22:43:46 +01:00
|
|
|
RenderTextbuf();
|
2020-12-18 00:01:09 +01:00
|
|
|
style.image = false;
|
|
|
|
text_colors.pop();
|
2020-12-21 02:59:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-12-29 11:31:45 +01:00
|
|
|
|
|
|
|
|
2021-11-13 18:21:44 +01:00
|
|
|
struct TABLE {
|
2021-11-21 12:42:21 +01:00
|
|
|
int count;
|
2021-11-13 18:21:44 +01:00
|
|
|
int depth;
|
2021-11-25 02:11:11 +01:00
|
|
|
int margin;
|
2021-11-13 18:21:44 +01:00
|
|
|
collection_int cols;
|
2021-11-25 02:11:11 +01:00
|
|
|
collection_int width;
|
2021-11-13 18:21:44 +01:00
|
|
|
} table;
|
2021-08-02 16:08:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
int tr_pos, td_pos;
|
|
|
|
int row_start_y;
|
|
|
|
int colcount;
|
|
|
|
dword tallest_cell_in_row;
|
2020-12-29 11:31:45 +01:00
|
|
|
|
|
|
|
void TWebBrowser::tag_table_reset()
|
|
|
|
{
|
2021-11-13 18:21:44 +01:00
|
|
|
table.depth = 0;
|
2021-11-21 12:42:21 +01:00
|
|
|
table.count = 0;
|
2021-08-02 16:08:12 +02:00
|
|
|
colcount = 0;
|
|
|
|
tr_pos = 0;
|
|
|
|
td_pos = 0;
|
2020-12-29 11:31:45 +01:00
|
|
|
}
|
2020-12-21 02:59:34 +01:00
|
|
|
|
|
|
|
void TWebBrowser::tag_table()
|
|
|
|
{
|
2021-11-21 04:19:08 +01:00
|
|
|
if (!tag.opened) {
|
|
|
|
if (style.font) tag_font();
|
|
|
|
if (link) tag_a();
|
|
|
|
style.b = false;
|
|
|
|
}
|
2021-08-02 16:08:12 +02:00
|
|
|
if (tag.is("table")) {
|
|
|
|
if(tag.opened) {
|
2021-11-13 18:21:44 +01:00
|
|
|
table.depth++;
|
|
|
|
if (table.depth==1) {
|
2021-11-21 12:42:21 +01:00
|
|
|
table.count++;
|
2021-11-13 18:21:44 +01:00
|
|
|
colcount = 0;
|
2021-11-26 00:53:46 +01:00
|
|
|
td_pos = 0;
|
|
|
|
row_start_y = draw_y;
|
2021-11-25 02:11:11 +01:00
|
|
|
if (tag.get_number_of("width")) {
|
|
|
|
if (strchr(tag.value, '%')) tag.number = list.w * tag.number / 100;
|
|
|
|
table.width.set(table.count, math.min(tag.number,list.w));
|
|
|
|
} else {
|
|
|
|
table.width.set(table.count, list.w);
|
|
|
|
}
|
2021-11-13 18:21:44 +01:00
|
|
|
}
|
2020-12-29 11:31:45 +01:00
|
|
|
} else {
|
2021-11-13 18:21:44 +01:00
|
|
|
if (table.depth>0) {
|
|
|
|
table.depth--;
|
|
|
|
}
|
|
|
|
if (table.depth==0) {
|
2021-08-02 16:08:12 +02:00
|
|
|
draw_x = left_gap = style.tag_list.level * 5 * list.font_w + BODY_MARGIN;
|
|
|
|
draw_w = list.w;
|
2021-11-26 00:53:46 +01:00
|
|
|
if (td_pos) draw_y = math.max(draw_y, tallest_cell_in_row);
|
2021-08-02 16:08:12 +02:00
|
|
|
draw_y = math.max(draw_y+style.cur_line_h, tallest_cell_in_row);
|
2021-11-26 00:53:46 +01:00
|
|
|
row_start_y = tallest_cell_in_row = draw_y;
|
2021-08-02 16:08:12 +02:00
|
|
|
style.cur_line_h = list.item_h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-13 18:21:44 +01:00
|
|
|
if (table.depth>1) {
|
2021-08-02 16:08:12 +02:00
|
|
|
if (tag.is("tr")) && (tag.opened) NewLine();
|
|
|
|
return;
|
2020-12-21 02:59:34 +01:00
|
|
|
}
|
2021-01-02 13:45:42 +01:00
|
|
|
|
2021-08-02 16:08:12 +02:00
|
|
|
if (!secondrun) {
|
|
|
|
if (tag.is("tr")) {
|
|
|
|
if (tag.opened) {
|
2021-11-13 18:21:44 +01:00
|
|
|
table.cols.add(1);
|
2021-01-02 13:45:42 +01:00
|
|
|
}
|
2021-08-02 19:57:41 +02:00
|
|
|
colcount = 0;
|
2020-12-29 11:31:45 +01:00
|
|
|
}
|
2021-11-21 12:42:21 +01:00
|
|
|
if (tag.opened) if (tag.is("td")) || (tag.is("th")) {
|
|
|
|
if (!table.cols.count) { table.cols.add(1); colcount = 0;}
|
2021-08-02 16:08:12 +02:00
|
|
|
colcount++;
|
2021-11-13 18:21:44 +01:00
|
|
|
if (colcount) table.cols.set(table.cols.count-1, colcount);
|
2021-08-02 16:08:12 +02:00
|
|
|
//if (tag.get_number_of("colspan")) colcount += tag.number-1;
|
2021-11-21 12:42:21 +01:00
|
|
|
}
|
2021-08-02 16:08:12 +02:00
|
|
|
} else {
|
|
|
|
if (tag.is("tr")) {
|
|
|
|
if (tag.opened) {
|
2021-11-26 00:53:46 +01:00
|
|
|
if (td_pos) draw_y = math.max(draw_y, tallest_cell_in_row);
|
2021-11-21 12:42:21 +01:00
|
|
|
_TR_FIX:
|
2021-08-02 16:08:12 +02:00
|
|
|
if (draw_x==left_gap) && (draw_y==BODY_MARGIN) {
|
|
|
|
row_start_y = tallest_cell_in_row = draw_y;
|
|
|
|
} else {
|
|
|
|
row_start_y = tallest_cell_in_row = draw_y = draw_y + style.cur_line_h;
|
|
|
|
}
|
|
|
|
style.cur_line_h = list.item_h;
|
|
|
|
tr_pos++;
|
|
|
|
td_pos = 0;
|
|
|
|
} else {
|
2021-08-02 19:57:41 +02:00
|
|
|
draw_y = math.max(draw_y, tallest_cell_in_row);
|
2021-11-26 00:53:46 +01:00
|
|
|
td_pos = 0;
|
2021-08-02 16:08:12 +02:00
|
|
|
}
|
2021-08-02 19:57:41 +02:00
|
|
|
draw_x = left_gap = style.tag_list.level * 5 * list.font_w + BODY_MARGIN;
|
|
|
|
draw_w = list.w;
|
2021-01-02 13:45:42 +01:00
|
|
|
}
|
2021-11-21 12:42:21 +01:00
|
|
|
if (tag.is("td")) || (tag.is("th")) {
|
|
|
|
|
|
|
|
if (!tr_pos) goto _TR_FIX;
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (tag.opened) {
|
|
|
|
if (tag.get_value_of("bgcolor")) {
|
|
|
|
bg_colors.add(GetColor(tag.value));
|
|
|
|
} else {
|
|
|
|
bg_colors.add(bg_colors.get(0));
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
|
2021-08-02 16:08:12 +02:00
|
|
|
tallest_cell_in_row = math.max(draw_y+style.cur_line_h-list.item_h, tallest_cell_in_row);
|
|
|
|
style.cur_line_h = list.item_h;
|
|
|
|
if (tag.opened) {
|
2021-11-21 12:42:21 +01:00
|
|
|
|
|
|
|
if (!td_pos) {
|
2021-11-25 02:11:11 +01:00
|
|
|
table.margin = list.w - table.width.get(table.count) / 2 + BODY_MARGIN;
|
|
|
|
draw_x = left_gap = table.margin;
|
|
|
|
draw_w = table.width.get(table.count) - BODY_MARGIN;
|
2021-11-21 12:42:21 +01:00
|
|
|
} else {
|
|
|
|
draw_x = left_gap = left_gap + draw_w;
|
2021-11-26 00:53:46 +01:00
|
|
|
draw_w = table.width.get(table.count) - left_gap + table.margin - BODY_MARGIN;
|
2021-11-21 12:42:21 +01:00
|
|
|
}
|
|
|
|
|
2021-11-26 00:53:46 +01:00
|
|
|
if (EAX = table.cols.get(tr_pos-1)-td_pos) {
|
|
|
|
draw_w /= EAX;
|
|
|
|
} else {
|
2021-11-21 12:42:21 +01:00
|
|
|
draw_y = row_start_y;
|
2021-11-25 02:11:11 +01:00
|
|
|
draw_x = left_gap = table.margin;
|
2021-11-21 12:42:21 +01:00
|
|
|
}
|
|
|
|
if (table.cols.get(tr_pos-1)-td_pos>1) && (tag.get_number_of("width")) {
|
|
|
|
if (strchr(tag.value, '%')) {
|
2021-11-25 02:11:11 +01:00
|
|
|
tag.number = table.width.get(table.count) - table.margin - 23 - left_gap * tag.number / 100;
|
2021-11-21 12:42:21 +01:00
|
|
|
}
|
|
|
|
if (tag.number < draw_w) draw_w = tag.number;
|
|
|
|
}
|
2021-08-02 16:08:12 +02:00
|
|
|
draw_y = row_start_y;
|
|
|
|
//canvas.WriteText(draw_x, draw_y, 10001001b, 0x0000FE, itoa(draw_x), NULL);
|
2021-11-26 00:53:46 +01:00
|
|
|
//canvas.WriteText(draw_x, draw_y+20, 10001001b, 0xFF0000, itoa(draw_w), NULL);
|
|
|
|
td_pos++;
|
2021-08-02 16:08:12 +02:00
|
|
|
}
|
2021-01-02 13:45:42 +01:00
|
|
|
}
|
2021-08-02 16:08:12 +02:00
|
|
|
}
|
2021-11-25 02:11:11 +01:00
|
|
|
if (draw_x > table.width.get(table.count)) {
|
|
|
|
draw_x = left_gap = table.margin;
|
|
|
|
draw_w = table.width.get(table.count) - table.margin - 23 - left_gap;
|
2021-11-21 12:42:21 +01:00
|
|
|
table.depth = 0;
|
|
|
|
NewLine();
|
|
|
|
if (debug_mode) {
|
|
|
|
debugln("anomaly draw_x");
|
|
|
|
canvas.DrawBar(0, draw_y, 20, 20, 0xFF0000);
|
|
|
|
}
|
|
|
|
}
|
2021-11-26 00:53:46 +01:00
|
|
|
/*
|
|
|
|
if (left_gap + draw_w > list.w) {
|
|
|
|
draw_w = list.w - left_gap;
|
|
|
|
if (debug_mode) debugln("anomaly draw_W");
|
|
|
|
}
|
|
|
|
*/
|
2020-12-29 11:31:45 +01:00
|
|
|
}
|
2021-08-02 16:08:12 +02:00
|
|
|
|