Bug 597315 Part 1 (session history) - Frameset history does not work properly when restoring a tab [r=bz, a=blocking2.0:betaN+]
authorOlli Pettay <Olli.Pettay@gmail.com>
Mon, 27 Dec 2010 16:22:46 -0500
changeset 59694 93a8fb0292bab50e6b1816ef49d531531e48131f
parent 59693 b7acaa08a9c5cf43831ce524e8d8c8337c3df7ca
child 59695 e736115286a855d64331db958f019b5203cf0cca
push idunknown
push userunknown
push dateunknown
reviewersbz, blocking2.0
bugs597315
milestone2.0b9pre
Bug 597315 Part 1 (session history) - Frameset history does not work properly when restoring a tab [r=bz, a=blocking2.0:betaN+]
docshell/shistory/public/nsISHistory.idl
docshell/shistory/src/nsSHistory.cpp
docshell/shistory/src/nsSHistory.h
--- a/docshell/shistory/public/nsISHistory.idl
+++ b/docshell/shistory/public/nsISHistory.idl
@@ -173,8 +173,14 @@ interface nsISHistory: nsISupports
    *
    * @see nsISimpleEnumerator
    * @see nsIHistoryEntry
    * @see QueryInterface()
    * @see do_QueryInterface()
    */
    readonly attribute nsISimpleEnumerator SHistoryEnumerator;
 };
+
+[scriptable, uuid(ac8b3eb3-2051-4cce-8303-d6e7938501dd)]
+interface nsISHistory_2_0_BRANCH: nsISHistory
+{
+  void reloadCurrentEntry();
+};
--- a/docshell/shistory/src/nsSHistory.cpp
+++ b/docshell/shistory/src/nsSHistory.cpp
@@ -148,16 +148,17 @@ nsSHistory::~nsSHistory()
 NS_IMPL_ADDREF(nsSHistory)
 NS_IMPL_RELEASE(nsSHistory)
 
 NS_INTERFACE_MAP_BEGIN(nsSHistory)
    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
    NS_INTERFACE_MAP_ENTRY(nsISHistory)
    NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
    NS_INTERFACE_MAP_ENTRY(nsISHistoryInternal)
+   NS_INTERFACE_MAP_ENTRY(nsISHistory_2_0_BRANCH)
 NS_INTERFACE_MAP_END
 
 //*****************************************************************************
 //    nsSHistory: nsISHistory
 //*****************************************************************************
 
 // static
 PRUint32
@@ -791,16 +792,35 @@ nsSHistory::Reload(PRUint32 aReloadFlags
     }
   }
   if (!canNavigate)
     return NS_OK;
 
   return LoadEntry(mIndex, loadType, HIST_CMD_RELOAD);
 }
 
+NS_IMETHODIMP
+nsSHistory::ReloadCurrentEntry()
+{
+  // Notify listeners
+  PRBool canNavigate = PR_TRUE;
+  if (mListener) {
+    nsCOMPtr<nsISHistoryListener> listener(do_QueryReferent(mListener));
+    if (listener) {
+      nsCOMPtr<nsIURI> currentURI;
+      GetCurrentURI(getter_AddRefs(currentURI));
+      listener->OnHistoryGotoIndex(mIndex, currentURI, &canNavigate);
+    }
+  }
+  if (!canNavigate)
+    return NS_OK;
+
+  return LoadEntry(mIndex, nsIDocShellLoadInfo::loadHistory, HIST_CMD_RELOAD);
+}
+
 void
 nsSHistory::EvictWindowContentViewers(PRInt32 aFromIndex, PRInt32 aToIndex)
 {
   // To enforce the per SHistory object limit on cached content viewers, we
   // need to release all of the content viewers that are no longer in the
   // "window" that now ends/begins at aToIndex.  Existing content viewers
   // should be in the window from
   // aFromIndex - gHistoryMaxViewers to aFromIndex + gHistoryMaxViewers
--- a/docshell/shistory/src/nsSHistory.h
+++ b/docshell/shistory/src/nsSHistory.h
@@ -57,27 +57,28 @@
 
 // Needed to maintain global list of all SHistory objects
 #include "prclist.h"
 
 class nsIDocShell;
 class nsSHEnumerator;
 class nsSHistoryObserver;
 class nsSHistory: public PRCList,
-                  public nsISHistory,
+                  public nsISHistory_2_0_BRANCH,
                   public nsISHistoryInternal,
                   public nsIWebNavigation
 {
 public:
   nsSHistory();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHISTORY
   NS_DECL_NSISHISTORYINTERNAL
   NS_DECL_NSIWEBNAVIGATION
+  NS_DECL_NSISHISTORY_2_0_BRANCH
 
   // One time initialization method called upon docshell module construction
   static nsresult Startup();
   static void UpdatePrefs(nsIPrefBranch *aPrefBranch);
 
   // Max number of total cached content viewers.  If the pref
   // browser.sessionhistory.max_total_viewers is negative, then
   // this value is calculated based on the total amount of memory.