Bug 449780. When doing a frameloader swap, clear the bfcache on both docshells, since we can't deal with all those presentations. r+sr=jst

This commit is contained in:
Boris Zbarsky
2009-01-13 14:32:30 -05:00
parent 6c767c576c
commit 524bd297e2
7 changed files with 163 additions and 20 deletions

View File

@@ -73,6 +73,7 @@
#include "nsGUIEvent.h"
#include "nsEventDispatcher.h"
#include "nsISHistory.h"
#include "nsISHistoryInternal.h"
#include "nsIURI.h"
#include "nsIURL.h"
@@ -494,24 +495,23 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
nsCOMPtr<nsIDocShellTreeItem> ourRootTreeItem, otherRootTreeItem;
ourTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(ourRootTreeItem));
otherTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(otherRootTreeItem));
if (ourRootTreeItem != ourTreeItem || otherRootTreeItem != otherTreeItem) {
nsCOMPtr<nsIWebNavigation> ourRootWebnav =
do_QueryInterface(ourRootTreeItem);
nsCOMPtr<nsIWebNavigation> otherRootWebnav =
do_QueryInterface(otherRootTreeItem);
nsCOMPtr<nsIWebNavigation> ourRootWebnav =
do_QueryInterface(ourRootTreeItem);
nsCOMPtr<nsIWebNavigation> otherRootWebnav =
do_QueryInterface(otherRootTreeItem);
if (!ourRootWebnav || !otherRootWebnav) {
return NS_ERROR_NOT_IMPLEMENTED;
}
if (!ourRootWebnav || !otherRootWebnav) {
return NS_ERROR_NOT_IMPLEMENTED;
}
nsCOMPtr<nsISHistory> ourHistory;
nsCOMPtr<nsISHistory> otherHistory;
ourRootWebnav->GetSessionHistory(getter_AddRefs(ourHistory));
otherRootWebnav->GetSessionHistory(getter_AddRefs(otherHistory));
nsCOMPtr<nsISHistory> ourHistory;
nsCOMPtr<nsISHistory> otherHistory;
ourRootWebnav->GetSessionHistory(getter_AddRefs(ourHistory));
otherRootWebnav->GetSessionHistory(getter_AddRefs(otherHistory));
if (ourHistory || otherHistory) {
return NS_ERROR_NOT_IMPLEMENTED;
}
if ((ourRootTreeItem != ourTreeItem || otherRootTreeItem != otherTreeItem) &&
(ourHistory || otherHistory)) {
return NS_ERROR_NOT_IMPLEMENTED;
}
// Also make sure that the two docshells are the same type. Otherwise
@@ -524,7 +524,7 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
return NS_ERROR_NOT_IMPLEMENTED;
}
// One more twist here. Setting up the right treeowners in a heterogenous
// One more twist here. Setting up the right treeowners in a heterogeneous
// tree is a bit of a pain. So make sure that if ourType is not
// nsIDocShellTreeItem::typeContent then all of our descendants are the same
// type as us.
@@ -692,6 +692,18 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
aFirstToSwap.swap(aSecondToSwap);
// Drop any cached content viewers in the two session histories.
nsCOMPtr<nsISHistoryInternal> ourInternalHistory =
do_QueryInterface(ourHistory);
nsCOMPtr<nsISHistoryInternal> otherInternalHistory =
do_QueryInterface(otherHistory);
if (ourInternalHistory) {
ourInternalHistory->EvictAllContentViewers();
}
if (otherInternalHistory) {
otherInternalHistory->EvictAllContentViewers();
}
// We shouldn't have changed frames, but be really careful about it
if (ourFrame == ourShell->GetPrimaryFrameFor(ourContent) &&
otherFrame == otherShell->GetPrimaryFrameFor(otherContent)) {