Bug 1741132 - Add a property for whether an entry is in the BFCache (holds a content viewer or a frame loader). r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D131893
This commit is contained in:
Peter Van der Beken 2021-11-23 15:37:24 +00:00
Родитель b55325dab8
Коммит 00ffaf83c0
5 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -595,6 +595,12 @@ SessionHistoryEntry::SetContentViewer(nsIContentViewer* aContentViewer) {
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
SessionHistoryEntry::GetIsInBFCache(bool* aResult) {
*aResult = !!SharedInfo()->mFrameLoader;
return NS_OK;
}
NS_IMETHODIMP
SessionHistoryEntry::GetSticky(bool* aSticky) {
*aSticky = SharedInfo()->mSticky;

Просмотреть файл

@ -110,6 +110,8 @@ interface nsISHEntry : nsISupports
/** Content viewer, for fast restoration of presentation */
[infallible] attribute nsIContentViewer contentViewer;
[infallible] readonly attribute boolean isInBFCache;
/** Whether the content viewer is marked "sticky" */
[infallible] attribute boolean sticky;

Просмотреть файл

@ -996,6 +996,12 @@ nsSHEntry::GetContentViewer(nsIContentViewer** aResult) {
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetIsInBFCache(bool* aResult) {
*aResult = !!GetState()->mContentViewer;
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::Clone(nsISHEntry** aResult) {
nsCOMPtr<nsISHEntry> entry = new nsSHEntry(*this);

Просмотреть файл

@ -972,6 +972,10 @@ static void LogEntry(nsISHEntry* aEntry, int32_t aIndex, int32_t aTotal,
MOZ_LOG(gSHLog, LogLevel::Debug,
(" %s%s Name = %s\n", prefix.get(), childCount > 0 ? "|" : " ",
NS_LossyConvertUTF16toASCII(name).get()));
MOZ_LOG(
gSHLog, LogLevel::Debug,
(" %s%s Is in BFCache = %s\n", prefix.get(), childCount > 0 ? "|" : " ",
aEntry->GetIsInBFCache() ? "true" : "false"));
nsCOMPtr<nsISHEntry> prevChild;
for (int32_t i = 0; i < childCount; ++i) {

Просмотреть файл

@ -69,7 +69,7 @@
for (let i = 0; i < history.count; i++) {
var shEntry = history.getEntryAtIndex(i).
QueryInterface(Ci.nsISHEntry);
is(!!shEntry.contentViewer, gExpected[i], "content viewer "+i+", test "+gTestCount);
is(shEntry.isInBFCache, gExpected[i], `BFCache for shentry[${i}], test ${gTestCount}`);
}
// Make sure none of the SHEntries share bfcache entries with one