[epiphany/mcatanzaro/#1622] Fix loss of tab history if placeholder page is not removed




commit 5c47c41f73f392641a1ac313a1c9837d358b6d4d
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Wed Aug 31 15:21:26 2022 -0500

    Fix loss of tab history if placeholder page is not removed
    
    When starting Epiphany, we load an empty HTML document in all tabs
    except the currently-presented tab in order to start quickly and avoid
    excess memory usage. The real document is loaded later when the user
    clicks on the tab for the first time after starting the browser. But
    there's a problem with this strategy: if the user never clicks on the
    tab, then the placeholder document is still there when we quit, and we
    accidentally save the *placeholder* into the session state instead of
    the real state of the tab that was restored from the previous session.
    The most obvious impact of this is you lose the contents of the
    back/forward list.
    
    This fixes the issue by ensuring we check to see if delayed session
    state is available when saving the session. If so, the web view is
    displaying a placeholder document and we want to save the delayed state,
    not the placeholder state.
    
    Fixes #1622

 embed/ephy-embed.c | 8 ++++++++
 embed/ephy-embed.h | 2 ++
 src/ephy-session.c | 4 ++--
 3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 3d81f8783..ddc919fbb 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -1008,3 +1008,11 @@ ephy_embed_detach_notification_container (EphyEmbed *embed)
     gtk_container_remove (GTK_CONTAINER (embed->overlay), g_object_ref (GTK_WIDGET (container)));
   }
 }
+
+WebKitWebViewSessionState *
+ephy_embed_get_session_state (EphyEmbed *embed)
+{
+  if (embed->delayed_state)
+    return webkit_web_view_session_state_ref (embed->delayed_state);
+  return webkit_web_view_get_session_state (embed->web_view);
+}
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index 5004bffcd..c79f99b0d 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -56,5 +56,7 @@ void             ephy_embed_attach_notification_container (EphyEmbed *embed);
 void             ephy_embed_detach_notification_container (EphyEmbed *embed);
 void             ephy_embed_download_started              (EphyEmbed    *embed,
                                                            EphyDownload *ephy_download);
+WebKitWebViewSessionState
+                *ephy_embed_get_session_state             (EphyEmbed *embed);
 
 G_END_DECLS
diff --git a/src/ephy-session.c b/src/ephy-session.c
index e0a7e8b90..42486179d 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -219,7 +219,7 @@ closed_tab_new (EphyWebView    *web_view,
   tab->position = position;
   /* Takes the ownership of the tracker */
   tab->tab_view_tracker = tab_view_tracker;
-  tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));
+  tab->state = ephy_embed_get_session_state (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view));
 
   return tab;
 }
@@ -574,7 +574,7 @@ session_tab_new (EphyEmbed   *embed,
                           !session->closing);
   session_tab->crashed = (error_page == EPHY_WEB_VIEW_ERROR_PAGE_CRASH ||
                           error_page == EPHY_WEB_VIEW_ERROR_PROCESS_CRASH);
-  session_tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));
+  session_tab->state = ephy_embed_get_session_state (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view));
   session_tab->pinned = ephy_tab_view_get_is_pinned (tab_view, GTK_WIDGET (embed));
 
   return session_tab;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]