WebView 3.31: speed up text rendering (less strcpy, use pointers), fix click on a non-existing link in the toolbar, use // instwead of http:// in buildin pages
git-svn-id: svn://kolibrios.org@8500 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
CANVAS canvas;
|
||||
|
||||
void TWebBrowser::RenderLine()
|
||||
void TWebBrowser::RenderLine(dword _line)
|
||||
{
|
||||
unsigned px; //paint x coordinate
|
||||
unsigned pw; //paint y coordinate
|
||||
@@ -9,22 +9,28 @@ void TWebBrowser::RenderLine()
|
||||
|
||||
if (style.title)
|
||||
{
|
||||
strncpy(#header, #linebuf, sizeof(TWebBrowser.header)-1);
|
||||
strncpy(#header, _line, sizeof(TWebBrowser.header)-1);
|
||||
strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
|
||||
strncat(#header, #version, sizeof(TWebBrowser.header)-1);
|
||||
linebuf = 0;
|
||||
return;
|
||||
}
|
||||
if (t_html) && (!t_body) {
|
||||
linebuf = 0;
|
||||
return;
|
||||
else if (t_html) && (!t_body) {
|
||||
//
|
||||
}
|
||||
|
||||
if (linebuf)
|
||||
else if (ESBYTE[_line])
|
||||
{
|
||||
pw = strlen(#linebuf) * list.font_w;
|
||||
pw = strlen(_line) * list.font_w;
|
||||
zoom = list.font_w / BASIC_CHAR_W;
|
||||
|
||||
if (pw > draw_w) {
|
||||
draw_w = pw;
|
||||
NewLine();
|
||||
}
|
||||
|
||||
if (debug_mode) {
|
||||
canvas.DrawBar(draw_x, draw_y, pw, list.item_h, 0xCCCccc);
|
||||
debugln(_line);
|
||||
}
|
||||
|
||||
style.cur_line_h = math.max(style.cur_line_h, list.item_h);
|
||||
|
||||
if (bg_colors.get_last() - bg_colors.get(0)) {
|
||||
@@ -42,63 +48,81 @@ void TWebBrowser::RenderLine()
|
||||
pc = text_colors.get_last();
|
||||
if (link) && (pc == text_colors.get(0)) pc = link_color_default;
|
||||
|
||||
canvas.WriteText(draw_x, draw_y, list.font_type, pc, #linebuf, NULL);
|
||||
if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, #linebuf, NULL);
|
||||
canvas.WriteText(draw_x, draw_y, list.font_type, pc, _line, NULL);
|
||||
if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, _line, NULL);
|
||||
if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc);
|
||||
if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc);
|
||||
if (link) {
|
||||
if (linebuf[0]==' ') && (linebuf[1]==NULL) {} else {
|
||||
if (ESBYTE[_line]==' ') && (ESBYTE[_line+1]==NULL) {} else {
|
||||
canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default);
|
||||
links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom);
|
||||
}
|
||||
}
|
||||
draw_x += pw;
|
||||
if (debug_mode) debugln(#linebuf);
|
||||
}
|
||||
linebuf = NULL;
|
||||
ESBYTE[_line] = NULL;
|
||||
}
|
||||
|
||||
|
||||
void TWebBrowser::RenderTextbuf()
|
||||
{
|
||||
int break_pos;
|
||||
char next_line[sizeof(TWebBrowser.linebuf)];
|
||||
int zoom = list.font_w / BASIC_CHAR_W;
|
||||
dword lbp = #linebuf;
|
||||
int br; //break position
|
||||
char nul = '\0';
|
||||
int len;
|
||||
|
||||
//Do we need a line break?
|
||||
while (strlen(#linebuf) * list.font_w + draw_x >= draw_w) {
|
||||
while (len = strlen(lbp)) && (len * list.font_w + draw_x >= draw_w) {
|
||||
//Yes, we do. Lets calculate where...
|
||||
break_pos = strrchr(#linebuf, ' ');
|
||||
br = strrchr(lbp, ' ');
|
||||
|
||||
//Is a new line fits in the current line?
|
||||
if (break_pos * list.font_w + draw_x > draw_w) {
|
||||
break_pos = draw_w - draw_x /list.font_w;
|
||||
while(break_pos) {
|
||||
if (linebuf[break_pos]==' ') {
|
||||
break_pos++;
|
||||
if (br * list.font_w + draw_x >= draw_w) {
|
||||
br = draw_w - draw_x /list.font_w;
|
||||
while(br) {
|
||||
if (ESBYTE[lbp + br]==' ') {
|
||||
br++;
|
||||
break;
|
||||
}
|
||||
break_pos--;
|
||||
br--;
|
||||
}
|
||||
}
|
||||
//Maybe a new line is too big for the whole new line? Then we have to split it
|
||||
if (!break_pos) && (style.tag_list.level*5 + strlen(#linebuf) * zoom >= list.column_max) {
|
||||
break_pos = draw_w - draw_x / list.font_w;
|
||||
if (!br) && (len * list.font_w >= draw_w) {
|
||||
br = draw_w - draw_x / list.font_w;
|
||||
}
|
||||
|
||||
|
||||
if (break_pos) {
|
||||
strlcpy(#next_line, #linebuf + break_pos, sizeof(next_line));
|
||||
linebuf[break_pos] = 0x00;
|
||||
RenderLine();
|
||||
strlcpy(#linebuf, #next_line, sizeof(TWebBrowser.linebuf));
|
||||
NewLine();
|
||||
if (br) {
|
||||
ESBYTE[lbp + br] >< nul;
|
||||
RenderLine(lbp);
|
||||
ESBYTE[lbp + br] >< nul;
|
||||
lbp += br;
|
||||
while (ESBYTE[lbp]==' ') && (ESBYTE[lbp]) lbp++;
|
||||
if (ESBYTE[lbp]) NewLine();
|
||||
} else {
|
||||
NewLine();
|
||||
RenderLine();
|
||||
RenderLine(lbp);
|
||||
}
|
||||
}
|
||||
RenderLine();
|
||||
RenderLine(lbp);
|
||||
}
|
||||
|
||||
void TWebBrowser::NewLine()
|
||||
{
|
||||
static bool empty_line = true;
|
||||
|
||||
if (draw_x==left_gap) && (draw_y==BODY_MARGIN) return;
|
||||
if (t_html) && (!t_body) return;
|
||||
|
||||
if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) {
|
||||
if (!empty_line) empty_line=true; else return;
|
||||
} else {
|
||||
empty_line = false;
|
||||
}
|
||||
|
||||
draw_y += style.cur_line_h;
|
||||
style.cur_line_h = list.item_h;
|
||||
if (style.blq) draw_x = 6 * list.font_w; else draw_x = 0; //left_gap += style.tag_list.level * 5 * list.font_w ???
|
||||
draw_x += style.tag_list.level * 5 * list.font_w + left_gap;
|
||||
}
|
||||
|
||||
bool TWebBrowser::RenderImage(dword cur_img)
|
||||
|
Reference in New Issue
Block a user