WebView 3.27: do not draw scroll for a short page, better handle wrong code

git-svn-id: svn://kolibrios.org@8490 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-12-28 19:20:59 +00:00
parent f2523cedaa
commit 0aaee5cee7
7 changed files with 82 additions and 62 deletions

View File

@ -115,6 +115,7 @@ void TWebBrowser::SetPageDefaults()
cur_encoding = custom_encoding;
bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
}
list.SetFont(8, 14, 10011000b);
}
//============================================================================================
void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
@ -150,7 +151,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
Render();
NewLine();
} else {
AddCharToTheLine(0x0a);
AddCharToTheLine(' ');
}
break;
case 0x09:
@ -159,7 +160,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len;
for (j=0; j<tab_len; j++;) chrcat(#line,' ');
} else {
AddCharToTheLine(0x09);
AddCharToTheLine(' ');
}
break;
case '&': //&nbsp; and so on
@ -176,15 +177,8 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
break;
case '<':
if (!is_html) goto _DEFAULT;
if (!strchr("!/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", ESBYTE[bufpos+1])) goto _DEFAULT;
bufpos++;
switch (ESBYTE[bufpos]) {
case '!': case '/': case '?':
case 'a'...'z': case 'A'...'Z':
goto _TAG;
default:
goto _DEFAULT;
}
_TAG:
if (tag.parse(#bufpos, bufpointer + bufsize)) {
CheckForLineBreak();
Render();
@ -314,6 +308,11 @@ void TWebBrowser::DrawPage()
scroll_wv.start_x = list.x + list.w;
scroll_wv.start_y = list.y;
scroll_wv.size_y = list.h;
scrollbar_v_draw(#scroll_wv);
if (list.count <= list.visible) {
DrawBar(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x,
scroll_wv.size_y, bg_colors.get(0) & 0x00FFFFFF);
} else {
scrollbar_v_draw(#scroll_wv);
}
}

View File

@ -31,6 +31,7 @@ bool _tag::parse(dword _bufpos, bufend)
dword closepos;
dword whitepos;
dword openpos;
if (name) strcpy(#prior, #name); else prior = '\0';
name = '\0';
@ -72,6 +73,19 @@ bool _tag::parse(dword _bufpos, bufend)
bufpos = closepos;
} else {
//we have param
while (chrlnum(whitepos, '\"', closepos - whitepos)%2) { //alt="Next>>"
/*
openpos = strchr(closepos+1, '<');
closepos = strchr(closepos+1, '>');
if (openpos) && (openpos < closepos) {
closepos = openpos - 1;
break;
}
*/
if (!openpos = strchr(closepos+1, '<')) break;
if (openpos < strchr(closepos+1, '>')) break;
if (!closepos = EAX) {closepos = bufend;break;}
}
strncpy(#name, bufpos, math.min(whitepos - bufpos, sizeof(tag.name)));
debug_tag();
bufpos = closepos;

View File

@ -52,16 +52,9 @@ void TWebBrowser::SetStyle()
if (tag.is("html")) { t_html = tag.opened; return; }
//TO BE REWORKED
//td_x = td_w = tr_y = highest_td = 0;
//if (tag.is("table")) { tag_table(); return; }
//if (tag.is("td")) { tag_td(); return; }
//if (tag.is("tr")) { tag_tr(); return; }
if (tag.is("dd")) {
//NewLine();
//if (tag.opened) stolbec += 5; //may overflow!
return;
}
//if (tag.is("td")) { tag_td(); return; }
}
void TWebBrowser::tag_p()
@ -101,6 +94,8 @@ void TWebBrowser::tag_font()
void TWebBrowser::tag_div()
{
if (streq(#tag.prior,"div")) && (tag.opened) return;
if (streq(#tag.prior,"td")) return;
//if (streq(#tag.prior,"div")) return;
if (!tag.opened) && (style.font) text_colors.pop();
NewLine();
}
@ -287,6 +282,7 @@ void TWebBrowser::tag_img()
if (!strcmp(tag.value + strrchr(tag.value, '.'), "webp")) goto NOIMG;
strlcpy(#img_path, tag.value, sizeof(img_path)-1);
replace_char(#img_path, ' ', '\0', sizeof(img_path));
get_absolute_url(#img_path, history.current());
if (check_is_the_adress_local(#img_path)) {

View File

@ -41,10 +41,6 @@
// DATA //
// //
//===================================================//
char version[]="WebView 3.26";
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
bool debug_mode = false;
bool show_images = true;
@ -144,11 +140,13 @@ void main()
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
scrollbar_v_mouse (#scroll_wv);
if (scroll_wv.delta2) {
WB1.list.first = scroll_wv.position;
WB1.DrawPage();
break;
if (WB1.list.count > WB1.list.visible) {
scrollbar_v_mouse (#scroll_wv);
if (scroll_wv.delta2) {
WB1.list.first = scroll_wv.position;
WB1.DrawPage();
break;
}
}
if (links.hover(WB1.list.y, WB1.list.first))
@ -187,8 +185,9 @@ void main()
break;
case evReDraw:
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),
GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2-random(80),GetScreenHeight()-WIN_H/2-random(80),
//DefineAndDrawWindow(0,0,
WIN_W,WIN_H,0x73,0,0,0);
GetProcessInfo(#Form, SelfInfo);
ProcessMenuClick();
sc.get();
@ -410,11 +409,11 @@ void EventToggleDebugMode()
void EventAllTabsClick(dword _n)
{
if (http.transfer) return;
if (mouse.mkm) {
StopLoading();
EventTabClose(_n);
} else {
EventTabClick(_n);
if (!http.transfer) EventTabClick(_n);
}
}

View File

@ -1,4 +1,9 @@
#ifdef LANG_RUS
//===================================================//
// //
// CYRILLIC //
// //
//===================================================//
char buildin_page_error[] = FROM "res/page_not_found_ru.htm""\0";
char buildin_page_home[] = FROM "res/homepage_ru.htm""\0";
char buildin_page_help[] = FROM "res/help_ru.htm""\0";
@ -31,6 +36,11 @@ char clear_cache_ok[] = "'WebView\n
#define T_RENDERING "<22>¥­¤¥à¨­£ áâà ­¨æë..."
#define T_DONE_IN_SEC "ƒ®â®¢®: %i ᥪ"
#else
//===================================================//
// //
// ENGLISH //
// //
//===================================================//
char buildin_page_error[] = FROM "res/page_not_found_en.htm""\0";
char buildin_page_home[] = FROM "res/homepage_en.htm""\0";
char buildin_page_help[] = FROM "res/help_en.htm""\0";
@ -63,12 +73,18 @@ char clear_cache_ok[] = "'WebView\nThe cache has been cleared.' -tI";
#define T_DONE_IN_SEC "Done in %i sec"
#endif
//===================================================//
// //
// GLOBAL //
// //
//===================================================//
char buildin_page_test[] = FROM "res/test.htm""\0";
#define URL_SERVICE_HISTORY "WebView:history"
#define URL_SERVICE_HISTORY "WebView:history"
#define URL_SERVICE_HOMEPAGE "WebView:home"
#define URL_SERVICE_HELP "WebView:help"
#define URL_SERVICE_TEST "WebView:test"
#define URL_SERVICE_HELP "WebView:help"
#define URL_SERVICE_TEST "WebView:test"
char webview_shared[] = "WEBVIEW";
@ -84,4 +100,11 @@ enum {
TAB_CLOSE_ID = 900
};
char editbox_icons[] = FROM "res/editbox_icons.raw";
char editbox_icons[] = FROM "res/editbox_icons.raw";
#define WIN_W 850
#define WIN_H 920
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
char version[]="WebView 3.27";

View File

@ -7,7 +7,7 @@
#define TABS_MAX 5
TWebBrowser data[TABS_MAX+1]=0;
TWebBrowser tabdata[TABS_MAX+1]=0;
_history tabstory[TABS_MAX+1]=0;
struct TAB
@ -36,7 +36,7 @@ bool TAB::close(int _tab_number)
int i;
if (count==1) return false;
for (i=_tab_number; i<TABS_MAX; i++) {
data[i] = data[i+1];
tabdata[i] = tabdata[i+1];
tabstory[i] = tabstory[i+1];
}
if (_tab_number<active) && (active>0) active--;
@ -48,13 +48,13 @@ bool TAB::close(int _tab_number)
void TAB::save_state()
{
tabstory[active] = history;
data[active] = WB1;
tabdata[active] = WB1;
}
void TAB::restore(int _id)
{
tab.active = _id;
WB1 = data[_id];
WB1 = tabdata[_id];
history = tabstory[_id];
}
@ -90,8 +90,8 @@ void DrawTab(int _id)
bgcol=sc.work;
border_bottom_color = sc.work_graph;
}
if (data[_id].header) {
strncpy(#header_no_version, #data[_id].header, strlen(#data[_id].header)-sizeof(version)-2);
if (tabdata[_id].header) {
strncpy(#header_no_version, #tabdata[_id].header, strlen(#tabdata[_id].header)-sizeof(version)-2);
strncpy(#name, #header_no_version, tab_w-CLOSE_S/6-2);
}
DrawBar(xxx, TOOLBAR_H, 1, TAB_H, sc.work_dark);

View File

@ -16,15 +16,6 @@
char a_libdir[43] = "/sys/lib/\0";
:inline void error_init(dword lirary_path)
{
char error_text[1024];
strcpy(#error_text, _TEXT_ERROR_ADD);
strcat(#error_text, lirary_path);
strcat(#error_text, "' -E");
notify(#error_text);
}
// stdcall with 1 parameter
:void dll_Load() {
asm {
@ -188,9 +179,8 @@ asm {
}
}
:int load_dll2(dword dllname, import_table, byte need_init)
:void load_dll(dword dllname, import_table, byte need_init)
{
//dword dllentry=0;
// load DLL
$mov eax, 68
$mov ebx, 19
@ -237,19 +227,18 @@ asm {
#ifndef NO_DLL_INIT
IF (need_init) dll_Init (DSDWORD[EDX+4]);
#endif
return 0;
return;
@exit01:
return -1;
error_init(dllname);
}
:byte load_dll(dword dllname, import_table, byte need_init)
:inline void error_init(dword lirary_path)
{
if (load_dll2(dllname, import_table, need_init))
{
error_init(dllname);
return false;
}
return true;
char error_text[1024];
strcpy(#error_text, _TEXT_ERROR_ADD);
strcat(#error_text, lirary_path);
strcat(#error_text, "' -E");
notify(#error_text);
}