Added modifyHistory option to LoadURL.

git-svn-id: svn://10.0.0.236/trunk@7905 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
vidur%netscape.com
1998-08-13 04:36:42 +00:00
parent 7ea13344a9
commit 0108cd6479
3 changed files with 69 additions and 29 deletions

View File

@@ -143,8 +143,10 @@ public:
nsIWebShell*& aResult);
NS_IMETHOD Back(void);
NS_IMETHOD Forward(void);
NS_IMETHOD Reload();
NS_IMETHOD LoadURL(const nsString& aURLSpec,
nsIPostData* aPostData=nsnull);
nsIPostData* aPostData=nsnull,
PRBool aModifyHistory=PR_TRUE);
NS_IMETHOD GoTo(PRInt32 aHistoryIndex);
NS_IMETHOD GetHistoryIndex(PRInt32& aResult);
NS_IMETHOD GetURL(PRInt32 aHistoryIndex, nsString& aURLResult);
@@ -867,7 +869,8 @@ nsWebShell::Forward(void)
NS_IMETHODIMP
nsWebShell::LoadURL(const nsString& aURLSpec,
nsIPostData* aPostData)
nsIPostData* aPostData,
PRBool aModifyHistory)
{
nsresult rv;
PRInt32 colon, fSlash;
@@ -894,19 +897,29 @@ nsWebShell::LoadURL(const nsString& aURLSpec,
}
}
// Discard part of history that is no longer reachable
PRInt32 i, n = mHistory.Count();
i = mHistoryIndex + 1;
while (--n >= i) {
nsString* u = (nsString*) mHistory.ElementAt(n);
delete u;
mHistory.RemoveElementAt(n);
}
// Tack on new url
nsString* url = new nsString(urlSpec);
mHistory.AppendElement(url);
mHistoryIndex++;
if (aModifyHistory) {
// Discard part of history that is no longer reachable
PRInt32 i, n = mHistory.Count();
i = mHistoryIndex + 1;
while (--n >= i) {
nsString* u = (nsString*) mHistory.ElementAt(n);
delete u;
mHistory.RemoveElementAt(n);
}
// Tack on new url
mHistory.AppendElement(url);
mHistoryIndex++;
}
else {
// Replace the current history index with this URL
nsString* u = (nsString*) mHistory.ElementAt(mHistoryIndex);
if (nsnull != u) {
delete u;
}
mHistory.ReplaceElementAt(url, mHistoryIndex);
}
ShowHistory();
// Tell web-shell-container we are loading a new url
@@ -929,6 +942,12 @@ nsWebShell::LoadURL(const nsString& aURLSpec,
return rv;
}
NS_IMETHODIMP
nsWebShell::Reload()
{
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::GoTo(PRInt32 aHistoryIndex)
{