Fix bug 3413. Approved by chofmann. Reviewed by rpotts. We check nsIURL's

address in nsWebshell::OnStartBinding() and if a trailing slash has been
added to it, we replace the topmost history entry with the new address.
This commit is contained in:
nisheeth%netscape.com 1999-03-18 01:07:22 +00:00
Родитель 0c6e6332fa
Коммит 8256161ceb
2 изменённых файлов: 76 добавлений и 0 удалений

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

@ -307,6 +307,7 @@ public:
protected:
void InitFrameData();
nsresult CheckForTrailingSlash(nsIURL* aURL);
PLEventQueue* mThreadEventQueue;
nsIScriptGlobalObject *mScriptGlobal;
@ -2246,13 +2247,50 @@ nsWebShell::CancelRefreshURLTimers(void) {
return NS_OK;
}
//----------------------------------------------------------------------
/*
* There are cases where netlib does things like add a trailing slash
* to the url being retrieved. We need to watch out for such
* changes and update the currently loading url's entry in the history
* list. UpdateHistoryEntry() does this.
*
* Assumptions:
*
* 1) aURL is the URL that was inserted into the history list in LoadURL()
* 2) The load of aURL is in progress and this function is being called
* from one of the functions in nsIStreamListener implemented by nsWebShell.
*/
nsresult nsWebShell::CheckForTrailingSlash(nsIURL* aURL)
{
nsString* historyURL = (nsString*) mHistory.ElementAt(mHistoryIndex);
const char* spec;
aURL->GetSpec(&spec);
nsString* newURL = (nsString*) new nsString(spec);
if (newURL->Last() == '/' && !historyURL->Equals(*newURL)) {
// Replace the top most history entry with the new url
if (nsnull != historyURL) {
delete historyURL;
}
mHistory.ReplaceElementAt(newURL, mHistoryIndex);
}
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::OnStartBinding(nsIURL* aURL, const char *aContentType)
{
nsresult rv = NS_OK;
// XXX This is a temporary hack for meeting the M3 Dogfood milestone
// for seamonkey. I think Netlib should send a message to all stream listeners
// when it changes the URL like this. That would mean adding a new method
// to nsIStreamListener. Need to talk to Rick, Kipp, Gagan about this.
CheckForTrailingSlash(aURL);
if (nsnull != mObserver) {
rv = mObserver->OnStartBinding(aURL, aContentType);
}

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

@ -307,6 +307,7 @@ public:
protected:
void InitFrameData();
nsresult CheckForTrailingSlash(nsIURL* aURL);
PLEventQueue* mThreadEventQueue;
nsIScriptGlobalObject *mScriptGlobal;
@ -2246,13 +2247,50 @@ nsWebShell::CancelRefreshURLTimers(void) {
return NS_OK;
}
//----------------------------------------------------------------------
/*
* There are cases where netlib does things like add a trailing slash
* to the url being retrieved. We need to watch out for such
* changes and update the currently loading url's entry in the history
* list. UpdateHistoryEntry() does this.
*
* Assumptions:
*
* 1) aURL is the URL that was inserted into the history list in LoadURL()
* 2) The load of aURL is in progress and this function is being called
* from one of the functions in nsIStreamListener implemented by nsWebShell.
*/
nsresult nsWebShell::CheckForTrailingSlash(nsIURL* aURL)
{
nsString* historyURL = (nsString*) mHistory.ElementAt(mHistoryIndex);
const char* spec;
aURL->GetSpec(&spec);
nsString* newURL = (nsString*) new nsString(spec);
if (newURL->Last() == '/' && !historyURL->Equals(*newURL)) {
// Replace the top most history entry with the new url
if (nsnull != historyURL) {
delete historyURL;
}
mHistory.ReplaceElementAt(newURL, mHistoryIndex);
}
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::OnStartBinding(nsIURL* aURL, const char *aContentType)
{
nsresult rv = NS_OK;
// XXX This is a temporary hack for meeting the M3 Dogfood milestone
// for seamonkey. I think Netlib should send a message to all stream listeners
// when it changes the URL like this. That would mean adding a new method
// to nsIStreamListener. Need to talk to Rick, Kipp, Gagan about this.
CheckForTrailingSlash(aURL);
if (nsnull != mObserver) {
rv = mObserver->OnStartBinding(aURL, aContentType);
}