diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 7c8a9759245d..07bd00b390d8 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -322,8 +322,8 @@ nsDocShell::nsDocShell() , mMarginWidth(-1) , mMarginHeight(-1) , mItemType(typeContent) - , mPreviousTransIndex(-1) - , mLoadedTransIndex(-1) + , mPreviousEntryIndex(-1) + , mLoadedEntryIndex(-1) , mChildOffset(0) , mSandboxFlags(0) , mBusyFlags(BUSY_FLAGS_NONE) @@ -2286,16 +2286,16 @@ nsDocShell::SetUseErrorPages(bool aUseErrorPages) } NS_IMETHODIMP -nsDocShell::GetPreviousTransIndex(int32_t* aPreviousTransIndex) +nsDocShell::GetPreviousEntryIndex(int32_t* aPreviousEntryIndex) { - *aPreviousTransIndex = mPreviousTransIndex; + *aPreviousEntryIndex = mPreviousEntryIndex; return NS_OK; } NS_IMETHODIMP -nsDocShell::GetLoadedTransIndex(int32_t* aLoadedTransIndex) +nsDocShell::GetLoadedEntryIndex(int32_t* aLoadedEntryIndex) { - *aLoadedTransIndex = mLoadedTransIndex; + *aLoadedEntryIndex = mLoadedEntryIndex; return NS_OK; } @@ -2307,8 +2307,8 @@ nsDocShell::HistoryPurged(int32_t aNumEntries) // eviction. We need to adjust by the number of entries that we // just purged from history, so that we look at the right session history // entries during eviction. - mPreviousTransIndex = std::max(-1, mPreviousTransIndex - aNumEntries); - mLoadedTransIndex = std::max(0, mLoadedTransIndex - aNumEntries); + mPreviousEntryIndex = std::max(-1, mPreviousEntryIndex - aNumEntries); + mLoadedEntryIndex = std::max(0, mLoadedEntryIndex - aNumEntries); nsTObserverArray::ForwardIterator iter(mChildList); while (iter.HasMore()) { @@ -2322,29 +2322,29 @@ nsDocShell::HistoryPurged(int32_t aNumEntries) } nsresult -nsDocShell::HistoryTransactionRemoved(int32_t aIndex) +nsDocShell::HistoryEntryRemoved(int32_t aIndex) { // These indices are used for fastback cache eviction, to determine // which session history entries are candidates for content viewer // eviction. We need to adjust by the number of entries that we // just purged from history, so that we look at the right session history // entries during eviction. - if (aIndex == mPreviousTransIndex) { - mPreviousTransIndex = -1; - } else if (aIndex < mPreviousTransIndex) { - --mPreviousTransIndex; + if (aIndex == mPreviousEntryIndex) { + mPreviousEntryIndex = -1; + } else if (aIndex < mPreviousEntryIndex) { + --mPreviousEntryIndex; } - if (mLoadedTransIndex == aIndex) { - mLoadedTransIndex = 0; - } else if (aIndex < mLoadedTransIndex) { - --mLoadedTransIndex; + if (mLoadedEntryIndex == aIndex) { + mLoadedEntryIndex = 0; + } else if (aIndex < mLoadedEntryIndex) { + --mLoadedEntryIndex; } nsTObserverArray::ForwardIterator iter(mChildList); while (iter.HasMore()) { nsCOMPtr shell = do_QueryObject(iter.GetNext()); if (shell) { - static_cast(shell.get())->HistoryTransactionRemoved(aIndex); + static_cast(shell.get())->HistoryEntryRemoved(aIndex); } } @@ -3866,7 +3866,7 @@ nsDocShell::AddChildSHEntryToParent(nsISHEntry* aNewEntry, int32_t aChildOffset, // current index by 1 RefPtr rootSH = GetRootSessionHistory(); if (rootSH) { - mPreviousTransIndex = rootSH->Index(); + mPreviousEntryIndex = rootSH->Index(); } nsresult rv; @@ -3877,10 +3877,10 @@ nsDocShell::AddChildSHEntryToParent(nsISHEntry* aNewEntry, int32_t aChildOffset, } if (rootSH) { - mLoadedTransIndex = rootSH->Index(); + mLoadedEntryIndex = rootSH->Index(); #ifdef DEBUG_PAGE_CACHE - printf("Previous index: %d, Loaded index: %d\n\n", mPreviousTransIndex, - mLoadedTransIndex); + printf("Previous index: %d, Loaded index: %d\n\n", mPreviousEntryIndex, + mLoadedEntryIndex); #endif } @@ -8120,12 +8120,12 @@ nsDocShell::RestoreFromHistory() mURIResultedInDocument = true; RefPtr rootSH = GetRootSessionHistory(); if (rootSH) { - mPreviousTransIndex = rootSH->Index(); + mPreviousEntryIndex = rootSH->Index(); rootSH->LegacySHistory()->UpdateIndex(); - mLoadedTransIndex = rootSH->Index(); + mLoadedEntryIndex = rootSH->Index(); #ifdef DEBUG_PAGE_CACHE - printf("Previous index: %d, Loaded index: %d\n\n", mPreviousTransIndex, - mLoadedTransIndex); + printf("Previous index: %d, Loaded index: %d\n\n", mPreviousEntryIndex, + mLoadedEntryIndex); #endif } @@ -11607,12 +11607,12 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel, if (rootSH && ((mLoadType & (LOAD_CMD_HISTORY | LOAD_CMD_RELOAD)) || mLoadType == LOAD_NORMAL_REPLACE)) { - mPreviousTransIndex = rootSH->Index(); + mPreviousEntryIndex = rootSH->Index(); rootSH->LegacySHistory()->UpdateIndex(); - mLoadedTransIndex = rootSH->Index(); + mLoadedEntryIndex = rootSH->Index(); #ifdef DEBUG_PAGE_CACHE printf("Previous index: %d, Loaded index: %d\n\n", - mPreviousTransIndex, mLoadedTransIndex); + mPreviousEntryIndex, mLoadedEntryIndex); #endif } @@ -12254,14 +12254,14 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel, if (addToSHistory) { // Add to session history - mPreviousTransIndex = mSessionHistory->Index(); + mPreviousEntryIndex = mSessionHistory->Index(); bool shouldPersist = ShouldAddToSessionHistory(aURI, aChannel); rv = mSessionHistory->LegacySHistory()->AddEntry(entry, shouldPersist); - mLoadedTransIndex = mSessionHistory->Index(); + mLoadedEntryIndex = mSessionHistory->Index(); #ifdef DEBUG_PAGE_CACHE printf("Previous index: %d, Loaded index: %d\n\n", - mPreviousTransIndex, mLoadedTransIndex); + mPreviousEntryIndex, mLoadedEntryIndex); #endif } } else { diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 80358953cc9d..a766e7b95542 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -254,7 +254,7 @@ public: LOCATION_CHANGE_SAME_DOCUMENT); } - nsresult HistoryTransactionRemoved(int32_t aIndex); + nsresult HistoryEntryRemoved(int32_t aIndex); // Notify Scroll observers when an async panning/zooming transform // has started being applied @@ -1031,11 +1031,11 @@ private: // data members // Create() is called, the type is not expected to change. int32_t mItemType; - // Index into the SHTransaction list, indicating the previous and current - // transaction at the time that this DocShell begins to load. Consequently + // Index into the nsISHEntry array, indicating the previous and current + // entry at the time that this DocShell begins to load. Consequently // root docshell's indices can differ from child docshells'. - int32_t mPreviousTransIndex; - int32_t mLoadedTransIndex; + int32_t mPreviousEntryIndex; + int32_t mLoadedEntryIndex; // Offset in the parent's child list. // -1 if the docshell is added dynamically to the parent shell. diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index bd9d1bb97ba6..01802fbaff8d 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -539,12 +539,12 @@ interface nsIDocShell : nsIDocShellTreeItem readonly attribute nsIChannel failedChannel; /** - * Keeps track of the previous SHTransaction index and the current - * SHTransaction index at the time that the doc shell begins to load. + * Keeps track of the previous nsISHEntry index and the current + * nsISHEntry index at the time that the doc shell begins to load. * Used for ContentViewer eviction. */ - readonly attribute long previousTransIndex; - readonly attribute long loadedTransIndex; + readonly attribute long previousEntryIndex; + readonly attribute long loadedEntryIndex; /** * Notification that entries have been removed from the beginning of a diff --git a/docshell/shistory/nsISHEntry.idl b/docshell/shistory/nsISHEntry.idl index e829900569fa..b7b769b08666 100644 --- a/docshell/shistory/nsISHEntry.idl +++ b/docshell/shistory/nsISHEntry.idl @@ -402,7 +402,7 @@ interface nsISHEntry : nsISupports void ReplaceChild(in nsISHEntry aNewChild); /** - * When an entry is serving as a transaction within nsISHistory, this + * When an entry is serving is within nsISHistory's array of entries, this * property specifies if it should persist. If not it will be replaced by * new additions to the list. */ diff --git a/docshell/shistory/nsISHistory.idl b/docshell/shistory/nsISHistory.idl index 0485cc9bbcc0..6876036b9887 100644 --- a/docshell/shistory/nsISHistory.idl +++ b/docshell/shistory/nsISHistory.idl @@ -68,14 +68,11 @@ interface nsISHistory: nsISupports attribute long maxLength; /** - * Get the history entry at a given index. + * Get the history entry at a given index. Returns non-null on success. * * @param index The index value whose entry is requested. * The oldest entry is located at index == 0. - * @return NS_OK history entry for - * the index is obtained successfully. - * NS_ERROR_FAILURE Error in obtaining - * history entry for the given index. + * @return The found entry; never null. */ nsISHEntry getEntryAtIndex(in long aIndex); @@ -151,11 +148,6 @@ interface nsISHistory: nsISupports */ void addEntry(in nsISHEntry aEntry, in boolean aPersist); - /** - * Get the transaction at a particular index. Returns non-null on success. - */ - nsISHEntry GetTransactionAtIndex(in int32_t aIndex); - /** * Sets the toplevel docshell object to which this SHistory object belongs to. */ diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index e3876164f3c2..e7057afde170 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -184,11 +184,11 @@ nsSHistoryObserver::Observe(nsISupports* aSubject, const char* aTopic, namespace { already_AddRefed -GetContentViewerForTransaction(nsISHEntry* aTrans) +GetContentViewerForEntry(nsISHEntry* aEntry) { nsCOMPtr ownerEntry; nsCOMPtr viewer; - aTrans->GetAnyContentViewer(getter_AddRefs(ownerEntry), + aEntry->GetAnyContentViewer(getter_AddRefs(ownerEntry), getter_AddRefs(viewer)); return viewer.forget(); } @@ -196,11 +196,11 @@ GetContentViewerForTransaction(nsISHEntry* aTrans) } // namespace void -nsSHistory::EvictContentViewerForTransaction(nsISHEntry* aTrans) +nsSHistory::EvictContentViewerForEntry(nsISHEntry* aEntry) { nsCOMPtr viewer; nsCOMPtr ownerEntry; - aTrans->GetAnyContentViewer(getter_AddRefs(ownerEntry), + aEntry->GetAnyContentViewer(getter_AddRefs(ownerEntry), getter_AddRefs(viewer)); if (viewer) { NS_ASSERTION(ownerEntry, "Content viewer exists but its SHEntry is null"); @@ -219,9 +219,9 @@ nsSHistory::EvictContentViewerForTransaction(nsISHEntry* aTrans) // When dropping bfcache, we have to remove associated dynamic entries as well. int32_t index = -1; - GetIndexOfEntry(aTrans, &index); + GetIndexOfEntry(aEntry, &index); if (index != -1) { - RemoveDynEntries(index, aTrans); + RemoveDynEntries(index, aEntry); } } @@ -609,7 +609,7 @@ nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist) nsCOMPtr currentTxn; if (mIndex >= 0) { - nsresult rv = GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn)); + nsresult rv = GetEntryAtIndex(mIndex, getter_AddRefs(currentTxn)); NS_ENSURE_SUCCESS(rv, rv); } @@ -625,7 +625,7 @@ nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist) if (currentTxn && !currentTxn->GetPersist()) { NOTIFY_LISTENERS(OnHistoryReplaceEntry, (mIndex)); aSHEntry->SetPersist(aPersist); - mTransactions[mIndex] = aSHEntry; + mEntries[mIndex] = aSHEntry; return NS_OK; } @@ -633,12 +633,12 @@ nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist) aSHEntry->GetURI(getter_AddRefs(uri)); NOTIFY_LISTENERS(OnHistoryNewEntry, (uri, mIndex)); - // Remove all transactions after the current one, add the new one, and set - // the new one as the current one. + // Remove all entries after the current one, add the new one, and set the new + // one as the current one. MOZ_ASSERT(mIndex >= -1); aSHEntry->SetPersist(aPersist); - mTransactions.TruncateLength(mIndex + 1); - mTransactions.AppendElement(aSHEntry); + mEntries.TruncateLength(mIndex + 1); + mEntries.AppendElement(aSHEntry); mIndex++; NOTIFY_LISTENERS(OnLengthChanged, (Length())); @@ -693,13 +693,6 @@ nsSHistory::GetRequestedIndex(int32_t* aResult) NS_IMETHODIMP nsSHistory::GetEntryAtIndex(int32_t aIndex, nsISHEntry** aResult) -{ - return GetTransactionAtIndex(aIndex, aResult); -} - -/* Get the transaction at a given index */ -NS_IMETHODIMP -nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHEntry** aResult) { NS_ENSURE_ARG_POINTER(aResult); @@ -707,7 +700,7 @@ nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHEntry** aResult) return NS_ERROR_FAILURE; } - *aResult = mTransactions[aIndex]; + *aResult = mEntries[aIndex]; NS_ADDREF(*aResult); return NS_OK; } @@ -721,7 +714,7 @@ nsSHistory::GetIndexOfEntry(nsISHEntry* aSHEntry, int32_t* aResult) *aResult = -1; for (int32_t i = 0; i < Length(); i++) { - if (aSHEntry == mTransactions[i]) { + if (aSHEntry == mEntries[i]) { *aResult = i; return NS_OK; } @@ -735,7 +728,7 @@ nsresult nsSHistory::PrintHistory() { for (int32_t i = 0; i < Length(); i++) { - nsCOMPtr entry = mTransactions[i]; + nsCOMPtr entry = mEntries[i]; nsCOMPtr layoutHistoryState; nsCOMPtr uri; nsString title; @@ -750,7 +743,7 @@ nsSHistory::PrintHistory() uri->GetSpec(url); } - printf("**** SH Transaction #%d, Entry = %x\n", i, entry.get()); + printf("**** SH Entry #%d: %x\n", i, entry.get()); printf("\t\t URL = %s\n", url.get()); printf("\t\t Title = %s\n", NS_LossyConvertUTF16toASCII(title).get()); @@ -813,7 +806,7 @@ nsSHistory::PurgeHistory(int32_t aNumEntries) } // Remove the first `aNumEntries` entries. - mTransactions.RemoveElementsAt(0, aNumEntries); + mEntries.RemoveElementsAt(0, aNumEntries); // Adjust the indices, but don't let them go below -1. mIndex -= aNumEntries; @@ -884,7 +877,7 @@ nsSHistory::ReplaceEntry(int32_t aIndex, nsISHEntry* aReplaceEntry) NOTIFY_LISTENERS(OnHistoryReplaceEntry, (aIndex)); aReplaceEntry->SetPersist(true); - mTransactions[aIndex] = aReplaceEntry; + mEntries[aIndex] = aReplaceEntry; return NS_OK; } @@ -914,7 +907,7 @@ nsSHistory::EvictAllContentViewers() // XXXbz we don't actually do a good job of evicting things as we should, so // we might have viewers quite far from mIndex. So just evict everything. for (int32_t i = 0; i < Length(); i++) { - EvictContentViewerForTransaction(mTransactions[i]); + EvictContentViewerForEntry(mEntries[i]); } return NS_OK; @@ -982,11 +975,11 @@ nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex) // // to ensure that this SHistory object isn't responsible for more than // VIEWER_WINDOW content viewers. But our job is complicated by the - // fact that two transactions which are related by either hash navigations or + // fact that two entries which are related by either hash navigations or // history.pushState will have the same content viewer. // // To illustrate the issue, suppose VIEWER_WINDOW = 3 and we have four - // linked transactions in our history. Suppose we then add a new content + // linked entries in our history. Suppose we then add a new content // viewer and call into this function. So the history looks like: // // A A A A B @@ -1027,8 +1020,7 @@ nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex) // if it appears outside this range. nsCOMArray safeViewers; for (int32_t i = startSafeIndex; i <= endSafeIndex; i++) { - nsCOMPtr viewer = - GetContentViewerForTransaction(mTransactions[i]); + nsCOMPtr viewer = GetContentViewerForEntry(mEntries[i]); safeViewers.AppendObject(viewer); } @@ -1036,32 +1028,32 @@ nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex) // (It's important that the condition checks Length(), rather than a cached // copy of Length(), because the length might change between iterations.) for (int32_t i = 0; i < Length(); i++) { - nsCOMPtr trans = mTransactions[i]; - nsCOMPtr viewer = GetContentViewerForTransaction(trans); + nsCOMPtr entry = mEntries[i]; + nsCOMPtr viewer = GetContentViewerForEntry(entry); if (safeViewers.IndexOf(viewer) == -1) { - EvictContentViewerForTransaction(trans); + EvictContentViewerForEntry(entry); } } } namespace { -class TransactionAndDistance +class EntryAndDistance { public: - TransactionAndDistance(nsSHistory* aSHistory, nsISHEntry* aTrans, uint32_t aDist) + EntryAndDistance(nsSHistory* aSHistory, nsISHEntry* aEntry, uint32_t aDist) : mSHistory(aSHistory) - , mTransaction(aTrans) + , mEntry(aEntry) , mLastTouched(0) , mDistance(aDist) { - mViewer = GetContentViewerForTransaction(aTrans); - NS_ASSERTION(mViewer, "Transaction should have a content viewer"); + mViewer = GetContentViewerForEntry(aEntry); + NS_ASSERTION(mViewer, "Entry should have a content viewer"); - mTransaction->GetLastTouched(&mLastTouched); + mEntry->GetLastTouched(&mLastTouched); } - bool operator<(const TransactionAndDistance& aOther) const + bool operator<(const EntryAndDistance& aOther) const { // Compare distances first, and fall back to last-accessed times. if (aOther.mDistance != this->mDistance) { @@ -1071,17 +1063,17 @@ public: return this->mLastTouched < aOther.mLastTouched; } - bool operator==(const TransactionAndDistance& aOther) const + bool operator==(const EntryAndDistance& aOther) const { // This is a little silly; we need == so the default comaprator can be // instantiated, but this function is never actually called when we sort - // the list of TransactionAndDistance objects. + // the list of EntryAndDistance objects. return aOther.mDistance == this->mDistance && aOther.mLastTouched == this->mLastTouched; } RefPtr mSHistory; - nsCOMPtr mTransaction; + nsCOMPtr mEntry; nsCOMPtr mViewer; uint32_t mLastTouched; int32_t mDistance; @@ -1093,18 +1085,18 @@ public: void nsSHistory::GloballyEvictContentViewers() { - // First, collect from each SHistory object the transactions which have a - // cached content viewer. Associate with each transaction its distance from - // its SHistory's current index. + // First, collect from each SHistory object the entries which have a cached + // content viewer. Associate with each entry its distance from its SHistory's + // current index. - nsTArray transactions; + nsTArray entries; for (auto shist : gSHistoryList) { - // Maintain a list of the transactions which have viewers and belong to + // Maintain a list of the entries which have viewers and belong to // this particular shist object. We'll add this list to the global list, - // |transactions|, eventually. - nsTArray shTransactions; + // |entries|, eventually. + nsTArray shEntries; // Content viewers are likely to exist only within shist->mIndex -/+ // VIEWER_WINDOW, so only search within that range. @@ -1122,18 +1114,18 @@ nsSHistory::GloballyEvictContentViewers() int32_t startIndex, endIndex; shist->WindowIndices(shist->mIndex, &startIndex, &endIndex); for (int32_t i = startIndex; i <= endIndex; i++) { - nsCOMPtr trans = shist->mTransactions[i]; + nsCOMPtr entry = shist->mEntries[i]; nsCOMPtr contentViewer = - GetContentViewerForTransaction(trans); + GetContentViewerForEntry(entry); if (contentViewer) { // Because one content viewer might belong to multiple SHEntries, we - // have to search through shTransactions to see if we already know + // have to search through shEntries to see if we already know // about this content viewer. If we find the viewer, update its // distance from the SHistory's index and continue. bool found = false; - for (uint32_t j = 0; j < shTransactions.Length(); j++) { - TransactionAndDistance& container = shTransactions[j]; + for (uint32_t j = 0; j < shEntries.Length(); j++) { + EntryAndDistance& container = shEntries[j]; if (container.mViewer == contentViewer) { container.mDistance = std::min(container.mDistance, DeprecatedAbs(i - shist->mIndex)); @@ -1142,44 +1134,43 @@ nsSHistory::GloballyEvictContentViewers() } } - // If we didn't find a TransactionAndDistance for this content viewer, - // make a new one. + // If we didn't find a EntryAndDistance for this content viewer, make a + // new one. if (!found) { - TransactionAndDistance container(shist, trans, - DeprecatedAbs(i - shist->mIndex)); - shTransactions.AppendElement(container); + EntryAndDistance container(shist, entry, + DeprecatedAbs(i - shist->mIndex)); + shEntries.AppendElement(container); } } } - // We've found all the transactions belonging to shist which have viewers. - // Add those transactions to our global list and move on. - transactions.AppendElements(shTransactions); + // We've found all the entries belonging to shist which have viewers. + // Add those entries to our global list and move on. + entries.AppendElements(shEntries); } // We now have collected all cached content viewers. First check that we // have enough that we actually need to evict some. - if ((int32_t)transactions.Length() <= sHistoryMaxTotalViewers) { + if ((int32_t)entries.Length() <= sHistoryMaxTotalViewers) { return; } - // If we need to evict, sort our list of transactions and evict the largest + // If we need to evict, sort our list of entries and evict the largest // ones. (We could of course get better algorithmic complexity here by using // a heap or something more clever. But sHistoryMaxTotalViewers isn't large, // so let's not worry about it.) - transactions.Sort(); + entries.Sort(); - for (int32_t i = transactions.Length() - 1; i >= sHistoryMaxTotalViewers; + for (int32_t i = entries.Length() - 1; i >= sHistoryMaxTotalViewers; --i) { - (transactions[i].mSHistory)-> - EvictContentViewerForTransaction(transactions[i].mTransaction); + (entries[i].mSHistory)->EvictContentViewerForEntry(entries[i].mEntry); } } nsresult -nsSHistory::FindTransactionForBFCache(nsIBFCacheEntry* aEntry, - nsISHEntry** aResult, - int32_t* aResultIndex) +nsSHistory::FindEntryForBFCache(nsIBFCacheEntry* aBFEntry, + nsISHEntry** aResult, + int32_t* aResultIndex) { *aResult = nullptr; *aResultIndex = -1; @@ -1188,11 +1179,11 @@ nsSHistory::FindTransactionForBFCache(nsIBFCacheEntry* aEntry, WindowIndices(mIndex, &startIndex, &endIndex); for (int32_t i = startIndex; i <= endIndex; ++i) { - nsCOMPtr trans = mTransactions[i]; + nsCOMPtr shEntry = mEntries[i]; - // Does entry have the same BFCacheEntry as the argument to this method? - if (trans->HasBFCacheEntry(aEntry)) { - trans.forget(aResult); + // Does shEntry have the same BFCacheEntry as the argument to this method? + if (shEntry->HasBFCacheEntry(aBFEntry)) { + shEntry.forget(aResult); *aResultIndex = i; return NS_OK; } @@ -1201,28 +1192,28 @@ nsSHistory::FindTransactionForBFCache(nsIBFCacheEntry* aEntry, } nsresult -nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry* aEntry) +nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry* aBFEntry) { int32_t index; - nsCOMPtr trans; - FindTransactionForBFCache(aEntry, getter_AddRefs(trans), &index); + nsCOMPtr shEntry; + FindEntryForBFCache(aBFEntry, getter_AddRefs(shEntry), &index); if (index == mIndex) { NS_WARNING("How did the current SHEntry expire?"); return NS_OK; } - if (trans) { - EvictContentViewerForTransaction(trans); + if (shEntry) { + EvictContentViewerForEntry(shEntry); } return NS_OK; } NS_IMETHODIMP -nsSHistory::AddToExpirationTracker(nsIBFCacheEntry* aEntry) +nsSHistory::AddToExpirationTracker(nsIBFCacheEntry* aBFEntry) { - RefPtr entry = static_cast(aEntry); + RefPtr entry = static_cast(aBFEntry); if (!mHistoryTracker || !entry) { return NS_ERROR_FAILURE; } @@ -1232,9 +1223,9 @@ nsSHistory::AddToExpirationTracker(nsIBFCacheEntry* aEntry) } NS_IMETHODIMP -nsSHistory::RemoveFromExpirationTracker(nsIBFCacheEntry* aEntry) +nsSHistory::RemoveFromExpirationTracker(nsIBFCacheEntry* aBFEntry) { - RefPtr entry = static_cast(aEntry); + RefPtr entry = static_cast(aBFEntry); MOZ_ASSERT(mHistoryTracker && !mHistoryTracker->IsEmpty()); if (!mHistoryTracker || !entry) { return NS_ERROR_FAILURE; @@ -1368,19 +1359,19 @@ nsSHistory::RemoveDuplicate(int32_t aIndex, bool aKeepNext) NS_ENSURE_SUCCESS(rv, false); if (IsSameTree(root1, root2)) { - mTransactions.RemoveElementAt(aIndex); + mEntries.RemoveElementAt(aIndex); if (mRootDocShell) { - static_cast(mRootDocShell)->HistoryTransactionRemoved(aIndex); + static_cast(mRootDocShell)->HistoryEntryRemoved(aIndex); } - // Adjust our indices to reflect the removed transaction + // Adjust our indices to reflect the removed entry. if (mIndex > aIndex) { mIndex = mIndex - 1; NOTIFY_LISTENERS(OnIndexChanged, (mIndex)); } - // NB: If the transaction we are removing is the transaction currently + // NB: If the entry we are removing is the entry currently // being navigated to (mRequestedIndex) then we adjust the index // only if we're not keeping the next entry (because if we are keeping // the next entry (because the current is a duplicate of the next), then @@ -1444,13 +1435,13 @@ nsSHistory::RemoveDynEntries(int32_t aIndex, nsISHEntry* aEntry) } void -nsSHistory::RemoveDynEntriesForBFCacheEntry(nsIBFCacheEntry* aEntry) +nsSHistory::RemoveDynEntriesForBFCacheEntry(nsIBFCacheEntry* aBFEntry) { int32_t index; - nsCOMPtr trans; - FindTransactionForBFCache(aEntry, getter_AddRefs(trans), &index); - if (trans) { - RemoveDynEntries(index, trans); + nsCOMPtr shEntry; + FindEntryForBFCache(aBFEntry, getter_AddRefs(shEntry), &index); + if (shEntry) { + RemoveDynEntries(index, shEntry); } } diff --git a/docshell/shistory/nsSHistory.h b/docshell/shistory/nsSHistory.h index 85eaad2b094f..1875515e3dc6 100644 --- a/docshell/shistory/nsSHistory.h +++ b/docshell/shistory/nsSHistory.h @@ -143,16 +143,16 @@ private: nsresult PrintHistory(); #endif - // Find the transaction for a given bfcache entry. It only looks up between + // Find the history entry for a given bfcache entry. It only looks up between // the range where alive viewers may exist (i.e nsISHistory::VIEWER_WINDOW). - nsresult FindTransactionForBFCache(nsIBFCacheEntry* aEntry, - nsISHEntry** aResult, - int32_t* aResultIndex); + nsresult FindEntryForBFCache(nsIBFCacheEntry* aBFEntry, + nsISHEntry** aResult, + int32_t* aResultIndex); // Evict content viewers in this window which don't lie in the "safe" range // around aIndex. void EvictOutOfRangeWindowContentViewers(int32_t aIndex); - void EvictContentViewerForTransaction(nsISHEntry* aTrans); + void EvictContentViewerForEntry(nsISHEntry* aEntry); static void GloballyEvictContentViewers(); static void GloballyEvictAllContentViewers(); @@ -163,7 +163,7 @@ private: nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType, uint32_t aHistCmd); - // aIndex is the index of the transaction which may be removed. + // aIndex is the index of the entry which may be removed. // If aKeepNext is true, aIndex is compared to aIndex + 1, // otherwise comparison is done to aIndex - 1. bool RemoveDuplicate(int32_t aIndex, bool aKeepNext); @@ -171,15 +171,15 @@ private: // Track all bfcache entries and evict on expiration. mozilla::UniquePtr mHistoryTracker; - nsTArray> mTransactions; // entries are never null + nsTArray> mEntries; // entries are never null int32_t mIndex; // -1 means "no index" int32_t mRequestedIndex; // -1 means "no requested index" void WindowIndices(int32_t aIndex, int32_t* aOutStartIndex, int32_t* aOutEndIndex); - // Length of mTransactions. - int32_t Length() { return int32_t(mTransactions.Length()); } + // Length of mEntries. + int32_t Length() { return int32_t(mEntries.Length()); } // Session History listeners nsAutoTObserverArray mListeners; diff --git a/docshell/test/navigation/file_bug1326251.html b/docshell/test/navigation/file_bug1326251.html index 92801073e309..168100329388 100644 --- a/docshell/test/navigation/file_bug1326251.html +++ b/docshell/test/navigation/file_bug1326251.html @@ -49,8 +49,8 @@ let shistory = docShell.QueryInterface(SpecialPowers.Ci.nsIWebNavigation) .sessionHistory; // Now staticFrame has frame0 -> frame1 -> frame2. - opener.is(docShell.previousTransIndex, 3, 'docShell.previousTransIndex'); - opener.is(docShell.loadedTransIndex, 2, 'docShell.loadedTransIndex'); + opener.is(docShell.previousEntryIndex, 3, 'docShell.previousEntryIndex'); + opener.is(docShell.loadedEntryIndex, 2, 'docShell.loadedEntryIndex'); opener.is(shistory.index, 2, 'shistory.index'); opener.is(history.length, 4, 'history.length'); opener.is(document.getElementById('staticFrame').contentWindow.location.href, BASE_URL + 'frame2.html', 'staticFrame location'); @@ -109,8 +109,8 @@ .sessionHistory; // staticFrame: frame0 -> frame1 -> frame2 -> iframe_static // innerStaticFrame: frame0 -> frame1 - opener.is(docShell.previousTransIndex, 5, 'docShell.previousTransIndex'); - opener.is(docShell.loadedTransIndex, 4, 'docShell.loadedTransIndex'); + opener.is(docShell.previousEntryIndex, 5, 'docShell.previousEntryIndex'); + opener.is(docShell.loadedEntryIndex, 4, 'docShell.loadedEntryIndex'); opener.is(shistory.index, 4, 'shistory.index'); opener.is(history.length, 6, 'history.length'); let staticFrame = document.getElementById('staticFrame'); diff --git a/docshell/test/navigation/file_bug534178.html b/docshell/test/navigation/file_bug534178.html index 7e357945d34c..56647e17071e 100644 --- a/docshell/test/navigation/file_bug534178.html +++ b/docshell/test/navigation/file_bug534178.html @@ -12,7 +12,7 @@ isOK = true; } document.body.textContent = isOK ? "PASSED" : "FAILED"; - opener.ok(isOK, "Duplicate session history transactions should have been removed!"); + opener.ok(isOK, "Duplicate session history entries should have been removed!"); opener.nextTest(); window.close(); } diff --git a/docshell/test/navigation/test_sessionhistory.html b/docshell/test/navigation/test_sessionhistory.html index c93c4bd0617a..fb4cfc08512c 100644 --- a/docshell/test/navigation/test_sessionhistory.html +++ b/docshell/test/navigation/test_sessionhistory.html @@ -26,7 +26,7 @@ var testFiles = "file_bug508537_1.html", // Dynamic frames and forward-back "file_document_write_1.html", // Session history + document.write //"file_static_and_dynamic_1.html",// Static and dynamic frames and forward-back - "file_bug534178.html", // Session history transaction clean-up. + "file_bug534178.html", // Session history entry clean-up. "file_fragment_handling_during_load.html", "file_nested_frames.html", "file_shiftReload_and_pushState.html", diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 246810e3602a..cbcb41d8b664 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2247,8 +2247,8 @@ nsDocumentViewer::Show(void) if (history) { int32_t prevIndex,loadedIndex; nsCOMPtr docShell = do_QueryInterface(treeItem); - docShell->GetPreviousTransIndex(&prevIndex); - docShell->GetLoadedTransIndex(&loadedIndex); + docShell->GetPreviousEntryIndex(&prevIndex); + docShell->GetLoadedEntryIndex(&loadedIndex); #ifdef DEBUG_PAGE_CACHE printf("About to evict content viewers: prev=%d, loaded=%d\n", prevIndex, loadedIndex); diff --git a/toolkit/modules/sessionstore/SessionHistory.jsm b/toolkit/modules/sessionstore/SessionHistory.jsm index fadf05954370..5a07f6f21809 100644 --- a/toolkit/modules/sessionstore/SessionHistory.jsm +++ b/toolkit/modules/sessionstore/SessionHistory.jsm @@ -84,12 +84,12 @@ var SessionHistoryInternal = { let shistory = history.legacySHistory.QueryInterface(Ci.nsISHistory); let count = shistory.count; for ( ; entryCount < count; entryCount++) { - let txn = shistory.GetTransactionAtIndex(entryCount); + let shEntry = shistory.getEntryAtIndex(entryCount); if (entryCount <= aFromIdx) { skippedCount++; continue; } - let entry = this.serializeEntry(txn); + let entry = this.serializeEntry(shEntry); data.entries.push(entry); }