diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index f915ab5a76c..8e522aa7271 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -225,12 +225,16 @@ NS_IMETHODIMP nsDocShell::LoadURI(nsIURI* aURI, nsIDocShellLoadInfo* aLoadInfo) aLoadInfo->GetReferrer(getter_AddRefs(referrer)); aLoadInfo->GetLoadType(&loadType); aLoadInfo->GetOwner(getter_AddRefs(owner)); - } #ifdef SH_IN_FRAMES aLoadInfo->GetSHEntry(getter_AddRefs(loadInfoSHEntry)); -#endif +#endif + } + #ifdef SH_IN_FRAMES + if (loadInfoSHEntry) + NS_ENSURE_SUCCESS(LoadHistoryEntry(loadInfoSHEntry, loadType), NS_ERROR_FAILURE); + else NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull, loadType, loadInfoSHEntry), NS_ERROR_FAILURE); #else NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull, loadType), NS_ERROR_FAILURE); @@ -726,6 +730,19 @@ NS_IMETHODIMP nsDocShell::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner) return NS_OK; } +NS_IMETHODIMP nsDocShell::SetChildOffset(PRInt32 aChildOffset) +{ + mChildOffset = aChildOffset; + return NS_OK; +} + +NS_IMETHODIMP nsDocShell::GetChildOffset(PRInt32 *aChildOffset) +{ + NS_ENSURE_ARG_POINTER(aChildOffset); + *aChildOffset = mChildOffset; + return NS_OK; +} + //***************************************************************************** // nsDocShell::nsIDocShellTreeNode //***************************************************************************** @@ -737,6 +754,8 @@ NS_IMETHODIMP nsDocShell::GetChildCount(PRInt32 *aChildCount) return NS_OK; } + + NS_IMETHODIMP nsDocShell::AddChild(nsIDocShellTreeItem *aChild) { NS_ENSURE_ARG_POINTER(aChild); @@ -745,12 +764,18 @@ NS_IMETHODIMP nsDocShell::AddChild(nsIDocShellTreeItem *aChild) mChildren.AppendElement(aChild); NS_ADDREF(aChild); + // Set the child's index in the parent's children list + // XXX What if the parent had different types of children? + // XXX in that case docshell hierarchyand SH hierarchy won't match. + aChild->SetChildOffset((mChildren.Count())-1); + PRInt32 childType = ~mItemType; // Set it to not us in case the get fails aChild->GetItemType(&childType); if(childType != mItemType) return NS_OK; // Everything below here is only done when the child is the same type. + aChild->SetTreeOwner(mTreeOwner); nsCOMPtr childAsDocShell(do_QueryInterface(aChild)); @@ -871,6 +896,7 @@ NS_IMETHODIMP nsDocShell::FindChildWithName(const PRUnichar *aName, NS_IMETHODIMP nsDocShell::GetCanGoBack(PRBool* aCanGoBack) { +#ifndef SH_IN_FRAMES NS_ENSURE_ARG_POINTER(aCanGoBack); *aCanGoBack = PR_FALSE; if (mSessionHistory == nsnull) { @@ -883,12 +909,13 @@ NS_IMETHODIMP nsDocShell::GetCanGoBack(PRBool* aCanGoBack) NS_ENSURE_SUCCESS(mSessionHistory->GetIndex(&index), NS_ERROR_FAILURE); if(index > 0) *aCanGoBack = PR_TRUE; - +#endif return NS_OK; } NS_IMETHODIMP nsDocShell::GetCanGoForward(PRBool* aCanGoForward) { +#ifndef SH_IN_FRAMES NS_ENSURE_ARG_POINTER(aCanGoForward); *aCanGoForward = PR_FALSE; if (mSessionHistory == nsnull) { @@ -905,12 +932,13 @@ NS_IMETHODIMP nsDocShell::GetCanGoForward(PRBool* aCanGoForward) if((index >= 0) && (index < (count - 1))) *aCanGoForward = PR_TRUE; - +#endif return NS_OK; } NS_IMETHODIMP nsDocShell::GoBack() { +#ifndef SH_IN_FRAMES if (mSessionHistory == nsnull) { return NS_OK; } @@ -935,12 +963,13 @@ NS_IMETHODIMP nsDocShell::GoBack() NS_ENSURE_SUCCESS(LoadHistoryEntry(previousEntry), NS_ERROR_FAILURE); - +#endif return NS_OK; } NS_IMETHODIMP nsDocShell::GoForward() { +#ifndef SH_IN_FRAMES if (mSessionHistory == nsnull) { return NS_OK; } @@ -964,10 +993,17 @@ NS_IMETHODIMP nsDocShell::GoForward() NS_ENSURE_SUCCESS(LoadHistoryEntry(nextEntry), NS_ERROR_FAILURE); - +#endif return NS_OK; } +NS_IMETHODIMP +nsDocShell::GotoIndex(PRInt32 aIndex) +{ + + return NS_OK; +} + NS_IMETHODIMP nsDocShell::LoadURI(const PRUnichar* aURI) { nsCOMPtr uri; @@ -1993,11 +2029,11 @@ NS_IMETHODIMP nsDocShell::Embed(nsIContentViewer* aContentViewer, // Determine if this type of load should update history switch(mLoadType) { - case loadHistory: - case loadReloadNormal: - case loadReloadBypassCache: - case loadReloadBypassProxy: - case loadReloadBypassProxyAndCache: + case nsIDocShellLoadInfo::loadHistory: + case nsIDocShellLoadInfo::loadReloadNormal: + case nsIDocShellLoadInfo::loadReloadBypassCache: + case nsIDocShellLoadInfo::loadReloadBypassProxy: + case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache: updateHistory = PR_FALSE; break; default: @@ -2862,8 +2898,10 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType NS_ERROR("Need to update case"); break; } + + #ifdef SH_IN_FRAMES - if (!LSHE && updateHistory) { // Page load not from SH + if (!LSHE && updateHistory && (mItemType == typeContent)) { // Page load not from SH /* If no LSHE by this time, then this page load was not initiated * from SH. Now check, if you * can get your SHEntry from your parent's LSHE. This will help @@ -2872,14 +2910,16 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType * on back/forward and went to a frameset page. and currently, * a subframe in that page is being loaded. */ + nsCOMPtr parentAsItem; + GetSameTypeParent(getter_AddRefs(parentAsItem)); nsCOMPtr she; nsCOMPtr parent; // Get your SHEntry from your parent - if (mParent) { - parent = do_QueryInterface(mParent); + if (parentAsItem) { + parent = do_QueryInterface(parentAsItem); if (!parent) return NS_ERROR_FAILURE; - parent->GetSHEForChild(mOffset, getter_AddRefs(she)); + parent->GetSHEForChild(mChildOffset, getter_AddRefs(she)); } if (!she) { // Parent didn't have any SHEntry for you @@ -2892,7 +2932,7 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType ShouldPersistInSessionHistory(aURI, &shouldPersist); nsCOMPtr entry; - if(loadNormalReplace == mLoadType) + if(nsIDocShellLoadInfo::loadNormalReplace == mLoadType) { PRInt32 index = 0; mSessionHistory->GetIndex(&index); @@ -2924,10 +2964,11 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType NS_ERROR_FAILURE); } else { - NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE); - // OSHE could be null here - NS_ENSURE_SUCCESS(parent->AddChildSHEntry(OSHE, she), + if (parent) { + // OSHE could be null here + NS_ENSURE_SUCCESS(parent->AddChildSHEntry(nsnull /* OSHE */, entry), NS_ERROR_FAILURE); + } } } //!she // Set the LSHE for non-SH initiated loads. @@ -3196,7 +3237,11 @@ NS_IMETHODIMP nsDocShell::UpdateCurrentSessionHistory() } +#ifdef SH_IN_FRAMES +NS_IMETHODIMP nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, nsDocShellInfoLoadType aLoadType) +#else NS_IMETHODIMP nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry) +#endif { nsCOMPtr uri; nsCOMPtr postData; @@ -3228,7 +3273,7 @@ NS_IMETHODIMP nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry) #ifdef SH_IN_FRAMES - NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, nsIDocShellLoadInfo::loadHistory, aEntry), + NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, aLoadType, aEntry), NS_ERROR_FAILURE); #else NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, nsIDocShellLoadInfo::loadHistory), diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index 92ee36bdbf5..20131cf458e 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -206,7 +206,11 @@ protected: NS_IMETHOD ShouldPersistInSessionHistory(nsIURI* aURI, PRBool* aShouldPersist); NS_IMETHOD AddToSessionHistory(nsIURI* aURI, nsIChannel *aChannel); NS_IMETHOD UpdateCurrentSessionHistory(); +#ifdef SH_IN_FRAMES + NS_IMETHOD LoadHistoryEntry(nsISHEntry* aEntry, nsDocShellInfoLoadType aLoadType); +#else NS_IMETHOD LoadHistoryEntry(nsISHEntry* aEntry); +#endif // NS_IMETHOD GetCurrentSHE(PRInt32 aChildOffset, nsISHEntry ** aResult); NS_IMETHOD PersistLayoutHistoryState(); NS_IMETHOD CloneAndReplace(nsISHEntry * srcEntry, nsISHEntry * aCloneRef, @@ -259,7 +263,7 @@ protected: PRBool mAllowPlugins; PRInt32 mViewMode; - PRInt32 mOffset; // Offset in the parent's child list. + PRInt32 mChildOffset; // Offset in the parent's child list. // Reference to the SHEntry for this docshell until the page is destroyed. // Somebody give me better name nsCOMPtr OSHE; diff --git a/mozilla/docshell/base/nsIDocShellTreeItem.idl b/mozilla/docshell/base/nsIDocShellTreeItem.idl index 271a325d9b8..0b3771ce902 100644 --- a/mozilla/docshell/base/nsIDocShellTreeItem.idl +++ b/mozilla/docshell/base/nsIDocShellTreeItem.idl @@ -131,5 +131,8 @@ interface nsIDocShellTreeItem : nsISupports addref'd before handing it to them. */ attribute nsIDocShellTreeOwner treeOwner; + + /* The offset of yourself in your parent's child list */ + attribute long childOffset; }; diff --git a/mozilla/docshell/base/nsIWebNavigation.idl b/mozilla/docshell/base/nsIWebNavigation.idl index 01b7493320e..eb441399fb6 100644 --- a/mozilla/docshell/base/nsIWebNavigation.idl +++ b/mozilla/docshell/base/nsIWebNavigation.idl @@ -64,6 +64,14 @@ interface nsIWebNavigation : nsISupports */ void goForward(); + /* + Tells the object to navigate to the session history item at index. + @return NS_OK - Gotoindex was successfull + NS_ERROR_UNEXPECTED - This call was unexpected at this time. Most + likely you can't goto that index + */ + void gotoIndex(in long index); + /* Loads a given URI. This will give priority to loading the requested URI in the object implementing this interface. If it can't be loaded here diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 6f26a4fa4c4..ea731cfe9db 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -132,6 +132,8 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_C #define DETECT_WEBSHELL_LEAKS #endif +//#ifdef SH_IN_FRAMES 1 + #ifdef NS_DEBUG /** * Note: the log module is created during initialization which @@ -745,8 +747,11 @@ NS_IMETHODIMP nsWebShell::GoTo(PRInt32 aIndex) NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE); UpdateCurrentSessionHistory(); - +#ifdef SH_IN_FRAMES + NS_ENSURE_SUCCESS(LoadHistoryEntry(entry, nsIDocShellLoadInfo::loadHistory), NS_ERROR_FAILURE); +#else NS_ENSURE_SUCCESS(LoadHistoryEntry(entry), NS_ERROR_FAILURE); +#endif return NS_OK; } @@ -1019,8 +1024,11 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, nsCOMPtr owner; GetCurrentDocumentOwner(getter_AddRefs(owner)); - +#ifdef SH_IN_FRAMES + InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, nsIDocShellLoadInfo::loadLink, nsnull); +#else InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, nsIDocShellLoadInfo::loadLink); +#endif /* SH_IN_FRAMES */ } break; case eLinkVerb_Embed: @@ -1136,6 +1144,9 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, during this load handler. */ nsCOMPtr kungFuDeathGrip(this); + // Clear the LSHE reference in docshell to indicate document loading + // is done one way or another. + LSHE = nsnull; if(mScriptGlobal && !mEODForCurrentDocument && NS_SUCCEEDED(aStatus)) { if(mContentViewer) diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp index 0f043d007c5..f9e6f59fe3a 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -337,6 +337,18 @@ NS_IMETHODIMP nsWebBrowser::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner) return mDocShellTreeOwner->SetTreeOwner(aTreeOwner); } +NS_IMETHODIMP nsWebBrowser::SetChildOffset(PRInt32 aChildOffset) +{ + // Not implemented + return NS_OK; +} + +NS_IMETHODIMP nsWebBrowser::GetChildOffset(PRInt32 *aChildOffset) +{ + // Not implemented + return NS_OK; +} + //***************************************************************************** // nsWebBrowser::nsIWebNavigation //***************************************************************************** @@ -383,6 +395,13 @@ NS_IMETHODIMP nsWebBrowser::Reload(PRInt32 aReloadType) return mDocShellAsNav->Reload(aReloadType); } +NS_IMETHODIMP nsWebBrowser::GotoIndex(PRInt32 aIndex) +{ + NS_ENSURE_STATE(mDocShell); + + return mDocShellAsNav->GotoIndex(aIndex); +} + NS_IMETHODIMP nsWebBrowser::Stop() { NS_ENSURE_STATE(mDocShell); diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 6f26a4fa4c4..ea731cfe9db 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -132,6 +132,8 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_C #define DETECT_WEBSHELL_LEAKS #endif +//#ifdef SH_IN_FRAMES 1 + #ifdef NS_DEBUG /** * Note: the log module is created during initialization which @@ -745,8 +747,11 @@ NS_IMETHODIMP nsWebShell::GoTo(PRInt32 aIndex) NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE); UpdateCurrentSessionHistory(); - +#ifdef SH_IN_FRAMES + NS_ENSURE_SUCCESS(LoadHistoryEntry(entry, nsIDocShellLoadInfo::loadHistory), NS_ERROR_FAILURE); +#else NS_ENSURE_SUCCESS(LoadHistoryEntry(entry), NS_ERROR_FAILURE); +#endif return NS_OK; } @@ -1019,8 +1024,11 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, nsCOMPtr owner; GetCurrentDocumentOwner(getter_AddRefs(owner)); - +#ifdef SH_IN_FRAMES + InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, nsIDocShellLoadInfo::loadLink, nsnull); +#else InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, nsIDocShellLoadInfo::loadLink); +#endif /* SH_IN_FRAMES */ } break; case eLinkVerb_Embed: @@ -1136,6 +1144,9 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, during this load handler. */ nsCOMPtr kungFuDeathGrip(this); + // Clear the LSHE reference in docshell to indicate document loading + // is done one way or another. + LSHE = nsnull; if(mScriptGlobal && !mEODForCurrentDocument && NS_SUCCEEDED(aStatus)) { if(mContentViewer) diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp index b14ee1e2589..ac36d3be4ae 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp @@ -450,50 +450,81 @@ NS_INTERFACE_MAP_END NS_IMETHODIMP nsBrowserInstance::Back() { +#ifdef SH_IN_FRAMES + NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED); + nsCOMPtr webNav(do_QueryInterface(mSessionHistory)); + webNav->GoBack(); +#else nsCOMPtr webNav(do_QueryInterface(GetContentAreaDocShell())); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); webNav->GoBack(); +#endif return NS_OK; } NS_IMETHODIMP nsBrowserInstance::Forward() { +#ifdef SH_IN_FRAMES + NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED); + nsCOMPtr webNav(do_QueryInterface(mSessionHistory)); + webNav->GoForward(); +#else nsCOMPtr webNav(do_QueryInterface(GetContentAreaDocShell())); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); webNav->GoForward(); +#endif return NS_OK; } NS_IMETHODIMP nsBrowserInstance::GetCanGoBack(PRBool* aCan) { +#ifdef SH_IN_FRAMES + NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED); + nsCOMPtr webNav(do_QueryInterface(mSessionHistory)); + webNav->GetCanGoBack(aCan); +#else nsCOMPtr webNav(do_QueryInterface(GetContentAreaDocShell())); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); webNav->GetCanGoBack(aCan); +#endif return NS_OK; } NS_IMETHODIMP nsBrowserInstance::GetCanGoForward(PRBool* aCan) { +#ifdef SH_IN_FRAMES + NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED); + nsCOMPtr webNav(do_QueryInterface(mSessionHistory)); + webNav->GetCanGoForward(aCan); +#else + nsCOMPtr webNav(do_QueryInterface(GetContentAreaDocShell())); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); webNav->GetCanGoForward(aCan); +#endif return NS_OK; } NS_IMETHODIMP nsBrowserInstance::Reload(nsLoadFlags flags) { +#ifdef SH_IN_FRAMES + NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED); + nsCOMPtr webNav(do_QueryInterface(mSessionHistory)); + webNav->Reload(flags); +#else nsCOMPtr webNav(do_QueryInterface(GetContentAreaDocShell())); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); webNav->Reload(nsIWebNavigation::reloadNormal); +#endif return NS_OK; } @@ -763,8 +794,15 @@ nsBrowserInstance::ForwardButtonPopup(nsIDOMNode * aParent) NS_IMETHODIMP nsBrowserInstance::GotoHistoryIndex(PRInt32 aIndex) { +#ifdef SH_IN_FRAMES + NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED); + nsCOMPtr webNav(do_QueryInterface(mSessionHistory)); + webNav->GotoIndex(aIndex); +#else + nsCOMPtr webShell(do_QueryInterface(GetContentAreaDocShell())); webShell->GoTo(aIndex); +#endif return NS_OK; } @@ -944,9 +982,17 @@ 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); - + // Cache the Document Loader for the content area webshell. This is a // weak reference that is *not* reference counted... diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.h b/mozilla/xpfe/browser/src/nsBrowserInstance.h index 21153fb9723..ead5873ab8e 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.h +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.h @@ -46,6 +46,7 @@ #include "nsIWebProgressListener.h" #include "nsIWebShell.h" #include "nsIUrlbarHistory.h" +#include "nsISHistory.h" class nsIDocShell; class nsIScriptContext; @@ -58,6 +59,7 @@ class nsIFindComponent; #define SHISTORY_POPUP_LIST 10 +//#define SH_IN_FRAMES //////////////////////////////////////////////////////////////////////////////// // nsBrowserInstance: @@ -103,7 +105,9 @@ class nsBrowserInstance : public nsIBrowserInstance, PRBool mIsClosed; nsCOMPtr mXULBrowserWindow; - +#ifdef SH_IN_FRAMES + nsCOMPtr mSessionHistory; +#endif nsIScriptContext *mContentScriptContext; // weak reference nsWeakPtr mContentWindowWeak; diff --git a/mozilla/xpfe/components/shistory/src/nsSHistory.cpp b/mozilla/xpfe/components/shistory/src/nsSHistory.cpp index 563c9ba0d3e..f11323ecd28 100644 --- a/mozilla/xpfe/components/shistory/src/nsSHistory.cpp +++ b/mozilla/xpfe/components/shistory/src/nsSHistory.cpp @@ -34,6 +34,7 @@ #include "nsISHContainer.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" +#include "nsIDocShellLoadInfo.h" //***************************************************************************** //*** nsSHistory: Object Management @@ -329,6 +330,7 @@ nsSHistory::GetCanGoForward(PRBool * aCanGoForward) return NS_OK; } + NS_IMETHODIMP nsSHistory::GoBack() { @@ -354,10 +356,10 @@ nsSHistory::GoForward() } NS_IMETHODIMP -nsSHistory::Reload(PRInt32 reloadType) +nsSHistory::Reload(PRInt32 aReloadType) { - // NOT implemented - return NS_OK; + + return LoadEntry(mIndex, PR_TRUE, aReloadType); } @@ -438,6 +440,13 @@ nsSHistory::GetSHEForChild(PRInt32 aChildOffset, nsISHEntry ** aResult) NS_IMETHODIMP nsSHistory::GotoIndex(PRInt32 aIndex) +{ + + return LoadEntry(aIndex, PR_FALSE, nsIDocShellLoadInfo::loadHistory); +} + +NS_IMETHODIMP +nsSHistory::LoadEntry(PRInt32 aIndex, PRBool aReloadFlag, long aLoadType) { nsCOMPtr docShell; nsCOMPtr shEntry; @@ -450,22 +459,26 @@ nsSHistory::GotoIndex(PRInt32 aIndex) nsCOMPtr nextEntry; GetEntryAtIndex(mIndex, PR_FALSE, getter_AddRefs(nextEntry)); - PRBool result = CompareSHEntry(prevEntry, nextEntry, mRootDocShell, getter_AddRefs(docShell), getter_AddRefs(shEntry)); - - if (!result) - mIndex = oldIndex; - - if (!docShell || !shEntry || !mRootDocShell) - return NS_ERROR_FAILURE; - nsCOMPtr nexturi; nsCOMPtr loadInfo; + if (oldIndex != aIndex) { + PRBool result = CompareSHEntry(prevEntry, nextEntry, mRootDocShell, getter_AddRefs(docShell), getter_AddRefs(shEntry)); + if (!result) + mIndex = oldIndex; + + if (!docShell || !shEntry || !mRootDocShell) + return NS_ERROR_FAILURE; + + + shEntry->GetURI(getter_AddRefs(nexturi)); + } + else + nextEntry->GetURI(getter_AddRefs(nexturi)); - shEntry->GetURI(getter_AddRefs(nexturi)); mRootDocShell->CreateLoadInfo (getter_AddRefs(loadInfo)); // This is not available yet - // loadInfo->SetSessionHistoryEntry(nextEntry); - + loadInfo->SetLoadType(aLoadType); + loadInfo->SetSHEntry(nextEntry); // Time to initiate a document load return docShell->LoadURI(nexturi, loadInfo); diff --git a/mozilla/xpfe/components/shistory/src/nsSHistory.h b/mozilla/xpfe/components/shistory/src/nsSHistory.h index ce3737b16e7..8d285a9b6db 100644 --- a/mozilla/xpfe/components/shistory/src/nsSHistory.h +++ b/mozilla/xpfe/components/shistory/src/nsSHistory.h @@ -47,11 +47,11 @@ protected: virtual ~nsSHistory(); // Could become part of nsIWebNavigation - NS_IMETHOD GotoIndex(PRInt32 aIndex); NS_IMETHOD PrintHistory(); NS_IMETHOD GetTransactionAtIndex(PRInt32 aIndex, nsISHTransaction ** aResult); PRBool CompareSHEntry(nsISHEntry * prevEntry, nsISHEntry * nextEntry, nsIDocShell * rootDocShell, nsIDocShell ** aResultDocShell, nsISHEntry ** aResultSHEntry); + NS_IMETHOD LoadEntry(PRInt32 aIndex, PRBool aReloadFlag, long aLoadType); protected: nsCOMPtr mListRoot;