aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-12-17 03:22:41 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2013-03-12 05:14:24 +0800
commit628831d4ca65188f268ed933e3129ceca28702da (patch)
tree9c11842f05a4d67d5d51081141469c4d39ab8c7d /embed
parenta17d73e85e385a7168463ab2d10b73194708f081 (diff)
downloadgsoc2013-epiphany-628831d4ca65188f268ed933e3129ceca28702da.tar
gsoc2013-epiphany-628831d4ca65188f268ed933e3129ceca28702da.tar.gz
gsoc2013-epiphany-628831d4ca65188f268ed933e3129ceca28702da.tar.bz2
gsoc2013-epiphany-628831d4ca65188f268ed933e3129ceca28702da.tar.lz
gsoc2013-epiphany-628831d4ca65188f268ed933e3129ceca28702da.tar.xz
gsoc2013-epiphany-628831d4ca65188f268ed933e3129ceca28702da.tar.zst
gsoc2013-epiphany-628831d4ca65188f268ed933e3129ceca28702da.zip
Port to wk2 webview's snapshotting API
https://bugzilla.gnome.org/show_bug.cgi?id=695347
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-web-view.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index a5346b047..16e1d832b 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2032,26 +2032,70 @@ ephy_web_view_location_changed (EphyWebView *view,
g_object_thaw_notify (object);
}
-#ifndef HAVE_WEBKIT2
+#ifdef HAVE_WEBKIT2
+static void
+on_snapshot_ready (WebKitWebView *webview,
+ GAsyncResult *res,
+ GtkTreeRowReference *ref)
+{
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ cairo_surface_t *surface;
+ GError *error = NULL;
+
+ surface = webkit_web_view_get_snapshot_finish (webview, res, &error);
+ if (error) {
+ g_warning ("%s(): %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ return;
+ }
+
+ model = gtk_tree_row_reference_get_model (ref);
+ path = gtk_tree_row_reference_get_path (ref);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_path_free (path);
+
+ ephy_overview_store_set_snapshot (EPHY_OVERVIEW_STORE (model), &iter, surface);
+ cairo_surface_destroy (surface);
+}
+#endif
+
+/* FIXME: We should be using the snapshot service for this instead of
+ using the WK API directly. */
static gboolean
web_view_check_snapshot (WebKitWebView *web_view)
{
EphyOverviewStore *store;
GtkTreeIter iter;
+#ifdef HAVE_WEBKIT2
+ GtkTreeRowReference *ref;
+ GtkTreePath *path;
+#else
cairo_surface_t *surface;
+#endif
EphyEmbedShell *embed_shell = ephy_embed_shell_get_default ();
store = EPHY_OVERVIEW_STORE (ephy_embed_shell_get_frecent_store (embed_shell));
if (ephy_overview_store_find_url (store, webkit_web_view_get_uri (web_view), &iter) &&
ephy_overview_store_needs_snapshot (store, &iter)) {
+#ifdef HAVE_WEBKIT2
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
+ ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path);
+ gtk_tree_path_free (path);
+ webkit_web_view_get_snapshot (web_view, WEBKIT_SNAPSHOT_REGION_VISIBLE,
+ WEBKIT_SNAPSHOT_OPTIONS_NONE,
+ NULL, (GAsyncReadyCallback)on_snapshot_ready,
+ ref);
+#else
surface = webkit_web_view_get_snapshot (web_view);
ephy_overview_store_set_snapshot (store, &iter, surface);
cairo_surface_destroy (surface);
+#endif
}
return FALSE;
}
-#endif
#ifdef HAVE_WEBKIT2
static void
@@ -2158,6 +2202,12 @@ load_changed_cb (WebKitWebView *web_view,
/* Reset visit type. */
priv->visit_type = EPHY_PAGE_VISIT_NONE;
+ if (!ephy_web_view_is_history_frozen (view)) {
+ if (priv->snapshot_idle_id)
+ g_source_remove (priv->snapshot_idle_id);
+ priv->snapshot_idle_id = g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)web_view_check_snapshot, web_view, NULL);
+ }
+
break;
}