aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@gnome.org>2013-02-10 02:43:02 +0800
committerGustavo Noronha Silva <gns@gnome.org>2013-02-12 23:55:51 +0800
commitce7ab1e34804d9f7529bed13267f4619c37e32d9 (patch)
tree69f2a2e2dbce017980352b1afd57e1b38c8f278b /src
parent551eb0cec6469ece8e826411d65bf806ec043142 (diff)
downloadgsoc2013-epiphany-ce7ab1e34804d9f7529bed13267f4619c37e32d9.tar
gsoc2013-epiphany-ce7ab1e34804d9f7529bed13267f4619c37e32d9.tar.gz
gsoc2013-epiphany-ce7ab1e34804d9f7529bed13267f4619c37e32d9.tar.bz2
gsoc2013-epiphany-ce7ab1e34804d9f7529bed13267f4619c37e32d9.tar.lz
gsoc2013-epiphany-ce7ab1e34804d9f7529bed13267f4619c37e32d9.tar.xz
gsoc2013-epiphany-ce7ab1e34804d9f7529bed13267f4619c37e32d9.tar.zst
gsoc2013-epiphany-ce7ab1e34804d9f7529bed13267f4619c37e32d9.zip
Only load pages when their tab is switched to upon session restore
Firefox has led the way implementing this behaviour to improve the experience of restoring a session with lots of tabs. By delaying the loading of pages to when the user shows interest in them, the time it takes for the browser to become usable is diminished, and less pages are loaded in parallel, which improves load time for the first pages the user sees. It also has the advante of displaying less HTTP Basic Auth dialogs, when the user has many tabs pointed to the same server. https://bugzilla.gnome.org/show_bug.cgi?id=675302
Diffstat (limited to 'src')
-rw-r--r--src/ephy-notebook.c4
-rw-r--r--src/ephy-session.c23
-rw-r--r--src/ephy-shell.c9
-rw-r--r--src/ephy-shell.h3
4 files changed, 29 insertions, 10 deletions
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 2349af8f9..f9a9007c6 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -467,12 +467,14 @@ static void
sync_load_status (EphyWebView *view, GParamSpec *pspec, GtkWidget *proxy)
{
GtkWidget *spinner, *icon;
+ EphyEmbed *embed;
spinner = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "spinner"));
icon = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "icon"));
g_return_if_fail (spinner != NULL && icon != NULL);
- if (ephy_web_view_is_loading (view))
+ embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
+ if (ephy_web_view_is_loading (view) && !ephy_embed_has_load_pending (embed))
{
gtk_widget_hide (icon);
gtk_widget_show (spinner);
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 47dfe08bd..82ecf4149 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -631,7 +631,7 @@ session_tab_new (EphyEmbed *embed)
}
session_tab->title = g_strdup (ephy_web_view_get_title (web_view));
- session_tab->loading = ephy_web_view_is_loading (web_view);
+ session_tab->loading = ephy_web_view_is_loading (web_view) && !ephy_embed_has_load_pending (embed);
return session_tab;
}
@@ -1102,11 +1102,19 @@ session_parse_embed (SessionParserContext *context,
*/
if (!was_loading || is_blank_page)
{
- ephy_shell_new_tab (ephy_shell_get_default (),
- context->window, NULL, url,
- EPHY_NEW_TAB_IN_EXISTING_WINDOW |
- EPHY_NEW_TAB_OPEN_PAGE |
- EPHY_NEW_TAB_APPEND_LAST);
+ EphyNewTabFlags flags;
+ EphyEmbed *embed;
+ EphyWebView *web_view;
+
+ flags = EPHY_NEW_TAB_IN_EXISTING_WINDOW;
+ flags |= EPHY_NEW_TAB_APPEND_LAST;
+ flags |= EPHY_NEW_TAB_DELAYED_OPEN_PAGE;
+
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ context->window, NULL, url, flags);
+
+ web_view = ephy_embed_get_web_view (embed);
+ ephy_web_view_set_placeholder (web_view, url, title);
}
else if (was_loading && url != NULL)
{
@@ -1150,6 +1158,7 @@ session_end_element (GMarkupParseContext *ctx,
if (strcmp (element_name, "window") == 0)
{
GtkWidget *notebook;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
notebook = ephy_window_get_notebook (context->window);
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), context->active_tab);
@@ -1163,6 +1172,8 @@ session_end_element (GMarkupParseContext *ctx,
gtk_widget_show (GTK_WIDGET (context->window));
}
+ ephy_embed_shell_restored_window (shell);
+
context->window = NULL;
context->active_tab = 0;
context->is_first_window = FALSE;
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 7fd01d7de..ebdd48fd0 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -730,6 +730,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
gboolean fullscreen_lockdown = FALSE;
gboolean in_new_window = TRUE;
gboolean open_page = FALSE;
+ gboolean delayed_open_page = FALSE;
gboolean jump_to = FALSE;
gboolean active_is_blank = FALSE;
gboolean copy_history = TRUE;
@@ -748,6 +749,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
embed_shell = EPHY_EMBED_SHELL (shell);
if (flags & EPHY_NEW_TAB_OPEN_PAGE) open_page = TRUE;
+ if (flags & EPHY_NEW_TAB_DELAYED_OPEN_PAGE) delayed_open_page = TRUE;
if (flags & EPHY_NEW_TAB_IN_NEW_WINDOW) in_new_window = TRUE;
if (flags & EPHY_NEW_TAB_IN_EXISTING_WINDOW) in_new_window = FALSE;
if (flags & EPHY_NEW_TAB_DONT_COPY_HISTORY) copy_history = FALSE;
@@ -756,7 +758,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
fullscreen_lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
EPHY_PREFS_LOCKDOWN_FULLSCREEN);
in_new_window = in_new_window && !fullscreen_lockdown;
- g_return_val_if_fail (open_page == (gboolean)(request != NULL), NULL);
+ g_return_val_if_fail ((open_page || delayed_open_page) == (gboolean)(request != NULL), NULL);
LOG ("Opening new tab parent-window %p parent-embed %p in-new-window:%s jump-to:%s",
parent_window, previous_embed, in_new_window ? "t" : "f", jump_to ? "t" : "f");
@@ -822,7 +824,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
ephy_window_activate_location (window);
ephy_web_view_load_homepage (view);
is_empty = TRUE;
- } else if (flags & EPHY_NEW_TAB_OPEN_PAGE) {
+ } else if (open_page) {
ephy_web_view_load_request (ephy_embed_get_web_view (embed),
request);
@@ -831,7 +833,8 @@ ephy_shell_new_tab_full (EphyShell *shell,
#else
is_empty = ephy_embed_utils_url_is_empty (webkit_network_request_get_uri (request));
#endif
- }
+ } else if (delayed_open_page)
+ ephy_embed_set_delayed_load_request (embed, request);
/* Make sure the initial focus is somewhere sensible and not, for
* example, on the reload button.
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index f65083a7e..7b250fe26 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -59,6 +59,8 @@ typedef struct _EphyShellPrivate EphyShellPrivate;
* @EPHY_NEW_TAB_HOME_PAGE: loads the home page in the new tab.
* @EPHY_NEW_TAB_NEW_PAGE: legacy synonym for @EPHY_NEW_TAB_HOME_PAGE.
* @EPHY_NEW_TAB_OPEN_PAGE: opens the provided network-request.
+ * @EPHY_NEW_TAB_DELAYED_OPEN_PAGE: store the provided network-request
+ * so that it will be opened when the tab is switched to.
* @EPHY_NEW_TAB_FULLSCREEN_MODE: calls gtk_window_fullscreen on the
* parent window of the new tab.
* @EPHY_NEW_TAB_DONT_SHOW_WINDOW: do not show the window where the new
@@ -85,6 +87,7 @@ typedef enum {
EPHY_NEW_TAB_HOME_PAGE = 1 << 0,
EPHY_NEW_TAB_NEW_PAGE = 1 << 1,
EPHY_NEW_TAB_OPEN_PAGE = 1 << 2,
+ EPHY_NEW_TAB_DELAYED_OPEN_PAGE = 1 << 3,
/* Page mode */
EPHY_NEW_TAB_FULLSCREEN_MODE = 1 << 4,