On Tue, Jun 10, 2003 at 12:03:05PM +0200, Jan Stary wrote:
Hello,
there seems to be the following problem with the history of browsing:
If first.html contains a link <a href="second.html">, then clicking on it gets you to second.html - OK. If second.html contains a link <a href=#"anchor"> pointing to a place in second.html, then clicking on the link gets you to #anchor - OK. But then, when you press [,] to go back, you get back to first.thml.
Definitely, you want [,] to get you back to the beginning of second.html.
It looks like the #anchor links don't go into the 'stack of previous places'. I don't mean that second.html#anchor should be remembered as a unique record in browser history (e.g. for future runs, after dillo supports it), but definitely it's a step 'forward from second.html', so going 'back' should go to second.html, not first.html.
I have a patch for 0.6.6 that does this. I don't know if it still applies, but I'm appending it here. Note that I'm not sure this is/was the right way to do it. Frank diff -ur dillo-0.6.6/src/history.c dillo-0.6.6.fg/src/history.c --- dillo-0.6.6/src/history.c 2002-04-10 02:53:58.000000000 +0200 +++ dillo-0.6.6.fg/src/history.c 2002-08-16 17:58:55.000000000 +0200 @@ -38,7 +38,7 @@ gint i, idx; for (i = 0; i < history_size; ++i) - if (a_Url_cmp(history[i].url, url) == 0) + if (a_Url_cmp(history[i].url, url) == 0 && URL_STRCAMP_EQ(history[i].url->fragment,url->fragment)) return i; idx = history_size; diff -ur dillo-0.6.6/src/nav.c dillo-0.6.6.fg/src/nav.c --- dillo-0.6.6/src/nav.c 2002-04-10 03:10:16.000000000 +0200 +++ dillo-0.6.6.fg/src/nav.c 2002-08-16 20:34:52.000000000 +0200 @@ -176,7 +176,7 @@ MustLoad = ForceReload || !old_url; if (old_url){ MustLoad |= a_Url_cmp(old_url, url); - MustLoad |= strcmp(URL_STR(old_url), a_Interface_get_location_text(bw)); + MustLoad |= strcmp(URL_STR_NOANCHOR(old_url), a_Interface_get_location_text(bw)); } if ( MustLoad ) { @@ -195,9 +195,19 @@ a_Interface_set_cursor(bw, GDK_LEFT_PTR); } - /* Jump to #anchor position */ + /* Push on stack and jump to #anchor position */ if (URL_FRAGMENT_(url)) { - /* todo: push on stack */ + gint idx; + DilloUrl *hist_url=a_Url_dup(url); + + /* unset E2EReload before adding this url to history */ + a_Url_set_flags(hist_url, URL_FLAGS(hist_url) & ~URL_E2EReload); + idx = a_History_add_url(hist_url); + Nav_stack_add(bw, idx); + Nav_stack_clean(bw); + a_Interface_set_button_sens(bw); + a_Url_free(hist_url); + a_Dw_gtk_scrolled_window_set_anchor( GTK_DW_SCROLLED_WINDOW(bw->docwin), URL_FRAGMENT_(url)); } diff -ur dillo-0.6.6/src/url.c dillo-0.6.6.fg/src/url.c --- dillo-0.6.6/src/url.c 2002-04-10 03:10:28.000000000 +0200 +++ dillo-0.6.6.fg/src/url.c 2002-08-16 20:20:59.000000000 +0200 @@ -56,19 +56,47 @@ if (!url->url_string) { url->url_string = g_string_sized_new(60); - g_string_sprintf( - url->url_string, "%s%s%s%s%s%s%s%s%s%s", - url->scheme ? url->scheme : "", - url->scheme ? ":" : "", - url->authority ? "//" : "", - url->authority ? url->authority : "", - (url->path && url->path[0] != '/' && url->authority) ? "/" : "", - url->path ? url->path : "", - url->query ? "?" : "", - url->query ? url->query : "", - url->fragment ? "#" : "", - url->fragment ? url->fragment : ""); } + g_string_sprintf( + url->url_string, "%s%s%s%s%s%s%s%s%s%s", + url->scheme ? url->scheme : "", + url->scheme ? ":" : "", + url->authority ? "//" : "", + url->authority ? url->authority : "", + (url->path && url->path[0] != '/' && url->authority) ? "/" : "", + url->path ? url->path : "", + url->query ? "?" : "", + url->query ? url->query : "", + url->fragment ? "#" : "", + url->fragment ? url->fragment : ""); + + return url->url_string->str; +} + +/* + * Return the url as a string, without the anchor part. + * (initializing 'url_string' camp if necessary) + */ +gchar *a_Url_str_noanchor(const DilloUrl *u) +{ + /* Internal url handling IS transparent to the caller */ + DilloUrl *url = (DilloUrl *) u; + + g_return_val_if_fail (url != NULL, NULL); + + if (!url->url_string) { + url->url_string = g_string_sized_new(60); + } + g_string_sprintf( + url->url_string, "%s%s%s%s%s%s%s%s", + url->scheme ? url->scheme : "", + url->scheme ? ":" : "", + url->authority ? "//" : "", + url->authority ? url->authority : "", + (url->path && url->path[0] != '/' && url->authority) ? "/" : "", + url->path ? url->path : "", + url->query ? "?" : "", + url->query ? url->query : ""); return url->url_string->str; } diff -ur dillo-0.6.6/src/url.h dillo-0.6.6.fg/src/url.h --- dillo-0.6.6/src/url.h 2002-04-10 03:05:43.000000000 +0200 +++ dillo-0.6.6.fg/src/url.h 2002-08-16 20:25:02.000000000 +0200 @@ -56,6 +56,7 @@ #define URL_ALT_(u) u->alt #define URL_POS_(u) u->scrolling_position #define URL_STR_(u) a_Url_str(u) +#define URL_STR_NOANCHOR_(u) a_Url_str_noanchor(u) /* * Access methods that always return a string: @@ -75,6 +76,7 @@ #define URL_ALT(u) NPTR2STR(URL_ALT_(u)) #define URL_POS(u) URL_POS_(u) #define URL_STR(u) NPTR2STR(URL_STR_(u)) +#define URL_STR_NOANCHOR(u) NPTR2STR(URL_STR_NOANCHOR_(u)) @@ -117,6 +119,7 @@ gint flags, gint pos); void a_Url_free(DilloUrl *u); gchar *a_Url_str(const DilloUrl *url); +gchar *a_Url_str_noanchor(const DilloUrl *url); const gchar *a_Url_hostname(const DilloUrl *u); DilloUrl* a_Url_dup(const DilloUrl *u); gint a_Url_cmp(const DilloUrl* A, const DilloUrl* B);