WebView 1.52: couple of bugs fixed, open local files with @open, add <bg> tag; still very crashful

git-svn-id: svn://kolibrios.org@6730 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2016-11-20 11:10:10 +00:00
parent 6e9a21eee8
commit d6043d4e2b
4 changed files with 65 additions and 41 deletions

View File

@ -46,6 +46,7 @@ dword text_color_index;
dword link_color_inactive; dword link_color_inactive;
dword link_color_active; dword link_color_active;
dword bg_color; dword bg_color;
dword block_bg_color;
int stroka; int stroka;
int stolbec; int stolbec;
@ -124,7 +125,7 @@ void TWebBrowser::Prepare(){
style.align = ALIGN_LEFT; style.align = ALIGN_LEFT;
link_color_inactive = 0x0000FF; link_color_inactive = 0x0000FF;
link_color_active = 0xFF0000; link_color_active = 0xFF0000;
bg_color = 0xFFFFFF; bg_color = block_bg_color = 0xFFFFFF;
DrawBuf.Fill(bg_color); DrawBuf.Fill(bg_color);
PageLinks.Clear(); PageLinks.Clear();
strcpy(#header, #version); strcpy(#header, #version);
@ -289,7 +290,7 @@ void TWebBrowser::SetStyle() {
if (isattr("text=")) text_colors[0]=GetColor(#val); if (isattr("text=")) text_colors[0]=GetColor(#val);
if (isattr("bgcolor=")) if (isattr("bgcolor="))
{ {
bg_color=GetColor(#val); bg_color = block_bg_color = GetColor(#val);
DrawBuf.Fill(bg_color); DrawBuf.Fill(bg_color);
} }
} while(GetNextParam()); } while(GetNextParam());
@ -336,13 +337,12 @@ void TWebBrowser::SetStyle() {
else if (text_color_index > 0) text_color_index--; else if (text_color_index > 0) text_color_index--;
return; return;
} }
if (istag("bg")) {
if (opened) {block_bg_color=GetColor(#val); NewLine();}
if (!opened) block_bg_color=bg_color;
}
if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) { if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) {
IF(oldtag[0] != 'h') NewLine(); IF(oldtag[0] != 'h') NewLine();
if (isattr("bgcolor="))
{
bg_color=GetColor(#val);
DrawBuf.Fill(bg_color);
}
return; return;
} }
if (istag("p")) { if (istag("p")) {
@ -475,6 +475,7 @@ void TWebBrowser::NewLine()
onleft = list.x + 5; onleft = list.x + 5;
ontop = stroka * list.item_h + list.y + 5; ontop = stroka * list.item_h + list.y + 5;
if (t_html) && (!t_body) return; if (t_html) && (!t_body) return;
if (block_bg_color!=bg_color) DrawBuf.DrawBar(0, stroka+1*list.item_h+5, DrawBuf.bufw, list.item_h, block_bg_color);
if (stroka * list.item_h + 5 >= 0) && ( stroka + 1 * list.item_h + 5 < list.h) && (!anchor) if (stroka * list.item_h + 5 >= 0) && ( stroka + 1 * list.item_h + 5 < list.h) && (!anchor)
{ {
if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.item_h,stolbec * list.font_w); if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.item_h,stolbec * list.font_w);
@ -485,9 +486,9 @@ void TWebBrowser::NewLine()
if (style.li) stolbec = style.li_tab * 5; if (style.li) stolbec = style.li_tab * 5;
} }
//============================================================================================ //============================================================================================
int istag(dword text) { if (!strcmp(#tag,text)) return 1; else return 0; } int istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
int isattr(dword text) { if (!strcmp(#attr,text)) return 1; else return 0; } int isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; }
int isval(dword text) { if (!strcmp(#val,text)) return 1; else return 0; } int isval(dword text) { if (!strcmp(#val,text)) return true; else return false; }
//============================================================================================ //============================================================================================
void TWebBrowser::DrawPage() void TWebBrowser::DrawPage()
{ {

View File

@ -34,6 +34,7 @@
<br> <br>
<p> <p>
<bg bgcolor=#333>
Небольшой список:<ol> Небольшой список:<ol>
<li><q>Этот текст в кавычках</q></li> <li><q>Этот текст в кавычках</q></li>
<li><u>Это подчеркнутый текст</u></li> <li><u>Это подчеркнутый текст</u></li>
@ -41,6 +42,7 @@
<li><i>Это наклонный текст</i></li> <li><i>Это наклонный текст</i></li>
<li><strong>Это текст с усиленным выделением</strong></li> <li><strong>Это текст с усиленным выделением</strong></li>
<li><b><u><s><font color="#777444">Много тегов</font></s></u></b></ol> <li><b><u><s><font color="#777444">Много тегов</font></s></u></b></ol>
</bg>
</p> </p>
<br> <br>
@ -61,7 +63,7 @@
<br> <br>
<a href='./index.htm'>./index.htm</a><br> <a href='./index.htm'>./index.htm</a><br>
<a href='/sys/index.htm'>Незакрытый тег а - index.htm<br> <a href='/sys/index.htm'>Незакрытый тег а - index.htm<br>
<a href="/sys/kernel.mnt">kernel.mnt</a><br> <a href="/sys/calc">/sys/calc</a><br>
<a href="#2.1.4">#2.1.4</a><br> <a href="#2.1.4">#2.1.4</a><br>
<a href="http://bash.im">http://bash.im</a><br> <a href="http://bash.im">http://bash.im</a><br>
<a href="mailto:leency@mail.ru">Mail to Leency</a><br> <a href="mailto:leency@mail.ru">Mail to Leency</a><br>
@ -73,12 +75,10 @@
табы. Кое-какие символы: &quot; &amp; &lt; &gt; &#149; табы. Кое-какие символы: &quot; &amp; &lt; &gt; &#149;
&nbsp; &copy; &reg; &bdquo; &ldquo; &#151; Їжачок іншого боку р. Євфрат з'їв ґрунт та єврейський ґербалайф. &nbsp; &copy; &reg; &bdquo; &ldquo; &#151; Їжачок іншого боку р. Євфрат з'їв ґрунт та єврейський ґербалайф.
<condition show_if=1>
<p>61055,&nbsp; &#1075;. <p>61055,&nbsp; &#1075;.
&#1061;&#1072;&#1088;&#1100;&#1082;&#1086;&#1074;, &#1091;&#1083;.&nbsp; &#1050;&#1088;&#1072;&#1089;&#1085;&#1086;&#1079;&#1085;&#1072;&#1084;&#1077;&#1085;&#1085;&#1072;&#1103;, 16</SPAN>,&nbsp; &#1088;&#1072;&#1076;&#1080;&#1086;&#1092;&#1080;&#1079;&#1080;&#1095;&#1077;&#1089;&#1082;&#1080;&#1081; &#1061;&#1072;&#1088;&#1100;&#1082;&#1086;&#1074;, &#1091;&#1083;.&nbsp; &#1050;&#1088;&#1072;&#1089;&#1085;&#1086;&#1079;&#1085;&#1072;&#1084;&#1077;&#1085;&#1085;&#1072;&#1103;, 16</SPAN>,&nbsp; &#1088;&#1072;&#1076;&#1080;&#1086;&#1092;&#1080;&#1079;&#1080;&#1095;&#1077;&#1089;&#1082;&#1080;&#1081;
&#1082;&#1086;&#1088;&#1087;&#1091;&#1089; &#1085;&#1072; &#1090;&#1077;&#1088;&#1088;&#1080;&#1090;&#1086;&#1088;&#1080;&#1080; &#1053;&#1058;&#1059; «&#1061;&#1055;&#1048;» &#1082;&#1086;&#1088;&#1087;&#1091;&#1089; &#1085;&#1072; &#1090;&#1077;&#1088;&#1088;&#1080;&#1090;&#1086;&#1088;&#1080;&#1080; &#1053;&#1058;&#1059; «&#1061;&#1055;&#1048;»
</p> </p>
</condition>
<hr color="#758999"> <hr color="#758999">
<center>Zhitomyr 2008-2015</center> <center>Zhitomyr 2008-2015</center>

View File

@ -30,7 +30,7 @@
char homepage[] = FROM "html\\homepage.htm""\0"; char homepage[] = FROM "html\\homepage.htm""\0";
#ifdef LANG_RUS #ifdef LANG_RUS
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.51"; char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.52";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­" ?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤" ?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>"; char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
@ -43,7 +43,7 @@ char rmb_menu[] =
Žç¨áâ¨âì ªíè ª à⨭®ª Žç¨áâ¨âì ªíè ª à⨭®ª
Œ¥­¥¤¦¥à § £à㧮ª"; Œ¥­¥¤¦¥à § £à㧮ª";
#else #else
char version[]="Text-based Browser 1.51"; char version[]="Text-based Browser 1.52";
?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last" ?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...<br>"; char loading[] = "Loading...<br>";
@ -212,6 +212,11 @@ void main()
$stosb; $stosb;
} while (AL != 0) && (AL != 13) && (AL != 10); } while (AL != 0) && (AL != 13) && (AL != 10);
DSBYTE[EDI-1]='\0'; DSBYTE[EDI-1]='\0';
if (!strcmp(#URL,"https://"))
{
notify("HTTPS protocol is not supported yet");
StopLoading();
}
} }
} }
else else
@ -313,7 +318,8 @@ void ProcessEvent(dword id__)
return; return;
case GOTOURL_BUTTON: case GOTOURL_BUTTON:
case SCAN_CODE_ENTER: case SCAN_CODE_ENTER:
if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') || (!strncmp(#editURL,"WebView:",9)) if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
{ {
strcpy(#URL, #editURL); strcpy(#URL, #editURL);
} }
@ -466,7 +472,6 @@ void ShowPage()
{ {
WB1.Prepare(); WB1.Prepare();
} }
//if (!header) strcpy(#header, #version);
if (!strcmp(#version, #header)) DrawTitle(#header); if (!strcmp(#version, #header)) DrawTitle(#header);
} }
@ -510,35 +515,24 @@ void ClickLink()
//#1 //#1
if (URL[0] == '#') if (URL[0] == '#')
{ {
strcpy(#anchor, #URL+strrchr(#URL, '#')); if (URL[1] == NULL) {
WB1.list.first = 0;
strcpy(#URL, history.current()); strcpy(#URL, history.current());
WB1.list.first=WB1.list.count-WB1.list.visible; }
else {
strlcpy(#anchor, #URL+strrchr(#URL, '#'), sizeof(anchor));
strcpy(#URL, history.current());
}
ShowPage(); ShowPage();
return; return;
} }
//liner.ru#1 //liner.ru#1
if (strrchr(#URL, '#')!=-1) if (strrchr(#URL, '#')!=0)
{ {
strcpy(#anchor, #URL+strrchr(#URL, '#')); strcpy(#anchor, #URL+strrchr(#URL, '#'));
URL[strrchr(#URL, '#')-1] = 0x00; URL[strrchr(#URL, '#')-1] = 0x00;
} }
GetAbsoluteURL(#URL);
if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1)
{
//notify(#URL);
if (!strncmp(#URL,"http://", 7))
{
strcpy(#downloader_edit, #URL);
CreateThread(#Downloader,#downloader_stak+4092);
}
else RunProgram("@open", #URL);
strcpy(#editURL, history.current());
strcpy(#URL, history.current());
return;
}
if (!strncmp(#URL,"mailto:", 7)) if (!strncmp(#URL,"mailto:", 7))
{ {
notify(#URL); notify(#URL);
@ -546,8 +540,37 @@ void ClickLink()
strcpy(#URL, history.current()); strcpy(#URL, history.current());
return; return;
} }
OpenPage();
if (!strcmp(#URL,"https://"))
{
notify("HTTPS protocol is not supported yet");
}
GetAbsoluteURL(#URL);
if (strncmp(#URL,"http://",7)!=0)
{
if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true)
{
RunProgram("/sys/@open", #URL);
strcpy(#editURL, history.current());
strcpy(#URL, history.current());
return; return;
} }
}
else
{
if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true)
|| (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true)
|| (UrlExtIs(".7z")==true) || (UrlExtIs("netcfg")==true) {
strcpy(#downloader_edit, #URL);
CreateThread(#Downloader,#downloader_stak+4092);
strcpy(#editURL, history.current());
strcpy(#URL, history.current());
return;
}
}
OpenPage();
}
stop: stop:

View File

@ -181,7 +181,7 @@ inline signed int strcmp(dword text1, text2)
return 0; return 0;
} }
inline signed int streq(dword text1, text2) { :bool strequ(dword text1, text2) {
if (!strcmp(text1,text2)) return true; else return false; if (!strcmp(text1,text2)) return true; else return false;
} }