diff options
author | jcid <devnull@localhost> | 2008-03-13 14:52:27 +0100 |
---|---|---|
committer | jcid <devnull@localhost> | 2008-03-13 14:52:27 +0100 |
commit | a8f62360ef2f3f0d121a51ab20ba4b46ce8c9a28 (patch) | |
tree | c8148ed74d4b26f063f57ba45e1669f1de484633 /src | |
parent | b393f84a8a3f24c04443548204ae566eb43d96d1 (diff) |
- Added support for "charset" in the META element.
Diffstat (limited to 'src')
-rw-r--r-- | src/IO/http.c | 8 | ||||
-rw-r--r-- | src/html.cc | 25 | ||||
-rw-r--r-- | src/nav.c | 43 | ||||
-rw-r--r-- | src/nav.h | 1 |
4 files changed, 67 insertions, 10 deletions
diff --git a/src/IO/http.c b/src/IO/http.c index 8645a411..658dcc3b 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -417,6 +417,7 @@ static int Http_must_use_proxy(const DilloUrl *url) /* * Callback function for the DNS resolver. * Continue connecting the socket, or abort upon error condition. + * S->web is checked to assert the operation wasn't aborted while waiting. */ void a_Http_dns_cb(int Status, Dlist *addr_list, void *data) { @@ -425,7 +426,12 @@ void a_Http_dns_cb(int Status, Dlist *addr_list, void *data) S = a_Klist_get_data(ValidSocks, SKey); if (S) { - if (Status == 0 && addr_list) { + if (!a_Web_valid(S->web)) { + a_Chain_fcb(OpAbort, S->Info, NULL, NULL); + dFree(S->Info); + Http_socket_free(SKey); + + } else if (Status == 0 && addr_list) { /* Successful DNS answer; save the IP */ S->addr_list = addr_list; /* start connecting the socket */ diff --git a/src/html.cc b/src/html.cc index 48dc24c3..46d3e3bd 100644 --- a/src/html.cc +++ b/src/html.cc @@ -404,6 +404,10 @@ typedef struct { } TagInfo; extern const TagInfo Tags[]; +/* todo: implement this as an URL/charset pair in a DList. + * chances of this bare-bones implementation to fail are minimal though: + * two ROOT pages using meta-charset, parsing HEAD section at the same time */ +static char *meta_charset = NULL; /*----------------------------------------------------------------------------- *----------------------------------------------------------------------------- @@ -792,8 +796,17 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, if (charset) { MSG("HTTP Content-Type gave charset as: %s\n", charset); } - decoder = a_Decode_charset_init(charset); - this->charset = dStrdup(charset); + if (meta_charset) { + MSG("META Content-Type gave charset as: %s\n", meta_charset); + } + if (meta_charset) { + decoder = a_Decode_charset_init(meta_charset); + this->charset = meta_charset; + meta_charset = NULL; + } else { + decoder = a_Decode_charset_init(charset); + this->charset = dStrdup(charset); + } CurrTagOfs = 0; OldTagOfs = 0; @@ -3667,12 +3680,12 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize) if (charset) { if (!html->charset || dStrcasecmp(charset, html->charset)) { MSG("META Content-Type changes charset to: %s\n", charset); - a_Decode_free(html->decoder); - html->decoder = a_Decode_charset_init(charset); + dFree(meta_charset); + meta_charset = dStrdup(charset); + a_Nav_repush(html->bw); } - dFree(html->charset); - html->charset = charset; } + dFree(charset); } } } @@ -21,6 +21,7 @@ #include "dialog.hh" #include "prefs.h" #include "capi.h" +#include "timeout.hh" //#define DEBUG_LEVEL 3 #include "debug.h" @@ -192,7 +193,8 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset) bool_t MustLoad; int x, y, idx, ClientKey; DilloWeb *Web; - bool_t ForceReload = (URL_FLAGS(url) & URL_E2EReload); + bool_t ForceReload = (URL_FLAGS(url) & + (URL_E2EReload + URL_ReloadFromCache)); MSG("Nav_open_url: new url='%s'\n", URL_STR_(url)); @@ -272,6 +274,8 @@ void a_Nav_expect_done(BrowserWindow *bw) url = bw->nav_expect_url; /* unset E2EReload before adding this url to history */ a_Url_set_flags(url, URL_FLAGS(url) & ~URL_E2EReload); + /* unset ReloadFromCache before adding this url to history */ + a_Url_set_flags(url, URL_FLAGS(url) & ~URL_ReloadFromCache); url_idx = a_History_add_url(url); Nav_stack_add(bw, url_idx, 0, 0); /* Scroll to the origin unless there's a fragment part */ @@ -317,6 +321,40 @@ void a_Nav_push(BrowserWindow *bw, const DilloUrl *url) } /* + * This one does a_Nav_repush's job. + */ +static void Nav_repush(BrowserWindow *bw) +{ + DilloUrl *ReqURL; + + a_Nav_cancel_expect(bw); + if (a_Nav_stack_size(bw)) { + ReqURL = a_Url_dup(a_History_get_url(NAV_TOP_UIDX(bw))); + /* Let's make reload be from Cache */ + a_Url_set_flags(ReqURL, URL_FLAGS(ReqURL) | URL_ReloadFromCache); + Nav_open_url(bw, ReqURL, 0); + a_Url_free(ReqURL); + } +} + +static void Nav_repush_callback(void *data) +{ + Nav_repush(data); + a_Timeout_remove(); +} + +/* + * Repush current URL: not an end-to-end reload but from cache. + * - Currently used to switch to a charset decoder given by the META element. + * - Delayed to let dillo finish the call flow into a known state. + */ +void a_Nav_repush(BrowserWindow *bw) +{ + dReturn_if_fail (bw != NULL); + a_Timeout_add(0.0, Nav_repush_callback, (void*)bw); +} + +/* * Same as a_Nav_push() but in a new window. */ void a_Nav_push_nw(BrowserWindow *bw, const DilloUrl *url) @@ -378,11 +416,10 @@ void a_Nav_home(BrowserWindow *bw) */ static void Nav_reload(BrowserWindow *bw) { - DilloUrl *url, *ReqURL; + DilloUrl *ReqURL; a_Nav_cancel_expect(bw); if (a_Nav_stack_size(bw)) { - url = a_History_get_url(NAV_TOP_UIDX(bw)); ReqURL = a_Url_dup(a_History_get_url(NAV_TOP_UIDX(bw))); /* Let's make reload be end-to-end */ a_Url_set_flags(ReqURL, URL_FLAGS(ReqURL) | URL_E2EReload); @@ -16,6 +16,7 @@ extern "C" { void a_Nav_push(BrowserWindow *bw, const DilloUrl *url); void a_Nav_push_nw(BrowserWindow *bw, const DilloUrl *url); void a_Nav_vpush(void *vbw, const DilloUrl *url); +void a_Nav_repush(BrowserWindow *bw); void a_Nav_back(BrowserWindow *bw); void a_Nav_forw(BrowserWindow *bw); void a_Nav_home(BrowserWindow *bw); |