From 42c9d954b20721aaf303cc2be372e9e78f75761d Mon Sep 17 00:00:00 2001 From: leency Date: Sun, 16 Mar 2025 20:35:12 +0200 Subject: [PATCH] webview 3.84 - tagicon support - draw_buf => BufIsInvalid() add check --- programs/cmm/browser/TWB/TWB.c | 3 +- programs/cmm/browser/TWB/parse_tag.h | 4 +- programs/cmm/browser/TWB/render.h | 2 +- programs/cmm/browser/TWB/set_style.h | 14 ++++++- programs/cmm/browser/WebView.c | 26 +++++++------ programs/cmm/browser/const.h | 2 +- programs/cmm/browser/res/test.htm | 57 ++++++++++++++-------------- programs/cmm/lib/draw_buf.h | 34 +++++++++++++++++ 8 files changed, 96 insertions(+), 46 deletions(-) diff --git a/programs/cmm/browser/TWB/TWB.c b/programs/cmm/browser/TWB/TWB.c index 49d610519..ab011956a 100644 --- a/programs/cmm/browser/TWB/TWB.c +++ b/programs/cmm/browser/TWB/TWB.c @@ -68,6 +68,7 @@ struct TWebBrowser { void tag_a(); void tag_p(); void tag_img(); + void tag_kosicon(); void tag_div(); void tag_h1234_caption(); void tag_ol_ul_dt(); @@ -176,7 +177,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ } } if (ESBYTE[bufpos] == '&') { - bufpos = GetUnicodeSymbol(#linebuf, sizeof(TWebBrowser.linebuf), bufpos+1, bufpointer+bufsize); + bufpos = GetUnicodeSymbol(#linebuf, sizeof(TWebBrowser.linebuf)-1, bufpos+1, bufpointer+bufsize); continue; } if (ESBYTE[bufpos] == '<') && (is_html) { diff --git a/programs/cmm/browser/TWB/parse_tag.h b/programs/cmm/browser/TWB/parse_tag.h index a39645b16..1efb57562 100644 --- a/programs/cmm/browser/TWB/parse_tag.h +++ b/programs/cmm/browser/TWB/parse_tag.h @@ -67,7 +67,7 @@ bool _tag::parse(dword _bufpos, bufend) if (!whitepos) || (whitepos > closepos) { //no param - strncpy(#name, bufpos, math.min(closepos - bufpos, sizeof(tag.name))); + strncpy(#name, bufpos, math.min(closepos - bufpos, sizeof(tag.name)-1)); bufpos = closepos; } else { //we have param @@ -76,7 +76,7 @@ bool _tag::parse(dword _bufpos, bufend) if (openpos < strchr(closepos+1, '>')) break; if (!closepos = EAX) {closepos = bufend;break;} } - strncpy(#name, bufpos, math.min(whitepos - bufpos, sizeof(tag.name))); + strncpy(#name, bufpos, math.min(whitepos - bufpos, sizeof(tag.name)-1)); bufpos = closepos; params = malloc(closepos - whitepos + 1); diff --git a/programs/cmm/browser/TWB/render.h b/programs/cmm/browser/TWB/render.h index f1968fb56..33bd1652f 100644 --- a/programs/cmm/browser/TWB/render.h +++ b/programs/cmm/browser/TWB/render.h @@ -151,7 +151,7 @@ bool TWebBrowser::RenderImage(dword cur_img) int img_x, img_y, img_w, img_h; dword imgbuf[44]; - if (!cur_img) return false; + if (!cur_img) || (!buf_data) return false; img_h = ESDWORD[cur_img+8]; img_w = ESDWORD[cur_img+4]; diff --git a/programs/cmm/browser/TWB/set_style.h b/programs/cmm/browser/TWB/set_style.h index 1f0e0393d..b04704c4b 100644 --- a/programs/cmm/browser/TWB/set_style.h +++ b/programs/cmm/browser/TWB/set_style.h @@ -10,6 +10,7 @@ void TWebBrowser::SetStyle() if (tag.is("a")) { tag_a(); return; } if (tag.is("p")) { tag_p(); return; } if (tag.is("img")) { tag_img(); return; } + if (tag.is("kosicon")) { tag_kosicon(); return; } if (tag.is("div")) { tag_div(); return; } if (tag.is("br")) { /*draw_x++;*/NewLine(); return; } if (tag.is("nav")) { style.nav = tag.opened; return; } @@ -266,6 +267,17 @@ void TWebBrowser::tag_h1234_caption() } } +void TWebBrowser::tag_kosicon() +{ + dword imgbuf[44]; + dword shared_i18 = memopen("ICONS18", NULL, SHM_READ); + if (shared_i18) && (tag.get_number_of("n")) { + if (draw_x + 18 > canvas.bufw) NewLine(); + canvas.DrawImage(draw_x, draw_y-2, 18, 18, 18*18*4*tag.number+shared_i18); + draw_x += 22; + } + +} void TWebBrowser::tag_img() { @@ -305,7 +317,7 @@ void TWebBrowser::tag_img() img_decode stdcall (cache.current_buf, cache.current_size, 0); if (EAX) goto IMGOK; else goto NOIMG; } else { - img_url.add(#img_path); + if (img_url.get_pos_by_name(#img_path)==-1) img_url.add(#img_path); goto NOIMG; } diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 83022c6b0..c3ee16334 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -79,7 +79,7 @@ char default_dir[] = "/sys"; od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" }; char editURL[URL_SIZE+1]; -edit_box omnibox_edit = {, 0, 0, 0xffffff, +edit_box omnibox_edit = {250, 0, 0, 0xffffff, 0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19}; //===================================================// @@ -258,6 +258,7 @@ void main() free(http.content_pointer); GetImg(false); } + debugln("end evNetwork"); } break; default: @@ -516,7 +517,6 @@ bool GetLocalFileData(dword _path) bool GetUrl(dword _http_url) { char new_url_full[URL_SIZE+1]; - if (!strncmp(_http_url,"http:",5)) { http.get(_http_url); return true; @@ -571,10 +571,10 @@ void OpenPage(dword _open_URL) //INTERNAL PAGE history.add(#new_url); WB1.custom_encoding = -1; - if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home)); - else if (streq(#new_url, URL_SERVICE_TEST)) LoadInternalPage(#buildin_page_test, sizeof(buildin_page_test)); + if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home)-1); + else if (streq(#new_url, URL_SERVICE_TEST)) LoadInternalPage(#buildin_page_test, sizeof(buildin_page_test)-1); else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory(); - else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); + else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)-1); } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { //WEB PAGE @@ -589,7 +589,7 @@ void OpenPage(dword _open_URL) if (!http.transfer) { history.add(#new_url); - LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); + LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)-1); } } else { //LOCAL PAGE @@ -602,7 +602,7 @@ void OpenPage(dword _open_URL) strcpy(#new_url, "/tmp0/1/temp/word/document.xml"); } if (!GetLocalFileData(#new_url)) { - LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); + LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)-1); } } } @@ -712,7 +712,7 @@ void EventSubmitOmnibox() void LoadInternalPage(dword _bufdata, _in_bufsize){ if (!_bufdata) || (!_in_bufsize) { - LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)); + LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error)-1); } else { WB1.list.first = 0; //scroll page to the top DrawOmnibox(); @@ -920,7 +920,7 @@ dword GetAbsoluteActiveURL() void CheckContentType() { char content_type[64]; - if (http.header_field("content-type", #content_type, sizeof(content_type))) // application || image + if (http.header_field("content-type", #content_type, sizeof(content_type)-1)) // application || image if (content_type[0] == 'i') { EventDownloadAndOpenImage(http.cur_url); @@ -968,12 +968,14 @@ dword GetImg(bool _new) for (i = 0; i < WB1.img_url.count; i++) { cur_img_url = WB1.img_url.get(i); - if (debug_mode) - {debug("get img: ");debugln(cur_img_url);} if (cache.has(cur_img_url)==false) { prbar.max = WB1.img_url.count; prbar.value = i; - if (GetUrl(cur_img_url)) {DrawStatusBar(cur_img_url); DrawProgress(); return;} + if (GetUrl(cur_img_url)) { + DrawStatusBar(cur_img_url); + DrawProgress(); + return; + } } } if (_new) return; diff --git a/programs/cmm/browser/const.h b/programs/cmm/browser/const.h index 8843bed40..79b5621ae 100644 --- a/programs/cmm/browser/const.h +++ b/programs/cmm/browser/const.h @@ -112,4 +112,4 @@ char editbox_icons[] = FROM "res/editbox_icons.raw"; #define DEFAULT_URL URL_SERVICE_HOMEPAGE -char version[]="WebView 3.83"; \ No newline at end of file +char version[]="WebView 3.84"; \ No newline at end of file diff --git a/programs/cmm/browser/res/test.htm b/programs/cmm/browser/res/test.htm index 434bbb40c..298349f9d 100644 --- a/programs/cmm/browser/res/test.htm +++ b/programs/cmm/browser/res/test.htm @@ -2,38 +2,39 @@ TEST -
wiby.org
-OSX network cards
-Macintosh Garden
 
-
Simplest: -nostalgy.net.ru +

HTTP

+Total Hardware 1999 +wiby.org +menuetos.net +Macintosh Garden pci.ids -dgmag.in -bash.im -opennet -LOR -samlib.ru/b -mirrors.pdp-11.ru ATI drivers for Mac -
Simple: -lionovsky.us +GUI Gallery +weitek +abandonware +electromyne.de +neonfloppy +win31.de + +

VPN-only

+dgmag.in +fdd5-25 +old-dos.ru +artcon.ru +nubo.ru +mirrors.pdp-11.ru +nostalgy.net.ru + +

HTTPS :(

os-menuet.narod.ru mestack.narod.ru coolthemes.narod.ru -vetusware.com -Total Hardware 1999 -GUI Gallery -menuetos.net -
-Moderate: -fdd5-25 +lionovsky.us acmp.ru -old-dos.ru -weitek -abandonware -Complex: -artcon.ru -nubo.ru -electromyne.de -thg \ No newline at end of file +bashorg +opennet +LOR +OSX network cards +samlib.ru/b +vetusware.com diff --git a/programs/cmm/lib/draw_buf.h b/programs/cmm/lib/draw_buf.h index 70c9ed3fe..2f9cbac49 100644 --- a/programs/cmm/lib/draw_buf.h +++ b/programs/cmm/lib/draw_buf.h @@ -17,17 +17,25 @@ struct CANVAS { void Show(); void Fill(); void DrawBar(); + void DrawImage(); void WriteText(); void PutPixel(); void AlignCenter(); void AlignRight(); void IncreaseBufSize(); + bool BufIsInvalid(); }; char draw_buf_not_enaught_ram[] = "'CANVAS requested %i MB more memory than the system has. Application could be unstable.' -E"; +bool CANVAS::BufIsInvalid() +{ + if (!buf_data) || (!bufw) return true; + return false; +} + bool CANVAS::Init(dword i_bufx, i_bufy, i_bufw, i_bufh) { bufx = i_bufx; @@ -45,6 +53,7 @@ bool CANVAS::Init(dword i_bufx, i_bufy, i_bufw, i_bufh) void CANVAS::Fill(dword start_pointer, i_fill_color) { dword max_i = bufw * bufh * 4 - start_pointer/4; + if (BufIsInvalid()) return; fill_color = i_fill_color | 0xFF000000; //set background color non-transparent @MEMSETD(buf_data+start_pointer+8, max_i, fill_color); } @@ -52,6 +61,7 @@ void CANVAS::Fill(dword start_pointer, i_fill_color) void CANVAS::DrawBar(dword x, y, w, h, color) { dword i, j; + if (BufIsInvalid()) return; if (y + h >= bufh) IncreaseBufSize(); for (j=0; j= bufh) IncreaseBufSize(); //WHY NOT WORKING? + for (j=0; j= bufh) IncreaseBufSize(); if (y < BUGFIX_32000) { ESI = strlen; @@ -92,6 +120,7 @@ void CANVAS::WriteText(dword x, y, byte fontType, dword color, str_offset, strle void CANVAS::PutPixel(dword x, y, color) { dword pos = y*bufw+x*4+8+buf_data; + if (BufIsInvalid()) return; ESDWORD[pos] = color; } @@ -99,6 +128,7 @@ void CANVAS::AlignRight(dword x,y,w,h, content_width) { dword i, j, l; dword content_left = w - content_width / 2; + if (BufIsInvalid()) return; for (j=0; j=j*w+content_left*4) && (l>=j*w*4); i-=4, l-=4) @@ -112,6 +142,7 @@ void CANVAS::AlignCenter(dword x,y,w,h, content_width) { dword i, j, l; dword content_left = w - content_width / 2; + if (BufIsInvalid()) return; for (j=0; j=j*w+content_left*4) && (l>=j*w*4); i-=4, l-=4) @@ -123,6 +154,7 @@ void CANVAS::AlignCenter(dword x,y,w,h, content_width) void CANVAS::Show(dword _y_offset, _h) { + if (BufIsInvalid()) return; PutPaletteImage(_y_offset * bufw * 4 + buf_data+8, bufw, _h, bufx, bufy, 32, 0); } @@ -133,6 +165,8 @@ void CANVAS::IncreaseBufSize() dword free_ram_size; char error_str[256]; + if (!bufw) return; + if (!buf_data) { alloc_size = bufh * bufw * 4 + 8; buf_data = malloc(alloc_size);