Fix for bug # 37324 r=rpotts

git-svn-id: svn://10.0.0.236/trunk@74394 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
radha%netscape.com
2000-07-18 21:55:37 +00:00
parent bf5c105437
commit 50ef8aca6b
3 changed files with 43 additions and 5 deletions

View File

@@ -837,6 +837,14 @@ NS_IMETHODIMP nsDocShell::AddChild(nsIDocShellTreeItem *aChild)
PRInt32 childCount = mChildren.Count();
aChild->SetChildOffset(childCount-1);
/* Set the child's global history if the parent has one */
if (mGlobalHistory) {
nsCOMPtr<nsIDocShellHistory> dsHistoryChild(do_QueryInterface(aChild));
if (dsHistoryChild)
dsHistoryChild->SetGlobalHistory(mGlobalHistory);
}
PRInt32 childType = ~mItemType; // Set it to not us in case the get fails
aChild->GetItemType(&childType);
if(childType != mItemType)
@@ -1041,6 +1049,20 @@ nsDocShell::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry,
return rv;
}
NS_IMETHODIMP nsDocShell::SetGlobalHistory(nsIGlobalHistory* aGlobalHistory)
{
mGlobalHistory = aGlobalHistory;
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetGlobalHistory(nsIGlobalHistory** aGlobalHistory)
{
NS_ENSURE_ARG_POINTER(aGlobalHistory);
*aGlobalHistory = mGlobalHistory;
NS_IF_ADDREF(*aGlobalHistory);
return NS_OK;
}
//*****************************************************************************
// nsDocShell::nsIWebNavigation
@@ -1391,7 +1413,8 @@ NS_IMETHODIMP nsDocShell::Create()
{
NS_ENSURE_STATE(!mContentViewer);
mPrefs = do_GetService(NS_PREF_PROGID);
mGlobalHistory = do_GetService(NS_GLOBALHISTORY_PROGID);
//GlobalHistory is now set in SetGlobalHistory
// mGlobalHistory = do_GetService(NS_GLOBALHISTORY_PROGID);
// i don't want to read this pref in every time we load a url
// so read it in once here and be done with it...

View File

@@ -21,6 +21,7 @@
#include "nsISupports.idl"
interface nsISHEntry;
interface nsIGlobalHistory;
@@ -39,5 +40,12 @@ interface nsIDocShellHistory : nsISupports
in nsISHEntry aHistoryEntry,
in long aChildOffset);
/*
* The global history object used to store
* the global history for the session.
*/
attribute nsIGlobalHistory globalHistory;
};

View File

@@ -107,6 +107,8 @@
#include "nsICharsetConverterManager.h"
#include "nsICharsetConverterManager2.h"
#include "nsIDocShellHistory.h"
// Interface for "unknown content type handler" component/service.
#include "nsIUnkContentTypeHandler.h"
@@ -983,17 +985,22 @@ nsBrowserInstance::SetContentWindow(nsIDOMWindow* aWin)
nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(docShell));
webProgress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*, this));
nsCOMPtr<nsISHistory> sessionHistory(do_CreateInstance(NS_SHISTORY_PROGID));
#ifdef SH_IN_FRAMES
mSessionHistory = sessionHistory;
if (!mSessionHistory) {
printf("#### Error initialising Session History ####\n");
return NS_ERROR_FAILURE;
}
mSessionHistory->SetRootDocShell(docShell);
#endif
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
webNav->SetSessionHistory(sessionHistory);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
if (webNav)
webNav->SetSessionHistory(sessionHistory);
nsCOMPtr<nsIDocShellHistory> dsHistory(do_QueryInterface(GetContentAreaDocShell()));
nsCOMPtr<nsIGlobalHistory> history(do_GetService(kCGlobalHistoryCID));
if (dsHistory)
dsHistory->SetGlobalHistory(history);
// Cache the Document Loader for the content area webshell. This is a
// weak reference that is *not* reference counted...