From 10f300b27a14c450c9a20b12c23f4e542942655c Mon Sep 17 00:00:00 2001 From: Gustavo Noronha Silva Date: Fri, 15 Mar 2013 23:58:09 -0300 Subject: Load back item when back is clicked with control held/middle clicked, for wk2 In WebKit2 the back/forward list is not copiable, so that assumption doesn't hold, and the current code path fails. With this change we tell EphyShell to not copy the list and load the URL held by the back item of the existing WebView in the new WebView instead, for WebKit2. https://bugzilla.gnome.org/show_bug.cgi?id=695951 --- src/ephy-navigation-history-action.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/ephy-navigation-history-action.c b/src/ephy-navigation-history-action.c index ce53df929..dec229011 100644 --- a/src/ephy-navigation-history-action.c +++ b/src/ephy-navigation-history-action.c @@ -106,6 +106,29 @@ action_activate (GtkAction *action) if (history_action->priv->direction == EPHY_NAVIGATION_HISTORY_DIRECTION_BACK) { if (ephy_gui_is_middle_click () || ephy_link_action_get_button (EPHY_LINK_ACTION (history_action)) == 2) { + /* FIXME: in WebKit2 the back/forward list is immutable, so we are not able to + * copy it. Ideally the webkit1 code path should also work for webkit2. */ +#ifdef HAVE_WEBKIT2 + const char *back_uri; + WebKitBackForwardList *history; + WebKitBackForwardListItem *back_item; + + history = webkit_web_view_get_back_forward_list (web_view); + back_item = webkit_back_forward_list_get_back_item (history); + back_uri = webkit_back_forward_list_item_get_original_uri (back_item); + + embed = ephy_shell_new_tab (ephy_shell_get_default (), + EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))), + NULL, + NULL, + EPHY_NEW_TAB_IN_EXISTING_WINDOW | EPHY_NEW_TAB_DONT_COPY_HISTORY); + + web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); + webkit_web_view_load_uri (web_view, back_uri); + gtk_widget_grab_focus (GTK_WIDGET (embed)); + return; + } +#else embed = ephy_shell_new_tab (ephy_shell_get_default (), EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))), embed, @@ -113,6 +136,8 @@ action_activate (GtkAction *action) EPHY_NEW_TAB_IN_EXISTING_WINDOW); web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); } +#endif + webkit_web_view_go_back (web_view); gtk_widget_grab_focus (GTK_WIDGET (embed)); } else if (history_action->priv->direction == EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD) { -- cgit v1.2.3