More checkins for feature bug 36547. CODE NOT PART OF THE BUILD. reviewer will be provided

when feature is enabled.
This commit is contained in:
radha@netscape.com
2000-06-23 23:54:30 +00:00
parent c36c4adc11
commit ca1a2e25b8
11 changed files with 206 additions and 42 deletions

View File

@@ -225,12 +225,16 @@ NS_IMETHODIMP nsDocShell::LoadURI(nsIURI* aURI, nsIDocShellLoadInfo* aLoadInfo)
aLoadInfo->GetReferrer(getter_AddRefs(referrer)); aLoadInfo->GetReferrer(getter_AddRefs(referrer));
aLoadInfo->GetLoadType(&loadType); aLoadInfo->GetLoadType(&loadType);
aLoadInfo->GetOwner(getter_AddRefs(owner)); aLoadInfo->GetOwner(getter_AddRefs(owner));
}
#ifdef SH_IN_FRAMES #ifdef SH_IN_FRAMES
aLoadInfo->GetSHEntry(getter_AddRefs(loadInfoSHEntry)); aLoadInfo->GetSHEntry(getter_AddRefs(loadInfoSHEntry));
#endif #endif
}
#ifdef SH_IN_FRAMES #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); NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull, loadType, loadInfoSHEntry), NS_ERROR_FAILURE);
#else #else
NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull, loadType), NS_ERROR_FAILURE); 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; 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 // nsDocShell::nsIDocShellTreeNode
//***************************************************************************** //*****************************************************************************
@@ -737,6 +754,8 @@ NS_IMETHODIMP nsDocShell::GetChildCount(PRInt32 *aChildCount)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShell::AddChild(nsIDocShellTreeItem *aChild) NS_IMETHODIMP nsDocShell::AddChild(nsIDocShellTreeItem *aChild)
{ {
NS_ENSURE_ARG_POINTER(aChild); NS_ENSURE_ARG_POINTER(aChild);
@@ -745,12 +764,18 @@ NS_IMETHODIMP nsDocShell::AddChild(nsIDocShellTreeItem *aChild)
mChildren.AppendElement(aChild); mChildren.AppendElement(aChild);
NS_ADDREF(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 PRInt32 childType = ~mItemType; // Set it to not us in case the get fails
aChild->GetItemType(&childType); aChild->GetItemType(&childType);
if(childType != mItemType) if(childType != mItemType)
return NS_OK; return NS_OK;
// Everything below here is only done when the child is the same type. // Everything below here is only done when the child is the same type.
aChild->SetTreeOwner(mTreeOwner); aChild->SetTreeOwner(mTreeOwner);
nsCOMPtr<nsIDocShell> childAsDocShell(do_QueryInterface(aChild)); nsCOMPtr<nsIDocShell> childAsDocShell(do_QueryInterface(aChild));
@@ -871,6 +896,7 @@ NS_IMETHODIMP nsDocShell::FindChildWithName(const PRUnichar *aName,
NS_IMETHODIMP nsDocShell::GetCanGoBack(PRBool* aCanGoBack) NS_IMETHODIMP nsDocShell::GetCanGoBack(PRBool* aCanGoBack)
{ {
#ifndef SH_IN_FRAMES
NS_ENSURE_ARG_POINTER(aCanGoBack); NS_ENSURE_ARG_POINTER(aCanGoBack);
*aCanGoBack = PR_FALSE; *aCanGoBack = PR_FALSE;
if (mSessionHistory == nsnull) { if (mSessionHistory == nsnull) {
@@ -883,12 +909,13 @@ NS_IMETHODIMP nsDocShell::GetCanGoBack(PRBool* aCanGoBack)
NS_ENSURE_SUCCESS(mSessionHistory->GetIndex(&index), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(mSessionHistory->GetIndex(&index), NS_ERROR_FAILURE);
if(index > 0) if(index > 0)
*aCanGoBack = PR_TRUE; *aCanGoBack = PR_TRUE;
#endif
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShell::GetCanGoForward(PRBool* aCanGoForward) NS_IMETHODIMP nsDocShell::GetCanGoForward(PRBool* aCanGoForward)
{ {
#ifndef SH_IN_FRAMES
NS_ENSURE_ARG_POINTER(aCanGoForward); NS_ENSURE_ARG_POINTER(aCanGoForward);
*aCanGoForward = PR_FALSE; *aCanGoForward = PR_FALSE;
if (mSessionHistory == nsnull) { if (mSessionHistory == nsnull) {
@@ -905,12 +932,13 @@ NS_IMETHODIMP nsDocShell::GetCanGoForward(PRBool* aCanGoForward)
if((index >= 0) && (index < (count - 1))) if((index >= 0) && (index < (count - 1)))
*aCanGoForward = PR_TRUE; *aCanGoForward = PR_TRUE;
#endif
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShell::GoBack() NS_IMETHODIMP nsDocShell::GoBack()
{ {
#ifndef SH_IN_FRAMES
if (mSessionHistory == nsnull) { if (mSessionHistory == nsnull) {
return NS_OK; return NS_OK;
} }
@@ -935,12 +963,13 @@ NS_IMETHODIMP nsDocShell::GoBack()
NS_ENSURE_SUCCESS(LoadHistoryEntry(previousEntry), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(LoadHistoryEntry(previousEntry), NS_ERROR_FAILURE);
#endif
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShell::GoForward() NS_IMETHODIMP nsDocShell::GoForward()
{ {
#ifndef SH_IN_FRAMES
if (mSessionHistory == nsnull) { if (mSessionHistory == nsnull) {
return NS_OK; return NS_OK;
} }
@@ -964,6 +993,13 @@ NS_IMETHODIMP nsDocShell::GoForward()
NS_ENSURE_SUCCESS(LoadHistoryEntry(nextEntry), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(LoadHistoryEntry(nextEntry), NS_ERROR_FAILURE);
#endif
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GotoIndex(PRInt32 aIndex)
{
return NS_OK; return NS_OK;
} }
@@ -1993,11 +2029,11 @@ NS_IMETHODIMP nsDocShell::Embed(nsIContentViewer* aContentViewer,
// Determine if this type of load should update history // Determine if this type of load should update history
switch(mLoadType) switch(mLoadType)
{ {
case loadHistory: case nsIDocShellLoadInfo::loadHistory:
case loadReloadNormal: case nsIDocShellLoadInfo::loadReloadNormal:
case loadReloadBypassCache: case nsIDocShellLoadInfo::loadReloadBypassCache:
case loadReloadBypassProxy: case nsIDocShellLoadInfo::loadReloadBypassProxy:
case loadReloadBypassProxyAndCache: case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache:
updateHistory = PR_FALSE; updateHistory = PR_FALSE;
break; break;
default: default:
@@ -2862,8 +2898,10 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType
NS_ERROR("Need to update case"); NS_ERROR("Need to update case");
break; break;
} }
#ifdef SH_IN_FRAMES #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 /* If no LSHE by this time, then this page load was not initiated
* from SH. Now check, if you * from SH. Now check, if you
* can get your SHEntry from your parent's LSHE. This will help * 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, * on back/forward and went to a frameset page. and currently,
* a subframe in that page is being loaded. * a subframe in that page is being loaded.
*/ */
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
GetSameTypeParent(getter_AddRefs(parentAsItem));
nsCOMPtr<nsISHEntry> she; nsCOMPtr<nsISHEntry> she;
nsCOMPtr<nsIWebNavigation> parent; nsCOMPtr<nsIWebNavigation> parent;
// Get your SHEntry from your parent // Get your SHEntry from your parent
if (mParent) { if (parentAsItem) {
parent = do_QueryInterface(mParent); parent = do_QueryInterface(parentAsItem);
if (!parent) if (!parent)
return NS_ERROR_FAILURE; 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 if (!she) { // Parent didn't have any SHEntry for you
@@ -2892,7 +2932,7 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType
ShouldPersistInSessionHistory(aURI, &shouldPersist); ShouldPersistInSessionHistory(aURI, &shouldPersist);
nsCOMPtr<nsISHEntry> entry; nsCOMPtr<nsISHEntry> entry;
if(loadNormalReplace == mLoadType) if(nsIDocShellLoadInfo::loadNormalReplace == mLoadType)
{ {
PRInt32 index = 0; PRInt32 index = 0;
mSessionHistory->GetIndex(&index); mSessionHistory->GetIndex(&index);
@@ -2924,11 +2964,12 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
} }
else { else {
NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE); if (parent) {
// OSHE could be null here // OSHE could be null here
NS_ENSURE_SUCCESS(parent->AddChildSHEntry(OSHE, she), NS_ENSURE_SUCCESS(parent->AddChildSHEntry(nsnull /* OSHE */, entry),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
} }
}
} //!she } //!she
// Set the LSHE for non-SH initiated loads. // Set the LSHE for non-SH initiated loads.
LSHE = she; LSHE = she;
@@ -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) NS_IMETHODIMP nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry)
#endif
{ {
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIInputStream> postData; nsCOMPtr<nsIInputStream> postData;
@@ -3228,7 +3273,7 @@ NS_IMETHODIMP nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry)
#ifdef SH_IN_FRAMES #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); NS_ERROR_FAILURE);
#else #else
NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, nsIDocShellLoadInfo::loadHistory), NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, nsIDocShellLoadInfo::loadHistory),

View File

@@ -206,7 +206,11 @@ protected:
NS_IMETHOD ShouldPersistInSessionHistory(nsIURI* aURI, PRBool* aShouldPersist); NS_IMETHOD ShouldPersistInSessionHistory(nsIURI* aURI, PRBool* aShouldPersist);
NS_IMETHOD AddToSessionHistory(nsIURI* aURI, nsIChannel *aChannel); NS_IMETHOD AddToSessionHistory(nsIURI* aURI, nsIChannel *aChannel);
NS_IMETHOD UpdateCurrentSessionHistory(); NS_IMETHOD UpdateCurrentSessionHistory();
#ifdef SH_IN_FRAMES
NS_IMETHOD LoadHistoryEntry(nsISHEntry* aEntry, nsDocShellInfoLoadType aLoadType);
#else
NS_IMETHOD LoadHistoryEntry(nsISHEntry* aEntry); NS_IMETHOD LoadHistoryEntry(nsISHEntry* aEntry);
#endif
// NS_IMETHOD GetCurrentSHE(PRInt32 aChildOffset, nsISHEntry ** aResult); // NS_IMETHOD GetCurrentSHE(PRInt32 aChildOffset, nsISHEntry ** aResult);
NS_IMETHOD PersistLayoutHistoryState(); NS_IMETHOD PersistLayoutHistoryState();
NS_IMETHOD CloneAndReplace(nsISHEntry * srcEntry, nsISHEntry * aCloneRef, NS_IMETHOD CloneAndReplace(nsISHEntry * srcEntry, nsISHEntry * aCloneRef,
@@ -259,7 +263,7 @@ protected:
PRBool mAllowPlugins; PRBool mAllowPlugins;
PRInt32 mViewMode; 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. // Reference to the SHEntry for this docshell until the page is destroyed.
// Somebody give me better name // Somebody give me better name
nsCOMPtr<nsISHEntry> OSHE; nsCOMPtr<nsISHEntry> OSHE;

View File

@@ -131,5 +131,8 @@ interface nsIDocShellTreeItem : nsISupports
addref'd before handing it to them. addref'd before handing it to them.
*/ */
attribute nsIDocShellTreeOwner treeOwner; attribute nsIDocShellTreeOwner treeOwner;
/* The offset of yourself in your parent's child list */
attribute long childOffset;
}; };

View File

@@ -64,6 +64,14 @@ interface nsIWebNavigation : nsISupports
*/ */
void goForward(); 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 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 in the object implementing this interface. If it can't be loaded here

View File

@@ -132,6 +132,8 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_C
#define DETECT_WEBSHELL_LEAKS #define DETECT_WEBSHELL_LEAKS
#endif #endif
//#ifdef SH_IN_FRAMES 1
#ifdef NS_DEBUG #ifdef NS_DEBUG
/** /**
* Note: the log module is created during initialization which * 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); NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE);
UpdateCurrentSessionHistory(); UpdateCurrentSessionHistory();
#ifdef SH_IN_FRAMES
NS_ENSURE_SUCCESS(LoadHistoryEntry(entry, nsIDocShellLoadInfo::loadHistory), NS_ERROR_FAILURE);
#else
NS_ENSURE_SUCCESS(LoadHistoryEntry(entry), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(LoadHistoryEntry(entry), NS_ERROR_FAILURE);
#endif
return NS_OK; return NS_OK;
} }
@@ -1019,8 +1024,11 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
nsCOMPtr<nsISupports> owner; nsCOMPtr<nsISupports> owner;
GetCurrentDocumentOwner(getter_AddRefs(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); InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, nsIDocShellLoadInfo::loadLink);
#endif /* SH_IN_FRAMES */
} }
break; break;
case eLinkVerb_Embed: case eLinkVerb_Embed:
@@ -1136,6 +1144,9 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
during this load handler. */ during this load handler. */
nsCOMPtr<nsIWebShell> kungFuDeathGrip(this); nsCOMPtr<nsIWebShell> 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(mScriptGlobal && !mEODForCurrentDocument && NS_SUCCEEDED(aStatus))
{ {
if(mContentViewer) if(mContentViewer)

View File

@@ -337,6 +337,18 @@ NS_IMETHODIMP nsWebBrowser::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner)
return mDocShellTreeOwner->SetTreeOwner(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 // nsWebBrowser::nsIWebNavigation
//***************************************************************************** //*****************************************************************************
@@ -383,6 +395,13 @@ NS_IMETHODIMP nsWebBrowser::Reload(PRInt32 aReloadType)
return mDocShellAsNav->Reload(aReloadType); return mDocShellAsNav->Reload(aReloadType);
} }
NS_IMETHODIMP nsWebBrowser::GotoIndex(PRInt32 aIndex)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsNav->GotoIndex(aIndex);
}
NS_IMETHODIMP nsWebBrowser::Stop() NS_IMETHODIMP nsWebBrowser::Stop()
{ {
NS_ENSURE_STATE(mDocShell); NS_ENSURE_STATE(mDocShell);

View File

@@ -132,6 +132,8 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_C
#define DETECT_WEBSHELL_LEAKS #define DETECT_WEBSHELL_LEAKS
#endif #endif
//#ifdef SH_IN_FRAMES 1
#ifdef NS_DEBUG #ifdef NS_DEBUG
/** /**
* Note: the log module is created during initialization which * 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); NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE);
UpdateCurrentSessionHistory(); UpdateCurrentSessionHistory();
#ifdef SH_IN_FRAMES
NS_ENSURE_SUCCESS(LoadHistoryEntry(entry, nsIDocShellLoadInfo::loadHistory), NS_ERROR_FAILURE);
#else
NS_ENSURE_SUCCESS(LoadHistoryEntry(entry), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(LoadHistoryEntry(entry), NS_ERROR_FAILURE);
#endif
return NS_OK; return NS_OK;
} }
@@ -1019,8 +1024,11 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
nsCOMPtr<nsISupports> owner; nsCOMPtr<nsISupports> owner;
GetCurrentDocumentOwner(getter_AddRefs(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); InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, nsIDocShellLoadInfo::loadLink);
#endif /* SH_IN_FRAMES */
} }
break; break;
case eLinkVerb_Embed: case eLinkVerb_Embed:
@@ -1136,6 +1144,9 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
during this load handler. */ during this load handler. */
nsCOMPtr<nsIWebShell> kungFuDeathGrip(this); nsCOMPtr<nsIWebShell> 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(mScriptGlobal && !mEODForCurrentDocument && NS_SUCCEEDED(aStatus))
{ {
if(mContentViewer) if(mContentViewer)

View File

@@ -450,50 +450,81 @@ NS_INTERFACE_MAP_END
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserInstance::Back() nsBrowserInstance::Back()
{ {
#ifdef SH_IN_FRAMES
NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mSessionHistory));
webNav->GoBack();
#else
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell())); nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell()));
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
webNav->GoBack(); webNav->GoBack();
#endif
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserInstance::Forward() nsBrowserInstance::Forward()
{ {
#ifdef SH_IN_FRAMES
NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mSessionHistory));
webNav->GoForward();
#else
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell())); nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell()));
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
webNav->GoForward(); webNav->GoForward();
#endif
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserInstance::GetCanGoBack(PRBool* aCan) nsBrowserInstance::GetCanGoBack(PRBool* aCan)
{ {
#ifdef SH_IN_FRAMES
NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mSessionHistory));
webNav->GetCanGoBack(aCan);
#else
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell())); nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell()));
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
webNav->GetCanGoBack(aCan); webNav->GetCanGoBack(aCan);
#endif
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserInstance::GetCanGoForward(PRBool* aCan) nsBrowserInstance::GetCanGoForward(PRBool* aCan)
{ {
#ifdef SH_IN_FRAMES
NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mSessionHistory));
webNav->GetCanGoForward(aCan);
#else
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell())); nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell()));
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
webNav->GetCanGoForward(aCan); webNav->GetCanGoForward(aCan);
#endif
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserInstance::Reload(nsLoadFlags flags) nsBrowserInstance::Reload(nsLoadFlags flags)
{ {
#ifdef SH_IN_FRAMES
NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mSessionHistory));
webNav->Reload(flags);
#else
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell())); nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell()));
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
webNav->Reload(nsIWebNavigation::reloadNormal); webNav->Reload(nsIWebNavigation::reloadNormal);
#endif
return NS_OK; return NS_OK;
} }
@@ -763,8 +794,15 @@ nsBrowserInstance::ForwardButtonPopup(nsIDOMNode * aParent)
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserInstance::GotoHistoryIndex(PRInt32 aIndex) nsBrowserInstance::GotoHistoryIndex(PRInt32 aIndex)
{ {
#ifdef SH_IN_FRAMES
NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mSessionHistory));
webNav->GotoIndex(aIndex);
#else
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(GetContentAreaDocShell())); nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(GetContentAreaDocShell()));
webShell->GoTo(aIndex); webShell->GoTo(aIndex);
#endif
return NS_OK; return NS_OK;
} }
@@ -944,6 +982,14 @@ nsBrowserInstance::SetContentWindow(nsIDOMWindow* aWin)
nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(docShell)); nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(docShell));
webProgress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*, this)); webProgress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*, this));
nsCOMPtr<nsISHistory> sessionHistory(do_CreateInstance(NS_SHISTORY_PROGID)); 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)); nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
webNav->SetSessionHistory(sessionHistory); webNav->SetSessionHistory(sessionHistory);

View File

@@ -46,6 +46,7 @@
#include "nsIWebProgressListener.h" #include "nsIWebProgressListener.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIUrlbarHistory.h" #include "nsIUrlbarHistory.h"
#include "nsISHistory.h"
class nsIDocShell; class nsIDocShell;
class nsIScriptContext; class nsIScriptContext;
@@ -58,6 +59,7 @@ class nsIFindComponent;
#define SHISTORY_POPUP_LIST 10 #define SHISTORY_POPUP_LIST 10
//#define SH_IN_FRAMES
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsBrowserInstance: // nsBrowserInstance:
@@ -103,7 +105,9 @@ class nsBrowserInstance : public nsIBrowserInstance,
PRBool mIsClosed; PRBool mIsClosed;
nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow; nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow;
#ifdef SH_IN_FRAMES
nsCOMPtr<nsISHistory> mSessionHistory;
#endif
nsIScriptContext *mContentScriptContext; // weak reference nsIScriptContext *mContentScriptContext; // weak reference
nsWeakPtr mContentWindowWeak; nsWeakPtr mContentWindowWeak;

View File

@@ -34,6 +34,7 @@
#include "nsISHContainer.h" #include "nsISHContainer.h"
#include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h" #include "nsIDocShellTreeNode.h"
#include "nsIDocShellLoadInfo.h"
//***************************************************************************** //*****************************************************************************
//*** nsSHistory: Object Management //*** nsSHistory: Object Management
@@ -329,6 +330,7 @@ nsSHistory::GetCanGoForward(PRBool * aCanGoForward)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsSHistory::GoBack() nsSHistory::GoBack()
{ {
@@ -354,10 +356,10 @@ nsSHistory::GoForward()
} }
NS_IMETHODIMP 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 NS_IMETHODIMP
nsSHistory::GotoIndex(PRInt32 aIndex) nsSHistory::GotoIndex(PRInt32 aIndex)
{
return LoadEntry(aIndex, PR_FALSE, nsIDocShellLoadInfo::loadHistory);
}
NS_IMETHODIMP
nsSHistory::LoadEntry(PRInt32 aIndex, PRBool aReloadFlag, long aLoadType)
{ {
nsCOMPtr<nsIDocShell> docShell; nsCOMPtr<nsIDocShell> docShell;
nsCOMPtr<nsISHEntry> shEntry; nsCOMPtr<nsISHEntry> shEntry;
@@ -450,22 +459,26 @@ nsSHistory::GotoIndex(PRInt32 aIndex)
nsCOMPtr<nsISHEntry> nextEntry; nsCOMPtr<nsISHEntry> nextEntry;
GetEntryAtIndex(mIndex, PR_FALSE, getter_AddRefs(nextEntry)); GetEntryAtIndex(mIndex, PR_FALSE, getter_AddRefs(nextEntry));
nsCOMPtr<nsIURI> nexturi;
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
if (oldIndex != aIndex) {
PRBool result = CompareSHEntry(prevEntry, nextEntry, mRootDocShell, getter_AddRefs(docShell), getter_AddRefs(shEntry)); PRBool result = CompareSHEntry(prevEntry, nextEntry, mRootDocShell, getter_AddRefs(docShell), getter_AddRefs(shEntry));
if (!result) if (!result)
mIndex = oldIndex; mIndex = oldIndex;
if (!docShell || !shEntry || !mRootDocShell) if (!docShell || !shEntry || !mRootDocShell)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> nexturi;
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
shEntry->GetURI(getter_AddRefs(nexturi)); shEntry->GetURI(getter_AddRefs(nexturi));
}
else
nextEntry->GetURI(getter_AddRefs(nexturi));
mRootDocShell->CreateLoadInfo (getter_AddRefs(loadInfo)); mRootDocShell->CreateLoadInfo (getter_AddRefs(loadInfo));
// This is not available yet // This is not available yet
// loadInfo->SetSessionHistoryEntry(nextEntry); loadInfo->SetLoadType(aLoadType);
loadInfo->SetSHEntry(nextEntry);
// Time to initiate a document load // Time to initiate a document load
return docShell->LoadURI(nexturi, loadInfo); return docShell->LoadURI(nexturi, loadInfo);

View File

@@ -47,11 +47,11 @@ protected:
virtual ~nsSHistory(); virtual ~nsSHistory();
// Could become part of nsIWebNavigation // Could become part of nsIWebNavigation
NS_IMETHOD GotoIndex(PRInt32 aIndex);
NS_IMETHOD PrintHistory(); NS_IMETHOD PrintHistory();
NS_IMETHOD GetTransactionAtIndex(PRInt32 aIndex, nsISHTransaction ** aResult); NS_IMETHOD GetTransactionAtIndex(PRInt32 aIndex, nsISHTransaction ** aResult);
PRBool CompareSHEntry(nsISHEntry * prevEntry, nsISHEntry * nextEntry, nsIDocShell * rootDocShell, PRBool CompareSHEntry(nsISHEntry * prevEntry, nsISHEntry * nextEntry, nsIDocShell * rootDocShell,
nsIDocShell ** aResultDocShell, nsISHEntry ** aResultSHEntry); nsIDocShell ** aResultDocShell, nsISHEntry ** aResultSHEntry);
NS_IMETHOD LoadEntry(PRInt32 aIndex, PRBool aReloadFlag, long aLoadType);
protected: protected:
nsCOMPtr<nsISHTransaction> mListRoot; nsCOMPtr<nsISHTransaction> mListRoot;