зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
31c78e63fb
Коммит
5b9849d4fb
|
@ -70,7 +70,6 @@
|
|||
#include "nsIDocument.h"
|
||||
#include "nsILayoutDebugger.h"
|
||||
#include "nsThrobber.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeNode.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_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENTLOADEROBSERVER_IID);
|
||||
|
||||
#define FILE_PROTOCOL "file://"
|
||||
|
||||
#ifdef USE_LOCAL_WIDGETS
|
||||
|
@ -242,18 +239,9 @@ NS_IMETHODIMP nsBrowserWindow::Destroy()
|
|||
{
|
||||
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));
|
||||
docShellWin->Destroy();
|
||||
mDocShell = nsnull;
|
||||
// NS_RELEASE(mDocShell);
|
||||
}
|
||||
|
||||
nsrefcnt refCnt;
|
||||
|
||||
|
@ -1364,11 +1352,6 @@ nsBrowserWindow::QueryInterface(const nsIID& aIID,
|
|||
|
||||
*aInstancePtrResult = NULL;
|
||||
|
||||
if (aIID.Equals(kIDocumentLoaderObserverIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDocumentLoaderObserver*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIWebShellContainerIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIWebShellContainer*)this);
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -1435,14 +1418,8 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
|
|||
webBrowserWin->Create();
|
||||
mDocShell = do_GetInterface(mWebBrowser);
|
||||
mDocShell->SetAllowPlugins(aAllowPlugins);
|
||||
nsCOMPtr<nsIDocumentLoader> docLoader;
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
||||
webShell->SetContainer((nsIWebShellContainer*) this);
|
||||
|
||||
webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
|
||||
if (docLoader) {
|
||||
docLoader->AddObserver(this);
|
||||
}
|
||||
webBrowserWin->SetVisibility(PR_TRUE);
|
||||
|
||||
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
|
||||
|
@ -1519,13 +1496,8 @@ nsnull, r.x, r.y, r.width, r.height);
|
|||
webBrowserWin->Create();
|
||||
mDocShell = do_GetInterface(mWebBrowser);
|
||||
mDocShell->SetAllowPlugins(aAllowPlugins);
|
||||
nsCOMPtr<nsIDocumentLoader> docLoader;
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
||||
webShell->SetContainer((nsIWebShellContainer*) this);
|
||||
webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
|
||||
if (docLoader) {
|
||||
docLoader->AddObserver(this);
|
||||
}
|
||||
webBrowserWin->SetVisibility(PR_TRUE);
|
||||
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
|
||||
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
|
||||
nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt,
|
||||
PRUint32 aProgress, PRUint32 aProgressMax)
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocumentLoaderObserver.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsCRT.h"
|
||||
|
@ -68,7 +67,6 @@ class nsWebCrawler;
|
|||
* Abstract base class for our test app's browser windows
|
||||
*/
|
||||
class nsBrowserWindow : public nsIBaseWindow,
|
||||
public nsIDocumentLoaderObserver,
|
||||
public nsIProgressEventSink,
|
||||
public nsIWebShellContainer,
|
||||
public nsIPrompt
|
||||
|
@ -113,9 +111,6 @@ public:
|
|||
NS_IMETHOD GetWebShell(nsIWebShell*& aResult);
|
||||
NS_IMETHOD GetContentWebShell(nsIWebShell **aResult);
|
||||
|
||||
// nsIDocumentLoaderObserver
|
||||
NS_DECL_NSIDOCUMENTLOADEROBSERVER
|
||||
|
||||
// nsIProgressEventSink
|
||||
NS_DECL_NSIPROGRESSEVENTSINK
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@
|
|||
#include "nsIContentViewerFile.h"
|
||||
#include "nsIDocShell.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(kIFrameUtilIID, NS_IFRAME_UTIL_IID);
|
||||
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID);
|
||||
|
@ -206,7 +206,6 @@ nsWebCrawler::nsWebCrawler(nsViewerApp* aViewer)
|
|||
mPrinterTestType = 0;
|
||||
mIncludeStyleInfo = PR_TRUE;
|
||||
mLastWebShell = nsnull;
|
||||
mLastURL = nsnull;
|
||||
}
|
||||
|
||||
static void FreeStrings(nsVoidArray& aArray)
|
||||
|
@ -224,12 +223,13 @@ nsWebCrawler::~nsWebCrawler()
|
|||
FreeStrings(mSafeDomains);
|
||||
FreeStrings(mAvoidDomains);
|
||||
NS_IF_RELEASE(mLastWebShell);
|
||||
NS_IF_RELEASE(mLastURL);
|
||||
NS_IF_RELEASE(mBrowser);
|
||||
delete mVisited;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsWebCrawler, nsIDocumentLoaderObserver)
|
||||
NS_IMPL_ISUPPORTS2(nsWebCrawler,
|
||||
nsIWebProgressListener,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
void
|
||||
nsWebCrawler::DumpRegressionData(nsIWebShell* aWebShell,
|
||||
|
@ -314,10 +314,15 @@ nsWebCrawler::DumpRegressionData(nsIWebShell* aWebShell,
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
// nsIWebProgressListener implementation
|
||||
NS_IMETHODIMP
|
||||
nsWebCrawler::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL,
|
||||
const char* aCommand)
|
||||
{
|
||||
nsWebCrawler::OnStateChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 progressStateFlags,
|
||||
nsresult aStatus) {
|
||||
if (progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) {
|
||||
if (progressStateFlags & nsIWebProgressListener::STATE_START) {
|
||||
if (mDelay > 0) {
|
||||
if (mLastWebShell && mLastURL) {
|
||||
DumpRegressionData(mLastWebShell, mLastURL);
|
||||
|
@ -326,50 +331,33 @@ nsWebCrawler::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL,
|
|||
NS_IF_RELEASE(mLastWebShell);
|
||||
mBrowser->GetWebShell(mLastWebShell);
|
||||
|
||||
NS_IF_RELEASE(mLastURL);
|
||||
mLastURL = aURL;
|
||||
NS_ADDREF(mLastURL);
|
||||
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
|
||||
if (!channel) {
|
||||
NS_ASSERTION(channel, "no channel avail");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIRequest* request,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
(void) channel->GetURI(getter_AddRefs(uri));
|
||||
mLastURL = uri;
|
||||
}
|
||||
|
||||
if (progressStateFlags & nsIWebProgressListener::STATE_STOP) {
|
||||
nsresult rv;
|
||||
PRTime endLoadTime = PR_Now();
|
||||
|
||||
if (loader != mDocLoader.get()) {
|
||||
// This notifications is not for the "main" document...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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));
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
|
||||
rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (nsnull == aURL) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Ignore this notification unless its for the current url. That way
|
||||
// we skip over embedded webshell notifications (e.g. frame cells,
|
||||
// iframes, etc.)
|
||||
char* spec;
|
||||
aURL->GetSpec(&spec);
|
||||
uri->GetSpec(&spec);
|
||||
if (!spec) {
|
||||
nsCRT::free(spec);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -419,7 +407,7 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader,
|
|||
nsIWebShell* webShell;
|
||||
mBrowser->GetWebShell(webShell);
|
||||
if (webShell) {
|
||||
DumpRegressionData(webShell, aURL);
|
||||
DumpRegressionData(webShell, uri);
|
||||
NS_RELEASE(webShell);
|
||||
}
|
||||
}
|
||||
|
@ -453,39 +441,43 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader,
|
|||
if (mPostExit && (0 == mQueuedLoadURLs) && (0==mPendingURLs.Count())) {
|
||||
QueueExit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebCrawler::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIRequest* request)
|
||||
{
|
||||
return NS_OK;
|
||||
nsWebCrawler::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebCrawler::OnProgressURLLoad(nsIDocumentLoader* loader,
|
||||
nsIRequest* request,
|
||||
PRUint32 aProgress,
|
||||
PRUint32 aProgressMax)
|
||||
{
|
||||
return NS_OK;
|
||||
nsWebCrawler::OnLocationChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
nsIURI *location) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebCrawler::OnStatusURLLoad(nsIDocumentLoader* loader,
|
||||
nsIRequest* request,
|
||||
nsString& aMsg)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebCrawler::OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest* request,
|
||||
nsresult aStatus)
|
||||
{
|
||||
return NS_OK;
|
||||
nsWebCrawler::OnStatusChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* aMessage) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebCrawler::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 state) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
FILE*
|
||||
|
@ -595,9 +587,12 @@ nsWebCrawler::Start()
|
|||
nsIWebShell *shell = nsnull;
|
||||
mBrowser->GetWebShell(shell);
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(shell));
|
||||
docShell->SetDocLoaderObserver(this);
|
||||
shell->GetDocumentLoader(*getter_AddRefs(mDocLoader));
|
||||
NS_RELEASE(shell);
|
||||
nsCOMPtr<nsIWebProgress> progress(do_GetInterface(docShell));
|
||||
if (!progress) return;
|
||||
|
||||
(void) progress->AddProgressListener((nsIWebProgressListener*)this);
|
||||
|
||||
if (mPendingURLs.Count() >= 1) {
|
||||
mHaveURLList = PR_TRUE;
|
||||
// duplicate the last url if there is a delay since the regression data for the
|
||||
|
|
|
@ -24,11 +24,12 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsBrowserWindow.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIDocumentLoaderObserver.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
|
@ -38,7 +39,8 @@ class nsIPresShell;
|
|||
class nsViewerApp;
|
||||
class AtomHashTable;
|
||||
|
||||
class nsWebCrawler : public nsIDocumentLoaderObserver {
|
||||
class nsWebCrawler : public nsIWebProgressListener,
|
||||
public nsSupportsWeakReference {
|
||||
public:
|
||||
// Make a new web-crawler for the given viewer. Note: the web
|
||||
// crawler does not addref the viewer.
|
||||
|
@ -48,7 +50,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDocumentLoaderObserver
|
||||
NS_DECL_NSIDOCUMENTLOADEROBSERVER
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
// Add a url to load
|
||||
void AddURL(const nsString& aURL);
|
||||
|
@ -148,7 +150,6 @@ protected:
|
|||
|
||||
void PerformRegressionTest(const nsString& aOutputName);
|
||||
|
||||
nsCOMPtr<nsIDocumentLoader> mDocLoader;
|
||||
nsBrowserWindow* mBrowser;
|
||||
nsViewerApp* mViewer;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
@ -171,7 +172,7 @@ protected:
|
|||
PRInt32 mMaxPages;
|
||||
|
||||
nsString mCurrentURL;
|
||||
nsIURI* mLastURL;
|
||||
nsCOMPtr<nsIURI> mLastURL;
|
||||
nsIWebShell* mLastWebShell;
|
||||
|
||||
PRTime mStartLoad;
|
||||
|
|
Загрузка…
Ссылка в новой задаче