r=waterson, sr=rpotts. part of 15345. removing unused nsIDocLoaderObserver from nsBrowserWindow and making the webcrawler use nsIWebProgressListener instead of nsIDocLoaderObserver which is depricated.

This commit is contained in:
valeski%netscape.com 2001-05-02 23:58:42 +00:00
Родитель 31c78e63fb
Коммит 5b9849d4fb
4 изменённых файлов: 171 добавлений и 257 удалений

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

@ -70,7 +70,6 @@
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsILayoutDebugger.h" #include "nsILayoutDebugger.h"
#include "nsThrobber.h" #include "nsThrobber.h"
#include "nsIDocumentLoader.h"
#include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h" #include "nsIDocShellTreeNode.h"
#include "nsIWebNavigation.h" #include "nsIWebNavigation.h"
@ -200,8 +199,6 @@ static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_IID(kILayoutDebuggerIID, NS_ILAYOUT_DEBUGGER_IID); static NS_DEFINE_IID(kILayoutDebuggerIID, NS_ILAYOUT_DEBUGGER_IID);
static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID); static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID);
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENTLOADEROBSERVER_IID);
#define FILE_PROTOCOL "file://" #define FILE_PROTOCOL "file://"
#ifdef USE_LOCAL_WIDGETS #ifdef USE_LOCAL_WIDGETS
@ -242,18 +239,9 @@ NS_IMETHODIMP nsBrowserWindow::Destroy()
{ {
RemoveBrowser(this); RemoveBrowser(this);
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
if(webShell) {
//XXXTAB Should do this on the docShell
nsCOMPtr<nsIDocumentLoader> docLoader;
webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
if(docLoader)
docLoader->RemoveObserver(this);
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell)); nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
docShellWin->Destroy(); docShellWin->Destroy();
mDocShell = nsnull; mDocShell = nsnull;
// NS_RELEASE(mDocShell);
}
nsrefcnt refCnt; nsrefcnt refCnt;
@ -1364,11 +1352,6 @@ nsBrowserWindow::QueryInterface(const nsIID& aIID,
*aInstancePtrResult = NULL; *aInstancePtrResult = NULL;
if (aIID.Equals(kIDocumentLoaderObserverIID)) {
*aInstancePtrResult = (void*) ((nsIDocumentLoaderObserver*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIWebShellContainerIID)) { if (aIID.Equals(kIWebShellContainerIID)) {
*aInstancePtrResult = (void*) ((nsIWebShellContainer*)this); *aInstancePtrResult = (void*) ((nsIWebShellContainer*)this);
NS_ADDREF_THIS(); NS_ADDREF_THIS();
@ -1435,14 +1418,8 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
webBrowserWin->Create(); webBrowserWin->Create();
mDocShell = do_GetInterface(mWebBrowser); mDocShell = do_GetInterface(mWebBrowser);
mDocShell->SetAllowPlugins(aAllowPlugins); mDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIDocumentLoader> docLoader;
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell)); nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
webShell->SetContainer((nsIWebShellContainer*) this); webShell->SetContainer((nsIWebShellContainer*) this);
webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
if (docLoader) {
docLoader->AddObserver(this);
}
webBrowserWin->SetVisibility(PR_TRUE); webBrowserWin->SetVisibility(PR_TRUE);
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) { if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
@ -1519,13 +1496,8 @@ nsnull, r.x, r.y, r.width, r.height);
webBrowserWin->Create(); webBrowserWin->Create();
mDocShell = do_GetInterface(mWebBrowser); mDocShell = do_GetInterface(mWebBrowser);
mDocShell->SetAllowPlugins(aAllowPlugins); mDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIDocumentLoader> docLoader;
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell)); nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
webShell->SetContainer((nsIWebShellContainer*) this); webShell->SetContainer((nsIWebShellContainer*) this);
webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
if (docLoader) {
docLoader->AddObserver(this);
}
webBrowserWin->SetVisibility(PR_TRUE); webBrowserWin->SetVisibility(PR_TRUE);
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) { if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
rv = CreateMenuBar(r.width); rv = CreateMenuBar(r.width);
@ -2112,55 +2084,6 @@ nsBrowserWindow::FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTak
//---------------------------------------- //----------------------------------------
// document loader observer implementation
NS_IMETHODIMP
nsBrowserWindow::OnStartDocumentLoad(nsIDocumentLoader* loader,
nsIURI* aURL,
const char* aCommand)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::OnEndDocumentLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsresult aStatus)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::OnStartURLLoad(nsIDocumentLoader* loader,
nsIRequest* request)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::OnProgressURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
PRUint32 aProgress,
PRUint32 aProgressMax)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::OnStatusURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsString& aMsg)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::OnEndURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsresult aStatus)
{
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt, nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt,
PRUint32 aProgress, PRUint32 aProgressMax) PRUint32 aProgress, PRUint32 aProgressMax)

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

@ -37,7 +37,6 @@
#include "nsIProgressEventSink.h" #include "nsIProgressEventSink.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsString.h" #include "nsString.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsCRT.h" #include "nsCRT.h"
@ -68,7 +67,6 @@ class nsWebCrawler;
* Abstract base class for our test app's browser windows * Abstract base class for our test app's browser windows
*/ */
class nsBrowserWindow : public nsIBaseWindow, class nsBrowserWindow : public nsIBaseWindow,
public nsIDocumentLoaderObserver,
public nsIProgressEventSink, public nsIProgressEventSink,
public nsIWebShellContainer, public nsIWebShellContainer,
public nsIPrompt public nsIPrompt
@ -113,9 +111,6 @@ public:
NS_IMETHOD GetWebShell(nsIWebShell*& aResult); NS_IMETHOD GetWebShell(nsIWebShell*& aResult);
NS_IMETHOD GetContentWebShell(nsIWebShell **aResult); NS_IMETHOD GetContentWebShell(nsIWebShell **aResult);
// nsIDocumentLoaderObserver
NS_DECL_NSIDOCUMENTLOADEROBSERVER
// nsIProgressEventSink // nsIProgressEventSink
NS_DECL_NSIPROGRESSEVENTSINK NS_DECL_NSIPROGRESSEVENTSINK

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

@ -58,8 +58,8 @@
#include "nsIContentViewerFile.h" #include "nsIContentViewerFile.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsIWebNavigation.h" #include "nsIWebNavigation.h"
#include "nsIWebProgress.h"
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENTLOADEROBSERVER_IID);
static NS_DEFINE_IID(kFrameUtilCID, NS_FRAME_UTIL_CID); static NS_DEFINE_IID(kFrameUtilCID, NS_FRAME_UTIL_CID);
static NS_DEFINE_IID(kIFrameUtilIID, NS_IFRAME_UTIL_IID); static NS_DEFINE_IID(kIFrameUtilIID, NS_IFRAME_UTIL_IID);
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID); static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID);
@ -206,7 +206,6 @@ nsWebCrawler::nsWebCrawler(nsViewerApp* aViewer)
mPrinterTestType = 0; mPrinterTestType = 0;
mIncludeStyleInfo = PR_TRUE; mIncludeStyleInfo = PR_TRUE;
mLastWebShell = nsnull; mLastWebShell = nsnull;
mLastURL = nsnull;
} }
static void FreeStrings(nsVoidArray& aArray) static void FreeStrings(nsVoidArray& aArray)
@ -224,12 +223,13 @@ nsWebCrawler::~nsWebCrawler()
FreeStrings(mSafeDomains); FreeStrings(mSafeDomains);
FreeStrings(mAvoidDomains); FreeStrings(mAvoidDomains);
NS_IF_RELEASE(mLastWebShell); NS_IF_RELEASE(mLastWebShell);
NS_IF_RELEASE(mLastURL);
NS_IF_RELEASE(mBrowser); NS_IF_RELEASE(mBrowser);
delete mVisited; delete mVisited;
} }
NS_IMPL_ISUPPORTS1(nsWebCrawler, nsIDocumentLoaderObserver) NS_IMPL_ISUPPORTS2(nsWebCrawler,
nsIWebProgressListener,
nsISupportsWeakReference)
void void
nsWebCrawler::DumpRegressionData(nsIWebShell* aWebShell, nsWebCrawler::DumpRegressionData(nsIWebShell* aWebShell,
@ -314,10 +314,15 @@ nsWebCrawler::DumpRegressionData(nsIWebShell* aWebShell,
#endif #endif
} }
// nsIWebProgressListener implementation
NS_IMETHODIMP NS_IMETHODIMP
nsWebCrawler::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, nsWebCrawler::OnStateChange(nsIWebProgress* aWebProgress,
const char* aCommand) nsIRequest *aRequest,
{ PRInt32 progressStateFlags,
nsresult aStatus) {
if (progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) {
if (progressStateFlags & nsIWebProgressListener::STATE_START) {
if (mDelay > 0) { if (mDelay > 0) {
if (mLastWebShell && mLastURL) { if (mLastWebShell && mLastURL) {
DumpRegressionData(mLastWebShell, mLastURL); DumpRegressionData(mLastWebShell, mLastURL);
@ -326,50 +331,33 @@ nsWebCrawler::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL,
NS_IF_RELEASE(mLastWebShell); NS_IF_RELEASE(mLastWebShell);
mBrowser->GetWebShell(mLastWebShell); mBrowser->GetWebShell(mLastWebShell);
NS_IF_RELEASE(mLastURL); nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
mLastURL = aURL; if (!channel) {
NS_ADDREF(mLastURL); NS_ASSERTION(channel, "no channel avail");
return NS_ERROR_FAILURE;
return NS_OK;
} }
NS_IMETHODIMP nsCOMPtr<nsIURI> uri;
nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader, (void) channel->GetURI(getter_AddRefs(uri));
nsIRequest* request, mLastURL = uri;
nsresult aStatus) }
{
if (progressStateFlags & nsIWebProgressListener::STATE_STOP) {
nsresult rv; nsresult rv;
PRTime endLoadTime = PR_Now(); PRTime endLoadTime = PR_Now();
if (loader != mDocLoader.get()) { nsCOMPtr<nsIURI> uri;
// This notifications is not for the "main" document... nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
return NS_OK; rv = channel->GetURI(getter_AddRefs(uri));
}
if (NS_BINDING_ABORTED == aStatus) {
//
// Sometimes a Refresh will interrupt a document that is loading...
// When this happens just ignore the ABORTED notification and wait
// for the notification that the Refreshed document has finished..
//
return NS_OK;
}
nsCOMPtr<nsIURI> aURL;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
rv = channel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
if (nsnull == aURL) {
return NS_OK;
}
// Ignore this notification unless its for the current url. That way // Ignore this notification unless its for the current url. That way
// we skip over embedded webshell notifications (e.g. frame cells, // we skip over embedded webshell notifications (e.g. frame cells,
// iframes, etc.) // iframes, etc.)
char* spec; char* spec;
aURL->GetSpec(&spec); uri->GetSpec(&spec);
if (!spec) { if (!spec) {
nsCRT::free(spec); nsCRT::free(spec);
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -419,7 +407,7 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader,
nsIWebShell* webShell; nsIWebShell* webShell;
mBrowser->GetWebShell(webShell); mBrowser->GetWebShell(webShell);
if (webShell) { if (webShell) {
DumpRegressionData(webShell, aURL); DumpRegressionData(webShell, uri);
NS_RELEASE(webShell); NS_RELEASE(webShell);
} }
} }
@ -453,39 +441,43 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader,
if (mPostExit && (0 == mQueuedLoadURLs) && (0==mPendingURLs.Count())) { if (mPostExit && (0 == mQueuedLoadURLs) && (0==mPendingURLs.Count())) {
QueueExit(); QueueExit();
} }
}
}
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWebCrawler::OnStartURLLoad(nsIDocumentLoader* loader, nsWebCrawler::OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest* request) nsIRequest *aRequest,
{ PRInt32 aCurSelfProgress,
return NS_OK; PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress) {
return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWebCrawler::OnProgressURLLoad(nsIDocumentLoader* loader, nsWebCrawler::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* request, nsIRequest* aRequest,
PRUint32 aProgress, nsIURI *location) {
PRUint32 aProgressMax) return NS_ERROR_NOT_IMPLEMENTED;
{
return NS_OK;
} }
NS_IMETHODIMP
nsWebCrawler::OnStatusURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsString& aMsg)
{
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsWebCrawler::OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest* request, nsWebCrawler::OnStatusChange(nsIWebProgress* aWebProgress,
nsresult aStatus) nsIRequest* aRequest,
{ nsresult aStatus,
return NS_OK; const PRUnichar* aMessage) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsWebCrawler::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 state) {
return NS_ERROR_NOT_IMPLEMENTED;
} }
FILE* FILE*
@ -595,9 +587,12 @@ nsWebCrawler::Start()
nsIWebShell *shell = nsnull; nsIWebShell *shell = nsnull;
mBrowser->GetWebShell(shell); mBrowser->GetWebShell(shell);
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(shell)); nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(shell));
docShell->SetDocLoaderObserver(this);
shell->GetDocumentLoader(*getter_AddRefs(mDocLoader));
NS_RELEASE(shell); NS_RELEASE(shell);
nsCOMPtr<nsIWebProgress> progress(do_GetInterface(docShell));
if (!progress) return;
(void) progress->AddProgressListener((nsIWebProgressListener*)this);
if (mPendingURLs.Count() >= 1) { if (mPendingURLs.Count() >= 1) {
mHaveURLList = PR_TRUE; mHaveURLList = PR_TRUE;
// duplicate the last url if there is a delay since the regression data for the // duplicate the last url if there is a delay since the regression data for the

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

@ -24,11 +24,12 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsBrowserWindow.h" #include "nsBrowserWindow.h"
#include "nsIDocumentLoader.h" #include "nsIWebProgressListener.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsString.h" #include "nsString.h"
#include "nsIAtom.h" #include "nsIAtom.h"
#include "nsWeakReference.h"
class nsIContent; class nsIContent;
class nsIDocument; class nsIDocument;
@ -38,7 +39,8 @@ class nsIPresShell;
class nsViewerApp; class nsViewerApp;
class AtomHashTable; class AtomHashTable;
class nsWebCrawler : public nsIDocumentLoaderObserver { class nsWebCrawler : public nsIWebProgressListener,
public nsSupportsWeakReference {
public: public:
// Make a new web-crawler for the given viewer. Note: the web // Make a new web-crawler for the given viewer. Note: the web
// crawler does not addref the viewer. // crawler does not addref the viewer.
@ -48,7 +50,7 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
// nsIDocumentLoaderObserver // nsIDocumentLoaderObserver
NS_DECL_NSIDOCUMENTLOADEROBSERVER NS_DECL_NSIWEBPROGRESSLISTENER
// Add a url to load // Add a url to load
void AddURL(const nsString& aURL); void AddURL(const nsString& aURL);
@ -148,7 +150,6 @@ protected:
void PerformRegressionTest(const nsString& aOutputName); void PerformRegressionTest(const nsString& aOutputName);
nsCOMPtr<nsIDocumentLoader> mDocLoader;
nsBrowserWindow* mBrowser; nsBrowserWindow* mBrowser;
nsViewerApp* mViewer; nsViewerApp* mViewer;
nsCOMPtr<nsITimer> mTimer; nsCOMPtr<nsITimer> mTimer;
@ -171,7 +172,7 @@ protected:
PRInt32 mMaxPages; PRInt32 mMaxPages;
nsString mCurrentURL; nsString mCurrentURL;
nsIURI* mLastURL; nsCOMPtr<nsIURI> mLastURL;
nsIWebShell* mLastWebShell; nsIWebShell* mLastWebShell;
PRTime mStartLoad; PRTime mStartLoad;