more fixes for progress meteors,r=mscott 38598

This commit is contained in:
bienvenu%netscape.com 2000-06-30 13:30:02 +00:00
parent 2daa56f319
commit c5daa0bb05
3 changed files with 64 additions and 25 deletions

View File

@ -113,26 +113,28 @@ nsMsgStatusFeedback::OnStateChange(nsIWebProgress* aWebProgress,
nsresult aStatus) nsresult aStatus)
{ {
nsresult rv; nsresult rv;
if (aProgressStateFlags & flag_start) if (aProgressStateFlags & flag_is_network)
{ {
m_lastPercent = 0; if (aProgressStateFlags & flag_start)
StartMeteors(); {
nsXPIDLString loadingDocument; m_lastPercent = 0;
rv = mBundle->GetStringFromName(NS_ConvertASCIItoUCS2("documentLoading").GetUnicode(), StartMeteors();
getter_Copies(loadingDocument)); nsXPIDLString loadingDocument;
if (NS_SUCCEEDED(rv)) rv = mBundle->GetStringFromName(NS_ConvertASCIItoUCS2("documentLoading").GetUnicode(),
ShowStatusString(loadingDocument); getter_Copies(loadingDocument));
if (NS_SUCCEEDED(rv))
ShowStatusString(loadingDocument);
}
else if (aProgressStateFlags & flag_stop)
{
StopMeteors();
nsXPIDLString documentDone;
rv = mBundle->GetStringFromName(NS_ConvertASCIItoUCS2("documentDone").GetUnicode(),
getter_Copies(documentDone));
if (NS_SUCCEEDED(rv))
ShowStatusString(documentDone);
}
} }
else if (aProgressStateFlags & flag_stop)
{
StopMeteors();
nsXPIDLString documentDone;
rv = mBundle->GetStringFromName(NS_ConvertASCIItoUCS2("documentDone").GetUnicode(),
getter_Copies(documentDone));
if (NS_SUCCEEDED(rv))
ShowStatusString(documentDone);
}
return NS_OK; return NS_OK;
} }
@ -181,8 +183,6 @@ nsMsgStatusFeedback::ShowProgress(PRInt32 percentage)
if (mStatusFeedback) if (mStatusFeedback)
mStatusFeedback->ShowProgress(percentage); mStatusFeedback->ShowProgress(percentage);
if (mQueuedMeteorStarts <= 0)
mQueuedMeteorStarts++;
return NS_OK; return NS_OK;
} }
@ -299,7 +299,8 @@ nsMsgStatusFeedback::notifyStopMeteors(nsITimer *aTimer, void *aClosure)
void void
nsMsgStatusFeedback::NotifyStartMeteors(nsITimer *aTimer) nsMsgStatusFeedback::NotifyStartMeteors(nsITimer *aTimer)
{ {
mQueuedMeteorStarts--; if (mQueuedMeteorStarts > 0)
mQueuedMeteorStarts--;
// meteors already spinning, so noop // meteors already spinning, so noop
if (m_meteorsSpinning) return; if (m_meteorsSpinning) return;
@ -307,16 +308,17 @@ nsMsgStatusFeedback::NotifyStartMeteors(nsITimer *aTimer)
// we'll be stopping them soon, don't bother starting. // we'll be stopping them soon, don't bother starting.
if (mQueuedMeteorStops > 0) return; if (mQueuedMeteorStops > 0) return;
m_meteorsSpinning = PR_TRUE;
// actually start the meteors // actually start the meteors
if (mStatusFeedback) if (mStatusFeedback)
mStatusFeedback->StartMeteors(); mStatusFeedback->StartMeteors();
m_meteorsSpinning = PR_TRUE;
} }
void void
nsMsgStatusFeedback::NotifyStopMeteors(nsITimer* aTimer) nsMsgStatusFeedback::NotifyStopMeteors(nsITimer* aTimer)
{ {
mQueuedMeteorStops--; if (mQueuedMeteorStops > 0)
mQueuedMeteorStops--;
// meteors not spinning // meteors not spinning
if (!m_meteorsSpinning) return; if (!m_meteorsSpinning) return;

View File

@ -51,8 +51,8 @@ protected:
PRInt32 m_lastPercent; PRInt32 m_lastPercent;
PRInt64 m_lastProgressTime; PRInt64 m_lastProgressTime;
PRBool mQueuedMeteorStarts; PRInt32 mQueuedMeteorStarts;
PRBool mQueuedMeteorStops; PRInt32 mQueuedMeteorStops;
nsCOMPtr<nsITimer> mStartTimer; nsCOMPtr<nsITimer> mStartTimer;
nsCOMPtr<nsITimer> mStopTimer; nsCOMPtr<nsITimer> mStopTimer;

View File

@ -30,6 +30,9 @@
#include "nsILoadGroup.h" #include "nsILoadGroup.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsIWebProgress.h"
#include "nsIWebProgressListener.h"
#include "nsIInterfaceRequestor.h"
static NS_DEFINE_CID(kUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID); static NS_DEFINE_CID(kUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID); static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
@ -81,6 +84,17 @@ nsresult nsMsgMailNewsUrl::SetUrlState(PRBool aRunningUrl, nsresult aExitCode)
m_runningUrl = aRunningUrl; m_runningUrl = aRunningUrl;
nsCOMPtr <nsIMsgStatusFeedback> statusFeedback; nsCOMPtr <nsIMsgStatusFeedback> statusFeedback;
// put this back - we need it for urls that don't run through the doc loader
if (NS_SUCCEEDED(GetStatusFeedback(getter_AddRefs(statusFeedback))) && statusFeedback)
{
if (m_runningUrl)
statusFeedback->StartMeteors();
else
{
statusFeedback->ShowProgress(0);
statusFeedback->StopMeteors();
}
}
if (m_urlListeners) if (m_urlListeners)
{ {
if (m_runningUrl) if (m_runningUrl)
@ -231,6 +245,29 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetLoadGroup(nsILoadGroup **aLoadGroup)
nsCOMPtr<nsIDocShell> docShell; nsCOMPtr<nsIDocShell> docShell;
m_msgWindow->GetRootDocShell(getter_AddRefs(docShell)); m_msgWindow->GetRootDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell)); nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
#if 0 // since we're not going through the doc loader for most mail/news urls,
//, this code isn't useful
// but I can imagine it could be useful at some point.
// load group needs status feedback set, since it's
// not the main window load group.
nsCOMPtr<nsIMsgStatusFeedback> statusFeedback;
m_msgWindow->GetStatusFeedback(getter_AddRefs(statusFeedback));
if (statusFeedback)
{
nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(docShell));
nsCOMPtr<nsIWebProgressListener> webProgressListener(do_QueryInterface(statusFeedback));
// register our status feedback object
if (statusFeedback && docShell)
{
webProgressListener = do_QueryInterface(statusFeedback);
webProgress->AddProgressListener(webProgressListener);
}
}
#endif
if (webShell) if (webShell)
{ {
nsCOMPtr <nsIDocumentLoader> docLoader; nsCOMPtr <nsIDocumentLoader> docLoader;