forked from KolibriOS/kolibrios
WebView 2.2: pages cache, fast DrawBufer.Fill()
git-svn-id: svn://kolibrios.org@7764 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a3acc97488
commit
6aa36595f5
@ -400,7 +400,15 @@ void TWebBrowser::SetStyle() {
|
||||
if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
|
||||
if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;}
|
||||
if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
|
||||
//if (tag.is("dd")) { stolbec += 5; return; } //stolbec overflow!
|
||||
if (tag.is("dl")) {
|
||||
if (tag.opened) NewLine();
|
||||
return;
|
||||
}
|
||||
if (tag.is("dd")) {
|
||||
//NewLine();
|
||||
//if (tag.opened) stolbec += 5; //stolbec overflow!
|
||||
return;
|
||||
}
|
||||
if (tag.is("blockquote")) { style.blq = tag.opened; return; }
|
||||
if (tag.is("code")) {
|
||||
if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;
|
||||
|
@ -36,6 +36,7 @@ _history history;
|
||||
bool debug_mode = false;
|
||||
#include "..\TWB\TWB.c" //HTML Parser, a core component
|
||||
#include "texts.h"
|
||||
#include "cache.h"
|
||||
|
||||
TWebBrowser WB1;
|
||||
|
||||
@ -117,7 +118,7 @@ void main()
|
||||
int i, btn, redirect_count=0;
|
||||
LoadLibraries();
|
||||
CreateDir("/tmp0/1/Downloads");
|
||||
CreateDir("/tmp0/1/WebView_Cache");
|
||||
//CreateDir("/tmp0/1/WebView_Cache");
|
||||
Libimg_LoadImage(#skin, "/sys/toolbar.png");
|
||||
HandleParam();
|
||||
skin.h = 26;
|
||||
@ -231,6 +232,7 @@ void main()
|
||||
// Loading the page is complete, free resources
|
||||
redirect_count = 0;
|
||||
http.free();
|
||||
pages_cache.add(history.current(), http.content_pointer, http.content_received);
|
||||
LoadInternalPage(http.content_pointer, http.content_received);
|
||||
}
|
||||
}
|
||||
@ -450,15 +452,17 @@ void OpenPage(dword _open_URL)
|
||||
|
||||
history.add(#new_url);
|
||||
|
||||
//if (pages_cache.have(#new_url)) {
|
||||
// LoadInternalPage(pages_cache.current_page_buf, pages_cache.pages_cache.current_page_size);
|
||||
//} else
|
||||
if (!strncmp(#new_url,"WebView:",8)) {
|
||||
if (pages_cache.has(#new_url)) {
|
||||
//CACHED PAGE
|
||||
LoadInternalPage(pages_cache.current_page_buf, pages_cache.current_page_size);
|
||||
|
||||
} else if (!strncmp(#new_url,"WebView:",8)) {
|
||||
//INTERNAL PAGE
|
||||
if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage));
|
||||
else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help));
|
||||
else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
|
||||
else LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||
|
||||
} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
|
||||
//WEB PAGE
|
||||
if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
|
||||
|
34
programs/cmm/browser/cache.h
Normal file
34
programs/cmm/browser/cache.h
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
struct PAGES_CACHE
|
||||
{
|
||||
dword current_page_buf;
|
||||
dword current_page_size;
|
||||
collection url;
|
||||
collection data; //it has to be int
|
||||
collection size; //it has to be int
|
||||
void add();
|
||||
bool has();
|
||||
} pages_cache;
|
||||
|
||||
void PAGES_CACHE::add(dword _url, _data, _size)
|
||||
{
|
||||
dword data_pointer;
|
||||
data_pointer = malloc(_size);
|
||||
memmov(data_pointer, _data, _size);
|
||||
data.add(itoa(data_pointer));
|
||||
|
||||
url.add(_url);
|
||||
size.add(itoa(_size));
|
||||
}
|
||||
|
||||
bool PAGES_CACHE::has(dword _link)
|
||||
{
|
||||
int pos;
|
||||
pos = url.get_pos_by_name(_link);
|
||||
if (pos != -1) {
|
||||
current_page_buf = atoi(data.get(pos));
|
||||
current_page_size = atoi(size.get(pos));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
char version[]="WebView 2.15";
|
||||
char version[]="WebView 2.2";
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
||||
|
@ -49,9 +49,8 @@ void DrawBufer::Fill(dword start_pointer, i_fill_color)
|
||||
{
|
||||
dword i;
|
||||
dword max_i = bufw * bufh * 4 + buf_data + 8;
|
||||
EDI = fill_color = i_fill_color;
|
||||
for (ESI=buf_data+start_pointer+8; ESI<max_i; ESI+=4) ESDWORD[ESI] = EDI;
|
||||
//for (i=buf_data+start_pointer+8; i<max_i; i+=4) ESDWORD[i] = fill_color;
|
||||
fill_color = i_fill_color;
|
||||
MEMSETD(buf_data+start_pointer+8, max_i-buf_data-start_pointer-8/4, fill_color);
|
||||
}
|
||||
|
||||
void DrawBufer::DrawBar(dword x, y, w, h, color)
|
||||
@ -68,7 +67,7 @@ void DrawBufer::DrawBar(dword x, y, w, h, color)
|
||||
void DrawBufer::WriteText(dword x, y, byte fontType, dword color, str_offset)
|
||||
{
|
||||
#define BUGFIX_32000 32000
|
||||
int ydiv=0;
|
||||
dword ydiv=0;
|
||||
dword reserve_data_1, reserve_data_2;
|
||||
dword new_buf_offset;
|
||||
if (y + 30 >= bufh) IncreaseBufSize();
|
||||
|
@ -917,6 +917,15 @@ inline signed strcoll(dword text1,text2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// void * memset( ptr, value, num );
|
||||
// fills the memory with a dword
|
||||
// example: memset(str,'-', sizeof(str));
|
||||
inline void MEMSETD(EDI,ECX,EAX)
|
||||
{
|
||||
$REP
|
||||
$STOSD
|
||||
}
|
||||
|
||||
:replace_char(dword in_str, char from_char, to_char, int length) {
|
||||
int i;
|
||||
for (i=0; i<length; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user