This commit is contained in:
jevering 1998-05-19 19:06:59 +00:00
Родитель f4fdc83aaf
Коммит 480da7ee1f
9 изменённых файлов: 181 добавлений и 17 удалений

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

@ -37,6 +37,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD ProcessLink(const nsString& aURLSpec);
NS_IMETHOD VerifyDirectory (const char * verify_dir);
};
@ -48,6 +49,11 @@ static PRBool g_bHitTop;
NS_IMPL_ISUPPORTS(RobotSinkObserver, kIRobotSinkObserverIID);
NS_IMETHODIMP RobotSinkObserver::VerifyDirectory(const char * verify_dir)
{
return NS_OK;
}
NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec)
{
if (!g_bHitTop) {
@ -92,16 +98,25 @@ NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec)
return NS_OK;
}
//----------------------------------------------------------------------
extern "C" NS_EXPORT void SetVerificationDirectory(char * verify_dir);
extern "C" NS_EXPORT int DebugRobot(nsVoidArray * workList, nsIWebWidget * ww)
//----------------------------------------------------------------------
extern "C" NS_EXPORT int DebugRobot(
nsVoidArray * workList,
nsIWebWidget * ww,
int iMaxLoads,
char * verify_dir,
void (*yieldProc )(const char *)
)
{
if (nsnull==workList)
return -1;
g_iMaxProcess = iMaxLoads;
g_iProcessed = 0;
g_bHitTop = PR_FALSE;
g_duplicateList = new nsVoidArray();
RobotSinkObserver* myObserver = new RobotSinkObserver();
SetVerificationDirectory(verify_dir);
NS_ADDREF(myObserver);
g_workList = workList;
@ -142,6 +157,8 @@ extern "C" NS_EXPORT int DebugRobot(nsVoidArray * workList, nsIWebWidget * ww)
parser->SetContentSink(sink);
parser->Parse(url);
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
if (ww)
ww->LoadURL(url->GetSpec());
NS_RELEASE(sink);

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

@ -29,6 +29,7 @@ class nsString;
class nsIRobotSinkObserver : public nsISupports {
public:
NS_IMETHOD ProcessLink(const nsString& aURLSpec) = 0;
NS_IMETHOD VerifyDirectory(const char * verify_dir) = 0;
};
#endif /* nsIRobotSinkObserver_h___ */

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

@ -388,6 +388,25 @@ PRBool VerifyContextVector(PRInt32 aTags[],PRInt32 count,nsIDTD* aDTD) {
return result;
}
/**
* This debug routine sets the verification directory. It overrides
* the value from PR_GetEnv()
*
* @update jevering 5/19/98
* @param
* @return
*/
#if defined(NS_DEBUG)
extern "C" NS_EXPORT void SetVerificationDirectory(char * verify_dir)
{
if (verify_dir && PL_strlen(verify_dir))
gVerificationOutputDir = verify_dir;
else
gVerificationOutputDir = NULL;
}
#endif /* NS_DEBUG */
/**
* This is where we loop over the tokens created in the

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

@ -37,6 +37,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD ProcessLink(const nsString& aURLSpec);
NS_IMETHOD VerifyDirectory (const char * verify_dir);
};
@ -48,6 +49,11 @@ static PRBool g_bHitTop;
NS_IMPL_ISUPPORTS(RobotSinkObserver, kIRobotSinkObserverIID);
NS_IMETHODIMP RobotSinkObserver::VerifyDirectory(const char * verify_dir)
{
return NS_OK;
}
NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec)
{
if (!g_bHitTop) {
@ -92,16 +98,25 @@ NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec)
return NS_OK;
}
//----------------------------------------------------------------------
extern "C" NS_EXPORT void SetVerificationDirectory(char * verify_dir);
extern "C" NS_EXPORT int DebugRobot(nsVoidArray * workList, nsIWebWidget * ww)
//----------------------------------------------------------------------
extern "C" NS_EXPORT int DebugRobot(
nsVoidArray * workList,
nsIWebWidget * ww,
int iMaxLoads,
char * verify_dir,
void (*yieldProc )(const char *)
)
{
if (nsnull==workList)
return -1;
g_iMaxProcess = iMaxLoads;
g_iProcessed = 0;
g_bHitTop = PR_FALSE;
g_duplicateList = new nsVoidArray();
RobotSinkObserver* myObserver = new RobotSinkObserver();
SetVerificationDirectory(verify_dir);
NS_ADDREF(myObserver);
g_workList = workList;
@ -142,6 +157,8 @@ extern "C" NS_EXPORT int DebugRobot(nsVoidArray * workList, nsIWebWidget * ww)
parser->SetContentSink(sink);
parser->Parse(url);
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
if (ww)
ww->LoadURL(url->GetSpec());
NS_RELEASE(sink);

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

@ -29,6 +29,7 @@ class nsString;
class nsIRobotSinkObserver : public nsISupports {
public:
NS_IMETHOD ProcessLink(const nsString& aURLSpec) = 0;
NS_IMETHOD VerifyDirectory(const char * verify_dir) = 0;
};
#endif /* nsIRobotSinkObserver_h___ */

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

@ -388,6 +388,25 @@ PRBool VerifyContextVector(PRInt32 aTags[],PRInt32 count,nsIDTD* aDTD) {
return result;
}
/**
* This debug routine sets the verification directory. It overrides
* the value from PR_GetEnv()
*
* @update jevering 5/19/98
* @param
* @return
*/
#if defined(NS_DEBUG)
extern "C" NS_EXPORT void SetVerificationDirectory(char * verify_dir)
{
if (verify_dir && PL_strlen(verify_dir))
gVerificationOutputDir = verify_dir;
else
gVerificationOutputDir = NULL;
}
#endif /* NS_DEBUG */
/**
* This is where we loop over the tokens created in the

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

@ -44,7 +44,6 @@
#define VIEWER_DUMP_STYLE_SHEETS 40025
#define VIEWER_DUMP_STYLE_CONTEXTS 40026
#define VIEWER_DEBUGROBOT 40027
#define VIEWER_DEBUGROBOT_UPDATE 40028
// Note: must be in ascending sequential order
#define VIEWER_ONE_COLUMN 40031
@ -59,4 +58,12 @@
#define VIEWER_EDIT_SELECTALL 40204
#define VIEWER_EDIT_FINDINPAGE 40205
/* Debug Robot dialog setup */
#define IDD_DEBUGROBOT 101
#define IDC_UPDATE_DISPLAY 40301
#define IDC_VERIFICATION_DIRECTORY 40302
#define IDC_PAGE_LOADS 40303
#define IDC_STATIC -1
#endif /* resources_h___ */

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

@ -69,7 +69,6 @@ VIEWER MENU DISCARDABLE
MENUITEM "Dump &Style Contexts", VIEWER_DUMP_STYLE_CONTEXTS
MENUITEM SEPARATOR
MENUITEM "Debu&g Robot", VIEWER_DEBUGROBOT
MENUITEM "&Visual Debug Robot", VIEWER_DEBUGROBOT_UPDATE
}
POPUP "&Tools"
{
@ -136,3 +135,20 @@ BEGIN
VK_F5, ID_COMMANDSEVALALL, VIRTKEY
VK_F10, ID_COMMANDSEVALSEL, VIRTKEY
END
IDD_DEBUGROBOT DIALOG DISCARDABLE 0, 0, 246, 84
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Debug Robot Options"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "&Start",IDOK,67,57,50,14
PUSHBUTTON "&Cancel",IDCANCEL,127,57,50,14
CONTROL "&Update Display (Visual)",IDC_UPDATE_DISPLAY,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,7,98,10
EDITTEXT IDC_VERIFICATION_DIRECTORY,77,19,159,14,ES_AUTOHSCROLL
EDITTEXT IDC_PAGE_LOADS,41,36,40,14,ES_AUTOHSCROLL
LTEXT "&Verification Directory",IDC_STATIC,7,21,70,8
LTEXT "&Stop after",IDC_STATIC,7,38,32,8
LTEXT "page loads",IDC_STATIC,84,38,36,8
END

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

@ -46,12 +46,14 @@
#include "nsViewsCID.h"
#include "nsString.h"
#include "plevent.h"
#include "prenv.h"
#include <malloc.h>
#include "nsIScriptContext.h"
#include "nsDocLoader.h"
// DebugRobot call
extern "C" NS_EXPORT int DebugRobot(nsVoidArray * workList, nsIWebWidget * ww);
extern "C" NS_EXPORT int DebugRobot(
nsVoidArray * workList, nsIWebWidget * ww, int imax, char * verify_dir, void (*yieldProc)(const char *));
// Selection Repaint includes
#include "nsIPresShell.h"
@ -71,6 +73,13 @@ static HANDLE gInstance, gPrevInstance;
static char* startURL;
static nsVoidArray* gWindows;
// Debug Robot options
static int gDebugRobotLoads = 5000;
static char gVerifyDir[_MAX_PATH];
static BOOL gVisualDebug = TRUE;
#define DEBUG_EMPTY "(none)"
// Temporary Netlib stuff...
/* XXX: Don't include net.h... */
extern "C" {
@ -375,11 +384,16 @@ CopyTextContent(WindowData* wd, HWND aHWnd)
}
}
void yieldProc(const char * str)
{
}
long PASCAL
WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam)
{
HMENU hMenu;
PRBool bVisual = PR_FALSE;
BOOL CreateRobotDialog(HWND hParent);
if (msg == WM_CREATE) {
LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lparam;
@ -468,21 +482,25 @@ WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam)
wd->ww->DumpStyleContexts();
}
break;
case VIEWER_DEBUGROBOT_UPDATE:
bVisual = PR_TRUE;
case VIEWER_DEBUGROBOT:
if ((nsnull != wd) && (nsnull != wd->ww)) {
nsIDocument* doc = wd->ww->GetDocument();
if (nsnull!=doc) {
const char * str = doc->GetDocumentURL()->GetSpec();
nsVoidArray * gWorkList = new nsVoidArray();
gWorkList->AppendElement(new nsString(str));
DebugRobot(gWorkList, bVisual ? wd->ww : nsnull);
if (CreateRobotDialog(hWnd))
{
nsIDocument* doc = wd->ww->GetDocument();
if (nsnull!=doc) {
const char * str = doc->GetDocumentURL()->GetSpec();
nsVoidArray * gWorkList = new nsVoidArray();
gWorkList->AppendElement(new nsString(str));
DebugRobot(
gWorkList,
gVisualDebug ? wd->ww : nsnull,
gDebugRobotLoads,
PL_strdup(gVerifyDir),
yieldProc);
}
}
}
break;
case VIEWER_ONE_COLUMN:
case VIEWER_TWO_COLUMN:
case VIEWER_THREE_COLUMN:
@ -740,6 +758,53 @@ WinMain(HANDLE instance, HANDLE prevInstance, LPSTR cmdParam, int nCmdShow)
return msg.wParam;
}
/* Debug Robot Dialog options */
BOOL CALLBACK DlgProc(HWND hDlg, UINT msg, WPARAM wParam,LPARAM lParam)
{
BOOL translated = FALSE;
HWND hwnd;
switch (msg)
{
case WM_INITDIALOG:
{
SetDlgItemInt(hDlg,IDC_PAGE_LOADS,5000,FALSE);
char * text = PR_GetEnv("VERIFY_PARSER");
SetDlgItemText(hDlg,IDC_VERIFICATION_DIRECTORY,text ? text : DEBUG_EMPTY);
hwnd = GetDlgItem(hDlg,IDC_UPDATE_DISPLAY);
SendMessage(hwnd,BM_SETCHECK,TRUE,0);
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
gDebugRobotLoads = GetDlgItemInt(hDlg,IDC_PAGE_LOADS,&translated,FALSE);
GetDlgItemText(hDlg, IDC_VERIFICATION_DIRECTORY, gVerifyDir, sizeof(gVerifyDir));
if (!strcmp(gVerifyDir,DEBUG_EMPTY))
gVerifyDir[0] = '\0';
hwnd = GetDlgItem(hDlg,IDC_UPDATE_DISPLAY);
gVisualDebug = (BOOL)SendMessage(hwnd,BM_GETCHECK,0,0);
EndDialog(hDlg,IDOK);
break;
case IDCANCEL:
EndDialog(hDlg,IDCANCEL);
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
BOOL CreateRobotDialog(HWND hParent)
{
BOOL result = (DialogBox(gInstance,MAKEINTRESOURCE(IDD_DEBUGROBOT),hParent,(DLGPROC)DlgProc) == IDOK);
return result;
}
void main(int argc, char **argv)
{
if (argc > 1) {
@ -747,3 +812,5 @@ void main(int argc, char **argv)
}
WinMain(GetModuleHandle(NULL), NULL, 0, SW_SHOW);
}