mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Fix for bug 84519 r=adamlock sr=rpotts a=asa. history.go(toofar) gives problems to back/forward buttons
This commit is contained in:
parent
018c61d1b8
commit
8745507311
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user