mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-26 00:26:52 +03:00
WebView 1.0 Beta 2: a lot of fixes & small changes
git-svn-id: svn://kolibrios.org@4686 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
0119593da0
commit
c23bb9bf23
@ -1,5 +1,3 @@
|
||||
#include "..\TWB\links.h"
|
||||
|
||||
dword bufpointer;
|
||||
dword o_bufpointer;
|
||||
dword bufsize;
|
||||
@ -13,16 +11,13 @@ char header[2048];
|
||||
struct TWebBrowser {
|
||||
llist list;
|
||||
DrawBufer DrawBuf;
|
||||
void GetNewUrl();
|
||||
void Prepare();
|
||||
void Parse();
|
||||
void SetTextStyle();
|
||||
void DrawPage();
|
||||
void DrawScroller();
|
||||
void NewLine();
|
||||
};
|
||||
|
||||
TWebBrowser WB1;
|
||||
} WB1;
|
||||
|
||||
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
|
||||
link, ignor_text, cur_encoding, text_align, t_html, t_body;
|
||||
@ -51,6 +46,7 @@ char options[4096];
|
||||
char anchor[256];
|
||||
|
||||
#include "..\TWB\history.h"
|
||||
#include "..\TWB\links.h"
|
||||
#include "..\TWB\colors.h"
|
||||
#include "..\TWB\unicode_tags.h"
|
||||
#include "..\TWB\img_cache.h"
|
||||
@ -98,48 +94,6 @@ void TWebBrowser::DrawPage()
|
||||
//=======================================================================
|
||||
|
||||
|
||||
|
||||
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0};
|
||||
void TWebBrowser::GetNewUrl(){
|
||||
int i, len;
|
||||
char newurl[4096];
|
||||
|
||||
for (i=0; ABSOLUTE_LINKS[i]; i++)
|
||||
{
|
||||
len=strlen(ABSOLUTE_LINKS[i]);
|
||||
if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return;
|
||||
}
|
||||
|
||||
IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2);
|
||||
strcpy(#newurl, BrowserHistory.CurrentUrl());
|
||||
|
||||
if (URL[0] == '/')
|
||||
{
|
||||
i = strchr(#newurl+8, '/');
|
||||
if (i>0) newurl[i+7]=0;
|
||||
strcpy(#URL, #URL+1);
|
||||
}
|
||||
|
||||
_CUT_ST_LEVEL_MARK:
|
||||
|
||||
if (newurl[strrchr(#newurl, '/')-2]<>'/')
|
||||
{
|
||||
newurl[strrchr(#newurl, '/')] = 0x00;
|
||||
}
|
||||
|
||||
IF (!strncmp(#URL,"../",3))
|
||||
{
|
||||
strcpy(#URL,#URL+3);
|
||||
newurl[strrchr(#newurl, '/')-1] = 0x00;
|
||||
goto _CUT_ST_LEVEL_MARK;
|
||||
}
|
||||
|
||||
if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
|
||||
|
||||
strcat(#newurl, #URL);
|
||||
strcpy(#URL, #newurl);
|
||||
}
|
||||
|
||||
void BufEncode(int set_new_encoding)
|
||||
{
|
||||
int bufpointer_realsize;
|
||||
@ -213,6 +167,7 @@ void TWebBrowser::Parse(){
|
||||
case 0x0a:
|
||||
if (pre_text)
|
||||
{
|
||||
chrcat(#line, ' ');
|
||||
bukva = temp = NULL;
|
||||
goto NEXT_MARK;
|
||||
}
|
||||
@ -324,12 +279,12 @@ void TWebBrowser::Parse(){
|
||||
NEXT_MARK:
|
||||
perenos_num = strrchr(#line, ' ');
|
||||
if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
|
||||
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
|
||||
strcpy(#temp, #line + perenos_num);
|
||||
line[perenos_num] = 0x00;
|
||||
if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
|
||||
if (stroka-1 > list.visible) && (list.first <>0) break 1;
|
||||
DrawPage();
|
||||
strcpy(#line, #temp);
|
||||
NewLine(list.x + 5, stroka * 10 + list.y + 5); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
|
||||
NewLine(list.x + 5, stroka * 10 + list.y + 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -373,7 +328,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = opened;
|
||||
if (isTag("script")) || (isTag("style")) || (isTag("binary")) || (isTag("select")) ignor_text = opened;
|
||||
|
||||
if(isTag("title"))
|
||||
{
|
||||
@ -481,7 +436,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
||||
NewLine(left1, top1);
|
||||
return;
|
||||
}
|
||||
if (isTag("div")) || (isTag("header")) || (isTag("footer")) {
|
||||
if (isTag("div")) || (isTag("header")) || (isTag("article")) || (isTag("footer")) {
|
||||
IF(oldtag[0] <>'h') NewLine(left1, top1);
|
||||
return;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ struct LinksArray
|
||||
void AddText();
|
||||
dword GetURL();
|
||||
void Clear();
|
||||
void GetAbsoluteURL();
|
||||
};
|
||||
|
||||
void LinksArray::AddLink(dword new_link, int link_x, link_y)
|
||||
@ -63,7 +64,7 @@ void LinksArray::Clear()
|
||||
CursorPointer.Restore();
|
||||
}
|
||||
|
||||
char temp[4096];
|
||||
char temp[sizeof(URL)];
|
||||
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0};
|
||||
|
||||
void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
|
||||
@ -97,5 +98,48 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
|
||||
}
|
||||
}
|
||||
|
||||
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/",
|
||||
"/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", "WebView:", 0};
|
||||
void LinksArray::GetAbsoluteURL(dword in_URL){
|
||||
int i, len;
|
||||
dword orig_URL = in_URL;
|
||||
char newurl[sizeof(URL)];
|
||||
|
||||
for (i=0; ABSOLUTE_LINKS[i]; i++)
|
||||
{
|
||||
len=strlen(ABSOLUTE_LINKS[i]);
|
||||
if (!strcmpn(in_URL, ABSOLUTE_LINKS[i], len)) return;
|
||||
}
|
||||
IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
|
||||
strcpy(#newurl, BrowserHistory.CurrentUrl());
|
||||
|
||||
if (ESBYTE[in_URL] == '/')
|
||||
{
|
||||
i = strchr(#newurl+8, '/');
|
||||
if (i>0) newurl[i+7]=0;
|
||||
in_URL+=1;
|
||||
}
|
||||
|
||||
_CUT_ST_LEVEL_MARK:
|
||||
|
||||
if (newurl[strrchr(#newurl, '/')-2]<>'/')
|
||||
{
|
||||
newurl[strrchr(#newurl, '/')] = 0x00;
|
||||
}
|
||||
|
||||
IF (!strncmp(in_URL,"../",3))
|
||||
{
|
||||
in_URL+=3;
|
||||
newurl[strrchr(#newurl, '/')-1] = 0x00;
|
||||
goto _CUT_ST_LEVEL_MARK;
|
||||
}
|
||||
|
||||
if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
|
||||
|
||||
strcat(#newurl, in_URL);
|
||||
strcpy(orig_URL, #newurl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
LinksArray PageLinks;
|
||||
|
@ -29,14 +29,14 @@
|
||||
char homepage[] = FROM "html\homepage.htm";
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.0 Beta 1";
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.0 Beta 2";
|
||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||
char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
||||
char accept_language[]= "Accept-Language: ru\n";
|
||||
#else
|
||||
char version[]=" Text-based Browser 1.0 Beta 1";
|
||||
char version[]=" Text-based Browser 1.0 Beta 2";
|
||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||
?define T_LAST_SLIDE "This slide is the last"
|
||||
char loading[] = "Loading...<br>";
|
||||
@ -67,7 +67,7 @@ dword col_bg = 0xE4DFE1;
|
||||
dword panel_color = 0xF1F1F1;
|
||||
dword border_color = 0x9F9F9F;
|
||||
|
||||
pb progress_bar = {0, 10, 83, 150, 13, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
|
||||
pb progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
|
||||
|
||||
#include "..\TWB\TWB.c"
|
||||
#include "menu_rmb.h"
|
||||
@ -89,19 +89,30 @@ struct skin {
|
||||
int LoadSkin()
|
||||
{
|
||||
skin.image = load_image(abspath("wv_skin.png"));
|
||||
if (!skin.image) notify("WebView skin file 'wv_skin.png' not found, program will terminate");
|
||||
skin.w = DSWORD[skin.image+4];
|
||||
skin.h = DSWORD[skin.image+8];
|
||||
}
|
||||
|
||||
void DrawProgress()
|
||||
{
|
||||
unsigned long btn;
|
||||
//progressbar_draw stdcall(#progress_bar);
|
||||
progress_bar.width = progress_bar.left = 0;
|
||||
if (http_transfer == 0) return;
|
||||
if (progress_bar.max) btn = address_box.width*progress_bar.value/progress_bar.max; else btn = 30;
|
||||
DrawBar(address_box.left-1, address_box.top+14, btn, 2, progress_bar.progress_color);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
int key, btn;
|
||||
unsigned long key, btn;
|
||||
int half_scroll_size;
|
||||
int scroll_used=0, show_menu;
|
||||
|
||||
mem_Init();
|
||||
CursorPointer.Load(#CursorFile);
|
||||
if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
|
||||
if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj");
|
||||
if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
|
||||
if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
|
||||
if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
|
||||
@ -192,8 +203,11 @@ void main()
|
||||
$push EAX
|
||||
ESI = http_transfer;
|
||||
progress_bar.max = ESI.http_msg.content_length;
|
||||
progress_bar.value = ESI.http_msg.content_received;
|
||||
progressbar_draw stdcall(#progress_bar);
|
||||
if (progress_bar.value != ESI.http_msg.content_received)
|
||||
{
|
||||
progress_bar.value = ESI.http_msg.content_received;
|
||||
DrawProgress();
|
||||
}
|
||||
$pop EAX
|
||||
if (EAX == 0) {
|
||||
ESI = http_transfer;
|
||||
@ -228,13 +242,13 @@ void main()
|
||||
{
|
||||
http_free stdcall (http_transfer);
|
||||
http_transfer=0;
|
||||
WB1.GetNewUrl();
|
||||
PageLinks.GetAbsoluteURL(#URL);
|
||||
strcpy(#editURL, #URL);
|
||||
BrowserHistory.current--;
|
||||
OpenPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
BrowserHistory.AddUrl();
|
||||
ESI = http_transfer;
|
||||
bufpointer = ESI.http_msg.content_ptr;
|
||||
bufsize = ESI.http_msg.content_received;
|
||||
@ -274,7 +288,8 @@ void Draw_Window()
|
||||
// }
|
||||
DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg);
|
||||
DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color);
|
||||
DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-2, panel_color);
|
||||
DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color);
|
||||
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xe9e9e9);
|
||||
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
|
||||
img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0);
|
||||
|
||||
@ -299,7 +314,7 @@ void Draw_Window()
|
||||
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
|
||||
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
|
||||
progress_bar.top = Form.cheight - STATUSBAR_H + 4;
|
||||
progressbar_draw stdcall(#progress_bar);
|
||||
DrawProgress();
|
||||
}
|
||||
|
||||
|
||||
@ -478,7 +493,7 @@ void ProcessLinks(int id)
|
||||
URL[strrchr(#URL, '#')-1] = 0x00;
|
||||
}
|
||||
|
||||
WB1.GetNewUrl();
|
||||
PageLinks.GetAbsoluteURL(#URL);
|
||||
|
||||
if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
|
||||
{
|
||||
@ -533,7 +548,6 @@ void OpenPage()
|
||||
{
|
||||
StopLoading();
|
||||
strcpy(#editURL, #URL);
|
||||
BrowserHistory.AddUrl();
|
||||
if (strncmp(#URL,"WebView:",8)==0) return;
|
||||
if (strncmp(#URL,"http:",5)==0)
|
||||
{
|
||||
@ -551,6 +565,7 @@ void OpenPage()
|
||||
}
|
||||
else
|
||||
{
|
||||
BrowserHistory.AddUrl();
|
||||
file_size stdcall (#URL);
|
||||
bufsize = EBX;
|
||||
if (bufsize)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.1 KiB |
@ -60,7 +60,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent, status_text)
|
||||
:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent)
|
||||
{
|
||||
int progress_w;
|
||||
static int fill_old;
|
||||
@ -77,13 +77,6 @@
|
||||
DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill);
|
||||
DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff);
|
||||
}
|
||||
|
||||
if (status_text)
|
||||
{
|
||||
DrawBar(st_x+st_w+15, st_h/2-4+st_y, fill_old, 9, col_fon);
|
||||
WriteText(st_x+st_w+15, st_h/2-4+st_y, 0x80, col_text, status_text);
|
||||
fill_old = strlen(status_text) * 6;
|
||||
}
|
||||
}
|
||||
|
||||
:void DrawLink(dword x,y,font_type,btn_id, inscription)
|
||||
|
Loading…
Reference in New Issue
Block a user