зеркало из https://github.com/mozilla/pjs.git
Moved crawling code into EndLoadURL; eliminated bogus cast that hid the fact that the class wasn't implementing nsIStreamObserver
This commit is contained in:
Родитель
afdd177714
Коммит
055c57aa80
|
@ -26,6 +26,7 @@
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
#include "nsIPresContext.h"
|
#include "nsIPresContext.h"
|
||||||
|
#include "nsIViewManager.h"
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsITimer.h"
|
#include "nsITimer.h"
|
||||||
|
@ -227,14 +228,40 @@ nsWebCrawler::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg)
|
||||||
fputs(tmp, stdout);
|
fputs(tmp, stdout);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsWebCrawler:: EndLoadURL(nsIWebShell* aShell,
|
||||||
|
const PRUnichar* aURL,
|
||||||
|
PRInt32 aStatus)
|
||||||
|
{
|
||||||
if (nsnull == aURL) {
|
if (nsnull == aURL) {
|
||||||
return NS_OK;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsAutoString tmp(aURL);
|
||||||
|
if (mVerbose) {
|
||||||
|
printf("Crawler: done loading ");
|
||||||
|
fputs(tmp, stdout);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the document bits make it to the screen at least once
|
||||||
|
nsIPresShell* shell = GetPresShell();
|
||||||
|
if (nsnull != shell) {
|
||||||
|
nsIViewManager* vm;
|
||||||
|
vm = shell->GetViewManager();
|
||||||
|
if (nsnull != vm) {
|
||||||
|
vm->EnableRefresh();
|
||||||
|
NS_RELEASE(vm);
|
||||||
|
}
|
||||||
|
NS_RELEASE(shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip url post-processing for non-document urls
|
// Skip url post-processing for non-document urls
|
||||||
if (!mCurrentURL.Equals(aURL->GetSpec())) {
|
if (!mCurrentURL.Equals(tmp)) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nsnull != mFilter) || (nsnull != mOutputDir)) {
|
if ((nsnull != mFilter) || (nsnull != mOutputDir)) {
|
||||||
|
@ -245,14 +272,19 @@ nsWebCrawler::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg)
|
||||||
nsIListFilter *filter = nsIFrame::GetFilter(mFilter);
|
nsIListFilter *filter = nsIFrame::GetFilter(mFilter);
|
||||||
if (nsnull!=mOutputDir)
|
if (nsnull!=mOutputDir)
|
||||||
{
|
{
|
||||||
FILE *fp = GetOutputFile(aURL);
|
nsIURL* url;
|
||||||
if (nsnull!=fp)
|
nsresult rv = NS_NewURL(&url, tmp);
|
||||||
{
|
if (NS_SUCCEEDED(rv) && (nsnull != url)) {
|
||||||
root->DumpRegressionData(fp, 0);
|
FILE *fp = GetOutputFile(url);
|
||||||
fclose(fp);
|
if (nsnull!=fp)
|
||||||
|
{
|
||||||
|
root->DumpRegressionData(fp, 0);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("could not open output file for %s\n", url->GetFile());
|
||||||
|
NS_RELEASE(url);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
printf("could not open output file for %s\n", aURL->GetFile());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
root->DumpRegressionData(stdout, 0);
|
root->DumpRegressionData(stdout, 0);
|
||||||
|
@ -285,8 +317,6 @@ nsWebCrawler::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg)
|
||||||
if (0 == mDelay) {
|
if (0 == mDelay) {
|
||||||
LoadNextURL();
|
LoadNextURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE * nsWebCrawler::GetOutputFile(nsIURL *aURL)
|
FILE * nsWebCrawler::GetOutputFile(nsIURL *aURL)
|
||||||
|
@ -372,7 +402,7 @@ nsWebCrawler::Start()
|
||||||
// Enable observing each URL load...
|
// Enable observing each URL load...
|
||||||
nsIWebShell* shell = nsnull;
|
nsIWebShell* shell = nsnull;
|
||||||
mBrowser->GetWebShell(shell);
|
mBrowser->GetWebShell(shell);
|
||||||
shell->SetObserver((nsIStreamObserver*)this);
|
shell->SetObserver(this);
|
||||||
|
|
||||||
LoadNextURL();
|
LoadNextURL();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче