Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9102 → Rev 9103

/programs/cmm/browser/TWB/TWB.c
49,6 → 49,8
char linebuf[500];
char redirect[URL_SIZE];
 
bool secondrun;
 
void SetStyle();
void RenderTextbuf();
void RenderLine();
109,7 → 111,16
redirect = '\0';
list.SetFont(8, 14, 10011000b);
tag_table_reset();
is_html = true;
if (!strstri(bufpointer, "<body")) {
t_body = true;
if (!strstri(bufpointer, "<html")) && (!strstri(bufpointer, "<head"))
&& (!strstr(bufpointer, "<?xml")) && (!strstr(bufpointer, "<xml")) {
style.pre = true; //show linebreaks for a plaint text
is_html = false;
}
}
}
//============================================================================================
void TWebBrowser::Reparse()
{
142,45 → 153,50
}
 
 
tr_col_count.drop();
secondrun = false;
 
_PARSE_START_:
 
SetPageDefaults();
is_html = true;
if (!strstri(bufpointer, "<body")) {
t_body = true;
if (!strstri(bufpointer, "<html")) && (!strstri(bufpointer, "<head"))
&& (!strstr(bufpointer, "<?xml")) && (!strstr(bufpointer, "<xml")) {
style.pre = true; //show linebreaks for a plaint text
is_html = false;
}
}
for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
for (bufpos=bufpointer; bufpos < bufpointer+bufsize; bufpos++;)
{
switch (ESBYTE[bufpos])
{
case 0x0a:
if (style.pre) {
if (ESBYTE[bufpos] == 0x0a) {
RenderTextbuf();
NewLine();
} else {
goto _DEFAULT;
continue;
}
break;
case 0x09:
if (style.pre) {
if (ESBYTE[bufpos] == 0x09) {
tab_len = draw_x - left_gap / list.font_w + strlen(#linebuf) % 4;
if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len;
while (tab_len) {chrcat(#linebuf,' '); tab_len--;}
} else {
goto _DEFAULT;
continue;
}
break;
case '&': //&nbsp; and so on
}
if (ESBYTE[bufpos] == '&') {
bufpos = GetUnicodeSymbol(#linebuf, sizeof(TWebBrowser.linebuf), bufpos+1, bufpointer+bufsize);
break;
case '<':
if (!is_html) goto _DEFAULT;
if (!strchr("!/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", ESBYTE[bufpos+1])) goto _DEFAULT;
continue;
}
if (ESBYTE[bufpos] == '<') && (is_html) {
if (strchr("!/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", ESBYTE[bufpos+1])) {
bufpos++;
if (tag.parse(#bufpos, bufpointer + bufsize)) {
 
/*
if (secondrun)
{
if (streq(#tag.name, "tr")) debugln(" ");
if (!tag.opened) {
debugch('/');
} else {
debugch(' ');
}
debugln(sprintf(#param, "%s x%i y%i %s",
#tag.name, draw_x, draw_y, #linebuf));
}
//*/
 
RenderTextbuf();
$push cur_encoding
SetStyle();
193,12 → 209,17
return;
}
}
break;
default:
_DEFAULT:
continue;
}
}
AddCharToTheLine(ESBYTE[bufpos]);
}
 
if (!secondrun) {
secondrun = true;
goto _PARSE_START_;
}
 
RenderTextbuf();
list.count = draw_y + style.cur_line_h;
 
/programs/cmm/browser/TWB/parse_tag.h
1,3 → 1,11
/*
struct _DOM {
collection tag;
collection tagparam;
collection_int parent;
} dom;
*/
 
struct _tag
{
char name[32];
121,7 → 129,7
//find VAL start and copy
pe = strrchr(ps, q) + ps;
val = pe;
pe--;
if (pe>ps) pe--;
ESBYTE[pe] = '\0';
 
//find ATTR end
/programs/cmm/browser/TWB/render.h
21,8 → 21,9
pw = strlen(_line) * list.font_w;
zoom = list.font_w / BASIC_CHAR_W;
 
//there is some shit happens!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (pw > draw_w) {
draw_w = pw;
//draw_w = pw;
NewLine();
}
 
33,6 → 34,7
 
style.cur_line_h = math.max(style.cur_line_h, list.item_h);
 
if (!secondrun) goto _SKIP_DRAW;
if (bg_colors.get_last() - bg_colors.get(0)) {
canvas.DrawBar(draw_x, draw_y, pw, list.item_h, bg_colors.get_last());
}
58,6 → 60,7
links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom);
}
}
_SKIP_DRAW:
draw_x += pw;
}
ESBYTE[_line] = NULL;
71,13 → 74,16
int len;
 
//Do we need a line break?
while (len = strlen(lbp)) && (len * list.font_w + draw_x >= draw_w) {
while (len = strlen(lbp)) && (len * list.font_w + draw_x - left_gap >= draw_w) {
//Yes, we do. Lets calculate where...
br = strrchr(lbp, ' ');
br = len;
 
//debugln(" \\n");
 
//Is a new line fits in the current line?
if (br * list.font_w + draw_x >= draw_w) {
br = draw_w - draw_x /list.font_w;
if (br * list.font_w + draw_x - left_gap >= draw_w) {
br = draw_w - draw_x + left_gap /list.font_w;
while(br) {
if (ESBYTE[lbp + br]==' ') {
br++;
135,7 → 141,7
img_h = ESDWORD[cur_img+8];
img_w = ESDWORD[cur_img+4];
 
if (img_w + draw_x >= draw_w) NewLine();
if (img_w + draw_x - left_gap >= draw_w) NewLine();
img_y = draw_y;
if (img_h < list.item_h) img_y += list.item_h - img_h / 2 - 1; else img_y -= 2;
style.cur_line_h = math.max(style.cur_line_h, img_h);
146,6 → 152,8
 
if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
 
if (secondrun)
{
if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
$push eax
160,8 → 168,9
imgbuf[24] = buf_data+8;
img_blend stdcall(#imgbuf, cur_img, draw_x, img_y, 0, 0, img_w, img_h);
img_destroy stdcall(cur_img);
}
 
draw_x += img_w;
if (draw_x >= draw_w) NewLine();
if (draw_x - left_gap >= draw_w) NewLine();
return true;
}
/programs/cmm/browser/TWB/set_style.h
50,11 → 50,7
if (tag.is("title")) { tag_title(); return; }
if (tag.is("body")) { tag_body(); return; }
if (tag.is("html")) { t_html = tag.opened; return; }
 
if (tag.is("table")) { tag_table(); return; }
if (tag.is("tr")) { if (tag.opened) NewLine(); return; } //temp
//if (tag.is("tr")) { tag_tr(); return; }
//if (tag.is("td")) { tag_td(); return; }
tag_table();
}
 
void TWebBrowser::tag_p()
198,10 → 194,10
 
void TWebBrowser::tag_hr()
{
dword hrcol = 0x777777;
dword hrcol = 0x00777777;
if (tag.get_value_of("color")) hrcol = GetColor(tag.value);
if (draw_x != left_gap) NewLine();
canvas.DrawBar(5, style.cur_line_h / 2 + draw_y - 1, draw_w-10, 1, hrcol);
if (secondrun) canvas.DrawBar(5, style.cur_line_h / 2 + draw_y - 1, draw_w-10, 1, hrcol);
draw_x++;
NewLine();
return;
320,101 → 316,89
 
 
 
 
 
 
 
 
int tdepth;
int col_n;
 
struct TABLE {
collection_int col_w;
collection_int col_span;
collection_int row_h;
int row_y, next_row_y;
collection_int tr_col_count; //drop on once!
int tr_pos, td_pos;
int row_start_y;
int colcount;
} t[5];
dword tallest_cell_in_row;
 
void TWebBrowser::tag_table_reset()
{
int i;
tdepth = 0;
for (i=0; i<5; i++) {
t[i].col_w.drop();
t[i].row_h.drop();
t[i].col_span.drop();
t[i].row_y = 0;
t[i].next_row_y = 0;
colcount = 0;
tr_pos = 0;
td_pos = 0;
}
}
 
void TWebBrowser::tag_table()
{
if (tag.is("table")) {
if (tag.opened) {
if (tdepth==0) {
t[0].next_row_y = t[0].row_y = draw_y;
}
tdepth++;
} else {
tdepth--;
if (tdepth>0) tdepth--;
if (tdepth==0) {
draw_y = math.max(draw_y + style.cur_line_h, t[0].next_row_y);
left_gap = BODY_MARGIN;
draw_w = list.w - BODY_MARGIN;
draw_x = left_gap = style.tag_list.level * 5 * list.font_w + BODY_MARGIN;
draw_w = list.w;
draw_y = math.max(draw_y+style.cur_line_h, tallest_cell_in_row);
row_start_y = draw_y = tallest_cell_in_row = draw_y;
style.cur_line_h = list.item_h;
}
}
}
if (tdepth>1) {
if (tag.is("tr")) && (tag.opened) NewLine();
return;
}
 
:void TWebBrowser::tag_tr()
{
if (!secondrun) {
if (tag.is("tr")) {
if (colcount) tr_col_count.set(tr_col_count.count-1, colcount);
colcount = 0;
if (tag.opened) {
if (tdepth>1) {
NewLine();
} else {
t[0].colcount = math.max(t[0].colcount, col_n);
col_n = 0;
t[0].row_y = math.max(draw_y + style.cur_line_h, t[0].next_row_y);
left_gap = BODY_MARGIN;
NewLine();
tr_col_count.add(1);
}
}
if (tag.opened) && (tag.is("td")) || (tag.is("th")) {
colcount++;
//if (tag.get_number_of("colspan")) colcount += tag.number-1;
}
 
:void TWebBrowser::tag_td()
{
if (tdepth>1) return;
} else {
if (tag.is("tr")) {
if (tag.opened) {
 
t[0].next_row_y = math.max(draw_y + style.cur_line_h, t[0].next_row_y);
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;
t[0].col_w.set(col_n, math.max(draw_x,t[0].col_w.get(col_n)) );
draw_x = left_gap = t[0].col_w.get(col_n);
draw_w = list.w - left_gap;
draw_y = t[0].row_y;
if (tag.get_number_of("width")) {
if (!strchr(tag.value, '%')) {
draw_w = tag.number;
tr_pos++;
td_pos = 0;
} else {
if (tag.number < 100) {
draw_w = draw_w - left_gap * tag.number / 100;
if (draw_w > list.w - left_gap) draw_w = list.w - left_gap;
draw_x = left_gap = style.tag_list.level * 5 * list.font_w + BODY_MARGIN;
draw_w = list.w;
draw_y = tallest_cell_in_row;
}
}
if (tr_pos) && (tag.is("td")) || (tag.is("th")) {
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) {
draw_w = list.w - BODY_MARGIN - BODY_MARGIN - 23 / tr_col_count.get(tr_pos-1);
draw_x = left_gap = draw_w * td_pos + BODY_MARGIN;
//debugval(itoa(draw_x), list.w);
draw_y = row_start_y;
//canvas.WriteText(draw_x, draw_y, 10001001b, 0x0000FE, itoa(draw_x), NULL);
td_pos++;
}
col_n++;
t[0].col_w.set(col_n, draw_x + draw_w);
 
if (left_gap >= list.w - list.font_w - 10) {
debugln("left_gap overflow");
draw_x = left_gap = BODY_MARGIN;
t[0].col_w.drop();
NewLine();
canvas.WriteText(draw_x, draw_y, 10011001b, 0xFE0000, "lgo", NULL);
}
 
if (draw_w < 0) || (draw_w >= list.w) {
debugln("draw_w overflow");
draw_x = left_gap = BODY_MARGIN;
draw_w = list.w - left_gap;
NewLine();
canvas.WriteText(draw_x, draw_y, 10011001b, 0x0000FE, "drwo", NULL);
}
}
 
}
/programs/cmm/browser/TWB/special.h
81,7 → 81,7
{
if (__isWhite(ESBYTE[bufpos])) {bufpos--; break;}
if (ESBYTE[bufpos] == ';') || (bufpos >= buf_end) break;
if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ESBYTE[bufpos])) {bufpos--; break;}
if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#", ESBYTE[bufpos])) {bufpos--; break;}
special_code[i] = ESBYTE[bufpos];
}
special_code[i] = '\0';
/programs/cmm/browser/const.h
107,4 → 107,4
 
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
 
char version[]="WebView 3.32";
char version[]="WebView 3.5";
/programs/cmm/browser/res/test.htm
20,14 → 20,18
<a href=//mestack.narod.ru/index.html>mestack.narod.ru</a>
<a href=//coolthemes.narod.ru/indexold.html>coolthemes.narod.ru</a>
<a href=//vetusware.com>vetusware.com</a>
<a href=//th99.infania.net>Total Hardware 1999</a>
<a href=//toastytech.com/guis/index.html>GUI Gallery</a>
<a href=//menuetos.net>menuetos.net</a>
 
Moderate:
<a href=//fdd5-25.pdp-11.ru>fdd5-25</a>
<a href=//acmp.ru/index.asp?main=tasks>acmp.ru</a>
<a href=//old-dos.ru>old-dos.ru</a>
<a href=//www.weitek.com/textual/support/driver.html>weitek</a>
 
Complex:
<a href=//artcon.ru>artcon.ru</a>
<a href=//edition.cnn.com/EVENTS/1996/year.in.review>cnn 1996</a>
<a href=//nubo.ru>nubo.ru</a>
<a href=//salinc.ru>salinc.ru</a>
<a href=//electromyne.de>electromyne.de</a>