wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory() { wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist; WebKitWebBackForwardList* history; history = webkit_web_view_get_back_forward_list(m_web_view); GList* list = webkit_web_back_forward_list_get_forward_list_with_limit(history, m_historyLimit); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for(guint i = 0; i < g_list_length(list); i++) { WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i); wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem( webkit_web_history_item_get_uri(gtkitem), webkit_web_history_item_get_title(gtkitem)); wxitem->m_histItem = gtkitem; wxSharedPtr<wxWebViewHistoryItem> item(wxitem); forwardhist.push_back(item); } return forwardhist; }
static GtkWidget * build_menu (const GList *items, gboolean back) { GtkWidget *menu; const GList *iter; gint steps; if (! items) return NULL; menu = gtk_menu_new (); for (iter = items, steps = 1; iter; iter = g_list_next (iter), steps++) { WebKitWebHistoryItem *item = iter->data; const gchar *title; title = webkit_web_history_item_get_title (item); if (title) { GtkWidget *menu_item = gtk_menu_item_new_with_label (title); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); gtk_widget_show (menu_item); g_signal_connect (menu_item, "activate", G_CALLBACK (menu_callback), GINT_TO_POINTER (back ? - steps : steps)); } } return menu; }
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory() { wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist; WebKitWebBackForwardList* history; history = webkit_web_view_get_back_forward_list(m_web_view); GList* list = webkit_web_back_forward_list_get_back_list_with_limit(history, m_historyLimit); //We need to iterate in reverse to get the order we desire #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for(int i = g_list_length(list) - 1; i >= 0 ; i--) { WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i); wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem( webkit_web_history_item_get_uri(gtkitem), webkit_web_history_item_get_title(gtkitem)); wxitem->m_histItem = gtkitem; wxSharedPtr<wxWebViewHistoryItem> item(wxitem); backhist.push_back(item); } return backhist; }
/* session_save(const char *) {{{*/ gboolean session_save(const char *name, int flags) { if (!name) { if (s_session_name) name = s_session_name; else if (flags & SESSION_FORCE) name = "default"; } if (!s_has_marked && (flags & SESSION_FORCE) == 0) return false; GString *buffer = g_string_new(NULL); for (GList *l = g_list_first(dwb.state.views); l; l=l->next) { WebKitWebView *web = WEBVIEW(l); WebKitWebBackForwardList *bf_list = webkit_web_view_get_back_forward_list(web); if (VIEW(l)->status->deferred) { g_string_append_printf(buffer, "0|%d %s unknown\n", VIEW(l)->status->lockprotect, VIEW(l)->status->deferred_uri); continue; } for (int i= -webkit_web_back_forward_list_get_back_length(bf_list); i<=webkit_web_back_forward_list_get_forward_length(bf_list); i++) { WebKitWebHistoryItem *item = webkit_web_back_forward_list_get_nth_item(bf_list, i); if (item) { g_string_append_printf(buffer, "%d", i); if (i == 0) g_string_append_printf(buffer, "|%d", VIEW(l)->status->lockprotect); g_string_append_printf(buffer, " %s %s\n", webkit_web_history_item_get_uri(item), webkit_web_history_item_get_title(item)); } } } session_save_file(name, buffer->str, (flags & SESSION_SYNC) != 0); if (! (flags & SESSION_SYNC)) g_free(s_session_name); g_string_free(buffer, true); return true; }/*}}}*/
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory() { wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist; WebKitWebBackForwardList* history; history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view)); GList* list = webkit_web_back_forward_list_get_forward_list_with_limit(history, m_historyLimit); for(guint i = 0; i < g_list_length(list); i++) { WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i); wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem( webkit_web_history_item_get_uri(gtkitem), webkit_web_history_item_get_title(gtkitem)); wxitem->m_histItem = gtkitem; wxSharedPtr<wxWebViewHistoryItem> item(wxitem); forwardhist.push_back(item); } return forwardhist; }
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory() { wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist; WebKitWebBackForwardList* history; history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view)); GList* list = webkit_web_back_forward_list_get_back_list_with_limit(history, m_historyLimit); //We need to iterate in reverse to get the order we desire for(int i = g_list_length(list) - 1; i >= 0 ; i--) { WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i); wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem( webkit_web_history_item_get_uri(gtkitem), webkit_web_history_item_get_title(gtkitem)); wxitem->m_histItem = gtkitem; wxSharedPtr<wxWebViewHistoryItem> item(wxitem); backhist.push_back(item); } return backhist; }
static gint luaH_webview_push_history(lua_State *L, WebKitWebView *view) { /* obtain the history list of the tab and get information about it */ WebKitWebBackForwardList *bflist = webkit_web_back_forward_list_new_with_web_view(view); WebKitWebHistoryItem *item; gint backlen = webkit_web_back_forward_list_get_back_length(bflist); gint forwardlen = webkit_web_back_forward_list_get_forward_length(bflist); /* compose an overall table with the history list and the position thereof */ lua_createtable(L, 0, 2); /* Set hist[index] = pos */ lua_pushliteral(L, "index"); lua_pushnumber(L, backlen + 1); lua_rawset(L, -3); /* create a table with the history items */ lua_createtable(L, backlen + forwardlen + 1, 0); for(gint i = -backlen; i <= forwardlen; i++) { /* each individual history item is composed of a URL and a page title */ item = webkit_web_back_forward_list_get_nth_item(bflist, i); lua_createtable(L, 0, 2); /* Set hist_item[uri] = uri */ lua_pushliteral(L, "uri"); lua_pushstring(L, item ? webkit_web_history_item_get_uri(item) : "about:blank"); lua_rawset(L, -3); /* Set hist_item[title] = title */ lua_pushliteral(L, "title"); lua_pushstring(L, item ? webkit_web_history_item_get_title(item) : ""); lua_rawset(L, -3); lua_rawseti(L, -2, backlen + i + 1); } /* Set hist[items] = hist_items_table */ lua_pushliteral(L, "items"); lua_insert(L, lua_gettop(L) - 1); lua_rawset(L, -3); return 1; }
fixture->item = webkit_web_history_item_new_with_data("http://example.com/", "Example1"); g_assert_cmpint(G_OBJECT(fixture->item)->ref_count, == , 1); g_assert(fixture->item != NULL); } static void web_history_item_fixture_teardown(WebHistoryItemFixture* fixture, gconstpointer data) { g_assert(fixture->item != NULL); g_assert_cmpint(G_OBJECT(fixture->item)->ref_count, ==, 1); } static void test_webkit_web_history_item_get_data(WebHistoryItemFixture* fixture, gconstpointer data) { g_assert_cmpstr(webkit_web_history_item_get_title(fixture->item), ==, "Example1"); g_assert_cmpstr(webkit_web_history_item_get_uri(fixture->item), ==, "http://example.com/"); } static void test_webkit_web_history_item_alternate_title(WebHistoryItemFixture* fixture, gconstpointer data) { webkit_web_history_item_set_alternate_title(fixture->item, "Alternate title"); g_assert_cmpstr(webkit_web_history_item_get_alternate_title(fixture->item), ==, "Alternate title"); } int main(int argc, char** argv) { gtk_test_init(&argc, &argv, NULL); g_test_bug_base("https://bugs.webkit.org/");
void ephy_session_undo_close_tab (EphySession *session) { EphySessionPrivate *priv; EphyEmbed *embed, *new_tab; ClosedTab *tab; #ifndef HAVE_WEBKIT2 WebKitWebBackForwardList *dest; GList *i; #endif EphyNewTabFlags flags = EPHY_NEW_TAB_OPEN_PAGE | EPHY_NEW_TAB_PRESENT_WINDOW | EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_DONT_COPY_HISTORY; g_return_if_fail (EPHY_IS_SESSION (session)); priv = session->priv; tab = g_queue_pop_head (priv->closed_tabs); if (tab == NULL) return; LOG ("UNDO CLOSE TAB: %s", tab->url); if (*tab->parent_location != NULL) { GtkWidget *window; flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW; if (tab->position > 0) { /* Append in the n-th position. */ embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (*tab->parent_location), tab->position - 1)); flags |= EPHY_NEW_TAB_APPEND_AFTER; } else { /* Just prepend in the first position. */ embed = NULL; flags |= EPHY_NEW_TAB_FIRST; } window = gtk_widget_get_toplevel (GTK_WIDGET (*tab->parent_location)); new_tab = ephy_shell_new_tab (ephy_shell_get_default (), EPHY_WINDOW (window), embed, tab->url, flags); post_restore_cleanup (priv->closed_tabs, tab, FALSE); } else { EphyNotebook *notebook; flags |= EPHY_NEW_TAB_IN_NEW_WINDOW; new_tab = ephy_shell_new_tab (ephy_shell_get_default (), NULL, NULL, tab->url, flags); /* FIXME: This makes the assumption that the notebook is the parent of the returned EphyEmbed. */ notebook = EPHY_NOTEBOOK (gtk_widget_get_parent (GTK_WIDGET (new_tab))); *tab->parent_location = notebook; post_restore_cleanup (priv->closed_tabs, tab, TRUE); } /* This is deficient: we need to recreate the whole * BackForward list. Also, WebKit2 doesn't have this API. */ #ifndef HAVE_WEBKIT2 dest = webkit_web_view_get_back_forward_list (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_tab)); for (i = tab->bflist; i; i = i->next) { LOG ("ADDING TO BF: %s", webkit_web_history_item_get_title ((WebKitWebHistoryItem*) i->data)); webkit_web_back_forward_list_add_item (dest, webkit_web_history_item_copy ((WebKitWebHistoryItem*) i->data)); } #endif closed_tab_free (tab); if (g_queue_is_empty (priv->closed_tabs)) g_object_notify (G_OBJECT (session), "can-undo-tab-closed"); }