From 5e83fc07ff785200e9dd5078ce903fb0b053e526 Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Thu, 28 May 2009 17:55:53 +0300 Subject: Preserve back/forward history when opening links in new tabs/windows. Bug #583459. --- embed/ephy-embed-utils.h | 1 + embed/webkit/webkit-embed.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'embed') diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h index a5c64bb7d..e98860ed8 100644 --- a/embed/ephy-embed-utils.h +++ b/embed/ephy-embed-utils.h @@ -36,6 +36,7 @@ G_BEGIN_DECLS #define EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED(embed) (WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (gtk_bin_get_child (GTK_BIN (embed)))))) +#define EPHY_WEBKIT_BACK_FORWARD_LIMIT 100 char * ephy_embed_utils_link_message_parse (char *message); const char * ephy_embed_utils_get_title_composite (EphyEmbed *embed); diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c index 481e51432..cb6e9dcb1 100644 --- a/embed/webkit/webkit-embed.c +++ b/embed/webkit/webkit-embed.c @@ -858,6 +858,37 @@ impl_shistory_copy (EphyEmbed *source, gboolean copy_forward, gboolean copy_current) { + WebKitWebView *source_view, *dest_view; + WebKitWebBackForwardList* source_bflist, *dest_bflist; + WebKitWebHistoryItem *item; + GList *items; + + source_view = WEBKIT_EMBED (source)->priv->web_view; + dest_view = WEBKIT_EMBED (dest)->priv->web_view; + + source_bflist = webkit_web_view_get_back_forward_list (source_view); + dest_bflist = webkit_web_view_get_back_forward_list (dest_view); + + if (copy_back) { + items = webkit_web_back_forward_list_get_back_list_with_limit (source_bflist, EPHY_WEBKIT_BACK_FORWARD_LIMIT); + /* We want to add the items in the reverse order here, so the + history ends up the same */ + items = g_list_reverse (items); + for (; items; items = items->next) { + item = (WebKitWebHistoryItem*)items->data; + webkit_web_back_forward_list_add_item (dest_bflist, g_object_ref (item)); + } + g_list_free (items); + } + + /* The ephy/gecko behavior is to add the current item of the source + embed at the end of the back history, so keep doing that */ + item = webkit_web_back_forward_list_get_current_item (source_bflist); + webkit_web_back_forward_list_add_item (dest_bflist, g_object_ref (item)); + + /* We ignore the 'copy_current' flag, it's unused in Epiphany */ + /* We ignore the 'copy_forward' flag, ephy/gecko did nothing with it + either AFAICT*/ } static void -- cgit v1.2.3