From 54ecc4142910123fd78c8f7c6131f8154cc68070 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 10 Apr 2014 00:23:00 +0000 Subject: user_help fix character reference --- doc/user_help.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user_help.html b/doc/user_help.html index 9de2056f..88218f70 100644 --- a/doc/user_help.html +++ b/doc/user_help.html @@ -314,7 +314,7 @@

Example, in dillorc:

- search_url="dd Duckduckgo http://duckduckgo.com/lite/?kp=-1&q=%s" + search_url="dd Duckduckgo http://duckduckgo.com/lite/?kp=-1&q=%s"
means you can reach the location bar (CTRL+L), then type:
-- cgit v1.2.3 From 1d8b1db0a810d076bb0f831f1232d71985456b31 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 15 Apr 2014 21:49:30 +0000 Subject: startpage in search urls brought up on list; no objections --- dillorc | 1 + 1 file changed, 1 insertion(+) diff --git a/dillorc b/dillorc index 7395abd3..0d16bbda 100644 --- a/dillorc +++ b/dillorc @@ -161,6 +161,7 @@ search_url="dd DuckDuckGo http://duckduckgo.com/lite/?kp=-1&q=%s" search_url="Wikipedia http://www.wikipedia.org/w/index.php?search=%s&go=Go" search_url="Free Dictionary http://www.thefreedictionary.com/%s" +search_url="Startpage http://www.startpage.com/do/search?query=%s" search_url="Google http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s" # If set, dillo will ask web servers to send pages in this language. -- cgit v1.2.3 From ac53d9cc76baa0681a1216c668825d895c0694f2 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 3 Jun 2014 21:15:10 +0200 Subject: change fltk-config test to be more crosscompile/buildroot friendly Change fltk-config usage as suggested by Thomas Petazzoni [1]. submitted-by: Peter Seiderer [1] http://lists.busybox.net/pipermail/buildroot/2014-May/097607.html --- configure.ac | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 325411fc..8bc79e98 100644 --- a/configure.ac +++ b/configure.ac @@ -112,12 +112,13 @@ dnl ------------------------- dnl dnl For debugging and to be user friendly AC_MSG_CHECKING([FLTK 1.3]) -fltk_version="`fltk-config --version 2>/dev/null`" +AC_PATH_PROG(FLTK_CONFIG,fltk-config) +fltk_version="`$FLTK_CONFIG --version 2>/dev/null`" case $fltk_version in 1.3.*) AC_MSG_RESULT(yes) - LIBFLTK_CXXFLAGS=`fltk-config --cxxflags` - LIBFLTK_CFLAGS=`fltk-config --cflags` - LIBFLTK_LIBS=`fltk-config --ldflags`;; + LIBFLTK_CXXFLAGS=`$FLTK_CONFIG --cxxflags` + LIBFLTK_CFLAGS=`$FLTK_CONFIG --cflags` + LIBFLTK_LIBS=`$FLTK_CONFIG --ldflags`;; ?*) AC_MSG_RESULT(no) AC_MSG_ERROR(FLTK 1.3 required; version found: $fltk_version);; *) AC_MSG_RESULT(no) -- cgit v1.2.3 From df9ec9c07f2aec3e5ae7fa5dc6c844dd25779e07 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 13 Jul 2014 15:54:20 +0000 Subject: let's not mention ipaq anymore --- dillorc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dillorc b/dillorc index 0d16bbda..60770fd3 100644 --- a/dillorc +++ b/dillorc @@ -76,8 +76,7 @@ # Show tooltip popups for HTML title attributes #show_tooltip=YES -# Set this to YES if you want to limit the word wrap width to the viewport -# width (may be useful for iPAQ) +# Set this to YES to limit the word wrap width to the viewport width #limit_text_width=NO -- cgit v1.2.3 From 59f3502912a9bc89d814f9043ded3a675a6b1625 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 18 Jul 2014 18:53:28 +0000 Subject: dillorc consistency --- dillorc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dillorc b/dillorc index 60770fd3..20b1f912 100644 --- a/dillorc +++ b/dillorc @@ -21,7 +21,7 @@ # Change this if you want background images to be loaded initially. # (While browsing, this can be changed from the tools/settings menu.) -#load_background_images=FALSE +#load_background_images=NO # Change this if you want to disable loading of CSS stylesheets initially. # (While browsing, this can be changed from the tools/settings menu.) -- cgit v1.2.3 From 350a63ba1eff71706de28aef68fc168a18e0ee15 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 29 Jul 2014 21:54:09 +0000 Subject: fix icon name http://lists.dillo.org/pipermail/dillo-dev/2014-July/010187.html I'm still curious why odd behaviour hadn't been reported by others with other window managers, but I can't justify putting a lot of time into this, and it may be simply that we expect dillo to have lots of little imperfections. --- src/uicmd.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/uicmd.cc b/src/uicmd.cc index e1100219..c8454e20 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -433,7 +433,9 @@ void CustTabs::switch_tab(CustTabButton *cbtn) // Update window title if ((bw = a_UIcmd_get_bw_by_widget(cbtn->ui()))) { const char *title = (cbtn->ui())->label(); - cbtn->window()->copy_label(title ? title : ""); + Fl_Window *win = cbtn->window(); + win->copy_label(title ? title : ""); + win->iconlabel(win->label()); } // Update focus priority increase_focus_counter(); @@ -605,8 +607,11 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus) new_bw->render_layout = (void*)layout; // Clear the window title - if (focus) - new_ui->window()->copy_label(new_ui->label()); + if (focus) { + Fl_Window *win = new_ui->window(); + win->copy_label(new_ui->label()); + win->iconlabel(win->label()); + } // WORKAROUND: see findbar_toggle() new_ui->findbar_toggle(0); @@ -1413,7 +1418,9 @@ void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label) if (a_UIcmd_get_bw_by_widget(BW2UI(bw)->tabs()->wizard()->value()) == bw) { // This is the focused bw, set window title - BW2UI(bw)->window()->copy_label(title); + Fl_Window *win = BW2UI(bw)->window(); + win->copy_label(title); + win->iconlabel(win->label()); } } -- cgit v1.2.3 From 521dcf77bd4f37320c24806e850ad2d8751331d7 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 2 Aug 2014 05:14:24 +0000 Subject: fix the icon name fix Jorge found that AddressSanitizer complained about heap-use-after-free. The problem was that, with window name and icon name set to the same copied string (there is no separate copy_label() for the icon name), when Fl_Window::copy_label() was called to set the copied label to a new value, the old string is free()d and then iconlabel() is used before we have a chance to set it to our newly copied string. --- src/uicmd.cc | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/uicmd.cc b/src/uicmd.cc index c8454e20..5225be75 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -71,6 +71,7 @@ static const char *save_dir = ""; static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus); static void close_tab_btn_cb (Fl_Widget *w, void *cb_data); static char *UIcmd_make_search_str(const char *str); +static void UIcmd_set_window_labels(Fl_Window *win, const char *str); //---------------------------------------------------------------------------- @@ -433,9 +434,7 @@ void CustTabs::switch_tab(CustTabButton *cbtn) // Update window title if ((bw = a_UIcmd_get_bw_by_widget(cbtn->ui()))) { const char *title = (cbtn->ui())->label(); - Fl_Window *win = cbtn->window(); - win->copy_label(title ? title : ""); - win->iconlabel(win->label()); + UIcmd_set_window_labels(cbtn->window(), title ? title : ""); } // Update focus priority increase_focus_counter(); @@ -569,6 +568,18 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, return new_bw; } +/* + * Set the window name and icon name. + */ +static void UIcmd_set_window_labels(Fl_Window *win, const char *str) +{ + const char *copy; + + win->Fl_Widget::copy_label(str); + copy = win->label(); + win->label(copy, copy); +} + /* * Create a new Tab button, UI and its associated BrowserWindow data * structure. @@ -607,11 +618,8 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus) new_bw->render_layout = (void*)layout; // Clear the window title - if (focus) { - Fl_Window *win = new_ui->window(); - win->copy_label(new_ui->label()); - win->iconlabel(win->label()); - } + if (focus) + UIcmd_set_window_labels(new_ui->window(), new_ui->label()); // WORKAROUND: see findbar_toggle() new_ui->findbar_toggle(0); @@ -1418,9 +1426,7 @@ void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label) if (a_UIcmd_get_bw_by_widget(BW2UI(bw)->tabs()->wizard()->value()) == bw) { // This is the focused bw, set window title - Fl_Window *win = BW2UI(bw)->window(); - win->copy_label(title); - win->iconlabel(win->label()); + UIcmd_set_window_labels(BW2UI(bw)->window(), title); } } -- cgit v1.2.3 From 78316e89902cb44e456467eebaccfcb9f5899bbe Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 5 Aug 2014 20:50:31 +0000 Subject: html5 doctype, whitespace permitted between "html" and '>' ...not only permitted, but seen sometimes. Why anyone would do that, I don't know. Maybe to make certain browsers fail. --- src/html.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/html.cc b/src/html.cc index a8c70879..3c110664 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1559,7 +1559,6 @@ static int static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize) { static const char HTML_SGML_sig [] = ""; static const char HTML20 [] = "-//IETF//DTD HTML"; static const char HTML32 [] = "-//W3C//DTD HTML 3.2"; static const char HTML40 [] = "-//W3C//DTD HTML 4.0"; @@ -1624,7 +1623,8 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize) html->DocType = DT_HTML; html->DocTypeVersion = 2.0f; } - } else if (!dStrAsciiCasecmp(ntag, HTML5_sig)) { + } else if (!dStrAsciiCasecmp(ntag, "") || + !dStrAsciiCasecmp(ntag, "")) { html->DocType = DT_HTML; html->DocTypeVersion = 5.0f; } -- cgit v1.2.3 From 089154b8ab3d8b6f36ca04284ce8f37bc17d9250 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 14 Aug 2014 19:45:53 +0200 Subject: improve lang and xml:lang attribute parsing --- src/html.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/html.cc b/src/html.cc index 3c110664..3b89981f 100644 --- a/src/html.cc +++ b/src/html.cc @@ -3763,6 +3763,7 @@ static void Html_test_section(DilloHtml *html, int new_idx, int IsCloseTag) static void Html_parse_common_attrs(DilloHtml *html, char *tag, int tagsize) { const char *attrbuf; + char lang[3]; if (tagsize >= 8 && /* length of "" */ (attrbuf = a_Html_get_attr(html, tag, tagsize, "id"))) { @@ -3788,24 +3789,25 @@ static void Html_parse_common_attrs(DilloHtml *html, char *tag, int tagsize) html->styleEngine->setStyle (attrbuf); } - /* handle "xml:lang" and "lang" attributes */ - int hasXmlLang = 0; + /* handle "xml:lang" and "lang" attributes + * We use only the first two chars of the value to deal with + * extended language tags (see http://www.rfc-editor.org/rfc/bcp/bcp47.txt) + */ + memset(lang, 0, sizeof(lang)); if (tagsize >= 14) { /* length of "" */ attrbuf = a_Html_get_attr(html, tag, tagsize, "xml:lang"); - if (attrbuf) { - html->styleEngine->setNonCssHint(PROPERTY_X_LANG, CSS_TYPE_STRING, - attrbuf); - hasXmlLang = 1; - } + if (attrbuf) + strncpy(lang, attrbuf, 2); } - if (!hasXmlLang && tagsize >= 10) { /* 'xml:lang' prevails over 'lang' */ + if (!lang[0] && tagsize >= 10) { /* 'xml:lang' prevails over 'lang' */ /* length of "" */ attrbuf = a_Html_get_attr(html, tag, tagsize, "lang"); if (attrbuf) - html->styleEngine->setNonCssHint(PROPERTY_X_LANG, CSS_TYPE_STRING, - attrbuf); + strncpy(lang, attrbuf, 2); } + if (lang[0]) + html->styleEngine->setNonCssHint(PROPERTY_X_LANG, CSS_TYPE_STRING, lang); } /* -- cgit v1.2.3 From 0824591133ebfa5a360df92e22bdde0454f43b1d Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 3 Sep 2014 22:17:07 +0000 Subject: a couple of quick https improvements --- dpi/https.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dpi/https.c b/dpi/https.c index e6d2b0e9..f0b4ec89 100644 --- a/dpi/https.c +++ b/dpi/https.c @@ -156,9 +156,11 @@ static void yes_ssl_support(void) } } - /* Do not use the SSLv2 protocol. */ + /* Do not use the obsolete insecure SSLv2 protocol, and everyone disabled + * TLS compression when the CRIME exploit became widely known in 2012. + */ if (exit_error == 0){ - SSL_CTX_set_options(ssl_context, SSL_OP_NO_SSLv2); + SSL_CTX_set_options(ssl_context, SSL_OP_NO_SSLv2|SSL_OP_NO_COMPRESSION); } /*Set directory to load certificates from*/ @@ -188,10 +190,11 @@ static void yes_ssl_support(void) } if (exit_error == 0){ - /* Need to do the following if we want to deal with all - * possible ciphers + /* Don't want: eNULL, which has no encryption; aNULL, which has no + * authentication; LOW, which as of 2014 use 64 or 56-bit encryption; + * EXPORT40, which uses 40-bit encryption. */ - SSL_set_cipher_list(ssl_connection, "ALL"); + SSL_CTX_set_cipher_list(ssl_context, "ALL:!aNULL:!eNULL:!LOW:!EXPORT40"); /* Need to do this if we want to have the option of dealing * with self-signed certs -- cgit v1.2.3 From 4584cfb4041fc35b22886c0252b3169de64a787e Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 16 Sep 2014 00:21:49 +0000 Subject: url positioning in location bar the brief thread http://lists.dillo.org/pipermail/dillo-dev/2014-September/010205.html --- src/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui.cc b/src/ui.cc index d3bc7ff6..a5785576 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -816,7 +816,7 @@ void UI::set_location(const char *str) { if (!str) str = ""; Location->value(str); - Location->position(strlen(str)); + Location->position((Fl::focus() == Location) ? strlen(str) : 0); } /* -- cgit v1.2.3 From 4ee6cf9769ac462f46007243ea833d0c05723e7d Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 24 Sep 2014 23:11:07 +0000 Subject: handle irix's version of vsnprintf() thread: http://lists.dillo.org/pipermail/dillo-dev/2014-September/010230.html --- dlib/dlib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dlib/dlib.c b/dlib/dlib.c index d60f1bc6..23534730 100644 --- a/dlib/dlib.c +++ b/dlib/dlib.c @@ -406,6 +406,17 @@ void dStr_vsprintfa (Dstr *ds, const char *format, va_list argp) va_copy(argp2, argp); n = vsnprintf(ds->str + ds->len, ds->sz - ds->len, format, argp2); va_end(argp2); +#if defined(__sgi) + /* IRIX does not conform to C99; if the entire argument did not fit + * into the buffer, n = buffer space used (minus 1 for terminator) + */ + if (n > -1 && n + 1 < ds->sz - ds->len) { + ds->len += n; /* Success! */ + break; + } else { + n_sz = ds->sz * 2; + } +#else if (n > -1 && n < ds->sz - ds->len) { ds->len += n; /* Success! */ break; @@ -414,6 +425,7 @@ void dStr_vsprintfa (Dstr *ds, const char *format, va_list argp) } else { /* old glibc */ n_sz = ds->sz * 2; } +#endif dStr_resize(ds, n_sz, (ds->len > 0) ? 1 : 0); } } -- cgit v1.2.3 From 1126f75f2141329c6839c4bc6c58d6bb947689fd Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 17 Oct 2014 01:36:00 +0000 Subject: everyone's finally disabling SSL3; let's do so too --- dpi/https.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dpi/https.c b/dpi/https.c index f0b4ec89..da75b9e8 100644 --- a/dpi/https.c +++ b/dpi/https.c @@ -156,11 +156,12 @@ static void yes_ssl_support(void) } } - /* Do not use the obsolete insecure SSLv2 protocol, and everyone disabled - * TLS compression when the CRIME exploit became widely known in 2012. + /* SSL2 has been known to be insecure forever, disabling SSL3 is in response + * to POODLE, and disabling compression is in response to CRIME. */ if (exit_error == 0){ - SSL_CTX_set_options(ssl_context, SSL_OP_NO_SSLv2|SSL_OP_NO_COMPRESSION); + SSL_CTX_set_options(ssl_context, + SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION); } /*Set directory to load certificates from*/ -- cgit v1.2.3 From 32016ba3aba2371b8b7a02d81badd1ae336559d2 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 16 Jan 2015 02:59:01 +0000 Subject: don't inheritBackgroundColor for html5 sectioning stuff At least by default when that stuff's all block display, it's unnecessary and it restarts whatever background image the parent has. _That's_ why one part of arstechnica.com has been hard to read forever. --- src/html.cc | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/html.cc b/src/html.cc index 3b89981f..f1177bb1 100644 --- a/src/html.cc +++ b/src/html.cc @@ -3373,14 +3373,13 @@ static void Html_tag_open_span(DilloHtml *html, const char *tag, int tagsize) } /* - *
(TODO: make a complete implementation) + * html5 sectioning stuff: article aside nav section header footer */ -static void Html_tag_open_div(DilloHtml *html, const char *tag, int tagsize) +static void Html_tag_open_sectioning(DilloHtml *html, const char *tag, + int tagsize) { const char *attrbuf; - a_Html_tag_set_align_attr (html, tag, tagsize); - if (prefs.show_tooltip && (attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) { @@ -3389,6 +3388,15 @@ static void Html_tag_open_div(DilloHtml *html, const char *tag, int tagsize) } } +/* + *
(TODO: make a complete implementation) + */ +static void Html_tag_open_div(DilloHtml *html, const char *tag, int tagsize) +{ + a_Html_tag_set_align_attr (html, tag, tagsize); + Html_tag_open_sectioning(html, tag, tagsize); +} + /* * Default close for paragraph tags - pop the stack and break. */ @@ -3438,8 +3446,8 @@ const TagInfo Tags[] = { {"address", B8(010110),'R',2,Html_tag_open_default, NULL, Html_tag_close_par}, {"area", B8(010001),'F',0, Html_tag_open_default, Html_tag_content_area, NULL}, - {"article", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, - {"aside", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, + {"article", B8(011110),'R',2, Html_tag_open_sectioning, NULL, NULL}, + {"aside", B8(011110),'R',2, Html_tag_open_sectioning, NULL, NULL}, {"audio", B8(011101),'R',2, Html_tag_open_audio, NULL, Html_tag_close_media}, {"b", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, {"base", B8(100001),'F',0, Html_tag_open_base, NULL, NULL}, @@ -3472,7 +3480,7 @@ const TagInfo Tags[] = { {"figcaption", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, {"figure", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, {"font", B8(010101),'R',2, Html_tag_open_font, NULL, NULL}, - {"footer", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, + {"footer", B8(011110),'R',2, Html_tag_open_sectioning, NULL, NULL}, {"form", B8(011110),'R',2, Html_tag_open_form, NULL, Html_tag_close_form}, {"frame", B8(010010),'F',0, Html_tag_open_frame, Html_tag_content_frame, NULL}, @@ -3485,7 +3493,7 @@ const TagInfo Tags[] = { {"h5", B8(010110),'R',2, Html_tag_open_h, NULL, NULL}, {"h6", B8(010110),'R',2, Html_tag_open_h, NULL, NULL}, {"head", B8(101101),'O',1, Html_tag_open_head, NULL, Html_tag_close_head}, - {"header", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, + {"header", B8(011110),'R',2, Html_tag_open_sectioning, NULL, NULL}, {"hr", B8(010010),'F',0, Html_tag_open_hr, Html_tag_content_hr, NULL}, {"html", B8(001110),'O',1, Html_tag_open_html, NULL, Html_tag_close_html}, @@ -3508,7 +3516,7 @@ const TagInfo Tags[] = { /* menu 1010 -- TODO: not exactly 1010, it can contain LI and inline */ {"menu", B8(011010),'R',2, Html_tag_open_menu, NULL, Html_tag_close_par}, {"meta", B8(100001),'F',0, Html_tag_open_meta, NULL, NULL}, - {"nav", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, + {"nav", B8(011110),'R',2, Html_tag_open_sectioning, NULL, NULL}, /* noframes 1011 -- obsolete in HTML5 */ /* noscript 1011 */ {"object", B8(111101),'R',2, Html_tag_open_object, Html_tag_content_object, @@ -3524,7 +3532,7 @@ const TagInfo Tags[] = { {"s", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, {"samp", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, {"script", B8(111001),'R',2, Html_tag_open_script,NULL,Html_tag_close_script}, - {"section", B8(011110),'R',2, Html_tag_open_default, NULL, NULL}, + {"section", B8(011110),'R',2, Html_tag_open_sectioning, NULL, NULL}, {"select", B8(010101),'R',2, Html_tag_open_select,NULL,Html_tag_close_select}, {"small", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}, {"source", B8(010001),'F',0, Html_tag_open_source, Html_tag_content_source, -- cgit v1.2.3 From 5762e282eaa55de8e548730d64f1844e7261896c Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 22 Jan 2015 08:51:02 +0000 Subject: INPUT placeholder attribute --- dw/fltkplatform.cc | 6 ++- dw/fltkplatform.hh | 3 +- dw/fltkui.cc | 131 ++++++++++++++++++++++++++++++++++++++++++++++++----- dw/fltkui.hh | 3 +- dw/ui.hh | 3 +- src/form.cc | 14 ++++-- test/dw_ui_test.cc | 5 +- 7 files changed, 141 insertions(+), 24 deletions(-) diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 2fc7ff41..67b04688 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -413,9 +413,11 @@ FltkPlatform::FltkResourceFactory::createOptionMenuResource () core::ui::EntryResource * FltkPlatform::FltkResourceFactory::createEntryResource (int size, bool password, - const char *label) + const char *label, + const char *placeholder) { - return new ui::FltkEntryResource (platform, size, password, label); + return new ui::FltkEntryResource (platform, size, password, label, + placeholder); } core::ui::MultiLineTextResource * diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 2fb95633..4e0c855b 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -110,7 +110,8 @@ private: int rows); core::ui::OptionMenuResource *createOptionMenuResource (); core::ui::EntryResource *createEntryResource (int size, bool password, - const char *label); + const char *label, + const char *placeholder); core::ui::MultiLineTextResource *createMultiLineTextResource (int cols, int rows); core::ui::CheckButtonResource *createCheckButtonResource (bool diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 58bb2c6f..84e0b730 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -42,18 +42,108 @@ */ /* - * Used to enable CTRL+{a,e,d,k} in form inputs (for start,end,del,cut) + * Used to show optional placeholder text and to enable CTRL+{a,e,d,k} in + * form inputs (for start,end,del,cut) */ class CustInput2 : public Fl_Input { public: CustInput2 (int x, int y, int w, int h, const char* l=0) : - Fl_Input(x,y,w,h,l) {}; + Fl_Input(x,y,w,h,l) { placeholder = NULL; showing_placeholder = false; }; + ~CustInput2 () { if (placeholder) free(placeholder); }; + void set_placeholder(const char *str); + int show_placeholder(); + int show_normal(const char *str); + void textcolor(Fl_Color c); + void input_type(int t); + int value(const char* str); + const char* value(); int handle(int e); +private: + Fl_Color dimmed(Fl_Color c) {return fl_color_average(c, color(), .33f); }; + char *placeholder; + bool showing_placeholder; + Fl_Color usual_color; + int usual_type; }; +/* + * Show normal text. + */ +int CustInput2::show_normal(const char *str) +{ + showing_placeholder = false; + Fl_Input::textcolor(usual_color); + Fl_Input::input_type(usual_type); + return Fl_Input::value(str); +} + +/* + * Show the placeholder text. + */ +int CustInput2::show_placeholder() +{ + showing_placeholder = true; + Fl_Input::textcolor(dimmed(usual_color)); + Fl_Input::input_type(FL_NORMAL_INPUT); + return Fl_Input::value(placeholder); +} + +/* + * Set the placeholder text. + */ +void CustInput2::set_placeholder(const char *str) +{ + if (placeholder) + free(placeholder); + placeholder = strdup(str); + + if ((Fl::focus() != this) && !*value()) { + show_placeholder(); + } +} + +/* + * Set the text color. + */ +void CustInput2::textcolor(Fl_Color c) +{ + usual_color = c; + if (showing_placeholder) + c = dimmed(c); + Fl_Input::textcolor(c); +} + +/* + * Set the input type (normal, password, etc.) + */ +void CustInput2::input_type(int t) +{ + usual_type = t; + Fl_Input::input_type(t); +} + +/* + * Set the value of the input. + * NOTE that we're not being very careful with the return value, which is + * supposed to be nonzero iff the value was changed. + */ +int CustInput2::value(const char *str) +{ + return (placeholder && (!str || !*str) && Fl::focus() != this) + ? show_placeholder() : show_normal(str); +} + +/* + * Return the value (text) of the input. + */ +const char* CustInput2::value() +{ + return showing_placeholder ? "" : Fl_Input::value(); +} + int CustInput2::handle(int e) { - int k = Fl::event_key(); + int rc, k = Fl::event_key(); _MSG("CustInput2::handle event=%d\n", e); @@ -82,8 +172,20 @@ int CustInput2::handle(int e) return 0; } } + } else if (e == FL_UNFOCUS) { + if (placeholder && !value()[0]) { + show_placeholder(); + } + } + + rc = Fl_Input::handle(e); + + if (rc && e == FL_FOCUS) { + // Nonzero return from handle() should mean that focus was accepted. + if (showing_placeholder) + show_normal(""); } - return Fl_Input::handle(e); + return rc; } @@ -563,13 +665,15 @@ Fl_Widget *FltkComplexButtonResource::createNewWidget (core::Allocation // ---------------------------------------------------------------------- FltkEntryResource::FltkEntryResource (FltkPlatform *platform, int size, - bool password, const char *label): + bool password, const char *label, + const char *placeholder): FltkSpecificResource (platform) { this->size = size; this->password = password; this->label = label ? strdup(label) : NULL; this->label_w = 0; + this->placeholder = placeholder ? strdup(placeholder) : NULL; initText = NULL; editable = false; @@ -583,16 +687,17 @@ FltkEntryResource::~FltkEntryResource () free((char *)initText); if (label) free(label); + if (placeholder) + free(placeholder); } Fl_Widget *FltkEntryResource::createNewWidget (core::Allocation *allocation) { - Fl_Input *input = + CustInput2 *input = new CustInput2(allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent); - if (password) - input->type(FL_SECRET_INPUT); + input->input_type(password ? FL_SECRET_INPUT : FL_NORMAL_INPUT); input->callback (widgetCallback, this); input->when (FL_WHEN_ENTER_KEY_ALWAYS); @@ -602,6 +707,8 @@ Fl_Widget *FltkEntryResource::createNewWidget (core::Allocation } if (initText) input->value (initText); + if (placeholder) + input->set_placeholder(placeholder); return input; } @@ -609,12 +716,12 @@ Fl_Widget *FltkEntryResource::createNewWidget (core::Allocation void FltkEntryResource::setWidgetStyle (Fl_Widget *widget, core::style::Style *style) { - Fl_Input *in = (Fl_Input *)widget; + CustInput2 *in = (CustInput2 *)widget; FltkResource::setWidgetStyle(widget, style); in->textcolor(widget->labelcolor()); - in->cursor_color(in->textcolor()); + in->cursor_color(widget->labelcolor()); in->textsize(in->labelsize()); in->textfont(in->labelfont()); @@ -674,7 +781,7 @@ void FltkEntryResource::widgetCallback (Fl_Widget *widget, void *data) const char *FltkEntryResource::getText () { - return ((Fl_Input*)widget)->value (); + return ((CustInput2*)widget)->value (); } void FltkEntryResource::setText (const char *text) @@ -683,7 +790,7 @@ void FltkEntryResource::setText (const char *text) free((char *)initText); initText = strdup (text); - ((Fl_Input*)widget)->value (initText); + ((CustInput2*)widget)->value (initText); } bool FltkEntryResource::isEditable () diff --git a/dw/fltkui.hh b/dw/fltkui.hh index 8667a0cb..bdb13ddb 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -301,6 +301,7 @@ private: const char *initText; char *label; int label_w; + char *placeholder; bool editable; static void widgetCallback (Fl_Widget *widget, void *data); @@ -312,7 +313,7 @@ protected: public: FltkEntryResource (FltkPlatform *platform, int size, bool password, - const char *label); + const char *label, const char *placeholder); ~FltkEntryResource (); void sizeRequest (core::Requisition *requisition); diff --git a/dw/ui.hh b/dw/ui.hh index d46705fe..54bab8fe 100644 --- a/dw/ui.hh +++ b/dw/ui.hh @@ -544,7 +544,8 @@ public: selectionMode, int rows) = 0; virtual OptionMenuResource *createOptionMenuResource () = 0; virtual EntryResource *createEntryResource (int size, bool password, - const char *label) = 0; + const char *label, + const char *placeholder) = 0; virtual MultiLineTextResource *createMultiLineTextResource (int cols, int rows) = 0; virtual CheckButtonResource *createCheckButtonResource (bool activated) = 0; diff --git a/src/form.cc b/src/form.cc index 07c12815..c4d7cc98 100644 --- a/src/form.cc +++ b/src/form.cc @@ -431,7 +431,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) DilloHtmlInputType inp_type; Resource *resource = NULL; Embed *embed = NULL; - char *value, *name, *type, *init_str; + char *value, *name, *type, *init_str, *placeholder = NULL; const char *attrbuf, *label; bool init_val = false; ResourceFactory *factory; @@ -456,9 +456,10 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) inp_type = DILLO_HTML_INPUT_UNKNOWN; if (!dStrAsciiCasecmp(type, "password")) { inp_type = DILLO_HTML_INPUT_PASSWORD; + placeholder = a_Html_get_attr_wdef(html, tag,tagsize,"placeholder",NULL); attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); - resource = factory->createEntryResource (size, true, NULL); + resource = factory->createEntryResource (size, true, NULL, placeholder); init_str = value; } else if (!dStrAsciiCasecmp(type, "checkbox")) { inp_type = DILLO_HTML_INPUT_CHECKBOX; @@ -478,7 +479,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) inp_type = DILLO_HTML_INPUT_HIDDEN; init_str = value; int size = Html_input_get_size(html, NULL); - resource = factory->createEntryResource(size, false, name); + resource = factory->createEntryResource(size, false, name, NULL); } else if (!dStrAsciiCasecmp(type, "submit")) { inp_type = DILLO_HTML_INPUT_SUBMIT; init_str = (value) ? value : dStrdup("submit"); @@ -531,9 +532,10 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) } else { /* Text input, which also is the default */ inp_type = DILLO_HTML_INPUT_TEXT; + placeholder = a_Html_get_attr_wdef(html, tag,tagsize,"placeholder",NULL); attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); - resource = factory->createEntryResource(size, false, NULL); + resource = factory->createEntryResource(size, false, NULL, placeholder); init_str = value; } if (resource) @@ -573,6 +575,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) dFree(name); if (init_str != value) dFree(init_str); + dFree(placeholder); dFree(value); } @@ -606,7 +609,8 @@ void Html_tag_open_isindex(DilloHtml *html, const char *tag, int tagsize) HT2TB(html)->addText(attrbuf, html->wordStyle ()); ResourceFactory *factory = HT2LT(html)->getResourceFactory(); - EntryResource *entryResource = factory->createEntryResource (20,false,NULL); + EntryResource *entryResource = factory->createEntryResource (20, false, + NULL, NULL); embed = new Embed (entryResource); Html_add_input(html, DILLO_HTML_INPUT_INDEX, embed, NULL, NULL, FALSE); diff --git a/test/dw_ui_test.cc b/test/dw_ui_test.cc index 086a4976..b70349ca 100644 --- a/test/dw_ui_test.cc +++ b/test/dw_ui_test.cc @@ -81,10 +81,11 @@ int main(int argc, char **argv) // First of all, the resources. Later, they are embedded into the // widget tree. EntryResource *entryres1 = - layout->getResourceFactory()->createEntryResource (10, false, NULL); + layout->getResourceFactory()->createEntryResource (10, false, NULL,NULL); entryres1->setText ("Hi!"); EntryResource *entryres2 = - layout->getResourceFactory()->createEntryResource (10, true, NULL); + layout->getResourceFactory()->createEntryResource (10, true, NULL, + "password field!"); MultiLineTextResource *textres = layout->getResourceFactory()->createMultiLineTextResource (15,3); RadioButtonResource *radiores1 = -- cgit v1.2.3 From 4e9e0f60fe1f426dfae4cced9d3b5d1f1d4d9487 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 22 Jan 2015 12:59:41 -0300 Subject: Fix for segfault when there's no dpid and view source is requested. --- src/capi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/capi.c b/src/capi.c index 531ae34d..85aef974 100644 --- a/src/capi.c +++ b/src/capi.c @@ -571,8 +571,8 @@ int a_Capi_dpi_send_data(const DilloUrl *url, void *bw, } else { /* Re-use an open connection */ conn = Capi_conn_find(server); - if (conn) { - /* found */ + if (conn && conn->InfoSend) { + /* found & active */ dbuf = a_Chain_dbuf_new(data, data_sz, 0); a_Capi_ccc(OpSend, 1, BCK, conn->InfoSend, dbuf, NULL); dFree(dbuf); -- cgit v1.2.3 From cf075fda81d5450047721573ce6f2c17474ade7e Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 24 Jan 2015 00:21:18 +0000 Subject: input init usual_color Not 'necessary' at present, but valgrind complains and it's always good practice. --- dw/fltkui.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 84e0b730..fb6e61e1 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -47,8 +47,7 @@ */ class CustInput2 : public Fl_Input { public: - CustInput2 (int x, int y, int w, int h, const char* l=0) : - Fl_Input(x,y,w,h,l) { placeholder = NULL; showing_placeholder = false; }; + CustInput2 (int x, int y, int w, int h, const char* l=0); ~CustInput2 () { if (placeholder) free(placeholder); }; void set_placeholder(const char *str); int show_placeholder(); @@ -66,6 +65,14 @@ private: int usual_type; }; +CustInput2::CustInput2 (int x, int y, int w, int h, const char* l) : + Fl_Input(x,y,w,h,l) +{ + placeholder = NULL; + showing_placeholder = false; + usual_color = FL_BLACK; /* just init until widget style is set */ +}; + /* * Show normal text. */ -- cgit v1.2.3 From 848cfc9b134897d52aaf1243f9f4217d3255e4d8 Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 2 Feb 2015 22:23:45 +0000 Subject: TEXTAREA placeholder attribute --- dw/fltkplatform.cc | 5 +- dw/fltkplatform.hh | 3 +- dw/fltkui.cc | 180 ++++++++++++++++++++++++++++++++++++++++++++++------- dw/fltkui.hh | 7 +-- dw/ui.hh | 3 +- src/form.cc | 4 +- test/dw_ui_test.cc | 3 +- 7 files changed, 171 insertions(+), 34 deletions(-) diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 67b04688..948c1444 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -422,9 +422,10 @@ FltkPlatform::FltkResourceFactory::createEntryResource (int size, core::ui::MultiLineTextResource * FltkPlatform::FltkResourceFactory::createMultiLineTextResource (int cols, - int rows) + int rows, + const char *placeholder) { - return new ui::FltkMultiLineTextResource (platform, cols, rows); + return new ui::FltkMultiLineTextResource (platform, cols, rows,placeholder); } core::ui::CheckButtonResource * diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 4e0c855b..8f644227 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -113,7 +113,8 @@ private: const char *label, const char *placeholder); core::ui::MultiLineTextResource *createMultiLineTextResource (int cols, - int rows); + int rows, + const char *placeholder); core::ui::CheckButtonResource *createCheckButtonResource (bool activated); core::ui::RadioButtonResource * diff --git a/dw/fltkui.cc b/dw/fltkui.cc index fb6e61e1..7b94e11d 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -36,6 +36,13 @@ #include +//---------------------------------------------------------------------------- + +static Fl_Color fltkui_dimmed(Fl_Color c, Fl_Color bg) +{ + return fl_color_average(c, bg, .33f); +}; + //---------------------------------------------------------------------------- /* * Local sub classes @@ -58,7 +65,6 @@ public: const char* value(); int handle(int e); private: - Fl_Color dimmed(Fl_Color c) {return fl_color_average(c, color(), .33f); }; char *placeholder; bool showing_placeholder; Fl_Color usual_color; @@ -90,7 +96,7 @@ int CustInput2::show_normal(const char *str) int CustInput2::show_placeholder() { showing_placeholder = true; - Fl_Input::textcolor(dimmed(usual_color)); + Fl_Input::textcolor(fltkui_dimmed(usual_color, color())); Fl_Input::input_type(FL_NORMAL_INPUT); return Fl_Input::value(placeholder); } @@ -116,7 +122,7 @@ void CustInput2::textcolor(Fl_Color c) { usual_color = c; if (showing_placeholder) - c = dimmed(c); + c = fltkui_dimmed(c, color()); Fl_Input::textcolor(c); } @@ -195,6 +201,140 @@ int CustInput2::handle(int e) return rc; } +/* + * Used to show optional placeholder text. + */ +class CustTextEditor : public Fl_Text_Editor { +public: + CustTextEditor (int x, int y, int w, int h, const char* l=0); + ~CustTextEditor (); + void set_placeholder(const char *str); + void show_placeholder(); + void show_normal(const char *str); + void textcolor(Fl_Color c); + void value(const char* str); + char* value(); + int handle(int e); +private: + char *placeholder; + bool showing_placeholder; + Fl_Color usual_color; + char *text_copy; +}; + +CustTextEditor::CustTextEditor (int x, int y, int w, int h, const char* l) : + Fl_Text_Editor(x,y,w,h,l) +{ + placeholder = NULL; + showing_placeholder = false; + buffer(new Fl_Text_Buffer()); + usual_color = FL_BLACK; /* just init until widget style is set */ + text_copy = NULL; +}; + +CustTextEditor::~CustTextEditor () +{ + Fl_Text_Buffer *buf = buffer(); + + buffer(NULL); + delete buf; + + if (placeholder) + free(placeholder); + if (text_copy) + free(text_copy); +} + +/* + * Show normal text. + */ +void CustTextEditor::show_normal(const char *str) +{ + showing_placeholder = false; + Fl_Text_Editor::textcolor(usual_color); + buffer()->text(str); +} + +/* + * Show the placeholder text. + */ +void CustTextEditor::show_placeholder() +{ + showing_placeholder = true; + Fl_Text_Editor::textcolor(fltkui_dimmed(usual_color, color())); + buffer()->text(placeholder); +} + +/* + * Set the placeholder text. + */ +void CustTextEditor::set_placeholder(const char *str) +{ + if (placeholder) + free(placeholder); + placeholder = strdup(str); + + if ((Fl::focus() != this) && buffer()->length() == 0) { + show_placeholder(); + } +} + +/* + * Set the text color. + */ +void CustTextEditor::textcolor(Fl_Color c) +{ + usual_color = c; + if (showing_placeholder) + c = fltkui_dimmed(c, color()); + Fl_Text_Editor::textcolor(c); +} + +/* + * Set the value of the input. + */ +void CustTextEditor::value(const char *str) +{ + if (placeholder && (!str || !*str) && Fl::focus() != this) + show_placeholder(); + else + show_normal(str); +} + +/* + * Return the value (text) of the input. + */ +char* CustTextEditor::value() +{ + /* FLTK-1.3 insists upon returning a new copy of the buffer text, so + * we have to keep track of it. + */ + if (text_copy) + free(text_copy); + text_copy = showing_placeholder ? strdup("") : buffer()->text(); + return text_copy; +} + +int CustTextEditor::handle(int e) +{ + int rc; + + if (e == FL_UNFOCUS) { + if (placeholder && buffer()->length() == 0) { + show_placeholder(); + } + } + + rc = Fl_Text_Editor::handle(e); + + if (rc && e == FL_FOCUS) { + // Nonzero return from handle() should mean that focus was accepted. + if (showing_placeholder) + show_normal(""); + } + return rc; +} + /* * Used to handle some keystrokes as shortcuts to option menuitems @@ -832,11 +972,10 @@ static int kf_backspace_word (int c, Fl_Text_Editor *e) } FltkMultiLineTextResource::FltkMultiLineTextResource (FltkPlatform *platform, - int cols, int rows): + int cols, int rows, + const char *placeholder): FltkSpecificResource (platform) { - buffer = new Fl_Text_Buffer; - text_copy = NULL; editable = false; numCols = cols; @@ -851,42 +990,41 @@ FltkMultiLineTextResource::FltkMultiLineTextResource (FltkPlatform *platform, MSG_WARN("numRows = %d is set to 1.\n", numRows); numRows = 1; } + this->placeholder = placeholder ? strdup(placeholder) : NULL; init (platform); } FltkMultiLineTextResource::~FltkMultiLineTextResource () { - /* Free memory avoiding a double-free of text buffers */ - ((Fl_Text_Editor *) widget)->buffer (0); - delete buffer; - if (text_copy) - free(text_copy); + if (placeholder) + free(placeholder); } Fl_Widget *FltkMultiLineTextResource::createNewWidget (core::Allocation *allocation) { - Fl_Text_Editor *text = - new Fl_Text_Editor (allocation->x, allocation->y, allocation->width, + CustTextEditor *text = + new CustTextEditor (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent); text->wrap_mode(Fl_Text_Display::WRAP_AT_BOUNDS, 0); - text->buffer (buffer); text->remove_key_binding(FL_BackSpace, FL_TEXT_EDITOR_ANY_STATE); text->add_key_binding(FL_BackSpace, 0, Fl_Text_Editor::kf_backspace); text->add_key_binding(FL_BackSpace, FL_CTRL, kf_backspace_word); + if (placeholder) + text->set_placeholder(placeholder); return text; } void FltkMultiLineTextResource::setWidgetStyle (Fl_Widget *widget, core::style::Style *style) { - Fl_Text_Editor *ed = (Fl_Text_Editor *)widget; + CustTextEditor *ed = (CustTextEditor *)widget; FltkResource::setWidgetStyle(widget, style); ed->textcolor(widget->labelcolor()); - ed->cursor_color(ed->textcolor()); + ed->cursor_color(widget->labelcolor()); ed->textsize(ed->labelsize()); ed->textfont(ed->labelfont()); } @@ -915,18 +1053,12 @@ void FltkMultiLineTextResource::sizeRequest (core::Requisition *requisition) const char *FltkMultiLineTextResource::getText () { - /* FLTK-1.3 insists upon returning a new copy of the buffer text, so - * we have to keep track of it. - */ - if (text_copy) - free(text_copy); - text_copy = buffer->text(); - return text_copy; + return ((CustTextEditor*)widget)->value (); } void FltkMultiLineTextResource::setText (const char *text) { - buffer->text (text); + ((CustTextEditor*)widget)->value (text); } bool FltkMultiLineTextResource::isEditable () diff --git a/dw/fltkui.hh b/dw/fltkui.hh index bdb13ddb..3615714a 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -331,17 +331,16 @@ class FltkMultiLineTextResource: public FltkSpecificResource { private: - Fl_Text_Buffer *buffer; - char *text_copy; bool editable; int numCols, numRows; - + char *placeholder; protected: Fl_Widget *createNewWidget (core::Allocation *allocation); void setWidgetStyle (Fl_Widget *widget, core::style::Style *style); public: - FltkMultiLineTextResource (FltkPlatform *platform, int cols, int rows); + FltkMultiLineTextResource (FltkPlatform *platform, int cols, int rows, + const char *placeholder); ~FltkMultiLineTextResource (); void sizeRequest (core::Requisition *requisition); diff --git a/dw/ui.hh b/dw/ui.hh index 54bab8fe..e92c48d1 100644 --- a/dw/ui.hh +++ b/dw/ui.hh @@ -547,7 +547,8 @@ public: const char *label, const char *placeholder) = 0; virtual MultiLineTextResource *createMultiLineTextResource (int cols, - int rows) = 0; + int rows, + const char *placeholder) = 0; virtual CheckButtonResource *createCheckButtonResource (bool activated) = 0; virtual RadioButtonResource *createRadioButtonResource (RadioButtonResource *groupedWith, diff --git a/src/form.cc b/src/form.cc index c4d7cc98..ac7384aa 100644 --- a/src/form.cc +++ b/src/form.cc @@ -669,9 +669,11 @@ void Html_tag_content_textarea(DilloHtml *html, const char *tag, int tagsize) if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "name"))) name = dStrdup(attrbuf); + attrbuf = a_Html_get_attr(html, tag, tagsize, "placeholder"); + ResourceFactory *factory = HT2LT(html)->getResourceFactory(); MultiLineTextResource *textres = - factory->createMultiLineTextResource (cols, rows); + factory->createMultiLineTextResource (cols, rows, attrbuf); Embed *embed = new Embed(textres); /* Readonly or not? */ diff --git a/test/dw_ui_test.cc b/test/dw_ui_test.cc index b70349ca..f24cc9b9 100644 --- a/test/dw_ui_test.cc +++ b/test/dw_ui_test.cc @@ -87,7 +87,8 @@ int main(int argc, char **argv) layout->getResourceFactory()->createEntryResource (10, true, NULL, "password field!"); MultiLineTextResource *textres = - layout->getResourceFactory()->createMultiLineTextResource (15,3); + layout->getResourceFactory()->createMultiLineTextResource (15,3, + "textarea placeholder!"); RadioButtonResource *radiores1 = layout->getResourceFactory()->createRadioButtonResource (NULL, false); RadioButtonResource *radiores2 = -- cgit v1.2.3 From bb03e5569866c033371060de55c17309f3caf3f2 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 3 Feb 2015 01:06:26 +0000 Subject: for input placeholder, set position to beginning in case it's too long to show all at once --- dw/fltkui.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 7b94e11d..e22e4619 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -95,10 +95,14 @@ int CustInput2::show_normal(const char *str) */ int CustInput2::show_placeholder() { + int ret; + showing_placeholder = true; Fl_Input::textcolor(fltkui_dimmed(usual_color, color())); Fl_Input::input_type(FL_NORMAL_INPUT); - return Fl_Input::value(placeholder); + ret = Fl_Input::value(placeholder); + position(0); + return ret; } /* -- cgit v1.2.3 From c0843d9e2629d10bb3ac636bc38d59abb444b2ad Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 15 Feb 2015 19:17:51 +0100 Subject: use single symbols table in PrefsParser::parse() --- src/prefsparser.cc | 180 ++++++++++++++++++++++++++--------------------------- src/prefsparser.hh | 1 - 2 files changed, 90 insertions(+), 91 deletions(-) diff --git a/src/prefsparser.cc b/src/prefsparser.cc index 81b097e7..5f90f82f 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -44,100 +44,15 @@ typedef struct { /* * Parse a name/value pair and set preferences accordingly. */ -int PrefsParser::parseOption(char *name, char *value) +static int parseOption(char *name, char *value, + SymNode_t *symbols, int n_symbols) { const SymNode_t *node; - uint_t i; + int i; int st; - /* Symbol array, sorted alphabetically */ - const SymNode_t symbols[] = { - { "allow_white_bg", &prefs.allow_white_bg, PREFS_BOOL }, - { "white_bg_replacement", &prefs.white_bg_replacement, PREFS_COLOR }, - { "bg_color", &prefs.bg_color, PREFS_COLOR }, - { "buffered_drawing", &prefs.buffered_drawing, PREFS_INT32 }, - { "contrast_visited_color", &prefs.contrast_visited_color, PREFS_BOOL }, - { "enterpress_forces_submit", &prefs.enterpress_forces_submit, - PREFS_BOOL }, - { "focus_new_tab", &prefs.focus_new_tab, PREFS_BOOL }, - { "font_cursive", &prefs.font_cursive, PREFS_STRING }, - { "font_factor", &prefs.font_factor, PREFS_DOUBLE }, - { "font_fantasy", &prefs.font_fantasy, PREFS_STRING }, - { "font_max_size", &prefs.font_max_size, PREFS_INT32 }, - { "font_min_size", &prefs.font_min_size, PREFS_INT32 }, - { "font_monospace", &prefs.font_monospace, PREFS_STRING }, - { "font_sans_serif", &prefs.font_sans_serif, PREFS_STRING }, - { "font_serif", &prefs.font_serif, PREFS_STRING }, - { "fullwindow_start", &prefs.fullwindow_start, PREFS_BOOL }, - { "geometry", NULL, PREFS_GEOMETRY }, - { "home", &prefs.home, PREFS_URL }, - { "http_language", &prefs.http_language, PREFS_STRING }, - { "http_max_conns", &prefs.http_max_conns, PREFS_INT32 }, - { "http_proxy", &prefs.http_proxy, PREFS_URL }, - { "http_proxyuser", &prefs.http_proxyuser, PREFS_STRING }, - { "http_referer", &prefs.http_referer, PREFS_STRING }, - { "http_user_agent", &prefs.http_user_agent, PREFS_STRING }, - { "limit_text_width", &prefs.limit_text_width, PREFS_BOOL }, - { "load_images", &prefs.load_images, PREFS_BOOL }, - { "load_background_images", &prefs.load_background_images, PREFS_BOOL }, - { "load_stylesheets", &prefs.load_stylesheets, PREFS_BOOL }, - { "middle_click_drags_page", &prefs.middle_click_drags_page, - PREFS_BOOL }, - { "middle_click_opens_new_tab", &prefs.middle_click_opens_new_tab, - PREFS_BOOL }, - { "right_click_closes_tab", &prefs.right_click_closes_tab, PREFS_BOOL }, - { "no_proxy", &prefs.no_proxy, PREFS_STRING }, - { "panel_size", &prefs.panel_size, PREFS_PANEL_SIZE }, - { "parse_embedded_css", &prefs.parse_embedded_css, PREFS_BOOL }, - { "save_dir", &prefs.save_dir, PREFS_STRING }, - { "search_url", &prefs.search_urls, PREFS_STRINGS }, - { "show_back", &prefs.show_back, PREFS_BOOL }, - { "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL }, - { "show_clear_url", &prefs.show_clear_url, PREFS_BOOL }, - { "show_extra_warnings", &prefs.show_extra_warnings, PREFS_BOOL }, - { "show_filemenu", &prefs.show_filemenu, PREFS_BOOL }, - { "show_forw", &prefs.show_forw, PREFS_BOOL }, - { "show_help", &prefs.show_help, PREFS_BOOL }, - { "show_home", &prefs.show_home, PREFS_BOOL }, - { "show_msg", &prefs.show_msg, PREFS_BOOL }, - { "show_progress_box", &prefs.show_progress_box, PREFS_BOOL }, - { "show_quit_dialog", &prefs.show_quit_dialog, PREFS_BOOL }, - { "show_reload", &prefs.show_reload, PREFS_BOOL }, - { "show_save", &prefs.show_save, PREFS_BOOL }, - { "show_url", &prefs.show_url, PREFS_BOOL }, - { "show_search", &prefs.show_search, PREFS_BOOL }, - { "show_stop", &prefs.show_stop, PREFS_BOOL }, - { "show_tools", &prefs.show_tools, PREFS_BOOL }, - { "show_tooltip", &prefs.show_tooltip, PREFS_BOOL }, - { "show_ui_tooltip", &prefs.show_ui_tooltip, PREFS_BOOL }, - { "small_icons", &prefs.small_icons, PREFS_BOOL }, - { "start_page", &prefs.start_page, PREFS_URL }, - { "theme", &prefs.theme, PREFS_STRING }, - { "ui_button_highlight_color", &prefs.ui_button_highlight_color, - PREFS_COLOR }, - { "ui_fg_color", &prefs.ui_fg_color, PREFS_COLOR }, - { "ui_main_bg_color", &prefs.ui_main_bg_color, PREFS_COLOR }, - { "ui_selection_color", &prefs.ui_selection_color, PREFS_COLOR }, - { "ui_tab_active_bg_color", &prefs.ui_tab_active_bg_color, PREFS_COLOR }, - { "ui_tab_bg_color", &prefs.ui_tab_bg_color, PREFS_COLOR }, - { "ui_tab_active_fg_color", &prefs.ui_tab_active_fg_color, PREFS_COLOR }, - { "ui_tab_fg_color", &prefs.ui_tab_fg_color, PREFS_COLOR }, - { "ui_text_bg_color", &prefs.ui_text_bg_color, PREFS_COLOR }, - { "w3c_plus_heuristics", &prefs.w3c_plus_heuristics, PREFS_BOOL }, - { "penalty_hyphen", &prefs.penalty_hyphen, PREFS_FRACTION_100 }, - { "penalty_hyphen_2", &prefs.penalty_hyphen_2, PREFS_FRACTION_100 }, - { "penalty_em_dash_left", &prefs.penalty_em_dash_left, - PREFS_FRACTION_100 }, - { "penalty_em_dash_right", &prefs.penalty_em_dash_right, - PREFS_FRACTION_100 }, - { "penalty_em_dash_right_2", &prefs.penalty_em_dash_right_2, - PREFS_FRACTION_100 }, - { "stretchability_factor", &prefs.stretchability_factor, - PREFS_FRACTION_100 } - }; - node = NULL; - for (i = 0; i < sizeof(symbols) / sizeof(symbols[0]); i++) { + for (i = 0; i < n_symbols; i++) { if (!strcmp(symbols[i].name, name)) { node = & (symbols[i]); break; @@ -225,6 +140,91 @@ void PrefsParser::parse(FILE *fp) char *line, *name, *value, *oldLocale; int st; + /* Symbol array, sorted alphabetically */ + SymNode_t symbols[] = { + { "allow_white_bg", &prefs.allow_white_bg, PREFS_BOOL }, + { "white_bg_replacement", &prefs.white_bg_replacement, PREFS_COLOR }, + { "bg_color", &prefs.bg_color, PREFS_COLOR }, + { "buffered_drawing", &prefs.buffered_drawing, PREFS_INT32 }, + { "contrast_visited_color", &prefs.contrast_visited_color, PREFS_BOOL }, + { "enterpress_forces_submit", &prefs.enterpress_forces_submit, + PREFS_BOOL }, + { "focus_new_tab", &prefs.focus_new_tab, PREFS_BOOL }, + { "font_cursive", &prefs.font_cursive, PREFS_STRING }, + { "font_factor", &prefs.font_factor, PREFS_DOUBLE }, + { "font_fantasy", &prefs.font_fantasy, PREFS_STRING }, + { "font_max_size", &prefs.font_max_size, PREFS_INT32 }, + { "font_min_size", &prefs.font_min_size, PREFS_INT32 }, + { "font_monospace", &prefs.font_monospace, PREFS_STRING }, + { "font_sans_serif", &prefs.font_sans_serif, PREFS_STRING }, + { "font_serif", &prefs.font_serif, PREFS_STRING }, + { "fullwindow_start", &prefs.fullwindow_start, PREFS_BOOL }, + { "geometry", NULL, PREFS_GEOMETRY }, + { "home", &prefs.home, PREFS_URL }, + { "http_language", &prefs.http_language, PREFS_STRING }, + { "http_max_conns", &prefs.http_max_conns, PREFS_INT32 }, + { "http_proxy", &prefs.http_proxy, PREFS_URL }, + { "http_proxyuser", &prefs.http_proxyuser, PREFS_STRING }, + { "http_referer", &prefs.http_referer, PREFS_STRING }, + { "http_user_agent", &prefs.http_user_agent, PREFS_STRING }, + { "limit_text_width", &prefs.limit_text_width, PREFS_BOOL }, + { "load_images", &prefs.load_images, PREFS_BOOL }, + { "load_background_images", &prefs.load_background_images, PREFS_BOOL }, + { "load_stylesheets", &prefs.load_stylesheets, PREFS_BOOL }, + { "middle_click_drags_page", &prefs.middle_click_drags_page, + PREFS_BOOL }, + { "middle_click_opens_new_tab", &prefs.middle_click_opens_new_tab, + PREFS_BOOL }, + { "right_click_closes_tab", &prefs.right_click_closes_tab, PREFS_BOOL }, + { "no_proxy", &prefs.no_proxy, PREFS_STRING }, + { "panel_size", &prefs.panel_size, PREFS_PANEL_SIZE }, + { "parse_embedded_css", &prefs.parse_embedded_css, PREFS_BOOL }, + { "save_dir", &prefs.save_dir, PREFS_STRING }, + { "search_url", &prefs.search_urls, PREFS_STRINGS }, + { "show_back", &prefs.show_back, PREFS_BOOL }, + { "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL }, + { "show_clear_url", &prefs.show_clear_url, PREFS_BOOL }, + { "show_extra_warnings", &prefs.show_extra_warnings, PREFS_BOOL }, + { "show_filemenu", &prefs.show_filemenu, PREFS_BOOL }, + { "show_forw", &prefs.show_forw, PREFS_BOOL }, + { "show_help", &prefs.show_help, PREFS_BOOL }, + { "show_home", &prefs.show_home, PREFS_BOOL }, + { "show_msg", &prefs.show_msg, PREFS_BOOL }, + { "show_progress_box", &prefs.show_progress_box, PREFS_BOOL }, + { "show_quit_dialog", &prefs.show_quit_dialog, PREFS_BOOL }, + { "show_reload", &prefs.show_reload, PREFS_BOOL }, + { "show_save", &prefs.show_save, PREFS_BOOL }, + { "show_url", &prefs.show_url, PREFS_BOOL }, + { "show_search", &prefs.show_search, PREFS_BOOL }, + { "show_stop", &prefs.show_stop, PREFS_BOOL }, + { "show_tools", &prefs.show_tools, PREFS_BOOL }, + { "show_tooltip", &prefs.show_tooltip, PREFS_BOOL }, + { "show_ui_tooltip", &prefs.show_ui_tooltip, PREFS_BOOL }, + { "small_icons", &prefs.small_icons, PREFS_BOOL }, + { "start_page", &prefs.start_page, PREFS_URL }, + { "theme", &prefs.theme, PREFS_STRING }, + { "ui_button_highlight_color", &prefs.ui_button_highlight_color, + PREFS_COLOR }, + { "ui_fg_color", &prefs.ui_fg_color, PREFS_COLOR }, + { "ui_main_bg_color", &prefs.ui_main_bg_color, PREFS_COLOR }, + { "ui_selection_color", &prefs.ui_selection_color, PREFS_COLOR }, + { "ui_tab_active_bg_color", &prefs.ui_tab_active_bg_color, PREFS_COLOR }, + { "ui_tab_bg_color", &prefs.ui_tab_bg_color, PREFS_COLOR }, + { "ui_tab_active_fg_color", &prefs.ui_tab_active_fg_color, PREFS_COLOR }, + { "ui_tab_fg_color", &prefs.ui_tab_fg_color, PREFS_COLOR }, + { "ui_text_bg_color", &prefs.ui_text_bg_color, PREFS_COLOR }, + { "w3c_plus_heuristics", &prefs.w3c_plus_heuristics, PREFS_BOOL }, + { "penalty_hyphen", &prefs.penalty_hyphen, PREFS_FRACTION_100 }, + { "penalty_hyphen_2", &prefs.penalty_hyphen_2, PREFS_FRACTION_100 }, + { "penalty_em_dash_left", &prefs.penalty_em_dash_left, + PREFS_FRACTION_100 }, + { "penalty_em_dash_right", &prefs.penalty_em_dash_right, + PREFS_FRACTION_100 }, + { "penalty_em_dash_right_2", &prefs.penalty_em_dash_right_2, + PREFS_FRACTION_100 }, + { "stretchability_factor", &prefs.stretchability_factor, + PREFS_FRACTION_100 } + }; // changing the LC_NUMERIC locale (temporarily) to C // avoids parsing problems with float numbers oldLocale = dStrdup(setlocale(LC_NUMERIC, NULL)); @@ -236,7 +236,7 @@ void PrefsParser::parse(FILE *fp) if (st == 0) { _MSG("prefsparser: name=%s, value=%s\n", name, value); - parseOption(name, value); + parseOption(name, value, symbols, sizeof(symbols) / sizeof(symbols[0])); } else if (st < 0) { MSG_ERR("prefsparser: Syntax error in dillorc:" " name=\"%s\" value=\"%s\"\n", name, value); diff --git a/src/prefsparser.hh b/src/prefsparser.hh index d10c43c4..91f6f7ee 100644 --- a/src/prefsparser.hh +++ b/src/prefsparser.hh @@ -15,7 +15,6 @@ #ifdef __cplusplus class PrefsParser { public: - static int parseOption(char *name, char *value); static int parseLine(char *line, char *name, char *value); static void parse(FILE *fp); }; -- cgit v1.2.3 From 3467b484d1ffa1521750693daf30344f0062f8ac Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 15 Feb 2015 19:20:21 +0100 Subject: add count field in PrefsParser SymNode_t --- src/prefsparser.cc | 153 +++++++++++++++++++++++++++-------------------------- 1 file changed, 78 insertions(+), 75 deletions(-) diff --git a/src/prefsparser.cc b/src/prefsparser.cc index 5f90f82f..b82c58fa 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -39,6 +39,7 @@ typedef struct { const char *name; void *pref; PrefType_t type; + int count; } SymNode_t; /* @@ -47,7 +48,7 @@ typedef struct { static int parseOption(char *name, char *value, SymNode_t *symbols, int n_symbols) { - const SymNode_t *node; + SymNode_t *node; int i; int st; @@ -129,6 +130,8 @@ static int parseOption(char *name, char *value, MSG_WARN("prefs: {%s} IS recognized but not handled!\n", name); break; /* Not reached */ } + node->count++; + return 0; } @@ -142,88 +145,88 @@ void PrefsParser::parse(FILE *fp) /* Symbol array, sorted alphabetically */ SymNode_t symbols[] = { - { "allow_white_bg", &prefs.allow_white_bg, PREFS_BOOL }, - { "white_bg_replacement", &prefs.white_bg_replacement, PREFS_COLOR }, - { "bg_color", &prefs.bg_color, PREFS_COLOR }, - { "buffered_drawing", &prefs.buffered_drawing, PREFS_INT32 }, - { "contrast_visited_color", &prefs.contrast_visited_color, PREFS_BOOL }, + { "allow_white_bg", &prefs.allow_white_bg, PREFS_BOOL, 0 }, + { "white_bg_replacement", &prefs.white_bg_replacement, PREFS_COLOR, 0 }, + { "bg_color", &prefs.bg_color, PREFS_COLOR, 0 }, + { "buffered_drawing", &prefs.buffered_drawing, PREFS_INT32, 0 }, + { "contrast_visited_color", &prefs.contrast_visited_color, PREFS_BOOL, 0 }, { "enterpress_forces_submit", &prefs.enterpress_forces_submit, - PREFS_BOOL }, - { "focus_new_tab", &prefs.focus_new_tab, PREFS_BOOL }, - { "font_cursive", &prefs.font_cursive, PREFS_STRING }, - { "font_factor", &prefs.font_factor, PREFS_DOUBLE }, - { "font_fantasy", &prefs.font_fantasy, PREFS_STRING }, - { "font_max_size", &prefs.font_max_size, PREFS_INT32 }, - { "font_min_size", &prefs.font_min_size, PREFS_INT32 }, - { "font_monospace", &prefs.font_monospace, PREFS_STRING }, - { "font_sans_serif", &prefs.font_sans_serif, PREFS_STRING }, - { "font_serif", &prefs.font_serif, PREFS_STRING }, - { "fullwindow_start", &prefs.fullwindow_start, PREFS_BOOL }, - { "geometry", NULL, PREFS_GEOMETRY }, - { "home", &prefs.home, PREFS_URL }, - { "http_language", &prefs.http_language, PREFS_STRING }, - { "http_max_conns", &prefs.http_max_conns, PREFS_INT32 }, - { "http_proxy", &prefs.http_proxy, PREFS_URL }, - { "http_proxyuser", &prefs.http_proxyuser, PREFS_STRING }, - { "http_referer", &prefs.http_referer, PREFS_STRING }, - { "http_user_agent", &prefs.http_user_agent, PREFS_STRING }, - { "limit_text_width", &prefs.limit_text_width, PREFS_BOOL }, - { "load_images", &prefs.load_images, PREFS_BOOL }, - { "load_background_images", &prefs.load_background_images, PREFS_BOOL }, - { "load_stylesheets", &prefs.load_stylesheets, PREFS_BOOL }, + PREFS_BOOL, 0 }, + { "focus_new_tab", &prefs.focus_new_tab, PREFS_BOOL, 0 }, + { "font_cursive", &prefs.font_cursive, PREFS_STRING, 0 }, + { "font_factor", &prefs.font_factor, PREFS_DOUBLE, 0 }, + { "font_fantasy", &prefs.font_fantasy, PREFS_STRING, 0 }, + { "font_max_size", &prefs.font_max_size, PREFS_INT32, 0 }, + { "font_min_size", &prefs.font_min_size, PREFS_INT32, 0 }, + { "font_monospace", &prefs.font_monospace, PREFS_STRING, 0 }, + { "font_sans_serif", &prefs.font_sans_serif, PREFS_STRING, 0 }, + { "font_serif", &prefs.font_serif, PREFS_STRING, 0 }, + { "fullwindow_start", &prefs.fullwindow_start, PREFS_BOOL, 0 }, + { "geometry", NULL, PREFS_GEOMETRY, 0 }, + { "home", &prefs.home, PREFS_URL, 0 }, + { "http_language", &prefs.http_language, PREFS_STRING, 0 }, + { "http_max_conns", &prefs.http_max_conns, PREFS_INT32, 0 }, + { "http_proxy", &prefs.http_proxy, PREFS_URL, 0 }, + { "http_proxyuser", &prefs.http_proxyuser, PREFS_STRING, 0 }, + { "http_referer", &prefs.http_referer, PREFS_STRING, 0 }, + { "http_user_agent", &prefs.http_user_agent, PREFS_STRING, 0 }, + { "limit_text_width", &prefs.limit_text_width, PREFS_BOOL, 0 }, + { "load_images", &prefs.load_images, PREFS_BOOL, 0 }, + { "load_background_images", &prefs.load_background_images, PREFS_BOOL, 0 }, + { "load_stylesheets", &prefs.load_stylesheets, PREFS_BOOL, 0 }, { "middle_click_drags_page", &prefs.middle_click_drags_page, - PREFS_BOOL }, + PREFS_BOOL, 0 }, { "middle_click_opens_new_tab", &prefs.middle_click_opens_new_tab, - PREFS_BOOL }, - { "right_click_closes_tab", &prefs.right_click_closes_tab, PREFS_BOOL }, - { "no_proxy", &prefs.no_proxy, PREFS_STRING }, - { "panel_size", &prefs.panel_size, PREFS_PANEL_SIZE }, - { "parse_embedded_css", &prefs.parse_embedded_css, PREFS_BOOL }, - { "save_dir", &prefs.save_dir, PREFS_STRING }, - { "search_url", &prefs.search_urls, PREFS_STRINGS }, - { "show_back", &prefs.show_back, PREFS_BOOL }, - { "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL }, - { "show_clear_url", &prefs.show_clear_url, PREFS_BOOL }, - { "show_extra_warnings", &prefs.show_extra_warnings, PREFS_BOOL }, - { "show_filemenu", &prefs.show_filemenu, PREFS_BOOL }, - { "show_forw", &prefs.show_forw, PREFS_BOOL }, - { "show_help", &prefs.show_help, PREFS_BOOL }, - { "show_home", &prefs.show_home, PREFS_BOOL }, - { "show_msg", &prefs.show_msg, PREFS_BOOL }, - { "show_progress_box", &prefs.show_progress_box, PREFS_BOOL }, - { "show_quit_dialog", &prefs.show_quit_dialog, PREFS_BOOL }, - { "show_reload", &prefs.show_reload, PREFS_BOOL }, - { "show_save", &prefs.show_save, PREFS_BOOL }, - { "show_url", &prefs.show_url, PREFS_BOOL }, - { "show_search", &prefs.show_search, PREFS_BOOL }, - { "show_stop", &prefs.show_stop, PREFS_BOOL }, - { "show_tools", &prefs.show_tools, PREFS_BOOL }, - { "show_tooltip", &prefs.show_tooltip, PREFS_BOOL }, - { "show_ui_tooltip", &prefs.show_ui_tooltip, PREFS_BOOL }, - { "small_icons", &prefs.small_icons, PREFS_BOOL }, - { "start_page", &prefs.start_page, PREFS_URL }, - { "theme", &prefs.theme, PREFS_STRING }, + PREFS_BOOL, 0 }, + { "right_click_closes_tab", &prefs.right_click_closes_tab, PREFS_BOOL, 0 }, + { "no_proxy", &prefs.no_proxy, PREFS_STRING, 0 }, + { "panel_size", &prefs.panel_size, PREFS_PANEL_SIZE, 0 }, + { "parse_embedded_css", &prefs.parse_embedded_css, PREFS_BOOL, 0 }, + { "save_dir", &prefs.save_dir, PREFS_STRING, 0 }, + { "search_url", &prefs.search_urls, PREFS_STRINGS, 0 }, + { "show_back", &prefs.show_back, PREFS_BOOL, 0 }, + { "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL, 0 }, + { "show_clear_url", &prefs.show_clear_url, PREFS_BOOL, 0 }, + { "show_extra_warnings", &prefs.show_extra_warnings, PREFS_BOOL, 0 }, + { "show_filemenu", &prefs.show_filemenu, PREFS_BOOL, 0 }, + { "show_forw", &prefs.show_forw, PREFS_BOOL, 0 }, + { "show_help", &prefs.show_help, PREFS_BOOL, 0 }, + { "show_home", &prefs.show_home, PREFS_BOOL, 0 }, + { "show_msg", &prefs.show_msg, PREFS_BOOL, 0 }, + { "show_progress_box", &prefs.show_progress_box, PREFS_BOOL, 0 }, + { "show_quit_dialog", &prefs.show_quit_dialog, PREFS_BOOL, 0 }, + { "show_reload", &prefs.show_reload, PREFS_BOOL, 0 }, + { "show_save", &prefs.show_save, PREFS_BOOL, 0 }, + { "show_url", &prefs.show_url, PREFS_BOOL, 0 }, + { "show_search", &prefs.show_search, PREFS_BOOL, 0 }, + { "show_stop", &prefs.show_stop, PREFS_BOOL, 0 }, + { "show_tools", &prefs.show_tools, PREFS_BOOL, 0 }, + { "show_tooltip", &prefs.show_tooltip, PREFS_BOOL, 0 }, + { "show_ui_tooltip", &prefs.show_ui_tooltip, PREFS_BOOL, 0 }, + { "small_icons", &prefs.small_icons, PREFS_BOOL, 0 }, + { "start_page", &prefs.start_page, PREFS_URL, 0 }, + { "theme", &prefs.theme, PREFS_STRING, 0 }, { "ui_button_highlight_color", &prefs.ui_button_highlight_color, - PREFS_COLOR }, - { "ui_fg_color", &prefs.ui_fg_color, PREFS_COLOR }, - { "ui_main_bg_color", &prefs.ui_main_bg_color, PREFS_COLOR }, - { "ui_selection_color", &prefs.ui_selection_color, PREFS_COLOR }, - { "ui_tab_active_bg_color", &prefs.ui_tab_active_bg_color, PREFS_COLOR }, - { "ui_tab_bg_color", &prefs.ui_tab_bg_color, PREFS_COLOR }, - { "ui_tab_active_fg_color", &prefs.ui_tab_active_fg_color, PREFS_COLOR }, - { "ui_tab_fg_color", &prefs.ui_tab_fg_color, PREFS_COLOR }, - { "ui_text_bg_color", &prefs.ui_text_bg_color, PREFS_COLOR }, - { "w3c_plus_heuristics", &prefs.w3c_plus_heuristics, PREFS_BOOL }, - { "penalty_hyphen", &prefs.penalty_hyphen, PREFS_FRACTION_100 }, - { "penalty_hyphen_2", &prefs.penalty_hyphen_2, PREFS_FRACTION_100 }, + PREFS_COLOR, 0 }, + { "ui_fg_color", &prefs.ui_fg_color, PREFS_COLOR, 0 }, + { "ui_main_bg_color", &prefs.ui_main_bg_color, PREFS_COLOR, 0 }, + { "ui_selection_color", &prefs.ui_selection_color, PREFS_COLOR, 0 }, + { "ui_tab_active_bg_color", &prefs.ui_tab_active_bg_color, PREFS_COLOR, 0 }, + { "ui_tab_bg_color", &prefs.ui_tab_bg_color, PREFS_COLOR, 0 }, + { "ui_tab_active_fg_color", &prefs.ui_tab_active_fg_color, PREFS_COLOR, 0 }, + { "ui_tab_fg_color", &prefs.ui_tab_fg_color, PREFS_COLOR, 0 }, + { "ui_text_bg_color", &prefs.ui_text_bg_color, PREFS_COLOR, 0 }, + { "w3c_plus_heuristics", &prefs.w3c_plus_heuristics, PREFS_BOOL, 0 }, + { "penalty_hyphen", &prefs.penalty_hyphen, PREFS_FRACTION_100, 0 }, + { "penalty_hyphen_2", &prefs.penalty_hyphen_2, PREFS_FRACTION_100, 0 }, { "penalty_em_dash_left", &prefs.penalty_em_dash_left, - PREFS_FRACTION_100 }, + PREFS_FRACTION_100, 0 }, { "penalty_em_dash_right", &prefs.penalty_em_dash_right, - PREFS_FRACTION_100 }, + PREFS_FRACTION_100, 0 }, { "penalty_em_dash_right_2", &prefs.penalty_em_dash_right_2, - PREFS_FRACTION_100 }, + PREFS_FRACTION_100, 0 }, { "stretchability_factor", &prefs.stretchability_factor, - PREFS_FRACTION_100 } + PREFS_FRACTION_100, 0 } }; // changing the LC_NUMERIC locale (temporarily) to C // avoids parsing problems with float numbers -- cgit v1.2.3 From b9113ebdd132bf210b862c8b59942fc47b7d455e Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 15 Feb 2015 19:27:04 +0100 Subject: use new count field to override default search url --- src/prefsparser.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/prefsparser.cc b/src/prefsparser.cc index b82c58fa..d08dddfc 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -82,12 +82,13 @@ static int parseOption(char *name, char *value, case PREFS_STRINGS: { Dlist *lp = *(Dlist **)node->pref; - if (dList_length(lp) == 2 && !dList_nth_data(lp, 1)) { + if (node->count == 0) { /* override the default */ - void *data = dList_nth_data(lp, 0); - dList_remove(lp, data); - dList_remove(lp, NULL); - dFree(data); + for (i = 0; i < dList_length(lp); i++) { + void *data = dList_nth_data(lp, i); + dList_remove(lp, data); + dFree(dList_nth_data(lp, i)); + } } dList_append(lp, dStrdup(value)); break; -- cgit v1.2.3 From 286b8ddbc7d40834f9f80e4aea86ebc9eda462b1 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 6 Jan 2015 21:29:27 +0100 Subject: disable drag and drop DND support crashes on MacOSX and causes confusion on X11. reported by: James C --- src/dillo.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dillo.cc b/src/dillo.cc index ee2f4da4..20b2796e 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -496,6 +496,10 @@ int main(int argc, char **argv) Fl_Window::default_xclass("dillo"); Fl::scheme(prefs.theme); + + // Disable drag and drop as it crashes on MacOSX + Fl::dnd_text_ops(0); + setColors(); if (!prefs.show_ui_tooltip) { -- cgit v1.2.3 From bbfa39305b0bcef65270e700fbe27a5e628f9528 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 25 Jul 2014 22:48:32 +0200 Subject: avoid requesting background images if an ancestor has display:none noticed-by: eocene --- src/styleengine.cc | 16 ++++++++++------ src/styleengine.hh | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/styleengine.cc b/src/styleengine.cc index e07ab3d5..113eac44 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -112,7 +112,7 @@ StyleEngine::~StyleEngine () { void StyleEngine::stackPush () { static const Node emptyNode = { - NULL, NULL, NULL, NULL, NULL, NULL, false, NULL + NULL, NULL, NULL, NULL, NULL, NULL, false, false, NULL }; stack->setSize (stack->size () + 1, emptyNode); @@ -145,6 +145,8 @@ void StyleEngine::startElement (int element, BrowserWindow *bw) { dn->element = element; n->doctreeNode = dn; + if (stack->size () > 1) + n->displayNone = stack->getRef (stack->size () - 2)->displayNone; } void StyleEngine::startElement (const char *tagname, BrowserWindow *bw) { @@ -364,8 +366,8 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, DilloUrl *imgUrl = NULL; /* Determine font first so it can be used to resolve relative lengths. */ - for (int i = 0; i < props->size (); i++) { - CssProperty *p = props->getRef (i); + for (int j = 0; j < props->size (); j++) { + CssProperty *p = props->getRef (j); switch (p->name) { case CSS_PROPERTY_FONT_FAMILY: @@ -512,8 +514,8 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, attrs->font = Font::create (layout, &fontAttrs); - for (int i = 0; i < props->size (); i++) { - CssProperty *p = props->getRef (i); + for (int j = 0; j < props->size (); j++) { + CssProperty *p = props->getRef (j); switch (p->name) { /* \todo missing cases */ @@ -596,6 +598,8 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, break; case CSS_PROPERTY_DISPLAY: attrs->display = (DisplayType) p->value.intVal; + if (attrs->display == DISPLAY_NONE) + stack->getRef (i)->displayNone = true; break; case CSS_PROPERTY_LINE_HEIGHT: if (p->type == CSS_TYPE_ENUM) { //only valid enum value is "normal" @@ -709,7 +713,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, } if (imgUrl && prefs.load_background_images && - attrs->display != DISPLAY_NONE && + !stack->getRef (i)->displayNone && !(URL_FLAGS(pageUrl) & URL_SpamSafe)) { attrs->backgroundImage = StyleImage::create(); diff --git a/src/styleengine.hh b/src/styleengine.hh index 41f892d7..a07d1863 100644 --- a/src/styleengine.hh +++ b/src/styleengine.hh @@ -27,6 +27,7 @@ class StyleEngine { dw::core::style::Style *wordStyle; dw::core::style::Style *backgroundStyle; bool inheritBackgroundColor; + bool displayNone; DoctreeNode *doctreeNode; }; -- cgit v1.2.3 From c9b454f00baf3cea7f285cfa71abde1b4be39250 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 8 Mar 2015 20:05:21 +0100 Subject: fix leak introduced in bbd25bf5 noticed-by: eocene --- src/prefsparser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prefsparser.cc b/src/prefsparser.cc index d08dddfc..bf891491 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -87,7 +87,7 @@ static int parseOption(char *name, char *value, for (i = 0; i < dList_length(lp); i++) { void *data = dList_nth_data(lp, i); dList_remove(lp, data); - dFree(dList_nth_data(lp, i)); + dFree(data); } } dList_append(lp, dStrdup(value)); -- cgit v1.2.3 From be3c2cdc23b61431bb2d620c0aa9a87e7fcb7f0c Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 3 Apr 2015 19:24:10 +0000 Subject: html5 (and css3) permit gr[ae]y in color names --- src/colors.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/colors.c b/src/colors.c index fe3598eb..d4cc60c5 100644 --- a/src/colors.c +++ b/src/colors.c @@ -62,6 +62,7 @@ static const struct key { { "darkgoldenrod", 0xb8860b}, { "darkgray", 0xa9a9a9}, { "darkgreen", 0x006400}, + { "darkgrey", 0xa9a9a9}, { "darkkhaki", 0xbdb76b}, { "darkmagenta", 0x8b008b}, { "darkolivegreen", 0x556b2f}, @@ -72,11 +73,13 @@ static const struct key { { "darkseagreen", 0x8fbc8f}, { "darkslateblue", 0x483d8b}, { "darkslategray", 0x2f4f4f}, + { "darkslategrey", 0x2f4f4f}, { "darkturquoise", 0x00ced1}, { "darkviolet", 0x9400d3}, { "deeppink", 0xff1493}, { "deepskyblue", 0x00bfff}, { "dimgray", 0x696969}, + { "dimgrey", 0x696969}, { "dodgerblue", 0x1e90ff}, { "firebrick", 0xb22222}, { "floralwhite", 0xfffaf0}, @@ -93,6 +96,7 @@ static const struct key { { "green", 0x008000}, #ifdef EXTENDED_COLOR { "greenyellow", 0xadff2f}, + { "grey", 0x808080}, { "honeydew", 0xf0fff0}, { "hotpink", 0xff69b4}, { "indianred", 0xcd5c5c}, @@ -107,6 +111,7 @@ static const struct key { { "lightcoral", 0xf08080}, { "lightcyan", 0xe0ffff}, { "lightgoldenrodyellow", 0xfafad2}, + { "lightgray", 0xd3d3d3}, { "lightgreen", 0x90ee90}, { "lightgrey", 0xd3d3d3}, { "lightpink", 0xffb6c1}, @@ -114,6 +119,7 @@ static const struct key { { "lightseagreen", 0x20b2aa}, { "lightskyblue", 0x87cefa}, { "lightslategray", 0x778899}, + { "lightslategrey", 0x778899}, { "lightsteelblue", 0xb0c4de}, { "lightyellow", 0xffffe0}, #endif @@ -178,6 +184,7 @@ static const struct key { { "skyblue", 0x87ceeb}, { "slateblue", 0x6a5acd}, { "slategray", 0x708090}, + { "slategrey", 0x708090}, { "snow", 0xfffafa}, { "springgreen", 0x00ff7f}, { "steelblue", 0x4682b4}, -- cgit v1.2.3 From 706b795680528972802ccb3a9d7595d3014353fe Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 12 Apr 2015 17:35:43 +0000 Subject: more html5 doctype strings Followed a link to instructables.com and found that they use one of these. I'm a little surprised to see one of these strings around. A minute of research shows: Apparently it generally has something to do with xslt restrictions. --- src/html.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/html.cc b/src/html.cc index f1177bb1..c5fa470c 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1624,7 +1624,11 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize) html->DocTypeVersion = 2.0f; } } else if (!dStrAsciiCasecmp(ntag, "") || - !dStrAsciiCasecmp(ntag, "")) { + !dStrAsciiCasecmp(ntag, "") || + !dStrAsciiCasecmp(ntag, + "") || + !dStrAsciiCasecmp(ntag, + "")) { html->DocType = DT_HTML; html->DocTypeVersion = 5.0f; } -- cgit v1.2.3 From febefaacf08bbf5ef49e53fb799d88f227e89867 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 9 May 2015 02:54:15 +0000 Subject: fix font-size:(larger|smaller) --- src/styleengine.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/styleengine.cc b/src/styleengine.cc index 113eac44..91a2b2c5 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -429,12 +429,10 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, fontAttrs.size = roundInt(24.2 * prefs.font_factor); break; case CSS_FONT_SIZE_SMALLER: - fontAttrs.size = roundInt(fontAttrs.size * 0.83 * - prefs.font_factor); + fontAttrs.size = roundInt(fontAttrs.size * 0.83); break; case CSS_FONT_SIZE_LARGER: - fontAttrs.size = roundInt(fontAttrs.size * 1.2 * - prefs.font_factor); + fontAttrs.size = roundInt(fontAttrs.size * 1.2); break; default: assert(false); // invalid font-size enum -- cgit v1.2.3 From 800fe85be22ab132c20abcef32b24f563fe12139 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 9 May 2015 07:10:21 +0000 Subject: keys: add Menu key Now have a computer with windows keys :( and, at least for me, the one that looks like a menu is apparently "Menu" in xev. (Although some FLTK documentation and other stuff on the web suggests that this used to [or maybe still does for some people] cause Super_R (xev), which would then turn into FL_Meta_R in FLTK.) --- src/keys.cc | 1 + src/keysrc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/keys.cc b/src/keys.cc index 27b275a3..44f6acd9 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -59,6 +59,7 @@ static const Mapping_t keyNames[] = { { "Home", FL_Home }, { "Insert", FL_Insert }, { "Left", FL_Left }, + { "Menu", FL_Menu }, { "PageDown", FL_Page_Down }, { "PageUp", FL_Page_Up }, { "Print", FL_Print }, diff --git a/src/keysrc b/src/keysrc index 11913e78..64d527d6 100644 --- a/src/keysrc +++ b/src/keysrc @@ -9,7 +9,7 @@ # (OS X: Use "Meta" for Command) # # Key names recognized: "Backspace", "Delete", "Down", "End", "Esc", -# "F1" through "F12", "Home", "Insert", "Left", "PageDown", "PageUp", +# "F1" through "F12", "Home", "Insert", "Left", "Menu", "PageDown", "PageUp", # "Print", "Return", "Right", "Space", "Tab", "Up". # # Multimedia keys: "Back", "Favorites", "Forward", "HomePage", "Mail", -- cgit v1.2.3 From 710297d990e450ecfd7d02be82d8652aa0c52009 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 9 May 2015 15:24:53 +0000 Subject: splash: urge users to read help. mention domainrc. Just recently I added some mention of domainrc to the website. I hadn't made enough of an effort to communicate the fact that it exists, and now it's time to remedy that. --- src/IO/about.c | 76 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/src/IO/about.c b/src/IO/about.c index 5ffe7dff..0b2c01c0 100644 --- a/src/IO/about.c +++ b/src/IO/about.c @@ -229,29 +229,36 @@ const char *const AboutSplash= "\n" "\n" " \n" "
\n" -"

Release overview

\n" -" December 24, 2014\n" +"

Notes

\n" "
\n" " \n" " \n" "
\n" -"

\n" -"The dillo-3.0.4.1 release brings you fixes:\n" "

    \n" -"
  • for linking with the recently-released fltk-1.3.3\n" -" (we don't use fl_oldfocus anymore).\n" -"
  • to make sure that windows are resizable with fltk-1.3.3.\n" -"
  • not to load background images, or follow redirections or meta refresh,\n" -" in --local mode (security).\n" -"
  • to permit linking on OS X (remove our Fl_Printer stub).\n" -"
  • for a crash when searching from the address bar and no search urls are\n" -" found in dillorc.\n" +"
  • Read the help,\n" +" it's short.\n" +"
  • There's a\n" +" dillorc\n" +" (readable config) file inside the tarball. It is well-commented\n" +" and has plenty of options to customize dillo, so copy\n" +" it to your ~/.dillo/ directory, and\n" +" modify it to your taste.\n" +"
  • The right mouse button brings up a context-sensitive menu\n" +" (available on pages, links, images, forms, the Back and Forward buttons,\n" +" and the bug meter).\n" +"
  • Cookies are disabled by default for privacy. To log into certain\n" +" sites, you may need to enable\n" +" cookies selectively.\n" +"
  • To stop third-party ads and tracking, you can use a\n" +" ~/.dillo/domainrc/ file.\n" +"
  • Frames, Java and Javascript are not supported.\n" +"
  • This release is mainly intended for developers\n" +" and advanced users.\n" +"
  • Documentation for developers is in the /doc\n" +" dir inside the tarball; you can find directions on everything\n" +" else at the home page.\n" "
\n" -"

\n" -"...that shouldn't have to wait until dillo-3.1 is ready with its floating\n" -"elements and assorted good things.\n" -"

\n" "

\n" "
\n" "\n" @@ -262,38 +269,33 @@ const char *const AboutSplash= "\n" "\n" " \n" "
\n" -"

Notes

\n" +"

Release overview

\n" +" December 24, 2014\n" "
\n" " \n" " \n" "
\n" +"

\n" +"The dillo-3.0.4.1 release brings you fixes:\n" "

    \n" -"
  • There's a\n" -" dillorc\n" -" (readable config) file inside the tarball. It is well-commented\n" -" and has plenty of options to customize dillo, so copy\n" -" it to your ~/.dillo/ directory, and\n" -" modify it to your taste.\n" -"
  • Documentation for developers is in the /doc\n" -" dir inside the tarball; you can find directions on everything\n" -" else at the home page.\n" -"
  • The right mouse button brings up a context-sensitive menu\n" -" (available on pages, links, images, forms, the Back and Forward buttons,\n" -" and the bug meter).\n" -"
  • Dillo behaves very nicely when browsing local files, images, and HTML.\n" -" It's also very good for Internet searching.\n" -"
  • This release is mainly intended for developers\n" -" and advanced users.\n" -"
  • Frames, Java and Javascript are not supported.\n" +"
  • for linking with the recently-released fltk-1.3.3\n" +" (we don't use fl_oldfocus anymore).\n" +"
  • to make sure that windows are resizable with fltk-1.3.3.\n" +"
  • not to load background images, or follow redirections or meta refresh,\n" +" in --local mode (security).\n" +"
  • to permit linking on OS X (remove our Fl_Printer stub).\n" +"
  • for a crash when searching from the address bar and no search urls are\n" +" found in dillorc.\n" "
\n" -"
\n" +"

\n" +"...that shouldn't have to wait until dillo-3.1 is ready with its floating\n" +"elements and assorted good things.\n" +"

\n" "

\n" "
\n" "\n" "\n" -"
\n" -"\n" "\n" "\n" "\n" -- cgit v1.2.3 From 37948ff867620850b921429c9b36886f40ce3843 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 16 May 2015 17:28:24 +0000 Subject: dillorc: search urls duckduckgo and startpage always redirect to https, so just specify https --- dillorc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dillorc b/dillorc index 20b1f912..e3d859c9 100644 --- a/dillorc +++ b/dillorc @@ -157,10 +157,10 @@ # You can enable multiple search_url strings at once and select from among # them at runtime, with the first being the default. # (the prefix serves to search from the Location Bar. e.g. "dd dillo image") -search_url="dd DuckDuckGo http://duckduckgo.com/lite/?kp=-1&q=%s" +search_url="dd DuckDuckGo (https) https://duckduckgo.com/lite/?kp=-1&q=%s" search_url="Wikipedia http://www.wikipedia.org/w/index.php?search=%s&go=Go" search_url="Free Dictionary http://www.thefreedictionary.com/%s" -search_url="Startpage http://www.startpage.com/do/search?query=%s" +search_url="Startpage (https) https://www.startpage.com/do/search?query=%s" search_url="Google http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s" # If set, dillo will ask web servers to send pages in this language. -- cgit v1.2.3 From 24cff71d47c8b5cd15129a53295a4a27b93f89c0 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 26 May 2015 11:29:21 -0300 Subject: Fix view-source dpi to handle null characters correctly Although not allowed in text contexts, null characters should not stop/halt/fail dpi protocol, thus the patch. Test Example. Display a file with these contents: null padding^@^@ (two trailing null characters) and view source for it. Note that dillo will not _display_ the file completely correct, it will eat a char after each null, but this is not a problem in dpi nor dpip but in rendering, the cache gets it right. Adding code to correctly _display_ these anomalous pages is probably not worth the effort though. --- doc/Dpid.txt | 5 +++-- dpi/vsource.c | 56 +++++++++++++++++++++++++++++++------------------------- dpip/dpip.c | 21 ++++++++++++++++++--- dpip/dpip.h | 1 + 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/doc/Dpid.txt b/doc/Dpid.txt index 82b81311..6c418f57 100644 --- a/doc/Dpid.txt +++ b/doc/Dpid.txt @@ -285,9 +285,10 @@ commented code in hello.c and start making changes! Debugging a dpi --------------- - The simplest way is to add printf() feedback using the MSG* + The simplest way is to add printf-like feedback using the MSG* macros. You can start the dpid by hand on a terminal to force -messages to go there. +messages to go there. Filter dpis use sdterr and server dpis +stdout. Sometimes more complex dpis need more than MSG*. In this case you can use gdb like this. diff --git a/dpi/vsource.c b/dpi/vsource.c index 2f1129cb..c28e7b49 100644 --- a/dpi/vsource.c +++ b/dpi/vsource.c @@ -3,7 +3,7 @@ * * This server is an example. Play with it and modify to your taste. * - * Copyright 2010 Jorge Arellano Cid + * Copyright 2010-2015 Jorge Arellano Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ * Debugging macros */ #define _MSG(...) -#define MSG(...) printf("[vsource dpi]: " __VA_ARGS__) +#define MSG(...) fprintf(stderr, "[vsource dpi]: " __VA_ARGS__) /*---------------------------------------------------------------------------*/ @@ -42,38 +42,41 @@ void send_dpip_tag(Dsh *sh, char *dpip_tag) /* * Send source as plain text + * (handles embedded null chars correctly). */ void send_plain_text(Dsh *sh, int data_size) { - int bytes_read = 0; - char *src_str; + char *token; + int bytes_read = 0, token_size; /* Send HTTP header for plain text MIME type */ a_Dpip_dsh_write_str(sh, 0, "Content-type: text/plain\n\n"); while (bytes_read < data_size && - (src_str = a_Dpip_dsh_read_token(sh, 1))) { - bytes_read += strlen(src_str); - a_Dpip_dsh_write_str(sh, 1, src_str); - dFree(src_str); + (token = a_Dpip_dsh_read_token2(sh, 1, &token_size))) { + bytes_read += token_size; + _MSG("data_size=%d bytes_read=%d\n", data_size, bytes_read); + a_Dpip_dsh_write(sh, 1, token, token_size); + dFree(token); } } /* * Send source as plain text with line numbers + * (handles embedded null chars correctly). */ void send_numbered_text(Dsh *sh, int data_size) { - int bytes_read = 0, line = 1; - char *p, *q, *src_str, line_str[32]; + int bytes_read = 0, line = 1, token_size = 0; + char *p, *q, *token, line_str[32]; /* Send HTTP header for plain text MIME type */ a_Dpip_dsh_write_str(sh, 0, "Content-type: text/plain\n\n"); while (bytes_read < data_size && - (src_str = a_Dpip_dsh_read_token(sh, 1))) { - bytes_read += strlen(src_str); - p = q = src_str; + (token = a_Dpip_dsh_read_token2(sh, 1, &token_size))) { + bytes_read += token_size; + p = q = token; while (*p) { snprintf(line_str, 32, "%2d: ", line); @@ -84,28 +87,30 @@ void send_numbered_text(Dsh *sh, int data_size) ++p; ++line; } else { - a_Dpip_dsh_write_str(sh, 1, q); + /* send all the rest */ + a_Dpip_dsh_write(sh, 1, q, token_size - (q - token)); break; } q = ++p; } - dFree(src_str); + dFree(token); } } /* * Send source as html text with line numbers + * (handles embedded null chars correctly). */ void send_html_text(Dsh *sh, const char *url, int data_size) { - int bytes_read = 0, old_line = 0, line = 1; - char *p, *q, *src_str, line_str[128]; + int bytes_read = 0, old_line = 0, line = 1, token_size = 0; + char *p, *q, *token, line_str[128]; if (dStrnAsciiCasecmp(url, "dpi:", 4) == 0 && strncmp(url+4, "/vsource/:", 10) == 0) url += 14; - /* Send HTTP header for plain text MIME type */ + /* Send HTTP header for html text MIME type */ a_Dpip_dsh_write_str(sh, 0, "Content-type: text/html\n\n"); a_Dpip_dsh_write_str(sh, 0, DOCTYPE); @@ -119,9 +124,9 @@ void send_html_text(Dsh *sh, const char *url, int data_size) "\n\n", url); while (bytes_read < data_size && - (src_str = a_Dpip_dsh_read_token(sh, 1))) { - bytes_read += strlen(src_str); - p = q = src_str; + (token = a_Dpip_dsh_read_token2(sh, 1, &token_size))) { + bytes_read += token_size; + p = q = token; while (*p) { if (line > old_line) { @@ -143,13 +148,14 @@ void send_html_text(Dsh *sh, const char *url, int data_size) a_Dpip_dsh_write(sh, 0, q, p - q); a_Dpip_dsh_write_str(sh, 0, (*p == '<') ? "<" : "&"); } - } else { - a_Dpip_dsh_write_str(sh, 1, q); + } else { + /* send all the rest */ + a_Dpip_dsh_write(sh, 1, q, token_size - (q - token)); break; } q = ++p; } - dFree(src_str); + dFree(token); } if (data_size > 0) @@ -194,7 +200,7 @@ int main(void) * asking from us. a_Dpip_dsh_read_token() will block and return * a full dpip token or null on error (it's commented in dpip.c) */ dpip_tag = a_Dpip_dsh_read_token(sh, 1); - MSG("tag = [%s]\n", dpip_tag); + _MSG("tag = [%s]\n", dpip_tag); /* Now that we have the dpip_tag, let's isolate the command and url */ cmd = a_Dpip_get_attr(dpip_tag, "cmd"); diff --git a/dpip/dpip.c b/dpip/dpip.c index f4ce1bf0..2906ba2a 100644 --- a/dpip/dpip.c +++ b/dpip/dpip.c @@ -1,7 +1,7 @@ /* * File: dpip.c * - * Copyright 2005-2007 Jorge Arellano Cid + * Copyright 2005-2015 Jorge Arellano Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -427,11 +427,13 @@ static void Dpip_dsh_read(Dsh *dsh, int blocking) /* * Return a newlly allocated string with the next dpip token in the socket. - * Return value: token string on success, NULL otherwise + * Return value: token string and length on success, NULL otherwise. + * (useful for handling null characters in the data stream) */ -char *a_Dpip_dsh_read_token(Dsh *dsh, int blocking) +char *a_Dpip_dsh_read_token2(Dsh *dsh, int blocking, int *DataSize) { char *p, *ret = NULL; + *DataSize = 0; /* Read all available data without blocking */ Dpip_dsh_read(dsh, 0); @@ -462,6 +464,7 @@ char *a_Dpip_dsh_read_token(Dsh *dsh, int blocking) /* return a full tag */ if ((p = strstr(dsh->rdbuf->str, DPIP_TAG_END))) { ret = dStrndup(dsh->rdbuf->str, p - dsh->rdbuf->str + 3); + *DataSize = p - dsh->rdbuf->str + 3; dStr_erase(dsh->rdbuf, 0, p - dsh->rdbuf->str + 3); if (strstr(ret, DPIP_MODE_SWITCH_TAG)) dsh->mode |= DPIP_LAST_TAG; @@ -470,6 +473,7 @@ char *a_Dpip_dsh_read_token(Dsh *dsh, int blocking) /* raw mode, return what we have "as is" */ if (dsh->rdbuf->len > 0) { ret = dStrndup(dsh->rdbuf->str, dsh->rdbuf->len); + *DataSize = dsh->rdbuf->len; dStr_truncate(dsh->rdbuf, 0); } } @@ -477,6 +481,17 @@ char *a_Dpip_dsh_read_token(Dsh *dsh, int blocking) return ret; } +/* + * Return a newlly allocated string with the next dpip token in the socket. + * Return value: token string on success, NULL otherwise + */ +char *a_Dpip_dsh_read_token(Dsh *dsh, int blocking) +{ + int token_size; + + return a_Dpip_dsh_read_token2(dsh, blocking, &token_size); +} + /* * Close this socket for reading and writing. * (flush pending data) diff --git a/dpip/dpip.h b/dpip/dpip.h index 1a1846df..a63eb658 100644 --- a/dpip/dpip.h +++ b/dpip/dpip.h @@ -70,6 +70,7 @@ int a_Dpip_dsh_write_str(Dsh *dsh, int flush, const char *str); int a_Dpip_dsh_tryflush(Dsh *dsh); int a_Dpip_dsh_trywrite(Dsh *dsh, const char *Data, int DataSize); char *a_Dpip_dsh_read_token(Dsh *dsh, int blocking); +char *a_Dpip_dsh_read_token2(Dsh *dsh, int blocking, int *DataSize); void a_Dpip_dsh_close(Dsh *dsh); void a_Dpip_dsh_free(Dsh *dsh); -- cgit v1.2.3 From 468bea9977fabc5ca544bb3f668b74a97e20ae28 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 27 May 2015 11:07:04 -0300 Subject: Made view-source dpi use CSS formatting (it's shorter and cleaner) BTW, is there a point in using a monospaced font? Besides it looks like code printing (which is good), a proportional-spaced font may be easier to read. --- dpi/vsource.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dpi/vsource.c b/dpi/vsource.c index c28e7b49..9d5694b5 100644 --- a/dpi/vsource.c +++ b/dpi/vsource.c @@ -118,7 +118,10 @@ void send_html_text(Dsh *sh, const char *url, int data_size) "\n" "\n" "Source for %s\n" - "\n" "\n" "\n
\n", url); @@ -131,10 +134,9 @@ void send_html_text(Dsh *sh, const char *url, int data_size) while (*p) { if (line > old_line) { snprintf(line_str, 128, - "%s
%d%s
",
-                     (line > 1) ? "
" : "", - (line & 1) ? "#B87333" : "#DD7F32", line, - (line == 1 || (line % 10) == 0) ? "  " : ""); + "
%d%s", + (line & 1) ? "r1" : "r2", line, + (line == 1 || (line % 10) == 0) ? " " : ""); a_Dpip_dsh_write_str(sh, 0, line_str); old_line = line; } @@ -158,8 +160,6 @@ void send_html_text(Dsh *sh, const char *url, int data_size) dFree(token); } - if (data_size > 0) - a_Dpip_dsh_write_str(sh, 0, ""); a_Dpip_dsh_write_str(sh, 1, "
"); } -- cgit v1.2.3 From 247c80aa5e68567c87f49e647ef8e496163d77d9 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 28 May 2015 21:15:21 +0000 Subject: libpng 1.6 series works for me --- configure.ac | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 8bc79e98..46c25263 100644 --- a/configure.ac +++ b/configure.ac @@ -209,7 +209,10 @@ if test "x$enable_png" = "xyes"; then dnl Check if the user hasn't set the variable $PNG_CONFIG if test -z "$PNG_CONFIG"; then - PNG_CONFIG=`which libpng14-config` + PNG_CONFIG=`which libpng16-config` + if test -z "$PNG_CONFIG"; then + PNG_CONFIG=`which libpng14-config` + fi if test -z "$PNG_CONFIG"; then PNG_CONFIG=`which libpng12-config` fi @@ -235,7 +238,7 @@ dnl For debugging and to be user friendly AC_MSG_CHECKING([for libpng version]) png_version=`$PNG_CONFIG --version` case $png_version in - 1.[[024]].*) AC_MSG_RESULT([$png_version]) ;; + 1.[[0246]].*) AC_MSG_RESULT([$png_version]) ;; *) AC_MSG_RESULT([$png_version (unrecognised version)]) ;; esac -- cgit v1.2.3 From 8fa364fcdaf00545222059bc7a40f0873f743489 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 31 May 2015 02:17:35 +0000 Subject: rm MSG --- src/cache.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cache.c b/src/cache.c index 14e862b5..42573d10 100644 --- a/src/cache.c +++ b/src/cache.c @@ -751,6 +751,7 @@ static void Cache_parse_header(CacheEntry_t *entry) if (!web->requester || a_Url_same_organization(entry->Url, web->requester)) { + /* If cookies are third party, don't even consider them. */ char *server_date = Cache_parse_field(header, "Date"); a_Cookies_set(Cookies, entry->Url, server_date); @@ -759,10 +760,6 @@ static void Cache_parse_header(CacheEntry_t *entry) } } } - if (i >= dList_length(ClientQueue)) { - MSG("Cache: cookies not accepted from '%s'\n", URL_STR(entry->Url)); - } - for (i = 0; (data = dList_nth_data(Cookies, i)); ++i) dFree(data); dList_free(Cookies); -- cgit v1.2.3 From 8395c48df79d75ec9a1961db88bbc8f3bbd530eb Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 10 Jun 2015 22:08:12 +0000 Subject: https rm RC4 from cipher list --- dpi/https.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dpi/https.c b/dpi/https.c index da75b9e8..545d6a9b 100644 --- a/dpi/https.c +++ b/dpi/https.c @@ -193,9 +193,11 @@ static void yes_ssl_support(void) if (exit_error == 0){ /* Don't want: eNULL, which has no encryption; aNULL, which has no * authentication; LOW, which as of 2014 use 64 or 56-bit encryption; - * EXPORT40, which uses 40-bit encryption. + * EXPORT40, which uses 40-bit encryption; RC4, for which methods were + * found in 2013 to defeat it somewhat too easily. */ - SSL_CTX_set_cipher_list(ssl_context, "ALL:!aNULL:!eNULL:!LOW:!EXPORT40"); + SSL_CTX_set_cipher_list(ssl_context, + "ALL:!aNULL:!eNULL:!LOW:!EXPORT40:!RC4"); /* Need to do this if we want to have the option of dealing * with self-signed certs -- cgit v1.2.3 From 4685caab4eab495c06f5dff7c2b75126be5f277e Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 10 Jun 2015 22:22:11 +0000 Subject: ChangeLog --- ChangeLog | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index f7b7673b..118ffa5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,29 @@ Here we list changes that are relatively significant and/or visible to the user. For a history of changes in full detail, see our Mercurial repository at http://hg.dillo.org/dillo +dillo-3.0.5 [not released yet] + ++- Fix for segfault when there's no dpid and view source is requested. + - Fix view-source dpi to handle null characters correctly. + - Made view-source dpi use CSS formatting (it's shorter and cleaner). + Patches: Jorge Arellano Cid ++- Crosscompile/buildroot-friendly fltk-config test. + Patch: Peter Seiderer ++- Fix X11 icon name. + - In location bar, tend toward showing beginning of URL instead of end. + - Handle irix's version of vsnprintf(). + - INPUT, TEXTAREA placeholder attribute. + - Fix bug with font_factor preference and CSS font-size:(larger|smaller). + - Recognize Menu key in keysrc. + - HTTPS: change cipher list to "ALL:!aNULL:!eNULL:!LOW:!EXPORT40:!RC4", + disable SSL3, disable TLS compression. + Patches: corvid ++- Avoid requesting background images if an ancestor has display:none. + - Ignore built-in search url if any are specified in dillorc. + Patches: Johannes Hofmann + +----------------------------------------------------------------------------- + dillo-3.0.4.1 [December 24, 2014] +- Avoid a corner case segfault when no search URL is found in dillorc. -- cgit v1.2.3 From 76bda807e7ee0e2e201d01bae11136afcdf8fd2b Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 11 Jun 2015 02:20:55 +0000 Subject: 3.0.5 splash --- src/IO/about.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/IO/about.c b/src/IO/about.c index 0b2c01c0..ad9e293f 100644 --- a/src/IO/about.c +++ b/src/IO/about.c @@ -270,23 +270,29 @@ const char *const AboutSplash= "\n" " \n" "

Release overview

\n" -" December 24, 2014\n" +" ---- --, 2015\n" "\n" " \n" " \n" " \n" "
\n" "

\n" -"The dillo-3.0.4.1 release brings you fixes:\n" +"Among the improvements in dillo-3.0.5 are:\n" "

    \n" -"
  • for linking with the recently-released fltk-1.3.3\n" -" (we don't use fl_oldfocus anymore).\n" -"
  • to make sure that windows are resizable with fltk-1.3.3.\n" -"
  • not to load background images, or follow redirections or meta refresh,\n" -" in --local mode (security).\n" -"
  • to permit linking on OS X (remove our Fl_Printer stub).\n" -"
  • for a crash when searching from the address bar and no search urls are\n" -" found in dillorc.\n" +"
  • Fix for segfault when there's no dpid and view source is requested.\n" +"
  • Fix view-source dpi to handle null characters correctly.\n" +"
  • Made view-source dpi use CSS formatting (it's shorter and cleaner).\n" +"
  • Crosscompile/buildroot-friendly fltk-config test.\n" +"
  • Fix X11 icon name.\n" +"
  • In location bar, tend toward showing beginning of URL instead of end.\n" +"
  • Handle irix's version of vsnprintf().\n" +"
  • INPUT, TEXTAREA placeholder attribute.\n" +"
  • Fix bug with font_factor preference and CSS font-size:(larger|smaller).\n" +"
  • Recognize Menu key in keysrc.\n" +"
  • HTTPS: change cipher list to \"ALL:!aNULL:!eNULL:!LOW:!EXPORT40:!RC4\",\n" +" disable SSL3, disable TLS compression.\n" +"
  • Avoid requesting background images if an ancestor has display:none.\n" +"
  • Ignore built-in search url if any are specified in dillorc.\n" "
\n" "

\n" "...that shouldn't have to wait until dillo-3.1 is ready with its floating\n" -- cgit v1.2.3 From d6cf4437d0acac5831bb7e391569794c2dfa0151 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 18 Jul 2014 19:34:35 +0000 Subject: TODO --- src/url.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/url.c b/src/url.c index 9d3e14b2..1c6b3b0f 100644 --- a/src/url.c +++ b/src/url.c @@ -691,6 +691,12 @@ static uint_t Url_host_public_internal_dots(const char *host) * in February 2014 and picking out those where it was simplest for * them to describe the situation by beginning with a "*.[tld]" rule * or every rule was "[something].[tld]". + * + * TODO: Consider the old publicsuffix code again. This TLD list has + * shrunk and shrunk over the years, and has become a poorer and + * poorer approximation of administrative boundaries -- and, as of + * mid-2014, even NZ and UK are allowing domains to be registered + * at the second level, which doesn't leave much. */ const char *const tlds[] = {"bd","bn","ck","cy","er","et","fj","fk", "gu","il","jm","ke","kh","kw","mm","mz", -- cgit v1.2.3 From 6339752fb3fa2790c293bce40282bcf21cdf1918 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 22 Oct 2014 01:29:46 +0000 Subject: trim the publicsuffix TLDs yet again in January 2010, there were 42 entries. Now there are 22, and nearly all of them are rather...marginal. --- dpi/cookies.c | 7 +++---- src/url.c | 11 ++++------- test/cookies.c | 16 ++++++++-------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/dpi/cookies.c b/dpi/cookies.c index 6c5e958e..b858bd53 100644 --- a/dpi/cookies.c +++ b/dpi/cookies.c @@ -1042,14 +1042,13 @@ static uint_t Cookies_internal_dots_required(const char *host) if (tld_len > 0) { /* These TLDs were chosen by examining the current publicsuffix list - * in February 2014 and picking out those where it was simplest for + * in October 2014 and picking out those where it was simplest for * them to describe the situation by beginning with a "*.[tld]" rule * or every rule was "[something].[tld]". */ - const char *const tlds[] = {"bd","bn","ck","cy","er","et","fj","fk", + const char *const tlds[] = {"bd","bn","ck","cy","er","fj","fk", "gu","il","jm","ke","kh","kw","mm","mz", - "ni","np","nz","pg","tr","uk","ye","za", - "zm","zw"}; + "ni","np","pg","ye","za","zm","zw"}; uint_t i, tld_num = sizeof(tlds) / sizeof(tlds[0]); for (i = 0; i < tld_num; i++) { diff --git a/src/url.c b/src/url.c index 1c6b3b0f..a46e7f90 100644 --- a/src/url.c +++ b/src/url.c @@ -688,20 +688,17 @@ static uint_t Url_host_public_internal_dots(const char *host) if (tld_len > 0) { /* These TLDs were chosen by examining the current publicsuffix list - * in February 2014 and picking out those where it was simplest for + * in October 2014 and picking out those where it was simplest for * them to describe the situation by beginning with a "*.[tld]" rule * or every rule was "[something].[tld]". * * TODO: Consider the old publicsuffix code again. This TLD list has * shrunk and shrunk over the years, and has become a poorer and - * poorer approximation of administrative boundaries -- and, as of - * mid-2014, even NZ and UK are allowing domains to be registered - * at the second level, which doesn't leave much. + * poorer approximation of administrative boundaries. */ - const char *const tlds[] = {"bd","bn","ck","cy","er","et","fj","fk", + const char *const tlds[] = {"bd","bn","ck","cy","er","fj","fk", "gu","il","jm","ke","kh","kw","mm","mz", - "ni","np","nz","pg","tr","uk","ye","za", - "zm","zw"}; + "ni","np","pg","ye","za","zm","zw"}; uint_t i, tld_num = sizeof(tlds) / sizeof(tlds[0]); for (i = 0; i < tld_num; i++) { diff --git a/test/cookies.c b/test/cookies.c index 40661650..ff744c97 100644 --- a/test/cookies.c +++ b/test/cookies.c @@ -880,17 +880,17 @@ int main() path(); /* LEADING/TRAILING DOTS AND A LITTLE PUBLIC SUFFIX */ - a_Cookies_set("name=val; domain=co.uk", "www.co.uk", "/", NULL); - expect(__LINE__, "", "http", "www.co.uk", "/"); + a_Cookies_set("name=val; domain=co.il", "www.co.il", "/", NULL); + expect(__LINE__, "", "http", "www.co.il", "/"); - a_Cookies_set("name=val; domain=.co.uk", "www.co.uk", "/", NULL); - expect(__LINE__, "", "http", "www.co.uk", "/"); + a_Cookies_set("name=val; domain=.co.il", "www.co.il", "/", NULL); + expect(__LINE__, "", "http", "www.co.il", "/"); - a_Cookies_set("name=val; domain=co.uk.", "www.co.uk.", "/", NULL); - expect(__LINE__, "", "http", "www.co.uk.", "/"); + a_Cookies_set("name=val; domain=co.il.", "www.co.il.", "/", NULL); + expect(__LINE__, "", "http", "www.co.il.", "/"); - a_Cookies_set("name=val; domain=.co.uk.", "www.co.uk.", "/", NULL); - expect(__LINE__, "", "http", ".www.co.uk.", "/"); + a_Cookies_set("name=val; domain=.co.il.", "www.co.il.", "/", NULL); + expect(__LINE__, "", "http", ".www.co.il.", "/"); a_Cookies_set("name=val; domain=co.org", "www.co.org", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "www.co.org", "/"); -- cgit v1.2.3 From f1c7ad984e10e8ae28ffa4710f6d47a88200f771 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 8 Oct 2014 15:27:10 +0000 Subject: more compact MSG --- src/domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/domain.c b/src/domain.c index ea5c4948..8bff39de 100644 --- a/src/domain.c +++ b/src/domain.c @@ -129,7 +129,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) ret = source_host[0] == '\0' || !dStrAsciiCasecmp(URL_SCHEME(dest), "data"); if (ret == FALSE) - MSG("Domain: DENIED from %s to %s.\n", source_host, URL_STR(dest)); + MSG("Domain: DENIED %s -> %s.\n", source_host, URL_STR(dest)); return ret; } @@ -151,7 +151,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) if (ret == FALSE) { const char *src = source_host[0] ? source_host : URL_STR(source); - MSG("Domain: DENIED from %s to %s.\n", src, dest_host); + MSG("Domain: DENIED %s -> %s.\n", src, dest_host); } return ret; } -- cgit v1.2.3 From d26d459fb15a256f874af87035918f80f2e55f7f Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 23 Jul 2014 19:02:56 +0000 Subject: clarify situation with MENU element --- src/html.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/html.cc b/src/html.cc index c5fa470c..096437c6 100644 --- a/src/html.cc +++ b/src/html.cc @@ -2877,7 +2877,16 @@ static void Html_tag_open_dir(DilloHtml *html, const char *tag, int tagsize) */ static void Html_tag_open_menu(DilloHtml *html, const char *tag, int tagsize) { - Html_tag_open_dir(html, tag, tagsize); + /* In another bit of ridiculous mess from the HTML5 world, the menu + * element, which was deprecated in HTML4: + * - does not appear at all in W3C's HTML5 spec + * - appears in WHATWG's HTML5 doc and the W3C's 5.1 draft, where it + * means something totally different than it did in the old days + * (now it's for popup menus and toolbar menus rather than being a + * sort of list). + */ + if (!(html->DocType == DT_HTML && html->DocTypeVersion >= 5.0f)) + Html_tag_open_dir(html, tag, tagsize); } /* -- cgit v1.2.3 From 4b0c4d6895886f7faca4b96389e83253eb393121 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Sat, 12 Jul 2014 15:27:37 +0200 Subject: Tests are now linked to libX11 when needed. --- test/Makefile.am | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 156c8667..2110b5bc 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -34,7 +34,7 @@ dw_anchors_test_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_example_SOURCES = dw_example.cc dw_example_LDADD = \ @@ -42,7 +42,7 @@ dw_example_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_find_test_SOURCES = dw_find_test.cc dw_find_test_LDADD = \ @@ -50,7 +50,7 @@ dw_find_test_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_links_SOURCES = dw_links.cc dw_links_LDADD = \ @@ -58,7 +58,7 @@ dw_links_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_links2_SOURCES = dw_links2.cc dw_links2_LDADD = \ @@ -66,7 +66,7 @@ dw_links2_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_image_background_SOURCES = dw_image_background.cc dw_image_background_LDADD = \ @@ -74,7 +74,7 @@ dw_image_background_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_images_simple_SOURCES = dw_images_simple.cc dw_images_simple_LDADD = \ @@ -82,7 +82,7 @@ dw_images_simple_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_images_scaled_SOURCES = dw_images_scaled.cc dw_images_scaled_LDADD = \ @@ -90,7 +90,7 @@ dw_images_scaled_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_images_scaled2_SOURCES = dw_images_scaled2.cc dw_images_scaled2_LDADD = \ @@ -98,7 +98,7 @@ dw_images_scaled2_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_lists_SOURCES = dw_lists.cc dw_lists_LDADD = \ @@ -106,7 +106,7 @@ dw_lists_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_table_aligned_SOURCES = dw_table_aligned.cc dw_table_aligned_LDADD = \ @@ -114,7 +114,7 @@ dw_table_aligned_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_table_SOURCES = dw_table.cc dw_table_LDADD = \ @@ -122,7 +122,7 @@ dw_table_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_border_test_SOURCES = dw_border_test.cc dw_border_test_LDADD = \ @@ -130,7 +130,7 @@ dw_border_test_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_imgbuf_mem_test_SOURCES = dw_imgbuf_mem_test.cc @@ -139,7 +139,7 @@ dw_imgbuf_mem_test_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_resource_test_SOURCES = dw_resource_test.cc dw_resource_test_LDADD = \ @@ -147,7 +147,7 @@ dw_resource_test_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ dw_ui_test_SOURCES = \ dw_ui_test.cc \ @@ -158,7 +158,7 @@ dw_ui_test_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ shapes_SOURCES = shapes.cc shapes_LDADD = \ @@ -180,7 +180,7 @@ liang_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ trie_SOURCES = trie.cc @@ -189,7 +189,7 @@ trie_LDADD = \ $(top_builddir)/dw/libDw-fltk.a \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ notsosimplevector_SOURCES = notsosimplevector.cc @@ -199,4 +199,4 @@ unicode_test_SOURCES = unicode_test.cc unicode_test_LDADD = \ $(top_builddir)/lout/liblout.a \ - @LIBFLTK_LIBS@ + @LIBFLTK_LIBS@ @LIBX11_LIBS@ -- cgit v1.2.3 From ec145bb886f371d086b3ef76f6defadbde4c4986 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 11 Jun 2015 15:20:02 +0000 Subject: now give it a version number --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 46c25263..44711536 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with aclocal, autoconf and automake. -AC_INIT([dillo], [3.0.4.1]) +AC_INIT([dillo], [3.0.5-pre]) dnl Detect the canonical target build environment AC_CANONICAL_TARGET -- cgit v1.2.3 From 7dd06039905c62abe9b84ae9fb571072da0e7781 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 14 May 2014 19:48:33 -0400 Subject: Avoid creation of unnecessary image bufs (at alt-text to img switch) This is the first of a patch series for image code bugs that have severe impact on performance. With these testing files: 1imgA.html = img1 2imgSA.html = img1 img12 3imgSA.html = img1 img12 img123 2imgA.html = img1 img12 3imgA.html = img1 img12 img123 This are the results: .------------------------------------------------------------------. |imgbufs | No patch | Patched #1 | | | first time | upon reload | first time | upon reload | |------------------------------------------------------------------- |1imgA.html | 2 | 1 | 1 | 1 | |2imgSA.html | 3 | 2 | 1 | 2 | |3imgSA.html | 4 | 3 | 1 | 3 | |------------------------------------------------------------------- |2imgA.html | 4 | 2 | 2 | 2 | |3imgA.html | 6 | 3 | 3 | 3 | '------------------------------------------------------------------' --- dw/fltkimgbuf.cc | 10 ++++++---- dw/image.cc | 6 ++++-- src/dicache.c | 6 ++++-- src/html.cc | 4 ++-- src/image.cc | 6 ++++-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/dw/fltkimgbuf.cc b/dw/fltkimgbuf.cc index 26b46969..01bce455 100644 --- a/dw/fltkimgbuf.cc +++ b/dw/fltkimgbuf.cc @@ -80,7 +80,7 @@ FltkImgbuf::FltkImgbuf (Type type, int width, int height, double gamma) { DBG_OBJ_CREATE ("dw::fltk::FltkImgbuf"); - _MSG("FltkImgbuf: new root %p\n", this); + _MSG ("FltkImgbuf::FltkImgbuf: new root %p\n", this); init (type, width, height, gamma, NULL); } @@ -89,7 +89,7 @@ FltkImgbuf::FltkImgbuf (Type type, int width, int height, double gamma, { DBG_OBJ_CREATE ("dw::fltk::FltkImgbuf"); - _MSG("FltkImgbuf: new scaled %p, root is %p\n", this, root); + _MSG ("FltkImgbuf::FltkImgbuf: new scaled %p, root is %p\n", this, root); init (type, width, height, gamma, root); } @@ -135,8 +135,8 @@ void FltkImgbuf::init (Type type, int width, int height, double gamma, case RGB: bpp = 3; break; default: bpp = 1; break; } - _MSG("FltkImgbuf::init width=%d height=%d bpp=%d gamma=%g\n", - width, height, bpp, gamma); + _MSG("FltkImgbuf::init this=%p width=%d height=%d bpp=%d gamma=%g\n", + this, width, height, bpp, gamma); rawdata = new uchar[bpp * width * height]; // Set light-gray as interim background color. memset(rawdata, 222, width*height*bpp); @@ -163,6 +163,8 @@ void FltkImgbuf::init (Type type, int width, int height, double gamma, FltkImgbuf::~FltkImgbuf () { + _MSG ("FltkImgbuf::~FltkImgbuf\n"); + if (!isRoot()) root->detachScaledBuf (this); diff --git a/dw/image.cc b/dw/image.cc index 74f96e57..5df6b93e 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -428,8 +428,10 @@ void Image::setBuffer (core::Imgbuf *buffer, bool resize) if (resize) queueResize (0, true); - if (wasAllocated () && getContentWidth () > 0 && getContentHeight () > 0) { - // Only scale when both dimensions are known. + if (wasAllocated () && needsResize () && + getContentWidth () > 0 && getContentHeight () > 0) { + // Don't create a new buffer for the transition from alt text to img, + // and only scale when both dimensions are known. this->buffer = buffer->getScaledBuf (getContentWidth (), getContentHeight ()); } else { diff --git a/src/dicache.c b/src/dicache.c index db3b86b2..b63e9d3b 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -256,7 +256,9 @@ void a_Dicache_invalidate_entry(const DilloUrl *Url) /* * Set image's width, height & type - * (By now, we'll use the image information despite the html tags --Jcid) + * - 'width' and 'height' come from the image data. + * - HTML width and height attrs are handled with setNonCssHint. + * - CSS sizing is handled by the CSS engine. */ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image, uint_t width, uint_t height, DilloImgType type, @@ -269,7 +271,7 @@ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image, /* Find the DicEntry for this Image */ DicEntry = a_Dicache_get_entry(url, version); dReturn_if_fail ( DicEntry != NULL ); - /* Parameters already set? */ + /* Parameters already set? Don't do it twice. */ dReturn_if_fail ( DicEntry->State < DIC_SetParms ); _MSG(" RefCount=%d version=%d\n", DicEntry->RefCount, DicEntry->version); diff --git a/src/html.cc b/src/html.cc index 096437c6..f8734444 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1804,8 +1804,8 @@ static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize) static void Html_tag_close_style(DilloHtml *html) { if (prefs.parse_embedded_css && html->loadCssFromStash) - html->styleEngine->parse(html, html->base_url, html->Stash->str, html->Stash->len, - CSS_ORIGIN_AUTHOR); + html->styleEngine->parse(html, html->base_url, html->Stash->str, + html->Stash->len, CSS_ORIGIN_AUTHOR); } /* diff --git a/src/image.cc b/src/image.cc index 9915023a..97270eef 100644 --- a/src/image.cc +++ b/src/image.cc @@ -106,9 +106,11 @@ void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url, int version, uint_t width, uint_t height, DilloImgType type) { - _MSG("a_Image_set_parms: width=%d height=%d\n", width, height); + _MSG("a_Image_set_parms: width=%d height=%d iw=%d ih=%d\n", + width, height, Image->width, Image->height); - bool resize = (Image->width != width || Image->height != height); + /* Resize from 0,0 to width,height */ + bool resize = true; I2IR(Image)->setBuffer((Imgbuf*)v_imgbuf, resize); if (!Image->BitVec) -- cgit v1.2.3 From b93b25640a83b6826795dd55e98d785d6c0b6bfd Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 14 May 2014 20:21:27 -0400 Subject: Avoid removing imgbuf and decoding the whole image again for reloads. Using the same testing files as the previous patch, the results are: .---------------------------------------------. |imgbufs | No patch | Patch #1 | Patch #2 | |---------------------------------------------- |1imgA.html | 2/1 | 1/1 | 1/0 | |2imgSA.html | 3/2 | 1/2 | 1/0 | |3imgSA.html | 4/3 | 1/3 | 1/0 | |---------------------------------------------- |2imgA.html | 4/2 | 2/2 | 2/0 | |3imgA.html | 6/3 | 3/3 | 3/0 | '---------------------------------------------' n1/n2 means: n1 imgbufs were created for first load (empty cache) n2 imgbufs were created for reload (cached image) Notes: * Rendering is much faster. Easy to notice with Back operation. * Between four to five times on www.welt.de. * Corner cases can be more than ten times. Usually, it *feels* faster. --- dw/image.cc | 4 +--- dw/widget.cc | 5 ++++- src/cache.c | 1 - src/dicache.c | 45 ++++++++++++++++++++++++++++----------------- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/dw/image.cc b/dw/image.cc index 5df6b93e..e71c8f2f 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -425,9 +425,6 @@ void Image::setBuffer (core::Imgbuf *buffer, bool resize) { core::Imgbuf *oldBuf = this->buffer; - if (resize) - queueResize (0, true); - if (wasAllocated () && needsResize () && getContentWidth () > 0 && getContentHeight () > 0) { // Don't create a new buffer for the transition from alt text to img, @@ -438,6 +435,7 @@ void Image::setBuffer (core::Imgbuf *buffer, bool resize) this->buffer = buffer; buffer->ref (); } + queueResize (0, true); DBG_OBJ_ASSOC_CHILD (this->buffer); diff --git a/dw/widget.cc b/dw/widget.cc index 385bdb97..7e9591ff 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -159,7 +159,10 @@ void Widget::queueDrawArea (int x, int y, int width, int height) { /** \todo Maybe only the intersection? */ layout->queueDraw (x + allocation.x, y + allocation.y, width, height); - _MSG("Widget::queueDrawArea x=%d y=%d w=%d h=%d\n", x, y, width, height); + _MSG("Widget::queueDrawArea alloc(%d %d %d %d) wid(%d %d %d %d)\n", + allocation.x, allocation.y, + allocation.width, allocation.ascent + allocation.descent, + x, y, width, height); } /** diff --git a/src/cache.c b/src/cache.c index 42573d10..c7a0cc00 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1261,7 +1261,6 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) /* Trigger cleanup when there are no cache clients */ if (dList_length(ClientQueue) == 0) { - _MSG(" a_Dicache_cleanup()\n"); a_Dicache_cleanup(); } diff --git a/src/dicache.c b/src/dicache.c index b63e9d3b..2704da50 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -182,8 +182,8 @@ static void Dicache_remove(const DilloUrl *Url, int version) } if (entry) { - _MSG("Dicache_remove Decoder=%p DecoderData=%p\n", - entry->Decoder, entry->DecoderData); + _MSG("Dicache_remove Imgbuf=%p Decoder=%p DecoderData=%p\n", + entry->v_imgbuf, entry->Decoder, entry->DecoderData); /* Eliminate this dicache entry */ dFree(entry->cmap); a_Bitvec_free(entry->BitVec); @@ -218,9 +218,13 @@ void a_Dicache_unref(const DilloUrl *Url, int version) _MSG("a_Dicache_unref\n"); if ((entry = a_Dicache_get_entry(Url, version))) { - if (--entry->RefCount == 0) { + _MSG(" a_Dicache_unref: RefCount=%d\n", entry->RefCount); + _MSG(" a_Dicache_unref: ImgbufLastRef=%d\n", + entry->v_imgbuf ? a_Imgbuf_last_reference(entry->v_imgbuf) : -1); + if (entry->RefCount > 0) --entry->RefCount; + if (entry->v_imgbuf == NULL || + (entry->RefCount == 0 && a_Imgbuf_last_reference(entry->v_imgbuf))) Dicache_remove(Url, version); - } } } @@ -370,6 +374,9 @@ void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client) /* a_Dicache_unref() may free DicEntry */ _MSG("a_Dicache_close RefCount=%d\n", DicEntry->RefCount - 1); + _MSG("a_Dicache_close DIC_Close=%d State=%d\n", DIC_Close, DicEntry->State); + _MSG(" a_Dicache_close imgbuf=%p Decoder=%p DecoderData=%p\n", + DicEntry->v_imgbuf, DicEntry->Decoder, DicEntry->DecoderData); if (DicEntry->State < DIC_Close) { DicEntry->State = DIC_Close; @@ -412,24 +419,27 @@ static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr, DicEntry = a_Dicache_get_entry(web->url, DIC_Last); if (!DicEntry) { - /* Let's create an entry for this image... */ + /* Create an entry for this image... */ DicEntry = Dicache_add_entry(web->url); - DicEntry->DecoderData = - (ImgType == DIC_Png) ? - a_Png_new(web->Image, DicEntry->url, DicEntry->version) : - (ImgType == DIC_Gif) ? - a_Gif_new(web->Image, DicEntry->url, DicEntry->version) : - (ImgType == DIC_Jpeg) ? - a_Jpeg_new(web->Image, DicEntry->url, DicEntry->version) : - NULL; + /* Attach a decoder */ + if (ImgType == DIC_Jpeg) { + DicEntry->Decoder = (CA_Callback_t)a_Jpeg_callback; + DicEntry->DecoderData = + a_Jpeg_new(web->Image, DicEntry->url, DicEntry->version); + } else if (ImgType == DIC_Gif) { + DicEntry->Decoder = (CA_Callback_t)a_Gif_callback; + DicEntry->DecoderData = + a_Gif_new(web->Image, DicEntry->url, DicEntry->version); + } else if (ImgType == DIC_Png) { + DicEntry->Decoder = (CA_Callback_t)a_Png_callback; + DicEntry->DecoderData = + a_Png_new(web->Image, DicEntry->url, DicEntry->version); + } } else { /* Repeated image */ a_Dicache_ref(DicEntry->url, DicEntry->version); } - DicEntry->Decoder = (ImgType == DIC_Png) ? (CA_Callback_t)a_Png_callback : - (ImgType == DIC_Gif) ? (CA_Callback_t)a_Gif_callback : - (ImgType == DIC_Jpeg) ? (CA_Callback_t)a_Jpeg_callback: - NULL; + *Data = DicEntry->DecoderData; *Call = (CA_Callback_t) a_Dicache_callback; @@ -548,6 +558,7 @@ void a_Dicache_cleanup(void) if (entry->v_imgbuf && a_Imgbuf_last_reference(entry->v_imgbuf)) { /* free this unused entry */ + _MSG("a_Dicache_cleanup: removing entry...\n"); if (entry->next) { Dicache_remove(node->url, entry->version); } else { -- cgit v1.2.3 From 9facb557c8f98d7bbe92566d7c1e2242d927c981 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sat, 7 Jun 2014 20:12:08 -0400 Subject: Fixed an "invalid read" in dicache (detected with valgrind) Invalid read of size 8 at 0x426066: a_Dicache_cleanup (dicache.c:557) by 0x42421C: Cache_process_queue (cache.c:1261) by 0x42424B: Cache_delayed_process_queue_callback (cache.c:1278) Address 0x83ea120 is 96 bytes inside a block of size 104 free'd at 0x4C2870C: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x44CC43: dFree (dlib.c:68) by 0x42552D: Dicache_remove (dicache.c:207) Simple way to reproduce it: Load an html page with a single image, isolate image in new tab, reload the raw image, close html tab, go for bookmarks, exit. --- src/dicache.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/dicache.c b/src/dicache.c index 2704da50..7f4cac85 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -548,24 +548,21 @@ void a_Dicache_cleanup(void) { int i; DICacheNode *node; - DICacheEntry *entry; + DICacheEntry *entry, *next; _MSG("a_Dicache_cleanup\n"); for (i = 0; i < dList_length(CachedIMGs); ++i) { node = dList_nth_data(CachedIMGs, i); /* iterate each entry of this node */ - for (entry = node->first; entry; entry = entry->next) { + for (entry = node->first; entry; entry = next) { + next = entry->next; if (entry->v_imgbuf && a_Imgbuf_last_reference(entry->v_imgbuf)) { /* free this unused entry */ _MSG("a_Dicache_cleanup: removing entry...\n"); - if (entry->next) { - Dicache_remove(node->url, entry->version); - } else { - Dicache_remove(node->url, entry->version); - --i; - break; - } + Dicache_remove(node->url, entry->version); + if (!next && node != dList_nth_data(CachedIMGs, i)) + --i; /* removed node, adjust counter */ } } } -- cgit v1.2.3 From 0e2d30689c465c4b44a0b996e99864da35b1a72d Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 19 Jun 2014 12:20:08 -0400 Subject: Avoid a memory leak at exit time Useful to avoid "false positives" with valgrind. --- src/dicache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dicache.c b/src/dicache.c index 7f4cac85..39d89509 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -572,7 +572,7 @@ void a_Dicache_cleanup(void) /* * Deallocate memory used by dicache module - * (Call this one at exit time) + * (Call this one at exit time, with no cache clients queued) */ void a_Dicache_freeall(void) { @@ -587,6 +587,7 @@ void a_Dicache_freeall(void) a_Bitvec_free(entry->BitVec); a_Imgbuf_unref(entry->v_imgbuf); dicache_size_total -= entry->TotalSize; + dFree(entry); } dList_remove_fast(CachedIMGs, node); a_Url_free(node->url); -- cgit v1.2.3 From 5a8963b13795402c88451e7167b3335a94643643 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 19 Jun 2014 13:53:58 -0400 Subject: Fixed a potential problem in a_Dicache_unref() Currently I see no way to hit the condition, but better safe than sorry. --- src/dicache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dicache.c b/src/dicache.c index 39d89509..82043590 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -224,6 +224,8 @@ void a_Dicache_unref(const DilloUrl *Url, int version) if (entry->RefCount > 0) --entry->RefCount; if (entry->v_imgbuf == NULL || (entry->RefCount == 0 && a_Imgbuf_last_reference(entry->v_imgbuf))) + if (entry->RefCount == 0 && + (!entry->v_imgbuf || a_Imgbuf_last_reference(entry->v_imgbuf))) Dicache_remove(Url, version); } } -- cgit v1.2.3 From 95c83100fe731c652bfc6567d14ce5f415d37ee8 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sat, 21 Jun 2014 15:52:43 -0400 Subject: Ensure png, jpeg and gif decoders don't use DilloImage after set_parms() This allows reuse of the dicache entry after repush changes DilloImage. --- src/dicache.c | 8 ++++---- src/dicache.h | 2 +- src/gif.c | 15 ++++++--------- src/jpeg.c | 1 + src/png.c | 9 ++++++--- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/dicache.c b/src/dicache.c index 82043590..633d44f9 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -300,7 +300,7 @@ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image, /* * Implement the set_cmap method for the Image */ -void a_Dicache_set_cmap(DilloUrl *url, int version, DilloImage *Image, +void a_Dicache_set_cmap(DilloUrl *url, int version, int bg_color, const uchar_t *cmap, uint_t num_colors, int num_colors_max, int bg_index) { @@ -313,9 +313,9 @@ void a_Dicache_set_cmap(DilloUrl *url, int version, DilloImage *Image, DicEntry->cmap = dNew0(uchar_t, 3 * num_colors_max); memcpy(DicEntry->cmap, cmap, 3 * num_colors); if (bg_index >= 0 && (uint_t)bg_index < num_colors) { - DicEntry->cmap[bg_index * 3] = (Image->bg_color >> 16) & 0xff; - DicEntry->cmap[bg_index * 3 + 1] = (Image->bg_color >> 8) & 0xff; - DicEntry->cmap[bg_index * 3 + 2] = (Image->bg_color) & 0xff; + DicEntry->cmap[bg_index * 3] = (bg_color >> 16) & 0xff; + DicEntry->cmap[bg_index * 3 + 1] = (bg_color >> 8) & 0xff; + DicEntry->cmap[bg_index * 3 + 2] = (bg_color) & 0xff; } DicEntry->State = DIC_SetCmap; diff --git a/src/dicache.h b/src/dicache.h index df8a8b89..f1819b12 100644 --- a/src/dicache.h +++ b/src/dicache.h @@ -61,7 +61,7 @@ void a_Dicache_callback(int Op, CacheClient_t *Client); void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image, uint_t width, uint_t height, DilloImgType type, double gamma); -void a_Dicache_set_cmap(DilloUrl *url, int version, DilloImage *Image, +void a_Dicache_set_cmap(DilloUrl *url, int version, int bg_color, const uchar_t *cmap, uint_t num_colors, int num_colors_max, int bg_index); void a_Dicache_new_scan(const DilloUrl *url, int version); diff --git a/src/gif.c b/src/gif.c index 7ce1e110..34424d33 100644 --- a/src/gif.c +++ b/src/gif.c @@ -103,9 +103,7 @@ typedef struct { size_t ColorMap_ofs; uint_t ColorResolution; uint_t NumColors; -#if 0 - int Background; -#endif + int Background; uint_t spill_line_index; #if 0 uint_t AspectRatio; /* AspectRatio (not used) */ @@ -165,9 +163,7 @@ void *a_Gif_new(DilloImage *Image, DilloUrl *url, int version) gif->state = 0; gif->Start_Ofs = 0; gif->linebuf = NULL; -#if 0 - gif->Background = -1; -#endif + gif->Background = Image->bg_color; gif->transparent = -1; gif->num_spill_lines_max = 0; gif->spill_lines = NULL; @@ -222,7 +218,7 @@ static void Gif_write(DilloGif *gif, void *Buf, uint_t BufSize) int bufsize, bytes_consumed; /* Sanity checks */ - if (!Buf || !gif->Image || BufSize == 0) + if (!Buf || BufSize == 0) return; buf = ((uchar_t *) Buf) + gif->Start_Ofs; @@ -820,6 +816,7 @@ static size_t Gif_do_img_desc(DilloGif *gif, void *Buf, a_Dicache_set_parms(gif->url, gif->version, gif->Image, gif->Width, gif->Height, DILLO_IMG_TYPE_INDEXED, 1 / 2.2); + gif->Image = NULL; /* safeguard: hereafter it may be freed by its owner */ Flags = buf[8]; @@ -850,8 +847,8 @@ static size_t Gif_do_img_desc(DilloGif *gif, void *Buf, gif->spill_line_index = 0; gif->linebuf = dMalloc(gif->Width); gif->state = 3; /*Process the lzw data next */ - if (gif->Image && gif->ColorMap_ofs) { - a_Dicache_set_cmap(gif->url, gif->version, gif->Image, + if (gif->ColorMap_ofs) { + a_Dicache_set_cmap(gif->url, gif->version, gif->Background, (uchar_t *) Buf + gif->ColorMap_ofs, gif->NumColors, 256, gif->transparent); } diff --git a/src/jpeg.c b/src/jpeg.c index 625808fb..5652aa56 100644 --- a/src/jpeg.c +++ b/src/jpeg.c @@ -304,6 +304,7 @@ static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize) (uint_t)jpeg->cinfo.image_width, (uint_t)jpeg->cinfo.image_height, type, 1 / 2.2); + jpeg->Image = NULL; /* safeguard: may be freed by its owner later */ /* decompression step 4 (see libjpeg.doc) */ jpeg->state = DILLO_JPEG_STARTING; diff --git a/src/png.c b/src/png.c index 4f5da1c2..093e2600 100644 --- a/src/png.c +++ b/src/png.c @@ -62,6 +62,7 @@ typedef struct { DilloImage *Image; /* Image meta data */ DilloUrl *url; /* Primary Key for the dicache */ int version; /* Secondary Key for the dicache */ + int bgcolor; /* Parent widget background color */ png_uint_32 width; /* png image width */ png_uint_32 height; /* png image height */ @@ -204,6 +205,7 @@ Png_datainfo_callback(png_structp png_ptr, png_infop info_ptr) a_Dicache_set_parms(png->url, png->version, png->Image, (uint_t)png->width, (uint_t)png->height, DILLO_IMG_TYPE_RGB, file_gamma); + png->Image = NULL; /* safeguard: hereafter it may be freed by its owner */ } static void @@ -244,9 +246,9 @@ static void /* TODO: maybe change prefs.bg_color to `a_Dw_widget_get_bg_color`, * when background colors are correctly implementated */ - bg_blue = (png->Image->bg_color) & 0xFF; - bg_green = (png->Image->bg_color>>8) & 0xFF; - bg_red = (png->Image->bg_color>>16) & 0xFF; + bg_blue = (png->bgcolor) & 0xFF; + bg_green = (png->bgcolor>>8) & 0xFF; + bg_red = (png->bgcolor>>16) & 0xFF; for (i = 0; i < png->width; i++) { a = *(data+3); @@ -433,6 +435,7 @@ void *a_Png_new(DilloImage *Image, DilloUrl *url, int version) png->Image = Image; png->url = url; png->version = version; + png->bgcolor = Image->bg_color; png->error = 0; png->ipbuf = NULL; png->ipbufstart = 0; -- cgit v1.2.3 From 9b70e1ec061f43fd7c12c17ccd4ddc8e15fda7cf Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 24 Jun 2014 08:19:18 -0400 Subject: Moved dicache entry removal to a_Dicache_cleanup() This allows keeping the decompressed image entry until a_Dicache_cleanup() removes it. With the added SurvCleanup variable that controls how many cleanup passes the entry is kept, it is now possible to tune the dicache. For instance: SurvCleanup=0 same as without patch (negligible difference). SurvCleanup=1 allows Back and Forward reuse entries for adjacent pages. SurvCleanup=2 all the above, plus one more pass of lifetime. The default is SurvCleanup=3 (experimental). Example: If you read a newspaper with lots of images, this caching allows to click an article, read it, and go back *quickly* using the same tab. It is experimental because there may be other simple approaches that serve well/better these kind of usage patterns. --- src/dicache.c | 29 +++++++++++++++++------------ src/dicache.h | 5 +++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/dicache.c b/src/dicache.c index 633d44f9..33730f05 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -83,6 +83,7 @@ static DICacheEntry *Dicache_entry_new(void) entry->width = 0; entry->height = 0; + entry->SurvCleanup = 0; entry->type = DILLO_IMG_TYPE_NOTSET; entry->cmap = NULL; entry->v_imgbuf = NULL; @@ -209,23 +210,21 @@ static void Dicache_remove(const DilloUrl *Url, int version) } /* - * Unrefs the counter of a dicache entry, and _if_ no DwImage is acessing - * this buffer, then we call Dicache_remove() to do the job. + * Unrefs the counter of a dicache entry (it counts cache clients). + * If there're no clients and no imgbuf, remove the entry. + * Otherwise, let a_Dicache_cleanup() do the job later + * (keeping it cached meanwhile for e.g. reload, repush, back/fwd). */ void a_Dicache_unref(const DilloUrl *Url, int version) { DICacheEntry *entry; - _MSG("a_Dicache_unref\n"); if ((entry = a_Dicache_get_entry(Url, version))) { - _MSG(" a_Dicache_unref: RefCount=%d\n", entry->RefCount); - _MSG(" a_Dicache_unref: ImgbufLastRef=%d\n", + _MSG("a_Dicache_unref: RefCount=%d State=%d ImgbufLastRef=%d\n", + entry->RefCount, entry->State, entry->v_imgbuf ? a_Imgbuf_last_reference(entry->v_imgbuf) : -1); if (entry->RefCount > 0) --entry->RefCount; - if (entry->v_imgbuf == NULL || - (entry->RefCount == 0 && a_Imgbuf_last_reference(entry->v_imgbuf))) - if (entry->RefCount == 0 && - (!entry->v_imgbuf || a_Imgbuf_last_reference(entry->v_imgbuf))) + if (entry->RefCount == 0 && entry->v_imgbuf == NULL) Dicache_remove(Url, version); } } @@ -441,6 +440,8 @@ static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr, /* Repeated image */ a_Dicache_ref(DicEntry->url, DicEntry->version); } + /* Survive three cleanup passes (set to zero = old behaviour). */ + DicEntry->SurvCleanup = 3; *Data = DicEntry->DecoderData; *Call = (CA_Callback_t) a_Dicache_callback; @@ -552,14 +553,18 @@ void a_Dicache_cleanup(void) DICacheNode *node; DICacheEntry *entry, *next; - _MSG("a_Dicache_cleanup\n"); + MSG("a_Dicache_cleanup\n"); for (i = 0; i < dList_length(CachedIMGs); ++i) { node = dList_nth_data(CachedIMGs, i); /* iterate each entry of this node */ for (entry = node->first; entry; entry = next) { next = entry->next; - if (entry->v_imgbuf && - a_Imgbuf_last_reference(entry->v_imgbuf)) { + MSG(" SurvCleanup = %d\n", entry->SurvCleanup); + if (entry->RefCount == 0 && + (!entry->v_imgbuf || a_Imgbuf_last_reference(entry->v_imgbuf))) { + if (--entry->SurvCleanup >= 0) + continue; /* keep the entry one more pass */ + /* free this unused entry */ _MSG("a_Dicache_cleanup: removing entry...\n"); Dicache_remove(node->url, entry->version); diff --git a/src/dicache.h b/src/dicache.h index f1819b12..0390d214 100644 --- a/src/dicache.h +++ b/src/dicache.h @@ -26,8 +26,9 @@ typedef enum { typedef struct DICacheEntry { DilloUrl *url; /* Image URL for this entry */ - uint_t width, height; /* As taken from image data */ DilloImgType type; /* Image type */ + uint_t width, height; /* As taken from image data */ + int SurvCleanup; /* Cleanup-pass survival for unused images */ uchar_t *cmap; /* Color map */ void *v_imgbuf; /* Void pointer to an Imgbuf object */ uint_t TotalSize; /* Amount of memory the image takes up */ @@ -38,9 +39,9 @@ typedef struct DICacheEntry { int version; /* Version number, used for different versions of the same URL image */ + uint_t DecodedSize; /* Size of already decoded data */ CA_Callback_t Decoder; /* Client function */ void *DecoderData; /* Client function data */ - uint_t DecodedSize; /* Size of already decoded data */ struct DICacheEntry *next; /* Link to the next "newer" version */ } DICacheEntry; -- cgit v1.2.3 From 4f933856a481a1d4089837d3d8923c7559fbea47 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 24 Jun 2014 08:20:18 -0400 Subject: Reimplemented the Dicache using dlib ADTs For a long time it had a custom ADT with a list of nodes and each node a linked list (with pointers). The last memory bug motivated me to try to normalize it to use dlib. Now, it got simpler, shorter, and possibly faster (although conversion wasn't a simple task). PD: It also uses less memory now. --- src/cache.c | 2 +- src/dicache.c | 214 ++++++++++++++++++++++------------------------------------ src/dicache.h | 8 ++- 3 files changed, 85 insertions(+), 139 deletions(-) diff --git a/src/cache.c b/src/cache.c index c7a0cc00..c4a8e922 100644 --- a/src/cache.c +++ b/src/cache.c @@ -110,7 +110,7 @@ static int Cache_entry_by_url_cmp(const void *v1, const void *v2) } /* - * Initialize dicache data + * Initialize cache data */ void a_Cache_init(void) { diff --git a/src/dicache.c b/src/dicache.c index 33730f05..a2904c32 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -28,15 +28,10 @@ enum { DIC_Jpeg }; -typedef struct { - int valid; /* flag */ - DilloUrl *url; /* primary "Key" for this dicache entry */ - DICacheEntry *first; /* pointer to the first dicache entry in this list */ -} DICacheNode; /* - * List of DICacheNode. One node per URL. Each node may have several - * versions of the same image in a linked list. + * List of DICacheEntry. May hold several versions of the same image, + * although most of the time it holds just one. */ static Dlist *CachedIMGs = NULL; @@ -45,24 +40,20 @@ static uint_t dicache_size_total; /* invariant: dicache_size_total is * of all the images in the dicache. */ /* - * Compare two dicache nodes + * Compare function for image entries */ -static int Dicache_node_cmp(const void *v1, const void *v2) +static int Dicache_entry_cmp(const void *v1, const void *v2) { - const DICacheNode *n1 = v1, *n2 = v2; - - return a_Url_cmp(n1->url, n2->url); -} - -/* - * Compare function for searching a node by Url - */ -static int Dicache_node_by_url_cmp(const void *v1, const void *v2) -{ - const DICacheNode *node = v1; - const DilloUrl *url = v2; - - return a_Url_cmp(node->url, url); + const DICacheEntry *e1 = v1, *e2 = v2; + + int st = a_Url_cmp(e1->url, e2->url); + if (st == 0) { + if (e2->version == DIC_Last) + st = (e1->Flags & DIF_Last ? 0 : -1); + else + st = (e1->version - e2->version); + } + return st; } /* @@ -83,6 +74,7 @@ static DICacheEntry *Dicache_entry_new(void) entry->width = 0; entry->height = 0; + entry->Flags = DIF_Valid; entry->SurvCleanup = 0; entry->type = DILLO_IMG_TYPE_NOTSET; entry->cmap = NULL; @@ -98,41 +90,29 @@ static DICacheEntry *Dicache_entry_new(void) entry->DecoderData = NULL; entry->DecodedSize = 0; - entry->next = NULL; - return entry; } /* * Add a new entry in the dicache - * (a single node (URL) may have several entries) + * (a single URL may have several entries) */ static DICacheEntry *Dicache_add_entry(const DilloUrl *Url) { - DICacheEntry *entry; - DICacheNode *node; + DICacheEntry e, *entry, *last; entry = Dicache_entry_new(); - - if ((node = dList_find_sorted(CachedIMGs, Url, Dicache_node_by_url_cmp))) { - /* this URL is already in CachedIMGs, add entry at the END of the list */ - DICacheEntry *ptr = node->first; - - node->valid = 1; - for ( ; ptr->next; ptr = ptr->next); - ptr->next = entry; - entry->version = ptr->version+1; - entry->url = node->url; - - } else { /* no node yet, so create one */ - DICacheNode *node = dNew(DICacheNode, 1); - - node->url = a_Url_dup(Url); - entry->url = node->url; - node->first = entry; - node->valid = 1; - dList_insert_sorted(CachedIMGs, node, Dicache_node_cmp); + e.url = (DilloUrl*)Url; + e.version = DIC_Last; + last = dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp); + if (last) { + /* URL is already in CachedIMGs, make a new version */ + last->Flags &= ~DIF_Last; + entry->version = last->version + 1; } + entry->url = a_Url_dup(Url); + entry->Flags |= DIF_Last; + dList_insert_sorted(CachedIMGs, entry, Dicache_entry_cmp); return entry; } @@ -146,23 +126,15 @@ static DICacheEntry *Dicache_add_entry(const DilloUrl *Url) */ DICacheEntry *a_Dicache_get_entry(const DilloUrl *Url, int version) { - DICacheNode *node; + DICacheEntry e; DICacheEntry *entry = NULL; dReturn_val_if_fail(version != 0, NULL); - - node = dList_find_sorted(CachedIMGs, Url, Dicache_node_by_url_cmp); - if (node) { - if (version == DIC_Last) { - if (node->valid) { - entry = node->first; - for ( ; (entry && entry->next); entry = entry->next); - } - } else { - entry = node->first; - for ( ; entry && entry->version != version; entry = entry->next) ; - } - } + e.url = (DilloUrl*)Url; + e.version = version; + entry = dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp); + if (entry && !(entry->Flags & DIF_Valid) && version == DIC_Last) + entry = NULL; return entry; } @@ -171,42 +143,29 @@ DICacheEntry *a_Dicache_get_entry(const DilloUrl *Url, int version) */ static void Dicache_remove(const DilloUrl *Url, int version) { - DICacheNode *node; - DICacheEntry *entry, *prev; - _MSG("Dicache_remove url=%s\n", URL_STR(Url)); - node = dList_find_sorted(CachedIMGs, Url, Dicache_node_by_url_cmp); - prev = entry = (node) ? node->first : NULL; - - while (entry && (entry->version != version) ) { - prev = entry; - entry = entry->next; - } + DICacheEntry e, *entry; - if (entry) { - _MSG("Dicache_remove Imgbuf=%p Decoder=%p DecoderData=%p\n", - entry->v_imgbuf, entry->Decoder, entry->DecoderData); - /* Eliminate this dicache entry */ - dFree(entry->cmap); - a_Bitvec_free(entry->BitVec); - a_Imgbuf_unref(entry->v_imgbuf); - if (entry->Decoder) { - entry->Decoder(CA_Abort, entry->DecoderData); - } - dicache_size_total -= entry->TotalSize; - - if (node->first == entry) { - if (!entry->next) { - /* last entry with this URL. Remove the node as well */ - dList_remove(CachedIMGs, node); - a_Url_free(node->url); - dFree(node); - } else - node->first = entry->next; - } else { - prev->next = entry->next; - } - dFree(entry); + _MSG("Dicache_remove url=%s\n", URL_STR(Url)); + e.url = (DilloUrl*)Url; + e.version = version; + entry = dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp); + dReturn_if (entry == NULL); + + _MSG("Dicache_remove Imgbuf=%p Decoder=%p DecoderData=%p\n", + entry->v_imgbuf, entry->Decoder, entry->DecoderData); + /* Eliminate this dicache entry */ + dList_remove(CachedIMGs, entry); + dicache_size_total -= entry->TotalSize; + + /* entry cleanup */ + a_Url_free(entry->url); + dFree(entry->cmap); + a_Bitvec_free(entry->BitVec); + a_Imgbuf_unref(entry->v_imgbuf); + if (entry->Decoder) { + entry->Decoder(CA_Abort, entry->DecoderData); } + dFree(entry); } /* @@ -249,11 +208,9 @@ DICacheEntry* a_Dicache_ref(const DilloUrl *Url, int version) */ void a_Dicache_invalidate_entry(const DilloUrl *Url) { - DICacheNode *node; - - node = dList_find_sorted(CachedIMGs, Url, Dicache_node_by_url_cmp); - if (node) - node->valid = 0; + DICacheEntry *entry = a_Dicache_get_entry(Url, DIC_Last); + if (entry) + entry->Flags &= ~DIF_Valid; } @@ -550,29 +507,21 @@ void a_Dicache_callback(int Op, CacheClient_t *Client) void a_Dicache_cleanup(void) { int i; - DICacheNode *node; - DICacheEntry *entry, *next; - - MSG("a_Dicache_cleanup\n"); - for (i = 0; i < dList_length(CachedIMGs); ++i) { - node = dList_nth_data(CachedIMGs, i); - /* iterate each entry of this node */ - for (entry = node->first; entry; entry = next) { - next = entry->next; - MSG(" SurvCleanup = %d\n", entry->SurvCleanup); - if (entry->RefCount == 0 && - (!entry->v_imgbuf || a_Imgbuf_last_reference(entry->v_imgbuf))) { - if (--entry->SurvCleanup >= 0) - continue; /* keep the entry one more pass */ - - /* free this unused entry */ - _MSG("a_Dicache_cleanup: removing entry...\n"); - Dicache_remove(node->url, entry->version); - if (!next && node != dList_nth_data(CachedIMGs, i)) - --i; /* removed node, adjust counter */ - } + DICacheEntry *entry; + + for (i = 0; (entry = dList_nth_data(CachedIMGs, i)); ++i) { + _MSG(" SurvCleanup = %d\n", entry->SurvCleanup); + if (entry->RefCount == 0 && + (!entry->v_imgbuf || a_Imgbuf_last_reference(entry->v_imgbuf))) { + if (--entry->SurvCleanup >= 0) + continue; /* keep the entry one more pass */ + + /* free this unused entry */ + Dicache_remove(entry->url, entry->version); + --i; /* adjust counter */ } } + MSG("a_Dicache_cleanup: length = %d\n", dList_length(CachedIMGs)); } /* ------------------------------------------------------------------------- */ @@ -583,22 +532,17 @@ void a_Dicache_cleanup(void) */ void a_Dicache_freeall(void) { - DICacheNode *node; DICacheEntry *entry; - /* Remove every dicache node and its entries */ - while ((node = dList_nth_data(CachedIMGs, 0))) { - while ((entry = node->first)) { - node->first = entry->next; - dFree(entry->cmap); - a_Bitvec_free(entry->BitVec); - a_Imgbuf_unref(entry->v_imgbuf); - dicache_size_total -= entry->TotalSize; - dFree(entry); - } - dList_remove_fast(CachedIMGs, node); - a_Url_free(node->url); - dFree(node); + /* Remove all the dicache entries */ + while ((entry = dList_nth_data(CachedIMGs, dList_length(CachedIMGs)-1))) { + dList_remove_fast(CachedIMGs, entry); + a_Url_free(entry->url); + dFree(entry->cmap); + a_Bitvec_free(entry->BitVec); + a_Imgbuf_unref(entry->v_imgbuf); + dicache_size_total -= entry->TotalSize; + dFree(entry); } dList_free(CachedIMGs); } diff --git a/src/dicache.h b/src/dicache.h index 0390d214..7d5ef6ee 100644 --- a/src/dicache.h +++ b/src/dicache.h @@ -12,6 +12,9 @@ extern "C" { /* Symbolic name to request the last version of an image */ #define DIC_Last -1 +/* Flags: Last version, Valid entry */ +#define DIF_Last 1 +#define DIF_Valid 2 /* These will reflect the entry's "state" */ @@ -28,7 +31,8 @@ typedef struct DICacheEntry { DilloUrl *url; /* Image URL for this entry */ DilloImgType type; /* Image type */ uint_t width, height; /* As taken from image data */ - int SurvCleanup; /* Cleanup-pass survival for unused images */ + short Flags; /* See Flags */ + short SurvCleanup; /* Cleanup-pass survival for unused images */ uchar_t *cmap; /* Color map */ void *v_imgbuf; /* Void pointer to an Imgbuf object */ uint_t TotalSize; /* Amount of memory the image takes up */ @@ -42,8 +46,6 @@ typedef struct DICacheEntry { uint_t DecodedSize; /* Size of already decoded data */ CA_Callback_t Decoder; /* Client function */ void *DecoderData; /* Client function data */ - - struct DICacheEntry *next; /* Link to the next "newer" version */ } DICacheEntry; -- cgit v1.2.3 From d62880938f4e3fb98a2da0c52360b458c55489ae Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 12 Jun 2015 16:12:08 +0000 Subject: ChangeLog --- ChangeLog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 118ffa5d..57b10cfd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,7 +8,8 @@ at http://hg.dillo.org/dillo dillo-3.0.5 [not released yet] -+- Fix for segfault when there's no dpid and view source is requested. ++- Image buffer/cache improvements. + - Fix for segfault when there's no dpid and view source is requested. - Fix view-source dpi to handle null characters correctly. - Made view-source dpi use CSS formatting (it's shorter and cleaner). Patches: Jorge Arellano Cid -- cgit v1.2.3 From 76a032971d2dfdb0231a2e7f5298b636cfd88df3 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 11 Apr 2015 16:18:07 +0000 Subject: provide a redirection-blocked page --- src/cache.c | 108 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 41 deletions(-) diff --git a/src/cache.c b/src/cache.c index c4a8e922..a2ad357b 100644 --- a/src/cache.c +++ b/src/cache.c @@ -674,30 +674,23 @@ static void Cache_parse_header(CacheEntry_t *entry) if (header[9] == '3' && header[10] == '0' && (location_str = Cache_parse_field(header, "Location"))) { /* 30x: URL redirection */ - DilloUrl *location_url = a_Url_new(location_str,URL_STR_(entry->Url)); - - if (!a_Domain_permit(entry->Url, location_url)) { - /* don't redirect; just show body like usual (if any) */ + entry->Location = a_Url_new(location_str, URL_STR_(entry->Url)); + + if (!a_Domain_permit(entry->Url, entry->Location) || + (URL_FLAGS(entry->Location) & (URL_Post + URL_Get) && + dStrAsciiCasecmp(URL_SCHEME(entry->Location), "dpi") == 0 && + dStrAsciiCasecmp(URL_SCHEME(entry->Url), "dpi") != 0)) { + /* Domain test, and forbid dpi GET and POST from non dpi-generated + * urls. + */ MSG("Redirection not followed from %s to %s\n", - URL_HOST(entry->Url), URL_STR(location_url)); - a_Url_free(location_url); + URL_HOST(entry->Url), URL_STR(entry->Location)); } else { entry->Flags |= CA_Redirect; if (header[11] == '1') entry->Flags |= CA_ForceRedirect; /* 301 Moved Permanently */ else if (header[11] == '2') entry->Flags |= CA_TempRedirect; /* 302 Temporary Redirect */ - - if (URL_FLAGS(location_url) & (URL_Post + URL_Get) && - dStrAsciiCasecmp(URL_SCHEME(location_url), "dpi") == 0 && - dStrAsciiCasecmp(URL_SCHEME(entry->Url), "dpi") != 0) { - /* Forbid dpi GET and POST from non dpi-generated urls */ - MSG("Redirection Denied! '%s' -> '%s'\n", - URL_STR(entry->Url), URL_STR(location_url)); - a_Url_free(location_url); - } else { - entry->Location = location_url; - } } dFree(location_str); } else if (strncmp(header + 9, "401", 3) == 0) { @@ -1090,6 +1083,27 @@ static void Cache_savelink_cb(void *vdata) dFree(data); } +/* + * Let the client know that we're not following a redirection. + */ +static void Cache_provide_redirection_blocked_page(CacheEntry_t *entry, + CacheClient_t *client) +{ + DilloWeb *clientWeb = client->Web; + + a_Web_dispatch_by_type("text/html", clientWeb, &client->Callback, + &client->CbData); + client->Buf = dStrconcat("" + "Dillo blocked a redirection attempt from Url), "\">", URL_STR(entry->Url), + " to Location), "\">", + URL_STR(entry->Location), " based on your domainrc " + "settings.", NULL); + client->BufSize = strlen(client->Buf); + (client->Callback)(CA_Send, client); + dFree(client->Buf); +} + /* * Update cache clients for a single cache-entry * Tasks: @@ -1175,33 +1189,40 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) /* Set the client function */ if (!Client->Callback) { Client->Callback = Cache_null_client; - if (TypeMismatch) { - AbortEntry = TRUE; + + if (entry->Location && !(entry->Flags & CA_Redirect)) { + /* Not following redirection, so don't display page body. */ } else { - const char *curr_type = Cache_current_content_type(entry); - st = a_Web_dispatch_by_type(curr_type, ClientWeb, - &Client->Callback, &Client->CbData); - if (st == -1) { - /* MIME type is not viewable */ - if (ClientWeb->flags & WEB_RootUrl) { - MSG("Content-Type '%s' not viewable.\n", curr_type); - /* prepare a download offer... */ - AbortEntry = OfferDownload = TRUE; - } else { - /* TODO: Resource Type not handled. - * Not aborted to avoid multiple connections on the same - * resource. A better idea is to abort the connection and - * to keep a failed-resource flag in the cache entry. */ + if (TypeMismatch) { + AbortEntry = TRUE; + } else { + const char *curr_type = Cache_current_content_type(entry); + st = a_Web_dispatch_by_type(curr_type, ClientWeb, + &Client->Callback, + &Client->CbData); + if (st == -1) { + /* MIME type is not viewable */ + if (ClientWeb->flags & WEB_RootUrl) { + MSG("Content-Type '%s' not viewable.\n", curr_type); + /* prepare a download offer... */ + AbortEntry = OfferDownload = TRUE; + } else { + /* TODO: Resource Type not handled. + * Not aborted to avoid multiple connections on the + * same resource. A better idea is to abort the + * connection and to keep a failed-resource flag in + * the cache entry. */ + } } } - } - if (AbortEntry) { - if (ClientWeb->flags & WEB_RootUrl) - a_Nav_cancel_expect_if_eq(Client_bw, Client->Url); - a_Bw_remove_client(Client_bw, Client->Key); - Cache_client_dequeue(Client); - --i; /* Keep the index value in the next iteration */ - continue; + if (AbortEntry) { + if (ClientWeb->flags & WEB_RootUrl) + a_Nav_cancel_expect_if_eq(Client_bw, Client->Url); + a_Bw_remove_client(Client_bw, Client->Key); + Cache_client_dequeue(Client); + --i; /* Keep the index value in the next iteration */ + continue; + } } } @@ -1225,6 +1246,11 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) if (entry->Flags & CA_GotData) { /* Copy flags to a local var */ int flags = ClientWeb->flags; + + if (ClientWeb->flags & WEB_RootUrl && entry->Location && + !(entry->Flags & CA_Redirect)) { + Cache_provide_redirection_blocked_page(entry, Client); + } /* We finished sending data, let the client know */ (Client->Callback)(CA_Close, Client); if (ClientWeb->flags & WEB_RootUrl) -- cgit v1.2.3 From 6031f8f9a0e736a7aad47f4f24266f0125cdf76e Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 12 Jun 2015 16:16:32 +0000 Subject: ChangeLog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 57b10cfd..5c824ae0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ dillo-3.0.5 [not released yet] - In location bar, tend toward showing beginning of URL instead of end. - Handle irix's version of vsnprintf(). - INPUT, TEXTAREA placeholder attribute. + - Better notification when user's domainrc settings block page redirection. - Fix bug with font_factor preference and CSS font-size:(larger|smaller). - Recognize Menu key in keysrc. - HTTPS: change cipher list to "ALL:!aNULL:!eNULL:!LOW:!EXPORT40:!RC4", -- cgit v1.2.3 From d1ed173827bedfa07ac504c1c2966bc0e2c65ce3 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 22 Apr 2014 04:50:40 +0000 Subject: in bad-url BUG_MSG, provide the url string --- src/html.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/html.cc b/src/html.cc index f8734444..5b080b27 100644 --- a/src/html.cc +++ b/src/html.cc @@ -158,15 +158,15 @@ DilloUrl *a_Html_url_new(DilloHtml *html, const char *suffix = (n_ic) > 1 ? "s" : ""; n_ic_spc = URL_ILLEGAL_CHARS_SPC(url); if (n_ic == n_ic_spc) { - BUG_MSG("URL has %d illegal space%s\n", n_ic, suffix); + BUG_MSG("URL has %d illegal space%s ('%s')\n", n_ic, suffix, url_str); } else if (n_ic_spc == 0) { - BUG_MSG("URL has %d illegal character%s in {00-1F, 7F} range\n", - n_ic, suffix); + BUG_MSG("URL has %d illegal byte%s in {00-1F, 7F} range ('%s')\n", + n_ic, suffix, url_str); } else { - BUG_MSG("URL has %d illegal character%s: " - "%d space%s, and %d in {00-1F, 7F} range\n", + BUG_MSG("URL has %d illegal byte%s: " + "%d space%s and %d in {00-1F, 7F} range ('%s')\n", n_ic, suffix, - n_ic_spc, n_ic_spc > 1 ? "s" : "", n_ic-n_ic_spc); + n_ic_spc, n_ic_spc > 1 ? "s" : "", n_ic-n_ic_spc, url_str); } } return url; -- cgit v1.2.3 From a607a53e06059f67150d65dddbfa9d25f8325a5c Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 4 May 2014 02:03:46 +0000 Subject: acknowledge that we view 0x80-0xFF bytes in urls as illegal, and make handling uniform whether char is signed or unsigned --- src/html.cc | 4 ++-- src/url.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/html.cc b/src/html.cc index 5b080b27..5d282209 100644 --- a/src/html.cc +++ b/src/html.cc @@ -160,11 +160,11 @@ DilloUrl *a_Html_url_new(DilloHtml *html, if (n_ic == n_ic_spc) { BUG_MSG("URL has %d illegal space%s ('%s')\n", n_ic, suffix, url_str); } else if (n_ic_spc == 0) { - BUG_MSG("URL has %d illegal byte%s in {00-1F, 7F} range ('%s')\n", + BUG_MSG("URL has %d illegal byte%s in {00-1F, 7F-FF} range ('%s')\n", n_ic, suffix, url_str); } else { BUG_MSG("URL has %d illegal byte%s: " - "%d space%s and %d in {00-1F, 7F} range ('%s')\n", + "%d space%s and %d in {00-1F, 7F-FF} range ('%s')\n", n_ic, suffix, n_ic_spc, n_ic_spc > 1 ? "s" : "", n_ic-n_ic_spc, url_str); } diff --git a/src/url.c b/src/url.c index a46e7f90..4eacb7a4 100644 --- a/src/url.c +++ b/src/url.c @@ -366,18 +366,18 @@ DilloUrl* a_Url_new(const char *url_str, const char *base_url) dReturn_val_if_fail (url_str != NULL, NULL); - /* Count illegal characters (0x00-0x1F, 0x7F and space) */ + /* Count illegal characters (0x00-0x1F, 0x7F-0xFF and space) */ n_ic = n_ic_spc = 0; for (p = (char*)url_str; *p; p++) { n_ic_spc += (*p == ' ') ? 1 : 0; - n_ic += (*p != ' ' && *p > 0x1F && *p != 0x7F) ? 0 : 1; + n_ic += (*p != ' ' && *p > 0x1F && *p < 0x7F) ? 0 : 1; } if (n_ic) { /* Encode illegal characters (they could also be stripped). * There's no standard for illegal chars; we chose to encode. */ p = str1 = dNew(char, strlen(url_str) + 2*n_ic + 1); for (i = 0; url_str[i]; ++i) - if (url_str[i] > 0x1F && url_str[i] != 0x7F && url_str[i] != ' ') + if (url_str[i] > 0x1F && url_str[i] < 0x7F && url_str[i] != ' ') *p++ = url_str[i]; else { *p++ = '%'; @@ -611,7 +611,7 @@ char *a_Url_encode_hex_str(const char *str) /* * RFC-3986 suggests this stripping when "importing" URLs from other media. * Strip: "URL:", enclosing < >, and embedded whitespace. - * (We also strip illegal chars: 00-1F and 7F) + * (We also strip illegal chars: 00-1F and 7F-FF) */ char *a_Url_string_strip_delimiters(const char *str) { @@ -626,7 +626,7 @@ char *a_Url_string_strip_delimiters(const char *str) text++; for (p = new_str; *text; text++) - if (*text > 0x1F && *text != 0x7F && *text != ' ') + if (*text > 0x1F && *text < 0x7F && *text != ' ') *p++ = *text; if (p > new_str && p[-1] == '>') --p; -- cgit v1.2.3 From 27033e55c806d4ac9f331ded804f3b1a786628ea Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 7 May 2014 20:36:52 +0000 Subject: page bugs: fix line numbers for bugs in entities --- src/html.cc | 25 +++++++++++++------------ src/html_common.hh | 5 ++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/html.cc b/src/html.cc index 5d282209..997287ca 100644 --- a/src/html.cc +++ b/src/html.cc @@ -134,7 +134,7 @@ void DilloHtml::bugMessage(const char *format, ... ) dStr_sprintfa(bw->page_bugs, "HTML warning: line %d, ", - getCurTagLineNumber()); + getCurrLineNumber()); va_start(argp, format); dStr_vsprintfa(bw->page_bugs, format, argp); va_end(argp); @@ -397,9 +397,8 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, stop_parser = false; - CurrTagOfs = 0; - OldTagOfs = 0; - OldTagLine = 1; + CurrOfs = OldOfs = 0; + OldLine = 1; DocType = DT_NONE; /* assume Tag Soup 0.0! :-) */ DocTypeVersion = 0.0f; @@ -539,10 +538,10 @@ void DilloHtml::write(char *Buf, int BufSize, int Eof) } /* - * Return the line number of the tag being processed by the parser. + * Return the line number of the tag/word being processed by the parser. * Also update the offsets. */ -int DilloHtml::getCurTagLineNumber() +int DilloHtml::getCurrLineNumber() { int i, ofs, line; const char *p = Start_Buf; @@ -551,13 +550,13 @@ int DilloHtml::getCurTagLineNumber() /* Disable line counting for META hack. Buffers differ. */ dReturn_val_if((InFlags & IN_META_HACK), -1); - ofs = CurrTagOfs; - line = OldTagLine; - for (i = OldTagOfs; i < ofs; ++i) + ofs = CurrOfs; + line = OldLine; + for (i = OldOfs; i < ofs; ++i) if (p[i] == '\n' || (p[i] == '\r' && p[i+1] != '\n')) ++line; - OldTagOfs = CurrTagOfs; - OldTagLine = line; + OldOfs = CurrOfs; + OldLine = line; return line; } @@ -4251,7 +4250,7 @@ static int Html_write_raw(DilloHtml *html, char *buf, int bufsize, int Eof) buf_index = bufsize; } else { /* Tag: search end of tag (skipping over quoted strings) */ - html->CurrTagOfs = html->Start_Ofs + token_start; + html->CurrOfs = html->Start_Ofs + token_start; while ( buf_index < bufsize ) { buf_index++; @@ -4295,6 +4294,8 @@ static int Html_write_raw(DilloHtml *html, char *buf, int bufsize, int Eof) } } else { /* A Word: search for whitespace or tag open */ + html->CurrOfs = html->Start_Ofs + token_start; + while (++buf_index < bufsize) { buf_index += strcspn(buf + buf_index, " <\n\r\t\f\v"); if (buf[buf_index] == '<' && (ch = buf[buf_index + 1]) && diff --git a/src/html_common.hh b/src/html_common.hh index 147807b3..68ed0d08 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -156,8 +156,7 @@ public: //BUG: for now everything is public char *content_type, *charset; bool stop_parser; - size_t CurrTagOfs; - size_t OldTagOfs, OldTagLine; + size_t CurrOfs, OldOfs, OldLine; DilloHtmlDocumentType DocType; /* as given by DOCTYPE tag */ float DocTypeVersion; /* HTML or XHTML version number */ @@ -211,7 +210,7 @@ public: void bugMessage(const char *format, ... ); void connectSignals(dw::core::Widget *dw); void write(char *Buf, int BufSize, int Eof); - int getCurTagLineNumber(); + int getCurrLineNumber(); void finishParsing(int ClientKey); int formNew(DilloHtmlMethod method, const DilloUrl *action, DilloHtmlEnc enc, const char *charset); -- cgit v1.2.3 From 14dcb7a9e312d03ac7a63d6a8ec955550de69653 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 23 May 2014 02:49:19 +0000 Subject: paths MSG consistency --- src/paths.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/paths.cc b/src/paths.cc index 32478728..18712995 100644 --- a/src/paths.cc +++ b/src/paths.cc @@ -38,16 +38,16 @@ void Paths::init(void) oldWorkingDir = dGetcwd(); rc = chdir("/tmp"); if (rc == -1) { - MSG("paths: error changing directory to /tmp: %s\n", + MSG("paths: Error changing directory to /tmp: %s\n", dStrerror(errno)); } path = dStrconcat(dGethomedir(), "/.dillo", NULL); if (stat(path, &st) == -1) { if (errno == ENOENT) { - MSG("paths: creating directory %s.\n", path); + MSG("paths: Creating directory %s\n", path); if (mkdir(path, 0700) < 0) { - MSG("paths: error creating directory %s: %s\n", + MSG("paths: Error creating directory %s: %s\n", path, dStrerror(errno)); } } else { -- cgit v1.2.3 From 38a1bc1f8075b35025ee1ae3eebda066e6d534a3 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 23 May 2014 03:00:29 +0000 Subject: a little more --- src/paths.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/paths.cc b/src/paths.cc index 18712995..bb233de8 100644 --- a/src/paths.cc +++ b/src/paths.cc @@ -45,7 +45,7 @@ void Paths::init(void) path = dStrconcat(dGethomedir(), "/.dillo", NULL); if (stat(path, &st) == -1) { if (errno == ENOENT) { - MSG("paths: Creating directory %s\n", path); + MSG("paths: Creating directory '%s/'\n", path); if (mkdir(path, 0700) < 0) { MSG("paths: Error creating directory %s: %s\n", path, dStrerror(errno)); -- cgit v1.2.3 From c1b4f7f51ab8a9190bcaabc13015ffeff292a4a1 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 30 Jul 2014 02:46:27 +0000 Subject: KB --- dpi/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dpi/file.c b/dpi/file.c index 5f1459ad..00e10468 100644 --- a/dpi/file.c +++ b/dpi/file.c @@ -346,10 +346,10 @@ static void File_info2html(ClientInfo *client, FileInfo *finfo, int n) sizeunits = "bytes"; } else if (finfo->size / 1024 <= 9999) { size = finfo->size / 1024 + (finfo->size % 1024 >= 1024 / 2); - sizeunits = "Kb"; + sizeunits = "KB"; } else { size = finfo->size / 1048576 + (finfo->size % 1048576 >= 1048576 / 2); - sizeunits = "Mb"; + sizeunits = "MB"; } /* we could note if it's a symlink... */ -- cgit v1.2.3 From ad5acf836446b260329ce464e1fb27dc97e48d3e Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 3 Aug 2014 17:38:04 +0000 Subject: MSG --- src/html.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/html.cc b/src/html.cc index 997287ca..04b4ac84 100644 --- a/src/html.cc +++ b/src/html.cc @@ -2770,7 +2770,8 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize) /* We compare the "id" value with the url-decoded "name" value */ if (!id || strcmp(nameVal, id)) { if (id) - BUG_MSG("'id' and 'name' attribute of tag differ\n"); + BUG_MSG("id ('%s') and name ('%s') attributes of tag " + "differ\n", id, nameVal); Html_add_anchor(html, nameVal); } -- cgit v1.2.3 From 02ba033e04c72019be578d011e9cdd64221deb11 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 3 Aug 2014 22:28:57 +0000 Subject: BUG_MSG --- src/html.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/html.cc b/src/html.cc index 04b4ac84..28c44dbe 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1517,8 +1517,8 @@ static int bool valid = *val && !strchr(val, ' '); if (!valid) { - BUG_MSG("'%s' value must not be empty and must not contain spaces.\n", - attrname); + BUG_MSG("'%s' value \"%s\" must not be empty and must not contain " + "spaces.\n", attrname, val); } return valid ? 1 : 0; } else { -- cgit v1.2.3 From 37a8c614c14c76f1d1e16b1e4f6a7c4c3ecf3f68 Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 4 Aug 2014 01:10:56 +0000 Subject: bug messages: '\n' as separator instead of terminator Now no extra line at the bottom of the bugs, plus shorter strings. --- src/form.cc | 34 +++++++-------- src/html.cc | 136 ++++++++++++++++++++++++++++++----------------------------- src/table.cc | 22 +++++----- 3 files changed, 97 insertions(+), 95 deletions(-) diff --git a/src/form.cc b/src/form.cc index ac7384aa..b48bb45e 100644 --- a/src/form.cc +++ b/src/form.cc @@ -343,7 +343,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) HT2TB(html)->addParbreak (9, html->wordStyle ()); if (html->InFlags & IN_FORM) { - BUG_MSG("nested forms\n"); + BUG_MSG("nested forms"); return; } html->InFlags |= IN_FORM; @@ -356,14 +356,14 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) if (!dStrAsciiCasecmp(attrbuf, "post")) { method = DILLO_HTML_METHOD_POST; } else if (dStrAsciiCasecmp(attrbuf, "get")) { - BUG_MSG("Unknown form submission method \"%s\"\n", attrbuf); + BUG_MSG("Unknown form submission method \"%s\"", attrbuf); } } if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "action"))) action = a_Html_url_new(html, attrbuf, NULL, 0); else { if (html->DocType != DT_HTML || html->DocTypeVersion <= 4.01f) - BUG_MSG("action attribute is required for

\n"); + BUG_MSG("action attribute is required for "); action = a_Url_dup(html->base_url); } content_type = DILLO_HTML_ENC_URLENCODED; @@ -417,7 +417,7 @@ static int Html_input_get_size(DilloHtml *html, const char *attrbuf) if (size < 1 || size > MAX_SIZE) { int badSize = size; size = (size < 1 ? 20 : MAX_SIZE); - BUG_MSG("input size=%d, using size=%d instead\n", badSize, size); + BUG_MSG("input size=%d, using size=%d instead", badSize, size); } } return size; @@ -437,11 +437,11 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) ResourceFactory *factory; if (html->InFlags & IN_SELECT) { - BUG_MSG(" element inside element inside element inside