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
Родитель 293e139886
Коммит 746ed558e5
2 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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,