From 50ef8aca6b5cff14c3460eaba18e83a65b70a557 Mon Sep 17 00:00:00 2001 From: "radha%netscape.com" Date: Tue, 18 Jul 2000 21:55:37 +0000 Subject: [PATCH] Fix for bug # 37324 r=rpotts git-svn-id: svn://10.0.0.236/trunk@74394 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 25 ++++++++++++++++++- mozilla/docshell/base/nsIDocShellHistory.idl | 8 ++++++ .../xpfe/browser/src/nsBrowserInstance.cpp | 15 ++++++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index fb22aca5dcf..3e54b340b3c 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -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 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... diff --git a/mozilla/docshell/base/nsIDocShellHistory.idl b/mozilla/docshell/base/nsIDocShellHistory.idl index 4d7244caeb0..80004012394 100644 --- a/mozilla/docshell/base/nsIDocShellHistory.idl +++ b/mozilla/docshell/base/nsIDocShellHistory.idl @@ -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; + + }; diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp index 38b432493ec..4d6b3b2d381 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp @@ -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 webProgress(do_GetInterface(docShell)); webProgress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*, this)); nsCOMPtr 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 webNav(do_QueryInterface(docShell)); - webNav->SetSessionHistory(sessionHistory); + nsCOMPtr webNav(do_QueryInterface(docShell)); + if (webNav) + webNav->SetSessionHistory(sessionHistory); + + nsCOMPtr dsHistory(do_QueryInterface(GetContentAreaDocShell())); + nsCOMPtr 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...