mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-29 09:49:41 +03:00
HTMLv: fixed memory leaks, fixed - show error page if page not found, some code refactoring
git-svn-id: svn://kolibrios.org@4650 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
4a31e76907
commit
8dc139d234
@ -16,10 +16,10 @@ struct TWebBrowser {
|
||||
void GetNewUrl();
|
||||
void Prepare();
|
||||
void Parse();
|
||||
void WhatTextStyle();
|
||||
void SetTextStyle();
|
||||
void DrawPage();
|
||||
void DrawScroller();
|
||||
void TextGoDown();
|
||||
void NewLine();
|
||||
};
|
||||
|
||||
TWebBrowser WB1;
|
||||
@ -302,11 +302,11 @@ void TWebBrowser::Parse(){
|
||||
if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
|
||||
DrawPage();
|
||||
strcpy(#line, #temp);
|
||||
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
NewLine(list.x + 5, stroka * 10 + list.y + 5); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
}
|
||||
DrawPage();
|
||||
line=NULL;
|
||||
if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáðàáîòêà òåãîâ
|
||||
if (tag) SetTextStyle(list.x + 5, stroka * 10 + list.y + 5); //îáðàáîòêà òåãîâ
|
||||
tag = parametr = tagparam = ignor_param = NULL;
|
||||
break;
|
||||
default:
|
||||
@ -329,13 +329,13 @@ void TWebBrowser::Parse(){
|
||||
if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
|
||||
DrawPage();
|
||||
strcpy(#line, #temp);
|
||||
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
NewLine(list.x + 5, stroka * 10 + list.y + 5); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
|
||||
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
NewLine(list.x + 5, stroka * 10 + list.y + 5); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
|
||||
if (list.visible * 10 + 25 <= list.h)
|
||||
DrawBar(list.x, list.visible * 10 + list.y + 25, list.w, -list.visible * 10 + list.h - 25, bg_color);
|
||||
@ -354,7 +354,7 @@ void TWebBrowser::Parse(){
|
||||
|
||||
|
||||
char oldtag[100];
|
||||
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
void TWebBrowser::SetTextStyle(int left1, top1) {
|
||||
dword hr_color;
|
||||
byte opened;
|
||||
byte meta_encoding;
|
||||
@ -388,13 +388,13 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
{
|
||||
if (opened)
|
||||
{
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
strcat(#line, ' \"');
|
||||
}
|
||||
if (!opened)
|
||||
{
|
||||
chrcat(#line, '\"');
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,63 +478,70 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
return;
|
||||
}
|
||||
if (isTag("br")) {
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
return;
|
||||
}
|
||||
if (isTag("div")) || (isTag("header")) || (isTag("footer")) {
|
||||
IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
|
||||
IF(oldtag[0] <>'h') NewLine(left1, top1);
|
||||
return;
|
||||
}
|
||||
if (isTag("p")) {
|
||||
IF(oldtag[0] == 'h') return;
|
||||
TextGoDown(left1, top1, width1);
|
||||
IF(opened) TextGoDown(left1, top1 + 10, width1);
|
||||
NewLine(left1, top1);
|
||||
IF(opened) NewLine(left1, top1 + 10);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(isTag("table")) {
|
||||
if (opened)
|
||||
{
|
||||
table.active = true;
|
||||
TextGoDown(left1, top1, width1);
|
||||
table.NewTable();
|
||||
}
|
||||
else
|
||||
{
|
||||
table.active = false;
|
||||
TextGoDown(left1, top1, width1);
|
||||
}
|
||||
table.active = opened;
|
||||
NewLine(left1, top1);
|
||||
if (opened) table.NewTable();
|
||||
}
|
||||
|
||||
if(isTag("td")) {
|
||||
if (opened)
|
||||
{
|
||||
//
|
||||
table.cur_col++;
|
||||
table.row_h = 0;
|
||||
do {
|
||||
if (!strcmp(#parametr, "width="))
|
||||
{
|
||||
table.col_w[table.cur_col] = atoi(#options);
|
||||
// NewLine(left1, top1);
|
||||
// strcpy(#line, #options);
|
||||
// NewLine(left1, top1);
|
||||
}
|
||||
} while(GetNextParam());
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
if (table.row_h > table.row_max_h) table.row_max_h = table.row_h;
|
||||
}
|
||||
}
|
||||
|
||||
if(isTag("tr")) {
|
||||
if (opened)
|
||||
{
|
||||
//
|
||||
table.cur_col = 0;
|
||||
table.row_max_h = 0;
|
||||
table.row_start = stroka;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
if (table.cur_row == 0) table.max_cols = table.cur_col;
|
||||
table.cur_row++;
|
||||
table.max_cols = table.cur_col;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (isTag("center"))
|
||||
{
|
||||
if (opened) text_align = ALIGN_CENTER;
|
||||
if (!opened)
|
||||
{
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
text_align = ALIGN_LEFT;
|
||||
}
|
||||
return;
|
||||
@ -544,15 +551,15 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
if (opened) text_align = ALIGN_RIGHT;
|
||||
if (!opened)
|
||||
{
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
text_align = ALIGN_LEFT;
|
||||
}
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
|
||||
TextGoDown(left1, top1, width1);
|
||||
if (opened) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
|
||||
NewLine(left1, top1);
|
||||
if (opened) && (stroka>1) NewLine(left1, top1 + 10);
|
||||
strcpy(#oldtag, #tag);
|
||||
if (opened)
|
||||
{
|
||||
@ -582,7 +589,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
{
|
||||
li_text = opened;
|
||||
IF(opened == 0) return;
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
return;
|
||||
}
|
||||
if (isTag("condition"))
|
||||
@ -596,7 +603,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
li_text = opened;
|
||||
if (opened)
|
||||
{
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
|
||||
}
|
||||
return;
|
||||
@ -607,7 +614,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
{
|
||||
li_text = opened;
|
||||
li_tab--;
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
} ELSE li_tab++;
|
||||
if (isTag("dd")) stolbec += 5;
|
||||
if (isTag("blockquote")) blq_text = opened;
|
||||
@ -620,13 +627,13 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||
return;
|
||||
}
|
||||
if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
|
||||
TextGoDown(left1, top1, width1);
|
||||
NewLine(left1, top1);
|
||||
DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
|
||||
TextGoDown(left1, top1+list.line_h, width1);
|
||||
NewLine(left1, top1+list.line_h);
|
||||
}
|
||||
if (isTag("img"))
|
||||
{
|
||||
ImgCache.Images( left1, top1, width1);
|
||||
ImgCache.Images( left1, top1);
|
||||
return;
|
||||
}
|
||||
if (isTag("meta")) || (isTag("?xml"))
|
||||
@ -664,7 +671,7 @@ void TWebBrowser::DrawScroller() //
|
||||
}
|
||||
|
||||
|
||||
void TWebBrowser::TextGoDown(int left1, top1, width1)
|
||||
void TWebBrowser::NewLine(int left1, top1)
|
||||
{
|
||||
if (!stroka) DrawBar(list.x, list.y, list.w, 5, bg_color); //çàêðàøèâàåì ôîí íàä ïåðâîé ñòðîêîé
|
||||
if (t_html) && (!t_body) return;
|
||||
|
@ -5,8 +5,8 @@ struct Table
|
||||
byte max_rows;
|
||||
byte cur_col;
|
||||
byte cur_row;
|
||||
int col_w[255];
|
||||
int col_h[255];
|
||||
int col_w[32];
|
||||
int row_start, row_h, row_max_h;
|
||||
void NewTable();
|
||||
} table;
|
||||
|
||||
|
@ -30,14 +30,14 @@
|
||||
#include "img\URLgoto.txt";
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 0.99.73";
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 0.99.74";
|
||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||
unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
||||
char accept_language[]= "Accept-Language: ru\n";
|
||||
#else
|
||||
char version[]=" Text-based Browser 0.99.73";
|
||||
char version[]=" Text-based Browser 0.99.74";
|
||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||
?define T_LAST_SLIDE "This slide is the last"
|
||||
char loading[] = "Loading...<br>";
|
||||
@ -469,6 +469,7 @@ void StopLoading()
|
||||
mem_Free(EAX); // free data
|
||||
http_transfer=0;
|
||||
bufsize = 0;
|
||||
bufpointer = mem_Free(bufpointer);
|
||||
}
|
||||
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
||||
}
|
||||
@ -499,6 +500,7 @@ void OpenPage()
|
||||
{
|
||||
StopLoading();
|
||||
bufsize = 0;
|
||||
bufpointer = mem_Free(bufpointer);
|
||||
ShowPage();
|
||||
return;
|
||||
}
|
||||
@ -507,11 +509,13 @@ void OpenPage()
|
||||
{
|
||||
file_size stdcall (#URL);
|
||||
bufsize = EBX;
|
||||
if (!bufsize) return;
|
||||
mem_Free(bufpointer);
|
||||
bufpointer = mem_Alloc(bufsize);
|
||||
SetPageDefaults();
|
||||
ReadFile(0, bufsize, bufpointer, #URL);
|
||||
if (bufsize)
|
||||
{
|
||||
bufpointer = mem_Free(bufpointer);
|
||||
bufpointer = mem_Alloc(bufsize);
|
||||
SetPageDefaults();
|
||||
ReadFile(0, bufsize, bufpointer, #URL);
|
||||
}
|
||||
ShowPage();
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,15 @@
|
||||
<title>Page not found</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Webpage Not Available</h1>
|
||||
<h2>What could be done:</h2>
|
||||
<h1> Webpage Not Available</h1>
|
||||
<h2> What could be done:</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Make sure that evetything fine with Internet connection.<br>
|
||||
Open /sys/network/netcfg network diagnostic tool.<br>
|
||||
</li>
|
||||
<li>
|
||||
Check page address, there may have been made a typo<br>
|
||||
Check page address, there may have been made a typo.<br>
|
||||
</li>
|
||||
<li>
|
||||
Server is temporarily unavailable.<br>
|
||||
|
@ -4,15 +4,15 @@
|
||||
<title>‘âà ¨æ ¥ ©¤¥ </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>‚¥¡-áâà ¨æ ¥¤®áâ㯠</h1>
|
||||
<h2>—â® ¬®¦® ᤥ« âì:</h2>
|
||||
<h1> ‚¥¡-áâà ¨æ ¥¤®áâ㯠</h1>
|
||||
<h2> —â® ¬®¦® ᤥ« âì:</h2>
|
||||
<ul>
|
||||
<li>
|
||||
“¡¥¤¨â¥áì, çâ® ¥áâì ¯®¤ª«î票¥ ª á¥â¨ ˆâ¥à¥â.<br>
|
||||
Žâªà®©â¥ /sys/network/netcfg ¤«ï ¤¨ £®á⨪¨ á¥â¨.<br>
|
||||
</li>
|
||||
<li>
|
||||
<09>஢¥àì⥠¤à¥áá áâà ¨æë, ¢®§¬®¦®, ¡ë« ᤥ« ®¯¥ç ⪠<br>
|
||||
<09>஢¥àì⥠¤à¥áá áâà ¨æë, ¢®§¬®¦®, ¡ë« ᤥ« ®¯¥ç ⪠.<br>
|
||||
</li>
|
||||
<li>
|
||||
‘¥à¢¥à ¢à¥¬¥® ¥¤®áâ㯥. <br>
|
||||
|
Loading…
Reference in New Issue
Block a user