WebView 3.82: fix text rendering, speedup #130

Merged
mxlgv merged 1 commits from webview-3.82 into main 2025-03-10 20:28:53 +01:00
7 changed files with 82 additions and 95 deletions

View File

@@ -101,16 +101,16 @@ void TWebBrowser::SetPageDefaults()
img_url.drop(); img_url.drop();
text_colors.drop(); text_colors.drop();
text_colors.add(0); text_colors.add(0);
if (!secondrun) { if (secondrun) {
bg_colors.drop(); canvas.Init(list.x, list.y, list.w, math.max(list.visible, list.count));
bg_colors.add(DEFAULT_BG_COL);
} else {
canvas.Fill(0, bg_colors.get(0)); canvas.Fill(0, bg_colors.get(0));
} }
bg_colors.drop();
bg_colors.add(DEFAULT_BG_COL);
header = NULL; header = NULL;
draw_y = BODY_MARGIN; draw_y = BODY_MARGIN;
draw_x = left_gap = BODY_MARGIN; draw_x = left_gap = BODY_MARGIN;
draw_w = list.w - BODY_MARGIN; draw_w = list.w - BODY_MARGIN - BODY_MARGIN;
linebuf = 0; linebuf = 0;
redirect = '\0'; redirect = '\0';
list.SetFont(8, 14, 10011000b); list.SetFont(8, 14, 10011000b);
@@ -136,8 +136,6 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
dword bufpos; dword bufpos;
bufsize = _bufsize; bufsize = _bufsize;
if (list.w!=canvas.bufw) canvas.Init(list.x, list.y, list.w, 400*20);
if (bufpointer == _bufpointer) { if (bufpointer == _bufpointer) {
custom_encoding = cur_encoding; custom_encoding = cur_encoding;
} else { } else {
@@ -156,7 +154,6 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
} }
} }
table.cols.drop(); table.cols.drop();
secondrun = false; secondrun = false;
@@ -219,19 +216,15 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
AddCharToTheLine(ESBYTE[bufpos]); AddCharToTheLine(ESBYTE[bufpos]);
} }
RenderTextbuf();
list.count = draw_y + style.cur_line_h;
list.CheckDoesValuesOkey();
anchors.current = NULL;
if (!secondrun) { if (!secondrun) {
secondrun = true; secondrun = true;
goto _PARSE_START_; goto _PARSE_START_;
} }
RenderTextbuf();
list.count = draw_y + style.cur_line_h;
canvas.bufh = math.max(list.visible, list.count);
buf_data = realloc(buf_data, canvas.bufh * canvas.bufw * 4 + 8);
list.CheckDoesValuesOkey();
anchors.current = NULL;
if (!header) { if (!header) {
strncpy(#header, #version, sizeof(TWebBrowser.header)-1); strncpy(#header, #version, sizeof(TWebBrowser.header)-1);
DrawTitle(#header); DrawTitle(#header);

View File

@@ -22,9 +22,8 @@ void TWebBrowser::RenderLine(dword _line)
zoom = list.font_w / BASIC_CHAR_W; zoom = list.font_w / BASIC_CHAR_W;
//there is some shit happens!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //there is some shit happens!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (pw > draw_w) { if (pw > draw_w + BODY_MARGIN) {
//draw_w = pw; //debugln("shit");
NewLine();
} }
if (debug_mode) { if (debug_mode) {
@@ -83,12 +82,13 @@ void TWebBrowser::RenderTextbuf()
//debugln(" \\n"); //debugln(" \\n");
//Is a new line fits in the current line? //Is a new line fits in the maximum line width?
if (br * list.font_w + draw_x - left_gap >= draw_w) { if (br * list.font_w + draw_x - left_gap >= draw_w) {
br = draw_w - draw_x + left_gap /list.font_w; br = draw_w - draw_x + left_gap /list.font_w;
if (br < 0) br = 0;
while(br) { while(br) {
if (ESBYTE[lbp + br]==' ') { if (ESBYTE[lbp + br]==' ') {
br++; if (br < len) br++;
break; break;
} }
br--; br--;
@@ -96,7 +96,16 @@ void TWebBrowser::RenderTextbuf()
} }
//Maybe a new line is too big for the whole new line? Then we have to split it //Maybe a new line is too big for the whole new line? Then we have to split it
if (!br) && (len * list.font_w >= draw_w) { if (!br) && (len * list.font_w >= draw_w) {
//debugln("bigbr");
//debugval("draw_x", draw_x);
//debugval("draw_w", draw_w);
br = draw_w - draw_x / list.font_w; br = draw_w - draw_x / list.font_w;
//debugval("cut into 1", br * list.font_w);
if (br < 0) {
NewLine();
br = draw_w - draw_x / list.font_w;
//debugval("cut into 2", br * list.font_w);
}
} }
if (br) { if (br) {
@@ -122,7 +131,11 @@ void TWebBrowser::NewLine()
if (t_html) && (!t_body) return; if (t_html) && (!t_body) return;
if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) { if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) {
if (!empty_line) empty_line=true; else return; if (!empty_line) {
empty_line=true;
} else {
return;
}
} else { } else {
empty_line = false; empty_line = false;
} }

View File

@@ -61,7 +61,7 @@ void TWebBrowser::SetStyle()
void TWebBrowser::tag_p() void TWebBrowser::tag_p()
{ {
IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) return; IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) return;
if (!tag.opened) && (streq(#tag.prior,"p")) return; IF (!tag.opened) && (streq(#tag.prior,"p")) return;
NewLine(); NewLine();
} }
@@ -119,6 +119,7 @@ void TWebBrowser::tag_iframe()
void TWebBrowser::tag_a() void TWebBrowser::tag_a()
{ {
if (!secondrun) return;
if (tag.opened) if (tag.opened)
{ {
if (tag.get_value_of("href")) && (!strstr(tag.value,"javascript:")) if (tag.get_value_of("href")) && (!strstr(tag.value,"javascript:"))
@@ -133,6 +134,7 @@ void TWebBrowser::tag_a()
void TWebBrowser::tag_meta_xml() void TWebBrowser::tag_meta_xml()
{ {
if (secondrun) return;
if (custom_encoding == -1) if (tag.get_value_of("charset")) if (custom_encoding == -1) if (tag.get_value_of("charset"))
|| (tag.get_value_of("content")) || (tag.get_value_of("encoding")) || (tag.get_value_of("content")) || (tag.get_value_of("encoding"))
{ {
@@ -187,7 +189,7 @@ void TWebBrowser::tag_ol_ul_dt()
void TWebBrowser::tag_li() void TWebBrowser::tag_li()
{ {
if (style.nav) return; //if (style.nav) return;
if (tag.opened) { if (tag.opened) {
if (!style.tag_list.level) style.tag_list.upd_level(1, 'u'); if (!style.tag_list.level) style.tag_list.upd_level(1, 'u');
if (!style.pre) NewLine(); if (!style.pre) NewLine();
@@ -219,10 +221,7 @@ void TWebBrowser::tag_body()
if (tag.get_value_of("link")) link_color_default = GetColor(tag.value); 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("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("text")) text_colors.set(0, GetColor(tag.value));
if (tag.get_value_of("bgcolor")) { if (tag.get_value_of("bgcolor")) bg_colors.set(0, GetColor(tag.value));
bg_colors.set(0, GetColor(tag.value));
canvas.Fill(0, bg_colors.get(0));
}
// Autodetecting encoding if no encoding was set // Autodetecting encoding if no encoding was set
if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) { if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) {
if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8); if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8);
@@ -250,10 +249,10 @@ void TWebBrowser::tag_h1234_caption()
NewLine(); NewLine();
} }
if (tag.is("h1")) { if (tag.is("h1")) {
list.SetFont(BASIC_CHAR_W*2, 14+12, 10011001b); list.SetFont(BASIC_CHAR_W*2, 14+14, 10011001b);
style.b = true; style.b = true;
} else if (tag.is("h2")) { } else if (tag.is("h2")) {
list.SetFont(BASIC_CHAR_W*2, 14+12, 10011001b); list.SetFont(BASIC_CHAR_W*2, 14+14, 10011001b);
} else { } else {
list.SetFont(6*2, 9+7, 10001001b); list.SetFont(6*2, 9+7, 10001001b);
} }
@@ -294,7 +293,7 @@ void TWebBrowser::tag_img()
if (!strcmp(tag.value + strrchr(tag.value, '.'), "webp")) goto NOIMG; if (!strcmp(tag.value + strrchr(tag.value, '.'), "webp")) goto NOIMG;
strlcpy(#img_path, tag.value, sizeof(img_path)-1); strlcpy(#img_path, tag.value, sizeof(img_path)-1);
replace_char(#img_path, ' ', '\0', sizeof(img_path)); replace_char(#img_path, ' ', '\0', sizeof(img_path)-1);
get_absolute_url(#img_path, history.current()); get_absolute_url(#img_path, history.current());
if (check_is_the_adress_local(#img_path)) { if (check_is_the_adress_local(#img_path)) {
@@ -331,31 +330,28 @@ NOIMG:
text_colors.pop(); text_colors.pop();
} }
struct TABLE { struct TABLE {
int count;
int depth; int depth;
int margin; int margin;
collection_int cols; collection_int cols;
collection_int width;
} table; } table;
unsigned table_id;
int tr_pos, td_pos; unsigned colcount;
int row_start_y; unsigned tr_pos;
int colcount; unsigned td_pos;
dword tallest_cell_in_row; unsigned row_start_y;
unsigned tallest_cell_in_row;
unsigned cur_cell_w;
void TWebBrowser::tag_table_reset() void TWebBrowser::tag_table_reset()
{ {
table.depth = 0; table_id = 0;
table.count = 0;
colcount = 0; colcount = 0;
tr_pos = 0; tr_pos = 0;
td_pos = 0; td_pos = 0;
table.depth = 0;
cur_cell_w = 0;
} }
void TWebBrowser::tag_table() void TWebBrowser::tag_table()
@@ -369,15 +365,15 @@ void TWebBrowser::tag_table()
if(tag.opened) { if(tag.opened) {
table.depth++; table.depth++;
if (table.depth==1) { if (table.depth==1) {
table.count++; table_id++;
colcount = 0; colcount = 0;
td_pos = 0; td_pos = 0;
row_start_y = draw_y; row_start_y = draw_y;
if (tag.get_number_of("width")) { if (tag.get_number_of("width")) {
if (strchr(tag.value, '%')) tag.number = list.w * tag.number / 100; if (strchr(tag.value, '%')) tag.number = list.w * tag.number / 100;
table.width.set(table.count, math.min(tag.number,list.w)); cur_cell_w = math.min(tag.number,list.w);
} else { } else {
table.width.set(table.count, list.w); cur_cell_w = list.w;
} }
} }
} else { } else {
@@ -436,26 +432,17 @@ void TWebBrowser::tag_table()
if (!tr_pos) goto _TR_FIX; 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));
}
} */
tallest_cell_in_row = math.max(draw_y+style.cur_line_h-list.item_h+1, tallest_cell_in_row); tallest_cell_in_row = math.max(draw_y+style.cur_line_h-list.item_h+1, tallest_cell_in_row);
style.cur_line_h = list.item_h; style.cur_line_h = list.item_h;
if (tag.opened) { if (tag.opened)
{
if (!td_pos) { if (!td_pos) {
table.margin = list.w - table.width.get(table.count) / 2 + BODY_MARGIN; table.margin = list.w - cur_cell_w / 2 + BODY_MARGIN;
draw_x = left_gap = table.margin; draw_x = left_gap = table.margin;
draw_w = table.width.get(table.count) - BODY_MARGIN; draw_w = cur_cell_w - BODY_MARGIN;
} else { } else {
draw_x = left_gap = left_gap + draw_w; draw_x = left_gap = left_gap + draw_w;
draw_w = table.width.get(table.count) - left_gap + table.margin - BODY_MARGIN; draw_w = cur_cell_w - left_gap + table.margin - BODY_MARGIN;
} }
if (EAX = table.cols.get(tr_pos-1)-td_pos) { if (EAX = table.cols.get(tr_pos-1)-td_pos) {
@@ -466,20 +453,18 @@ void TWebBrowser::tag_table()
} }
if (table.cols.get(tr_pos-1)-td_pos>1) && (tag.get_number_of("width")) { if (table.cols.get(tr_pos-1)-td_pos>1) && (tag.get_number_of("width")) {
if (strchr(tag.value, '%')) { if (strchr(tag.value, '%')) {
tag.number = table.width.get(table.count) - table.margin - 23 - left_gap * tag.number / 100; tag.number = cur_cell_w - table.margin - 23 - left_gap * tag.number / 100;
} }
if (tag.number < draw_w) draw_w = tag.number; if (tag.number < draw_w) draw_w = tag.number;
} }
draw_y = row_start_y; draw_y = row_start_y;
//canvas.WriteText(draw_x, draw_y, 10001001b, 0x0000FE, itoa(draw_x), NULL);
//canvas.WriteText(draw_x, draw_y+20, 10001001b, 0xFF0000, itoa(draw_w), NULL);
td_pos++; td_pos++;
} }
} }
} }
if (draw_x > table.width.get(table.count)) { if (draw_x > cur_cell_w) {
draw_x = left_gap = table.margin; draw_x = left_gap = table.margin;
draw_w = table.width.get(table.count) - table.margin - 23 - left_gap; draw_w = cur_cell_w - table.margin - 23 - left_gap;
table.depth = 0; table.depth = 0;
NewLine(); NewLine();
if (debug_mode) { if (debug_mode) {
@@ -487,11 +472,8 @@ void TWebBrowser::tag_table()
canvas.DrawBar(0, draw_y, 20, 20, 0xFF0000); canvas.DrawBar(0, draw_y, 20, 20, 0xFF0000);
} }
} }
/* //if (left_gap + draw_w > list.w) {
if (left_gap + draw_w > list.w) { // draw_w = list.w - left_gap;
draw_w = list.w - left_gap; // if (debug_mode) debugln("anomaly draw_W");
if (debug_mode) debugln("anomaly draw_W"); //}
} }
*/
}

View File

@@ -1,4 +1,4 @@
//Copyright 2007-2021 by Veliant & Leency //Copyright 2007-2025 by Veliant & Leency
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr... //Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
//BUGS //BUGS

View File

@@ -112,4 +112,4 @@ char editbox_icons[] = FROM "res/editbox_icons.raw";
#define DEFAULT_URL URL_SERVICE_HOMEPAGE #define DEFAULT_URL URL_SERVICE_HOMEPAGE
char version[]="WebView 3.8"; char version[]="WebView 3.82";

View File

@@ -4,10 +4,10 @@
</head> </head>
<body><pre>Welcome to WebView a Text-Based Browser. <body><pre>Welcome to WebView a Text-Based Browser.
Bookmarks: KolibriOS Bookmarks:
1. <a href=//kolibrios.org>KolibriOS homepage</a> 1. <a href=//kolibrios.org>Homepage</a>
2. <a href="//builds.kolibrios.org">Night-builds</a> 2. <a href="//builds.kolibrios.org">Night-builds</a>
3. <a href="//ftp.kolibrios.org">KolibriOS FTP</a> 3. <a href="//ftp.kolibrios.org">FTP Server</a>
<font bg=#F8F15B>By the way,</font> <font bg=#F8F15B>By the way,</font>
<font color="#555555">&bull; You can check for browser updates from the main menu. <font color="#555555">&bull; You can check for browser updates from the main menu.

View File

@@ -1,16 +1,15 @@
<html> <html><head><meta charset="cp-866">
<head> <title><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E0A0AD><EFBFBD></title></head>
<meta charset="cp-866"> <body><pre><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><EFBFBD><E2AEA2> <20><><EFBFBD><EFBFBD> WebView!
<title><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E0A0AD><EFBFBD></title>
</head> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> KolibriOS:<ol>
<body><pre><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <li><a href=//kolibrios.org><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><></a>
1. <a href=//kolibrios.org><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><> KolibriOS</a> <li><a href="//builds.kolibrios.org"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᡮન</a>
2. <a href="//builds.kolibrios.org"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᡮન</a> <li><a href="//ftp.kolibrios.org">FTP <20><><EFBFBD></a></ol>
3. <a href="//ftp.kolibrios.org">KolibriOS FTP</a>
<font bg=#F8F15B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,</font> <font bg=#F8F15B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,</font>
<font color="#555555">&bull; <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <font color="#555555">&bull; <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
&bull; <20><><EFBFBD> <20><><EFBFBD><20> Google <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ctrl+Enter &bull; <20><><EFBFBD> <20><><EFBFBD><20> Google <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ctrl+Enter
&bull; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> F6 <20><><EFBFBD><EFBFBD><><EFBFBD><E2AEA2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. &bull; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> F6 <20><><EFBFBD><EFBFBD><><EFBFBD><E2AEA2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
&bull; <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E0AEA2> <20><><EFBFBD><E0A0AD><EFBFBD>, <20><><EFBFBD> <20><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><EFBFBD><E0A0A2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><> <20><><EFBFBD><EFBFBD>. &bull; <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E0AEA2> <20><><EFBFBD><E0A0AD><EFBFBD>, <20><><EFBFBD> <20><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><EFBFBD><E0A0A2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><> <20><><EFBFBD><EFBFBD>.
</font>