Added handling for the webProgress status changes.

This commit is contained in:
tbogard%aol.net 2000-04-04 02:46:17 +00:00
Родитель 3cbce7298c
Коммит bf5d308f53
4 изменённых файлов: 142 добавлений и 97 удалений

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

@ -1954,28 +1954,12 @@ NS_IMETHODIMP
nsBrowserWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL,
nsLoadType aReason)
{
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
if (aShell == webShell.get()) {
if (mStatus) {
nsAutoString url("Connecting to ");
url.Append(aURL);
PRUint32 size;
mStatus->SetText(url,size);
mLoadStartTime = PR_Now();
}
}
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
{
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
if (aShell == webShell.get()) {
if (mThrobber) {
mThrobber->Start();
}
}
return NS_OK;
}
@ -1992,33 +1976,8 @@ NS_IMETHODIMP
nsBrowserWindow::EndLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
nsresult aStatus)
{
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
if (aShell == webShell.get()) {
PRTime endLoadTime = PR_Now();
if (mShowLoadTimes) {
nsAutoString msg(aURL);
printf("Loading ");
fputs(msg, stdout);
PRTime delta;
LL_SUB(delta, endLoadTime, mLoadStartTime);
double usecs;
LL_L2D(usecs, delta);
printf(" took %g milliseconds\n", usecs / 1000.0);
}
if (mThrobber) {
mThrobber->Stop();
}
if (nsnull != mStatus) {
nsAutoString msg(aURL);
PRUint32 size;
msg.Append(" done.");
mStatus->SetText(msg, size);
}
}
return NS_OK;
{
return NS_OK;
}
@ -2147,25 +2106,7 @@ NS_IMETHODIMP
nsBrowserWindow::OnStartURLLoad(nsIDocumentLoader* loader,
nsIChannel* channel)
{
nsresult rv;
nsCOMPtr<nsIURI> aURL;
rv = channel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
if (mStatus) {
nsAutoString url;
if (nsnull != aURL) {
char* str;
aURL->GetSpec(&str);
url = str;
nsCRT::free(str);
}
url.Append(": start");
PRUint32 size;
mStatus->SetText(url,size);
}
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP
@ -2190,24 +2131,6 @@ nsBrowserWindow::OnEndURLLoad(nsIDocumentLoader* loader,
nsIChannel* channel,
nsresult aStatus)
{
nsresult rv;
nsCOMPtr<nsIURI> aURL;
rv = channel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
if (mStatus) {
nsAutoString url;
if (nsnull != aURL) {
char* str;
aURL->GetSpec(&str);
url = str;
nsCRT::free(str);
}
url.Append(": stop");
PRUint32 size;
mStatus->SetText(url,size);
}
return NS_OK;
}

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

@ -24,6 +24,7 @@
// Local Includes
#include "nsWebBrowserChrome.h"
#include "nsThrobber.h"
// Helper Classes

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

@ -33,6 +33,7 @@
// Interfaces needed to be included
#include "nsIDocShellTreeItem.h"
#include "nsIWebProgress.h"
// CIDs
@ -40,8 +41,7 @@
//*** nsWebBrowserChrome: Object Management
//*****************************************************************************
nsWebBrowserChrome::nsWebBrowserChrome() : mBrowserWindow(nsnull),
mProgressStatusFlags(0)
nsWebBrowserChrome::nsWebBrowserChrome() : mBrowserWindow(nsnull)
{
NS_INIT_REFCNT();
}
@ -360,20 +360,26 @@ NS_IMETHODIMP nsWebBrowserChrome::OnChildProgressChange(nsIChannel* aChannel,
NS_IMETHODIMP nsWebBrowserChrome::OnStatusChange(nsIChannel* aChannel,
PRInt32 aProgressStatusFlags)
{
/* if(aProgressStatusFlags & nsIWebProgress::flag_networkActivity)
{ // There is network activity now
}
else
{ // There is no network Activity
if(mProgressStatusFlags & nsIWebProgress::flag_networkActivity)
{ // If there was netwoerk activity before
OnLoadFinished(nsIChannel);
}
}
//XXXTAB Implement
NS_ERROR("NotYetImplemented");*/
if(aProgressStatusFlags & nsIWebProgress::flag_net_start)
OnLoadStart(aChannel);
else if(aProgressStatusFlags & nsIWebProgress::flag_net_stop)
OnLoadFinished(aChannel, aProgressStatusFlags);
else if(aProgressStatusFlags & nsIWebProgress::flag_net_dns)
OnStatusDNS(aChannel);
else if(aProgressStatusFlags & nsIWebProgress::flag_net_connecting)
OnStatusConnecting(aChannel);
else if(aProgressStatusFlags & nsIWebProgress::flag_net_redirecting)
OnStatusRedirecting(aChannel);
else if(aProgressStatusFlags & nsIWebProgress::flag_net_negotiating)
OnStatusNegotiating(aChannel);
else if(aProgressStatusFlags & nsIWebProgress::flag_net_transferring)
OnStatusTransferring(aChannel);
if(aProgressStatusFlags & nsIWebProgress::flag_win_start)
OnWindowActivityStart();
else if(aProgressStatusFlags & nsIWebProgress::flag_win_stop)
OnWindowActivityFinished();
return NS_OK;
}
@ -417,3 +423,108 @@ nsBrowserWindow* nsWebBrowserChrome::BrowserWindow()
return mBrowserWindow;
}
//*****************************************************************************
// nsWebBrowserChrome: Status Change Handling
//*****************************************************************************
void nsWebBrowserChrome::OnLoadStart(nsIChannel* aChannel)
{
mBrowserWindow->mLoadStartTime = PR_Now();
if(mBrowserWindow->mThrobber)
mBrowserWindow->mThrobber->Start();
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
if(mBrowserWindow->mStatus)
{
nsXPIDLCString uriString;
uri->GetSpec(getter_Copies(uriString));
nsAutoString url(uriString);
url.Append(": start");
PRUint32 size;
mBrowserWindow->mStatus->SetText(url,size);
}
}
void nsWebBrowserChrome::OnLoadFinished(nsIChannel* aChannel,
PRInt32 aProgressStatusFlags)
{
nsXPIDLCString uriString;
if(aChannel)
{
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
uri->GetSpec(getter_Copies(uriString));
}
nsAutoString msg(uriString);
PRTime endLoadTime = PR_Now();
if(mBrowserWindow->mShowLoadTimes)
{
printf("Loading ");
fputs(msg, stdout);
PRTime delta;
LL_SUB(delta, endLoadTime, mBrowserWindow->mLoadStartTime);
double usecs;
LL_L2D(usecs, delta);
printf(" took %g milliseconds\n", usecs / 1000.0);
}
if(mBrowserWindow->mThrobber)
mBrowserWindow->mThrobber->Stop();
if(mBrowserWindow->mStatus)
{
PRUint32 size;
msg.Append(" done.");
mBrowserWindow->mStatus->SetText(msg, size);
}
}
void nsWebBrowserChrome::OnStatusDNS(nsIChannel* aChannel)
{
}
void nsWebBrowserChrome::OnStatusConnecting(nsIChannel* aChannel)
{
nsXPIDLCString uriString;
if(aChannel)
{
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
uri->GetSpec(getter_Copies(uriString));
}
nsAutoString msg("Connecting to ");
msg.Append(uriString);
PRUint32 size;
mBrowserWindow->mStatus->SetText(msg,size);
}
void nsWebBrowserChrome::OnStatusRedirecting(nsIChannel* aChannel)
{
}
void nsWebBrowserChrome::OnStatusNegotiating(nsIChannel* aChannel)
{
}
void nsWebBrowserChrome::OnStatusTransferring(nsIChannel* aChannel)
{
}
void nsWebBrowserChrome::OnWindowActivityStart()
{
}
void nsWebBrowserChrome::OnWindowActivityFinished()
{
}

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

@ -57,9 +57,19 @@ protected:
void BrowserWindow(nsBrowserWindow* aBrowserWindow);
nsBrowserWindow* BrowserWindow();
// Status Change Handling
void OnLoadStart(nsIChannel* aChannel);
void OnLoadFinished(nsIChannel* aChannel, PRInt32 aProgressStatusFlags);
void OnStatusDNS(nsIChannel* aChannel);
void OnStatusConnecting(nsIChannel* aChannel);
void OnStatusRedirecting(nsIChannel* aChannel);
void OnStatusNegotiating(nsIChannel* aChannel);
void OnStatusTransferring(nsIChannel* aChannel);
void OnWindowActivityStart();
void OnWindowActivityFinished();
protected:
nsBrowserWindow* mBrowserWindow;
PRInt32 mProgressStatusFlags;
};
#endif /* nsWebBrowserChrome_h__ */