Bug 396649: Content viewers not evicted when going back. r+sr+a=bzbarsky
authorajschult@verizon.net
Thu, 27 Sep 2007 19:56:08 -0700
changeset 6388 8952cbb842073e439e6bda02912d1b41165a239b
parent 6387 dc9882ee754fe96335b69fbc6e97def71c55f16f
child 6389 145ad92b817656500404589193b40840b13c193b
push idunknown
push userunknown
push dateunknown
bugs396649
milestone1.9a9pre
Bug 396649: Content viewers not evicted when going back. r+sr+a=bzbarsky
docshell/shistory/src/nsSHistory.cpp
--- a/docshell/shistory/src/nsSHistory.cpp
+++ b/docshell/shistory/src/nsSHistory.cpp
@@ -761,17 +761,23 @@ nsSHistory::Reload(PRUint32 aReloadFlags
   return LoadEntry(mIndex, loadType, 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.
+  // "window" that now ends/begins at aToIndex.  Existing content viewers
+  // should be in the window from
+  // aFromIndex - gHistoryMaxViewers to aFromIndex + gHistoryMaxViewers
+  //
+  // We make the assumption that entries outside this range have no viewers so
+  // that we don't have to walk the whole entire session history checking for
+  // content viewers.
 
   // This can happen on the first load of a page in a particular window
   if (aFromIndex < 0 || aToIndex < 0) {
     return;
   }
 
   // These indices give the range of SHEntries whose content viewers will be
   // evicted
@@ -782,17 +788,17 @@ nsSHistory::EvictWindowContentViewers(PR
       return;
     }
     startIndex = PR_MAX(0, aFromIndex - gHistoryMaxViewers);
   } else { // going backward
     startIndex = aToIndex + gHistoryMaxViewers + 1;
     if (startIndex >= mLength) {
       return;
     }
-    endIndex = PR_MIN(mLength, aFromIndex + gHistoryMaxViewers);
+    endIndex = PR_MIN(mLength, aFromIndex + gHistoryMaxViewers + 1);
   }
   
   EvictContentViewersInRange(startIndex, endIndex);
 }
 
 void
 nsSHistory::EvictContentViewersInRange(PRInt32 aStart, PRInt32 aEnd)
 {