Added LoadURL method to observer; cleaned up load progress messages

This commit is contained in:
kipp 1998-07-13 19:53:50 +00:00
Родитель 87961cb33b
Коммит 1608010504
1 изменённых файлов: 35 добавлений и 33 удалений

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

@ -364,6 +364,19 @@ DocObserver::QueryInterface(const nsIID& aIID,
return NS_NOINTERFACE; return NS_NOINTERFACE;
} }
nsresult
DocObserver::LoadURL(const nsString& aURLSpec,
const char* aCommand,
nsIViewerContainer* aContainer,
nsIPostData* aPostData,
nsISupports* aExtraInfo,
nsIStreamObserver* anObserver)
{
mURL = aURLSpec;
return mDocLoader->LoadURL(aURLSpec, aCommand, aContainer,
aPostData, aExtraInfo, anObserver);
}
// Pass title information through to all of the web widgets that // Pass title information through to all of the web widgets that
// belong to this document. // belong to this document.
NS_IMETHODIMP DocObserver::SetTitle(const nsString& aTitle) NS_IMETHODIMP DocObserver::SetTitle(const nsString& aTitle)
@ -464,11 +477,12 @@ NS_IMETHODIMP
DocObserver::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, DocObserver::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg) const nsString& aMsg)
{ {
fputs("[progress ", stdout);
fputs(mURL, stdout); fputs(mURL, stdout);
printf(" %d %d ", aProgress, aProgressMax); printf(": progress %d", aProgress);
fputs(aMsg, stdout); if (0 != aProgressMax) {
fputs("]\n", stdout); printf(" (out of %d)", aProgressMax);
}
fputs("\n", stdout);
return NS_OK; return NS_OK;
} }
@ -476,25 +490,21 @@ NS_IMETHODIMP
DocObserver::OnStartBinding(const char *aContentType) DocObserver::OnStartBinding(const char *aContentType)
{ {
//start the throbber... //start the throbber...
if (nsnull != mViewer) if (nsnull != mViewer)
mViewer->mUpdateThrobber = PR_TRUE; mViewer->mUpdateThrobber = PR_TRUE;
fputs("Loading ", stdout);
fputs(mURL, stdout); fputs(mURL, stdout);
fputs("\n", stdout); fputs(": start\n", stdout);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
DocObserver::OnStopBinding(PRInt32 status, const nsString& aMsg) DocObserver::OnStopBinding(PRInt32 status, const nsString& aMsg)
{ {
fputs("Done loading ", stdout);
fputs(mURL, stdout); fputs(mURL, stdout);
fputs("\n", stdout); fputs(": stop\n", stdout);
//stop the throbber... //stop the throbber...
if (nsnull != mViewer) if (nsnull != mViewer)
{ {
nsRect trect; nsRect trect;
@ -524,9 +534,10 @@ DocObserver::Embed(nsIDocumentWidget* aDocViewer,
aDocViewer->QueryInterface(kIWebWidgetIID, (void**)&mWebWidget); aDocViewer->QueryInterface(kIWebWidgetIID, (void**)&mWebWidget);
mWebWidget->SetContainer((nsIDocumentObserver*)this);
rv = mWebWidget->Init(mWindowWidget->GetNativeData(NS_NATIVE_WIDGET), rr); rv = mWebWidget->Init(mWindowWidget->GetNativeData(NS_NATIVE_WIDGET), rr);
mWebWidget->SetContainer((nsIDocumentObserver*)this);
// Associate a new document with our script global // Associate a new document with our script global
if (nsnull != mScriptGlobal) { if (nsnull != mScriptGlobal) {
nsIDOMDocument *domdoc; nsIDOMDocument *domdoc;
@ -544,13 +555,6 @@ DocObserver::Embed(nsIDocumentWidget* aDocViewer,
} }
mWebWidget->SetLinkHandler((nsILinkHandler*)this); mWebWidget->SetLinkHandler((nsILinkHandler*)this);
/// nsIURL* aURL = aDoc->GetDocumentURL();
/// if (aURL) {
/// mURL = aURL->GetSpec();
/// }
/// NS_IF_RELEASE(aURL);
mWebWidget->Show(); mWebWidget->Show();
return NS_OK; return NS_OK;
@ -589,10 +593,6 @@ DocObserver::HandleLinkClickEvent(const nsString& aURLSpec,
if (nsnull != mViewer) { if (nsnull != mViewer) {
mViewer->GoTo(aURLSpec, nsnull, this, aPostData, nsnull, this); mViewer->GoTo(aURLSpec, nsnull, this, aPostData, nsnull, this);
} }
/// if (nsnull != mWebWidget) {
/// nsIWebWidget* targetWidget = mWebWidget->GetTarget(aTargetSpec);
/// targetWidget->LoadURL(aURLSpec, (nsIStreamListener*)this, aPostData);
/// NS_RELEASE(targetWidget);
} }
} }
@ -1478,7 +1478,7 @@ void nsViewer::CleanupViewer(nsDocLoader* aDocLoader)
void void
nsViewer::ShowHistory() nsViewer::ShowHistory()
{ {
#if 0 #ifdef SHOW_HISTORY
PRInt32 i, n = mHistory.Count(); PRInt32 i, n = mHistory.Count();
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (i == mHistoryIndex) { if (i == mHistoryIndex) {
@ -1512,7 +1512,7 @@ nsViewer::Back()
mHistoryIndex--; mHistoryIndex--;
if (nsnull != mWD && nsnull != mWD->observer) { if (nsnull != mWD && nsnull != mWD->observer) {
nsString* s = (nsString*) mHistory.ElementAt(mHistoryIndex); nsString* s = (nsString*) mHistory.ElementAt(mHistoryIndex);
mWD->observer->mDocLoader->LoadURL(*s, nsnull, mWD->observer, mWD->observer->LoadURL(*s, nsnull, mWD->observer,
nsnull, nsnull, mWD->observer); nsnull, nsnull, mWD->observer);
} }
ShowHistory(); ShowHistory();
@ -1537,7 +1537,7 @@ nsViewer::Forward()
mHistoryIndex++; mHistoryIndex++;
if (nsnull != mWD && nsnull != mWD->observer) { if (nsnull != mWD && nsnull != mWD->observer) {
nsString* s = (nsString*) mHistory.ElementAt(mHistoryIndex); nsString* s = (nsString*) mHistory.ElementAt(mHistoryIndex);
mWD->observer->mDocLoader->LoadURL(*s, nsnull, mWD->observer, mWD->observer->LoadURL(*s, nsnull, mWD->observer,
nsnull, nsnull, mWD->observer); nsnull, nsnull, mWD->observer);
} }
ShowHistory(); ShowHistory();
@ -1575,7 +1575,7 @@ nsViewer::GoTo(const nsString& aURLSpec,
fputs(aURLSpec, stdout); fputs(aURLSpec, stdout);
printf("\n"); printf("\n");
rv = mWD->observer->mDocLoader->LoadURL(aURLSpec, // URL string rv = mWD->observer->LoadURL(aURLSpec, // URL string
aCommand, // Command aCommand, // Command
aContainer, // Container aContainer, // Container
aPostData, // Post Data aPostData, // Post Data
@ -1602,8 +1602,10 @@ nsViewer::GoingTo(const nsString& aURL)
mHistory.AppendElement(url); mHistory.AppendElement(url);
mHistoryIndex++; mHistoryIndex++;
#ifdef SHOW_HISTORY
printf("GoingTo: new history=\n"); printf("GoingTo: new history=\n");
ShowHistory(); ShowHistory();
#endif
} }
nsDocLoader* nsViewer::SetupViewer(nsIWidget **aMainWindow, int argc, char **argv) nsDocLoader* nsViewer::SetupViewer(nsIWidget **aMainWindow, int argc, char **argv)