Bug 1340828 - Part 2 - Make life easier for Fennec. r?mikedeboer draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 18 Feb 2017 22:50:58 +0100
changeset 494125 1d0234fe518e43d2b1ab0568e947c221f9c31113
parent 494124 4d8447db08455906935f08c84ebac046ec811357
child 494126 a8c82dc8825fd080038f76aa1e0f04118fe25378
push id47939
push usermozilla@buttercookie.de
push dateMon, 06 Mar 2017 18:09:38 +0000
reviewersmikedeboer
bugs1340828
milestone54.0a1
Bug 1340828 - Part 2 - Make life easier for Fennec. r?mikedeboer Life would easier if the restore function could return a reference to the session history object retrieved from the DocShell, so that Fennec's main session store code can use that to trigger the needed reload afterwards instead of having to retrieve it again independently. MozReview-Commit-ID: 1J5k4Evbc8Y
toolkit/modules/sessionstore/SessionHistory.jsm
--- a/toolkit/modules/sessionstore/SessionHistory.jsm
+++ b/toolkit/modules/sessionstore/SessionHistory.jsm
@@ -30,17 +30,17 @@ this.SessionHistory = Object.freeze({
     return SessionHistoryInternal.isEmpty(docShell);
   },
 
   collect(docShell, aFromIdx = -1) {
     return SessionHistoryInternal.collect(docShell, aFromIdx);
   },
 
   restore(docShell, tabData) {
-    SessionHistoryInternal.restore(docShell, tabData);
+    return SessionHistoryInternal.restore(docShell, tabData);
   }
 });
 
 /**
  * The internal API for the SessionHistory module.
  */
 var SessionHistoryInternal = {
   /**
@@ -270,16 +270,17 @@ var SessionHistoryInternal = {
 
   /**
    * Restores session history data for a given docShell.
    *
    * @param docShell
    *        The docShell that owns the session history.
    * @param tabData
    *        The tabdata including all history entries.
+   * @return A reference to the docShell's nsISHistoryInternal interface.
    */
   restore(docShell, tabData) {
     let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
     let history = webNavigation.sessionHistory;
     if (history.count > 0) {
       history.PurgeHistory(history.count);
     }
     history.QueryInterface(Ci.nsISHistoryInternal);
@@ -295,16 +296,17 @@ var SessionHistoryInternal = {
       history.addEntry(this.deserializeEntry(entry, idMap, docIdentMap), persist);
     }
 
     // Select the right history entry.
     let index = tabData.index - 1;
     if (index < history.count && history.index != index) {
       history.getEntryAtIndex(index, true);
     }
+    return history;
   },
 
   /**
    * Expands serialized history data into a session-history-entry instance.
    *
    * @param entry
    *        Object containing serialized history data for a URL
    * @param idMap