Bug 622315: Refuse to navigate if a navigation is already pending. r=bz
authorKyle Huey <khuey@kylehuey.com>
Tue, 07 Jun 2011 13:10:47 -0700
changeset 70746 ffead16f25ebc157ebb44189579979f6170baba9
parent 70745 ea5ed0f2a95226b6a3c68076241ca18c437bd41b
child 70747 235fa8782613e929d9db65cf0c46856bbd137830
push id20406
push usereakhgari@mozilla.com
push dateWed, 08 Jun 2011 21:46:52 +0000
treeherdermozilla-central@3a509617644e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs622315
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 622315: Refuse to navigate if a navigation is already pending. r=bz
docshell/shistory/src/nsSHistory.cpp
--- a/docshell/shistory/src/nsSHistory.cpp
+++ b/docshell/shistory/src/nsSHistory.cpp
@@ -711,33 +711,45 @@ nsSHistory::EvictAllContentViewers()
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsSHistory::GetCanGoBack(PRBool * aCanGoBack)
 {
   NS_ENSURE_ARG_POINTER(aCanGoBack);
   *aCanGoBack = PR_FALSE;
 
+  // If there is already a pending navigation, we cannot go back.
   PRInt32 index = -1;
+  NS_ENSURE_SUCCESS(GetRequestedIndex(&index), NS_ERROR_FAILURE);
+
+  if(index != -1)
+    return NS_OK;
+
   NS_ENSURE_SUCCESS(GetIndex(&index), NS_ERROR_FAILURE);
   if(index > 0)
      *aCanGoBack = PR_TRUE;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::GetCanGoForward(PRBool * aCanGoForward)
 {
   NS_ENSURE_ARG_POINTER(aCanGoForward);
   *aCanGoForward = PR_FALSE;
 
+  // If there is already a pending navigation, we cannot go forward.
   PRInt32 index = -1;
   PRInt32 count = -1;
 
+  NS_ENSURE_SUCCESS(GetRequestedIndex(&index), NS_ERROR_FAILURE);
+
+  if(index != -1)
+    return NS_OK;
+
   NS_ENSURE_SUCCESS(GetIndex(&index), NS_ERROR_FAILURE);
   NS_ENSURE_SUCCESS(GetCount(&count), NS_ERROR_FAILURE);
 
   if((index >= 0) && (index < (count - 1)))
     *aCanGoForward = PR_TRUE;
 
   return NS_OK;
 }