Fix for bug 1755. Separated out functionality of nsWebShell::Stop() into two methods, StopBeforeRequestingURL() and StopAfterURLAvailabl(). The former is called before sending a new url load request to the doc loader. The latter is called once the doc loader notifies the webshell via OnStartURLLoad() that the stream created from the URL is ready to be consumed.

This commit is contained in:
nisheeth%netscape.com 1999-07-07 10:47:35 +00:00
parent 1257dfd75f
commit 6f3aabd2a9
2 changed files with 108 additions and 2 deletions

View File

@ -442,6 +442,8 @@ public:
protected:
void InitFrameData(PRBool aCompleteInitScrolling);
nsresult CheckForTrailingSlash(nsIURI* aURL);
nsresult StopBeforeRequestingURL(void);
nsresult StopAfterURLAvailable(void);
nsIEventQueue* mThreadEventQueue;
nsIScriptGlobalObject *mScriptGlobal;
@ -1900,7 +1902,7 @@ nsWebShell::DoLoadURL(const nsString& aUrlSpec,
// Stop loading the current document (if any...). This call may result in
// firing an EndLoadURL notification for the old document...
Stop();
StopBeforeRequestingURL();
// Tell web-shell-container we are loading a new url
@ -2108,6 +2110,50 @@ NS_IMETHODIMP nsWebShell::Stop(void)
return NS_OK;
}
// This "stops" the current document load enough so that the document loader
// can be used to load a new URL.
nsresult
nsWebShell::StopBeforeRequestingURL()
{
if (mDocLoader) {
// Stop any documents that are currently being loaded...
mDocLoader->Stop();
}
// Recurse down the webshell hierarchy.
PRInt32 i, n = mChildren.Count();
for (i = 0; i < n; i++) {
nsWebShell* shell = (nsWebShell*) mChildren.ElementAt(i);
shell->StopBeforeRequestingURL();
}
return NS_OK;
}
// This "stops" the current document load completely and is called once
// it has been determined that the new URL is valid and ready to be thrown
// at us from netlib.
nsresult
nsWebShell::StopAfterURLAvailable()
{
if (nsnull != mContentViewer) {
mContentViewer->Stop();
}
// Cancel any timers that were set for this loader.
CancelRefreshURLTimers();
// Recurse down the webshell hierarchy.
PRInt32 i, n = mChildren.Count();
for (i = 0; i < n; i++) {
nsWebShell* shell = (nsWebShell*) mChildren.ElementAt(i);
shell->StopAfterURLAvailable();
}
return NS_OK;
}
#ifdef NECKO
NS_IMETHODIMP nsWebShell::Reload(nsLoadFlags aType)
#else
@ -2982,6 +3028,13 @@ nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,
#endif
// Stop loading of the earlier document completely when the document url
// load starts. Now we know that this url is valid and available.
const char* url;
aURL->GetSpec(&url);
if (0 == PL_strcmp(url, mURL.GetBuffer()))
StopAfterURLAvailable();
// XXX This is a temporary hack for meeting the M4 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

View File

@ -442,6 +442,8 @@ public:
protected:
void InitFrameData(PRBool aCompleteInitScrolling);
nsresult CheckForTrailingSlash(nsIURI* aURL);
nsresult StopBeforeRequestingURL(void);
nsresult StopAfterURLAvailable(void);
nsIEventQueue* mThreadEventQueue;
nsIScriptGlobalObject *mScriptGlobal;
@ -1900,7 +1902,7 @@ nsWebShell::DoLoadURL(const nsString& aUrlSpec,
// Stop loading the current document (if any...). This call may result in
// firing an EndLoadURL notification for the old document...
Stop();
StopBeforeRequestingURL();
// Tell web-shell-container we are loading a new url
@ -2108,6 +2110,50 @@ NS_IMETHODIMP nsWebShell::Stop(void)
return NS_OK;
}
// This "stops" the current document load enough so that the document loader
// can be used to load a new URL.
nsresult
nsWebShell::StopBeforeRequestingURL()
{
if (mDocLoader) {
// Stop any documents that are currently being loaded...
mDocLoader->Stop();
}
// Recurse down the webshell hierarchy.
PRInt32 i, n = mChildren.Count();
for (i = 0; i < n; i++) {
nsWebShell* shell = (nsWebShell*) mChildren.ElementAt(i);
shell->StopBeforeRequestingURL();
}
return NS_OK;
}
// This "stops" the current document load completely and is called once
// it has been determined that the new URL is valid and ready to be thrown
// at us from netlib.
nsresult
nsWebShell::StopAfterURLAvailable()
{
if (nsnull != mContentViewer) {
mContentViewer->Stop();
}
// Cancel any timers that were set for this loader.
CancelRefreshURLTimers();
// Recurse down the webshell hierarchy.
PRInt32 i, n = mChildren.Count();
for (i = 0; i < n; i++) {
nsWebShell* shell = (nsWebShell*) mChildren.ElementAt(i);
shell->StopAfterURLAvailable();
}
return NS_OK;
}
#ifdef NECKO
NS_IMETHODIMP nsWebShell::Reload(nsLoadFlags aType)
#else
@ -2982,6 +3028,13 @@ nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,
#endif
// Stop loading of the earlier document completely when the document url
// load starts. Now we know that this url is valid and available.
const char* url;
aURL->GetSpec(&url);
if (0 == PL_strcmp(url, mURL.GetBuffer()))
StopAfterURLAvailable();
// XXX This is a temporary hack for meeting the M4 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