From dba2c241d4fe9c86e8fc2f2c7c2a76840035bf4e Mon Sep 17 00:00:00 2001 From: "buster%netscape.com" Date: Tue, 15 Sep 1998 18:06:19 +0000 Subject: [PATCH] added command line switches for setting window width and height --- webshell/tests/viewer/nsViewerApp.cpp | 22 ++++++++++++++++++++++ webshell/tests/viewer/nsWebCrawler.cpp | 20 +++++++++++++++++++- webshell/tests/viewer/nsWebCrawler.h | 17 +++++++++++++---- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/webshell/tests/viewer/nsViewerApp.cpp b/webshell/tests/viewer/nsViewerApp.cpp index d6d443b12fa2..bbc86aa87e4e 100644 --- a/webshell/tests/viewer/nsViewerApp.cpp +++ b/webshell/tests/viewer/nsViewerApp.cpp @@ -210,6 +210,8 @@ PrintHelpInfo(char **argv) fprintf(stderr, "\t-r # -- set the repeat count, which is the number of times the URLs will be loaded in batch mode.\n"); fprintf(stderr, "\t-f filename -- read a list of URLs from \n"); fprintf(stderr, "\t-o dirname -- create an output file for the frame dump of each page and put it in \n\t\t must include the trailing character appropriate for your OS\n"); + fprintf(stderr, "\t-h # -- the initial height of the viewer window."); + fprintf(stderr, "\t-w # -- the initial width of the viewer window."); fprintf(stderr, "\t-filter filtername -- make 'Dump Frames' command use the filter to alter the output.\n\t\tfiltername = none, dump all frames\n\t\tfiltername = table, dump only table frames\n"); fprintf(stderr, "\t-C -- enable crawler\n"); fprintf(stderr, "\t-R filename -- record pages visited in \n"); @@ -337,6 +339,26 @@ nsViewerApp::ProcessArguments(int argc, char** argv) } mCrawler->SetDelay(delay); } + else if (PL_strcmp(argv[i], "-w") == 0) { + int width; + i++; + if (i>=argc || 1!=sscanf(argv[i], "%d", &width)) + { + PrintHelpInfo(argv); + exit(-1); + } + mCrawler->SetWidth(width); + } + else if (PL_strcmp(argv[i], "-h") == 0) { + int height; + i++; + if (i>=argc || 1!=sscanf(argv[i], "%d", &height)) + { + PrintHelpInfo(argv); + exit(-1); + } + mCrawler->SetHeight(height); + } else if (PL_strcmp(argv[i], "-r") == 0) { i++; if (i>=argc || 1!=sscanf(argv[i], "%d", &mRepeatCount)) diff --git a/webshell/tests/viewer/nsWebCrawler.cpp b/webshell/tests/viewer/nsWebCrawler.cpp index af74a8a86d36..1d04bd33be84 100644 --- a/webshell/tests/viewer/nsWebCrawler.cpp +++ b/webshell/tests/viewer/nsWebCrawler.cpp @@ -152,6 +152,8 @@ nsWebCrawler::nsWebCrawler(nsViewerApp* aViewer) mOutputDir= nsnull; mPostExit = PR_FALSE; mDelay = 0; + mWidth = -1; + mHeight = -1; mMaxPages = -1; mRecord = nsnull; mLinkTag = NS_NewAtom("A"); @@ -569,6 +571,13 @@ nsWebCrawler::FindMoreURLs() } } +void +nsWebCrawler::SetBrowserWindow(nsIBrowserWindow* aWindow) +{ + mBrowser = aWindow; + NS_ADDREF(mBrowser); +} + static void TimerCallBack(nsITimer *aTimer, void *aClosure) { @@ -592,7 +601,16 @@ nsWebCrawler::LoadNextURL() if (nsnull != url) { if (OkToLoad(*url)) { RecordLoadedURL(*url); - + if (0<=mWidth || 0<=mHeight) + { + nsRect r; + mBrowser->GetBounds(r); + if (0<=mWidth) + r.width = mWidth; + if (0<=mHeight) + r.height = mHeight; + mBrowser->SizeTo(r.width, r.height); + } nsIWebShell* webShell; mBrowser->GetWebShell(webShell); webShell->LoadURL(*url); diff --git a/webshell/tests/viewer/nsWebCrawler.h b/webshell/tests/viewer/nsWebCrawler.h index 0c1b8bb33372..dc9931b2a76a 100644 --- a/webshell/tests/viewer/nsWebCrawler.h +++ b/webshell/tests/viewer/nsWebCrawler.h @@ -54,16 +54,23 @@ public: // Add a domain that must be avoided void AddAvoidDomain(const nsString& aDomain); - void SetBrowserWindow(nsIBrowserWindow* aWindow) { - mBrowser = aWindow; - NS_ADDREF(mBrowser); - } + void SetBrowserWindow(nsIBrowserWindow* aWindow); // Set the delay (by default, the timer is set to one second) void SetDelay(PRInt32 aSeconds) { mDelay = aSeconds; } + /** Set the initial window width */ + void SetWidth(PRInt32 aWidth) { + mWidth = aWidth; + } + + /** Set the initial window width */ + void SetHeight(PRInt32 aHeight) { + mHeight = aHeight; + } + void EnableJiggleLayout() { mJiggleLayout = PR_TRUE; } @@ -128,6 +135,8 @@ protected: PRBool mJiggleLayout; PRBool mPostExit; PRInt32 mDelay; + PRInt32 mWidth; + PRInt32 mHeight; PRInt32 mMaxPages; nsVoidArray mPendingURLs;