WebView: small fixes

git-svn-id: svn://kolibrios.org@8302 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-12-02 14:21:06 +00:00
parent f05eecb7a1
commit cd00029f0e
3 changed files with 37 additions and 16 deletions

View File

@ -52,6 +52,7 @@ struct TWebBrowser {
void ChangeEncoding();
void DrawPage();
char header[150];
char redirect[URL_SIZE];
};
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
@ -137,6 +138,7 @@ void TWebBrowser::SetPageDefaults()
stolbec = 0;
line = 0;
zoom = 1;
redirect = '\0';
//hold original buffer
if (o_bufpointer) o_bufpointer=free(o_bufpointer);
o_bufpointer = malloc(bufsize);
@ -532,16 +534,22 @@ void TWebBrowser::SetStyle() {
draw_y += 10;
return;
}
if (tag.is("meta")) {
if (streq(tag.get_value_of("http-equiv="), "refresh")) && (value = tag.get_value_of("content=")) {
if (value = strstri(value, "url=")) strcpy(#redirect, value);
}
}
if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) {
if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding="))
{
value += strrchr(value, '='); //search in content=
if (ESBYTE[value] == '"') value++;
strlwr(value);
if (streq(value,"utf-8")) || (streq(value,"utf8")) ChangeEncoding(CH_UTF8);
else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) ChangeEncoding(CH_CP1251);
else if (streq(value,"dos")) || (streq(value,"cp-866")) ChangeEncoding(CH_CP866);
else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) ChangeEncoding(CH_ISO8859_5);
else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) ChangeEncoding(CH_KOI8);
if (streqrp(value,"utf-8")) || (streqrp(value,"utf8")) { ChangeEncoding(CH_UTF8); debugln("UTF"); }
else if (streqrp(value,"windows-1251")) || (streqrp(value,"windows1251")) ChangeEncoding(CH_CP1251);
else if (streqrp(value,"dos")) || (streqrp(value,"cp-866")) ChangeEncoding(CH_CP866);
else if (streqrp(value,"iso-8859-5")) || (streqrp(value,"iso8859-5")) ChangeEncoding(CH_ISO8859_5);
else if (streqrp(value,"koi8-r")) || (streqrp(value,"koi8-u")) ChangeEncoding(CH_KOI8);
}
return;
}

View File

@ -32,7 +32,7 @@
char editbox_icons[] = FROM "res/editbox_icons.raw";
char version[]="WebView 2.7";
char version[]="WebView 2.7a";
#include "texts.h"
#include "cache.h"
@ -238,7 +238,8 @@ void main()
if (http.transfer <= 0) break;
http.receive();
EventUpdateProgressBar();
if (http.check_content_type()) && (!strncmp(#http.content_type,"application",11)) {
if (http.check_content_type()) // application || image
if (http.content_type[0] == 'a') || (http.content_type[0] == 'i') {
EventOpenDownloader(history.current());
StopLoading();
history.back();
@ -705,13 +706,6 @@ void EventClickLink(dword _target)
}
return;
}
} else {
if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true)
|| (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true)
|| (UrlExtIs(#new_url,".7z")==true) {
EventOpenDownloader(#new_url);
return;
}
}
OpenPage(#new_url);
}
@ -741,6 +735,14 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){
DrawOmnibox();
}
WB1.ParseHtml(_bufdata, _in_bufsize);
// REJECTED. Reason: infinite redirect at Google Results.
/*
if (WB1.redirect) { //<meta http-equiv="refresh" content="0; url=http://site.com">
get_absolute_url(#WB1.redirect, history.current());
history.back();
OpenPage(#WB1.redirect);
}
*/
DrawStatusBar();
DrawActiveTab();
if (source_mode) {

View File

@ -206,7 +206,7 @@ inline signed int strcmp(dword text1, text2)
}
inline fastcall streq(ESI, EDI)
inline fastcall bool streq(ESI, EDI)
{
loop()
{
@ -220,7 +220,18 @@ inline fastcall streq(ESI, EDI)
ESI++;
EDI++;
}
return true;
}
inline fastcall bool streqrp(ESI, EDI) //streq right part
{
if(DSBYTE[ESI]==0) || (DSBYTE[EDI]==0) return false;
loop()
{
if(DSBYTE[EDI]==0) return true;
if(DSBYTE[ESI]!=DSBYTE[EDI]) return false;
ESI++;
EDI++;
}
}
inline fastcall void strcpy( EDI, ESI)