Fix for bug 84519 r=adamlock sr=rpotts a=asa. history.go(toofar) gives problems to back/forward buttons

This commit is contained in:
radha%netscape.com 2001-08-23 21:55:57 +00:00
parent 018c61d1b8
commit 8745507311
2 changed files with 19 additions and 7 deletions

View File

@ -215,11 +215,17 @@ HistoryImpl::GoIndex(PRInt32 aDelta)
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
PRInt32 curIndex=-1;
nsresult rv = session_history->GetIndex(&curIndex);
NS_ENSURE_SUCCESS(rv, rv);
return webnav->GotoIndex(curIndex + aDelta);
PRInt32 len = 0;
nsresult rv = session_history->GetIndex(&curIndex);
rv = session_history->GetCount(&len);
PRInt32 index = curIndex + aDelta;
if (index > -1 && index < len)
webnav->GotoIndex(index);
// We always want to return a NS_OK, since returning errors
// from GotoIndex() can lead to exceptions and a possible leak
// of history length
return NS_OK;
}
NS_IMETHODIMP

View File

@ -585,8 +585,10 @@ nsSHistory::LoadEntry(PRInt32 aIndex, long aLoadType)
nsCOMPtr<nsISHEntry> nextEntry;
GetEntryAtIndex(mIndex, PR_FALSE, getter_AddRefs(nextEntry));
nsCOMPtr<nsIHistoryEntry> nHEntry(do_QueryInterface(nextEntry));
if (!nextEntry || !prevEntry || !nHEntry)
if (!nextEntry || !prevEntry || !nHEntry) {
mIndex = oldIndex;
return NS_ERROR_FAILURE;
}
// Send appropriate listener notifications
PRBool canNavigate = PR_TRUE;
@ -658,8 +660,12 @@ nsSHistory::LoadEntry(PRInt32 aIndex, long aLoadType)
}
if (!docShell || !nextEntry || !mRootDocShell)
if (!docShell || !nextEntry || !mRootDocShell) {
// we did not successfully go to the proper index.
// reset mIndex to what it was before returning error
mIndex = oldIndex;
return NS_ERROR_FAILURE;
}
/* Set the loadType in the SHEntry too to what was passed on.
* This will be passed on to child subframes later in nsDocShell,