diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 02c1f7e3444..d839d120349 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -1730,6 +1730,26 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, */ SetHistoryState(aHistoryState); + /* If the current Uri is the same as the one to be loaded + * don't add it to session history. This avoids multiple + * entries for the same url in the go menu + */ + nsCOMPtr currentURI; + nsresult res = GetCurrentURI(getter_AddRefs(currentURI)); + if (NS_SUCCEEDED(res) && currentURI) { + nsXPIDLCString currentUriSpec; + rv = currentURI->GetSpec(getter_Copies(currentUriSpec)); + if (NS_FAILED(rv)) return rv; + nsAutoString currentURIString(currentUriSpec); + if (currentURIString == spec) { + /* The url to be loaded is the same as the + * url already in the page. Don't add it to session history + */ + aModifyHistory = PR_FALSE; + } + } + + /* Add the page to session history */ if (aModifyHistory && shist && (!isMail)) { PRInt32 ret; @@ -1738,13 +1758,13 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, } nsCOMPtr parent; - nsresult res = GetParent(*getter_AddRefs(parent)); + res = GetParent(*getter_AddRefs(parent)); nsCOMPtr newURI; if ((isLoadingHistory)) { /* if LoadURL() got called from SH, AND If we are going "Back/Forward" * to a frame page,SH will change the current uri to the right value - * for smoother redraw. + * for smoother redraw. */ res = GetCurrentURI(getter_AddRefs(newURI)); } diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 02c1f7e3444..d839d120349 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -1730,6 +1730,26 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, */ SetHistoryState(aHistoryState); + /* If the current Uri is the same as the one to be loaded + * don't add it to session history. This avoids multiple + * entries for the same url in the go menu + */ + nsCOMPtr currentURI; + nsresult res = GetCurrentURI(getter_AddRefs(currentURI)); + if (NS_SUCCEEDED(res) && currentURI) { + nsXPIDLCString currentUriSpec; + rv = currentURI->GetSpec(getter_Copies(currentUriSpec)); + if (NS_FAILED(rv)) return rv; + nsAutoString currentURIString(currentUriSpec); + if (currentURIString == spec) { + /* The url to be loaded is the same as the + * url already in the page. Don't add it to session history + */ + aModifyHistory = PR_FALSE; + } + } + + /* Add the page to session history */ if (aModifyHistory && shist && (!isMail)) { PRInt32 ret; @@ -1738,13 +1758,13 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, } nsCOMPtr parent; - nsresult res = GetParent(*getter_AddRefs(parent)); + res = GetParent(*getter_AddRefs(parent)); nsCOMPtr newURI; if ((isLoadingHistory)) { /* if LoadURL() got called from SH, AND If we are going "Back/Forward" * to a frame page,SH will change the current uri to the right value - * for smoother redraw. + * for smoother redraw. */ res = GetCurrentURI(getter_AddRefs(newURI)); }