Removed parser's knowledge of the Parser Debugger.

The Parser debugger has been moved out and renamed to DTDDebugger since this actually what it is doing.
I cant totally remove the DTDDebugger parameter passed to the parser under the DTD creation is somehow moved from the parser.
This commit is contained in:
jevering 1998-06-25 01:42:50 +00:00
Родитель c0bba18480
Коммит dc8bab4351
28 изменённых файлов: 342 добавлений и 134 удалений

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

@ -23,7 +23,7 @@
#include "nsString.h"
#include "nsIURL.h"
#include "nsIStreamListener.h"
#include "nsIParserDebug.h"
#include "nsIDTDDebug.h"
static NS_DEFINE_IID(kIRobotSinkObserverIID, NS_IROBOTSINKOBSERVER_IID);
@ -168,14 +168,14 @@ extern "C" NS_EXPORT int DebugRobot(
NS_ADDREF(myObserver);
g_workList = workList;
nsIParserDebug * pIParserDebug;
nsresult rval = NS_NewParserDebug(&pIParserDebug);
nsIDTDDebug * pIDTDDebug;
nsresult rval = NS_NewDTDDebug(&pIDTDDebug);
if (NS_OK != rval) {
fputs("Cannot create parser debugger.\n", stdout);
NS_RELEASE(myObserver);
return -1;
}
pIParserDebug->SetVerificationDirectory(verify_dir);
pIDTDDebug->SetVerificationDirectory(verify_dir);
for (;;) {
PRInt32 n = g_workList->Count();
@ -192,7 +192,7 @@ extern "C" NS_EXPORT int DebugRobot(
printf("invalid URL: '");
fputs(*urlName, stdout);
printf("'\n");
NS_RELEASE(pIParserDebug);
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -211,7 +211,7 @@ extern "C" NS_EXPORT int DebugRobot(
rv = NS_NewParser(&parser);
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(pIParserDebug);
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -220,7 +220,7 @@ extern "C" NS_EXPORT int DebugRobot(
rv = NS_NewRobotSink(&sink);
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(pIParserDebug);
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -229,7 +229,8 @@ extern "C" NS_EXPORT int DebugRobot(
parser->SetContentSink(sink);
g_bReadyForNextUrl = PR_FALSE;
parser->Parse(url, pl, pIParserDebug);/* XXX hook up stream listener here! */
parser->Parse(url, pl, pIDTDDebug);/* XXX hook up stream listener here! */
while (!g_bReadyForNextUrl) {
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
@ -253,8 +254,8 @@ extern "C" NS_EXPORT int DebugRobot(
NS_RELEASE(pl);
NS_RELEASE(myObserver);
pIParserDebug->DumpVectorRecord();
NS_RELEASE(pIParserDebug);
pIDTDDebug->DumpVectorRecord();
NS_RELEASE(pIDTDDebug);
return 0;
}

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

@ -31,7 +31,7 @@
*
*/
#include "nsIParserDebug.h"
#include "nsIDTDDebug.h"
#include "CNavDTD.h"
#include "nsHTMLTokens.h"
#include "nsCRT.h"
@ -233,7 +233,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mTokenDeque(gTokenKiller) {
NS_INIT_REFCNT();
mParser=0;
mFilename=0;
mParserDebug=0;
mDTDDebug=0;
nsCRT::zero(mLeafBits,sizeof(mLeafBits));
nsCRT::zero(mContextStack,sizeof(mContextStack));
nsCRT::zero(mStyleStack,sizeof(mStyleStack));
@ -257,18 +257,34 @@ CNavDTD::~CNavDTD(){
if (mFilename)
PL_strfree(mFilename);
if (mParserDebug)
NS_RELEASE(mParserDebug);
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
// NS_RELEASE(mSink);
}
/**
*
* @update jevering6/23/98
* @param
* @return
*/
void CNavDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
{
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
mDTDDebug = aDTDDebug;
if (mDTDDebug)
NS_ADDREF(mDTDDebug);
}
/**
*
* @update gess5/18/98
* @param
* @return
*/
PRInt32 CNavDTD::WillBuildModel(const char* aFilename, nsIParserDebug* aParserDebug){
PRInt32 CNavDTD::WillBuildModel(const char* aFilename){
PRInt32 result=0;
if (mFilename) {
@ -279,9 +295,6 @@ PRInt32 CNavDTD::WillBuildModel(const char* aFilename, nsIParserDebug* aParserDe
mFilename = PL_strdup(aFilename);
}
mParserDebug = aParserDebug;
NS_IF_ADDREF(mParserDebug);
if(mSink)
mSink->WillBuildModel();
@ -329,8 +342,8 @@ PRInt32 CNavDTD::HandleToken(CToken* aToken){
if(aHandler) {
result=(*aHandler)(theToken,this);
if (mParserDebug)
mParserDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
if (mDTDDebug)
mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
}
}//if

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

@ -42,7 +42,7 @@
class nsParser;
class nsIHTMLContentSink;
class nsIParserDebug;
class nsIDTDDebug;
class CNavDTD : public nsIDTD {
@ -69,13 +69,21 @@ class CNavDTD : public nsIDTD {
*/
virtual ~CNavDTD();
/**
*
* @update jevering6/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
/**
*
* @update gess5/18/98
* @param
* @return
*/
virtual PRInt32 WillBuildModel(const char* aFilename=0, nsIParserDebug* aParserDebug=0);
virtual PRInt32 WillBuildModel(const char* aFilename=0);
/**
*
@ -348,6 +356,8 @@ class CNavDTD : public nsIDTD {
*/
PRInt32 HandleStyleToken(CToken* aToken);
private:
/**
@ -680,7 +690,7 @@ protected:
PRBool mHasOpenMap;
nsDeque mTokenDeque;
char* mFilename;
nsIParserDebug* mParserDebug;
nsIDTDDebug* mDTDDebug;
};

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

@ -31,7 +31,7 @@
*
*/
#include "nsIParserDebug.h"
#include "nsIDTDDebug.h"
#include "COtherDTD.h"
#include "nsHTMLTokens.h"
#include "nsCRT.h"
@ -236,7 +236,7 @@ COtherDTD::COtherDTD() : nsIDTD(), mTokenDeque(gTokenKiller) {
NS_INIT_REFCNT();
mParser=0;
mFilename=0;
mParserDebug=0;
mDTDDebug=0;
nsCRT::zero(mLeafBits,sizeof(mLeafBits));
nsCRT::zero(mContextStack,sizeof(mContextStack));
nsCRT::zero(mStyleStack,sizeof(mStyleStack));
@ -259,18 +259,34 @@ COtherDTD::~COtherDTD(){
DeleteTokenHandlers();
if (mFilename)
PL_strfree(mFilename);
if (mParserDebug)
NS_RELEASE(mParserDebug);
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
// NS_RELEASE(mSink);
}
/**
*
* @update jevering6/23/98
* @param
* @return
*/
void COtherDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
{
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
mDTDDebug = aDTDDebug;
if (mDTDDebug)
NS_ADDREF(mDTDDebug);
}
/**
*
* @update gess5/18/98
* @param
* @return
*/
PRInt32 COtherDTD::WillBuildModel(const char* aFilename, nsIParserDebug* aParserDebug){
PRInt32 COtherDTD::WillBuildModel(const char* aFilename){
PRInt32 result=0;
if (mFilename) {
@ -281,9 +297,6 @@ PRInt32 COtherDTD::WillBuildModel(const char* aFilename, nsIParserDebug* aParser
mFilename = PL_strdup(aFilename);
}
mParserDebug = aParserDebug;
NS_IF_ADDREF(mParserDebug);
if(mSink)
mSink->WillBuildModel();
@ -330,8 +343,8 @@ PRInt32 COtherDTD::HandleToken(CToken* aToken){
if(aHandler) {
result=(*aHandler)(theToken,this);
if (mParserDebug)
mParserDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
if (mDTDDebug)
mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
}
}//if

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

@ -41,7 +41,7 @@
class nsParser;
class nsIHTMLContentSink;
class nsIParserDebug;
class nsIDTDDebug;
class COtherDTD : public nsIDTD {
@ -68,7 +68,13 @@ class COtherDTD : public nsIDTD {
*/
virtual ~COtherDTD();
/**
*
* @update jevering6/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
/**
*
@ -76,7 +82,7 @@ class COtherDTD : public nsIDTD {
* @param
* @return
*/
virtual PRInt32 WillBuildModel(const char* aFilename=0, nsIParserDebug* aIParserDebug=0);
virtual PRInt32 WillBuildModel(const char* aFilename=0);
/**
*
@ -681,7 +687,7 @@ protected:
PRBool mHasOpenMap;
nsDeque mTokenDeque;
char* mFilename;
nsIParserDebug* mParserDebug;
nsIDTDDebug* mDTDDebug;
};

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

@ -24,7 +24,7 @@ DEFINES = -D_IMPL_NS_HTMLPARS
CPPSRCS = \
nsHTMLContentSink.cpp \
nsParserNode.cpp \
nsParserDebug.cpp \
nsDTDDebug.cpp \
nsScanner.cpp \
nsToken.cpp \
nsTokenHandler.cpp \

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

@ -32,7 +32,7 @@ CPPSRCS=nsHTMLContentSink.cpp \
EXPORTS=nshtmlpars.h nsIContentSink.h nsIHTMLContentSink.h \
nsHTMLTokens.h nsIParserNode.h nsIParser.h nsToken.h \
nsIParserDebug.h nsIParserFilter.h
nsIDTDDebug.h nsIParserFilter.h
CPP_OBJS=.\$(OBJDIR)\nsHTMLContentSink.obj \
.\$(OBJDIR)\CNavDTD.obj \
@ -40,7 +40,7 @@ CPP_OBJS=.\$(OBJDIR)\nsHTMLContentSink.obj \
.\$(OBJDIR)\nsParser.obj \
.\$(OBJDIR)\nsHTMLTokens.obj .\$(OBJDIR)\nsParserNode.obj \
.\$(OBJDIR)\nsScanner.obj .\$(OBJDIR)\nsToken.obj \
.\$(OBJDIR)\nsTokenHandler.obj .\$(OBJDIR)\nsParserDebug.obj \
.\$(OBJDIR)\nsTokenHandler.obj .\$(OBJDIR)\nsDTDDebug.obj \
.\$(OBJDIR)\prstrm.obj
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\netlib

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

@ -37,7 +37,7 @@
class nsIParser;
class CToken;
class nsIContentSink;
class nsIParserDebug;
class nsIDTDDebug;
class nsIURL;
class nsIDTD : public nsISupports {
@ -69,7 +69,7 @@ class nsIDTD : public nsISupports {
* @param
* @return
*/
virtual PRInt32 WillBuildModel(const char* aFilename=0, nsIParserDebug* aParserDebug=0)=0;
virtual PRInt32 WillBuildModel(const char* aFilename=0)=0;
/**
*
@ -124,6 +124,13 @@ class nsIDTD : public nsISupports {
*/
virtual PRBool CanContain(PRInt32 aParent, PRInt32 aChild) = 0;
/**
*
* @update jevering6/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug) = 0;
};

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

@ -0,0 +1,57 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/**
* MODULE NOTES:
* @update gess 4/8/98
*
*
*/
#ifndef NS_IDTDDEBUG__
#define NS_IDTDDEBUG__
#include "nsISupports.h"
#include "nsHTMLTokens.h"
#include "prtypes.h"
#define NS_IDTDDEBUG_IID \
{0x7b68c220, 0x0685, 0x11d2, \
{0xa4, 0xb5, 0x00, 0x80, 0x5f, 0x2a, 0x0e, 0xd2}}
class nsIDTD;
class nsParser;
class nsIDTDDebug : public nsISupports {
public:
virtual void SetVerificationDirectory(char * verify_dir) = 0;
virtual void SetRecordStatistics(PRBool bval) = 0;
virtual PRBool Verify(nsIDTD * aDTD, nsParser * aParser, int ContextStackPos, eHTMLTags aContextStack[], char * aURLRef) = 0;
virtual void DumpVectorRecord(void) = 0;
};
extern NS_EXPORT nsresult NS_NewDTDDebug(nsIDTDDebug** aInstancePtrResult);
#endif /* NS_IDTDDEBUG__ */

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

@ -34,7 +34,7 @@ class nsString;
class CToken;
class nsIURL;
class nsIDTD;
class nsIParserDebug;
class nsIDTDDebug;
/**
* This class defines the iparser interface. This XPCOM
@ -48,6 +48,7 @@ class nsIParser : public nsISupports {
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
virtual void SetDTD(nsIDTD* aDTD)=0;
virtual nsIDTD* GetDTD(void)=0;
/**
@ -62,9 +63,9 @@ class nsIParser : public nsISupports {
virtual PRInt32 Parse(nsIURL* aURL,
nsIStreamListener* aListener,
nsIParserDebug * aDebug = 0) = 0;
nsIDTDDebug * aDTDDebug = 0) = 0;
virtual PRInt32 Parse(const char* aFilename,nsIParserDebug * aDebug = 0)=0;
virtual PRInt32 Parse(const char* aFilename)=0;
virtual PRInt32 Parse(nsString& anHTMLString,PRBool appendTokens)=0;

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

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

@ -30,7 +30,7 @@
#include <fstream.h>
#include "nsIInputStream.h"
#include "nsIParserFilter.h"
#include "nsIParserDebug.h"
#include "nsIDTDDebug.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kClassIID, NS_PARSER_IID);
@ -86,8 +86,8 @@ CTokenDeallocator gTokenKiller;
*/
nsParser::nsParser() : mTokenDeque(gTokenKiller) {
NS_INIT_REFCNT();
mDTDDebug = 0;
mParserFilter = 0;
mParserDebug = 0;
mListener = 0;
mTransferBuffer=0;
mSink=0;
@ -108,6 +108,7 @@ nsParser::nsParser() : mTokenDeque(gTokenKiller) {
*/
nsParser::~nsParser() {
NS_IF_RELEASE(mListener);
NS_IF_RELEASE(mDTDDebug);
if(mTransferBuffer)
delete [] mTransferBuffer;
mTransferBuffer=0;
@ -120,7 +121,6 @@ nsParser::~nsParser() {
mScanner=0;
NS_IF_RELEASE(mDTD);
NS_IF_RELEASE(mParserDebug);
NS_IF_RELEASE(mURL);
}
@ -334,16 +334,17 @@ PRBool nsParser::DetermineContentType(const char* aContentType) {
* @param
* @return
*/
PRInt32 nsParser::WillBuildModel(const char* aFilename, const char* aContentType, nsIParserDebug * aDebug){
PRInt32 nsParser::WillBuildModel(const char* aFilename, const char* aContentType){
mMajorIteration=-1;
mMinorIteration=-1;
mParseMode=DetermineParseMode();
mDTD=(0==mDTD) ? CreateDTD(mParseMode,aContentType) : mDTD;
if(mDTD) {
mDTD->SetDTDDebug(mDTDDebug);
mDTD->SetParser(this);
mDTD->SetContentSink(mSink);
mDTD->WillBuildModel(aFilename,mParserDebug);
mDTD->WillBuildModel(aFilename);
}
#ifdef DEBUG_SAVE_SOURCE_DOC
@ -394,20 +395,17 @@ PRInt32 nsParser::DidBuildModel(PRInt32 anErrorCode) {
* @param aFilename -- const char* containing file to be parsed.
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
*/
PRBool nsParser::Parse(const char* aFilename,nsIParserDebug* aParserDebug){
PRBool nsParser::Parse(const char* aFilename){
NS_PRECONDITION(0!=aFilename,kNullFilename);
PRInt32 status=kBadFilename;
if(aFilename) {
mParserDebug = aParserDebug;
NS_IF_ADDREF(mParserDebug);
//ok, time to create our tokenizer and begin the process
mScanner=new CScanner(aFilename,mParseMode);
char theContentType[600];
DetermineContentType(theContentType);
WillBuildModel(aFilename,theContentType,aParserDebug);
WillBuildModel(aFilename,theContentType);
status=ResumeParse();
DidBuildModel(status);
@ -429,14 +427,13 @@ PRBool nsParser::Parse(const char* aFilename,nsIParserDebug* aParserDebug){
* @param aFilename -- const char* containing file to be parsed.
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
*/
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamListener* aListener,nsIParserDebug* aParserDebug) {
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamListener* aListener, nsIDTDDebug * aDTDDebug) {
NS_PRECONDITION(0!=aURL,kNullURL);
PRInt32 status=kBadURL;
NS_IF_RELEASE(mParserDebug);
mParserDebug = aParserDebug;
NS_IF_ADDREF(mParserDebug);
mDTDDebug = aDTDDebug;
NS_IF_ADDREF(mDTDDebug);
NS_IF_RELEASE(mURL);
mURL = aURL;
@ -594,7 +591,7 @@ nsresult nsParser::OnStartBinding(const char* aContentType){
if (nsnull != mListener) {
mListener->OnStartBinding(aContentType);
}
nsresult result=WillBuildModel(mURL->GetSpec(),aContentType,mParserDebug);
nsresult result=WillBuildModel(mURL->GetSpec(),aContentType);
if(!mTransferBuffer) {
mTransferBuffer=new char[gTransferBufferSize+1];
}

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

@ -72,9 +72,9 @@ class IContentSink;
class nsIHTMLContentSink;
class nsIURL;
class nsIDTD;
class nsIDTDDebug;
class CScanner;
class nsIParserFilter;
class nsIParserDebug;
class nsParser : public nsIParser, public nsIStreamListener {
@ -129,8 +129,7 @@ friend class CTokenHandler;
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(nsIURL* aURL,
nsIStreamListener* aListener,
nsIParserDebug * aDebug = 0);
nsIStreamListener* aListener, nsIDTDDebug * aDTDDebug = 0);
/**
* Cause parser to parse input from given file in given mode
@ -139,7 +138,7 @@ friend class CTokenHandler;
* @param aMode is the desired parser mode (Nav, other, etc.)
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(const char* aFilename,nsIParserDebug * aDebug = 0);
virtual PRInt32 Parse(const char* aFilename);
/**
* @update gess5/11/98
@ -205,7 +204,7 @@ protected:
* @param
* @return
*/
PRInt32 WillBuildModel(const char* aFilename=0,const char* aContentType=0, nsIParserDebug* aDebug=0);
PRInt32 WillBuildModel(const char* aFilename=0,const char* aContentType=0);
/**
*
@ -324,8 +323,8 @@ protected:
nsDeque mTokenDeque;
CScanner* mScanner;
nsIParserDebug* mParserDebug;
nsIURL* mURL;
nsIDTDDebug* mDTDDebug;
};

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

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

@ -23,7 +23,7 @@
#include "nsString.h"
#include "nsIURL.h"
#include "nsIStreamListener.h"
#include "nsIParserDebug.h"
#include "nsIDTDDebug.h"
static NS_DEFINE_IID(kIRobotSinkObserverIID, NS_IROBOTSINKOBSERVER_IID);
@ -168,14 +168,14 @@ extern "C" NS_EXPORT int DebugRobot(
NS_ADDREF(myObserver);
g_workList = workList;
nsIParserDebug * pIParserDebug;
nsresult rval = NS_NewParserDebug(&pIParserDebug);
nsIDTDDebug * pIDTDDebug;
nsresult rval = NS_NewDTDDebug(&pIDTDDebug);
if (NS_OK != rval) {
fputs("Cannot create parser debugger.\n", stdout);
NS_RELEASE(myObserver);
return -1;
}
pIParserDebug->SetVerificationDirectory(verify_dir);
pIDTDDebug->SetVerificationDirectory(verify_dir);
for (;;) {
PRInt32 n = g_workList->Count();
@ -192,7 +192,7 @@ extern "C" NS_EXPORT int DebugRobot(
printf("invalid URL: '");
fputs(*urlName, stdout);
printf("'\n");
NS_RELEASE(pIParserDebug);
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -211,7 +211,7 @@ extern "C" NS_EXPORT int DebugRobot(
rv = NS_NewParser(&parser);
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(pIParserDebug);
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -220,7 +220,7 @@ extern "C" NS_EXPORT int DebugRobot(
rv = NS_NewRobotSink(&sink);
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(pIParserDebug);
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -229,7 +229,8 @@ extern "C" NS_EXPORT int DebugRobot(
parser->SetContentSink(sink);
g_bReadyForNextUrl = PR_FALSE;
parser->Parse(url, pl, pIParserDebug);/* XXX hook up stream listener here! */
parser->Parse(url, pl, pIDTDDebug);/* XXX hook up stream listener here! */
while (!g_bReadyForNextUrl) {
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
@ -253,8 +254,8 @@ extern "C" NS_EXPORT int DebugRobot(
NS_RELEASE(pl);
NS_RELEASE(myObserver);
pIParserDebug->DumpVectorRecord();
NS_RELEASE(pIParserDebug);
pIDTDDebug->DumpVectorRecord();
NS_RELEASE(pIDTDDebug);
return 0;
}

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

@ -31,7 +31,7 @@
*
*/
#include "nsIParserDebug.h"
#include "nsIDTDDebug.h"
#include "CNavDTD.h"
#include "nsHTMLTokens.h"
#include "nsCRT.h"
@ -233,7 +233,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mTokenDeque(gTokenKiller) {
NS_INIT_REFCNT();
mParser=0;
mFilename=0;
mParserDebug=0;
mDTDDebug=0;
nsCRT::zero(mLeafBits,sizeof(mLeafBits));
nsCRT::zero(mContextStack,sizeof(mContextStack));
nsCRT::zero(mStyleStack,sizeof(mStyleStack));
@ -257,18 +257,34 @@ CNavDTD::~CNavDTD(){
if (mFilename)
PL_strfree(mFilename);
if (mParserDebug)
NS_RELEASE(mParserDebug);
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
// NS_RELEASE(mSink);
}
/**
*
* @update jevering6/23/98
* @param
* @return
*/
void CNavDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
{
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
mDTDDebug = aDTDDebug;
if (mDTDDebug)
NS_ADDREF(mDTDDebug);
}
/**
*
* @update gess5/18/98
* @param
* @return
*/
PRInt32 CNavDTD::WillBuildModel(const char* aFilename, nsIParserDebug* aParserDebug){
PRInt32 CNavDTD::WillBuildModel(const char* aFilename){
PRInt32 result=0;
if (mFilename) {
@ -279,9 +295,6 @@ PRInt32 CNavDTD::WillBuildModel(const char* aFilename, nsIParserDebug* aParserDe
mFilename = PL_strdup(aFilename);
}
mParserDebug = aParserDebug;
NS_IF_ADDREF(mParserDebug);
if(mSink)
mSink->WillBuildModel();
@ -329,8 +342,8 @@ PRInt32 CNavDTD::HandleToken(CToken* aToken){
if(aHandler) {
result=(*aHandler)(theToken,this);
if (mParserDebug)
mParserDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
if (mDTDDebug)
mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
}
}//if

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

@ -42,7 +42,7 @@
class nsParser;
class nsIHTMLContentSink;
class nsIParserDebug;
class nsIDTDDebug;
class CNavDTD : public nsIDTD {
@ -69,13 +69,21 @@ class CNavDTD : public nsIDTD {
*/
virtual ~CNavDTD();
/**
*
* @update jevering6/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
/**
*
* @update gess5/18/98
* @param
* @return
*/
virtual PRInt32 WillBuildModel(const char* aFilename=0, nsIParserDebug* aParserDebug=0);
virtual PRInt32 WillBuildModel(const char* aFilename=0);
/**
*
@ -348,6 +356,8 @@ class CNavDTD : public nsIDTD {
*/
PRInt32 HandleStyleToken(CToken* aToken);
private:
/**
@ -680,7 +690,7 @@ protected:
PRBool mHasOpenMap;
nsDeque mTokenDeque;
char* mFilename;
nsIParserDebug* mParserDebug;
nsIDTDDebug* mDTDDebug;
};

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

@ -31,7 +31,7 @@
*
*/
#include "nsIParserDebug.h"
#include "nsIDTDDebug.h"
#include "COtherDTD.h"
#include "nsHTMLTokens.h"
#include "nsCRT.h"
@ -236,7 +236,7 @@ COtherDTD::COtherDTD() : nsIDTD(), mTokenDeque(gTokenKiller) {
NS_INIT_REFCNT();
mParser=0;
mFilename=0;
mParserDebug=0;
mDTDDebug=0;
nsCRT::zero(mLeafBits,sizeof(mLeafBits));
nsCRT::zero(mContextStack,sizeof(mContextStack));
nsCRT::zero(mStyleStack,sizeof(mStyleStack));
@ -259,18 +259,34 @@ COtherDTD::~COtherDTD(){
DeleteTokenHandlers();
if (mFilename)
PL_strfree(mFilename);
if (mParserDebug)
NS_RELEASE(mParserDebug);
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
// NS_RELEASE(mSink);
}
/**
*
* @update jevering6/23/98
* @param
* @return
*/
void COtherDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
{
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
mDTDDebug = aDTDDebug;
if (mDTDDebug)
NS_ADDREF(mDTDDebug);
}
/**
*
* @update gess5/18/98
* @param
* @return
*/
PRInt32 COtherDTD::WillBuildModel(const char* aFilename, nsIParserDebug* aParserDebug){
PRInt32 COtherDTD::WillBuildModel(const char* aFilename){
PRInt32 result=0;
if (mFilename) {
@ -281,9 +297,6 @@ PRInt32 COtherDTD::WillBuildModel(const char* aFilename, nsIParserDebug* aParser
mFilename = PL_strdup(aFilename);
}
mParserDebug = aParserDebug;
NS_IF_ADDREF(mParserDebug);
if(mSink)
mSink->WillBuildModel();
@ -330,8 +343,8 @@ PRInt32 COtherDTD::HandleToken(CToken* aToken){
if(aHandler) {
result=(*aHandler)(theToken,this);
if (mParserDebug)
mParserDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
if (mDTDDebug)
mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
}
}//if

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

@ -41,7 +41,7 @@
class nsParser;
class nsIHTMLContentSink;
class nsIParserDebug;
class nsIDTDDebug;
class COtherDTD : public nsIDTD {
@ -68,7 +68,13 @@ class COtherDTD : public nsIDTD {
*/
virtual ~COtherDTD();
/**
*
* @update jevering6/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
/**
*
@ -76,7 +82,7 @@ class COtherDTD : public nsIDTD {
* @param
* @return
*/
virtual PRInt32 WillBuildModel(const char* aFilename=0, nsIParserDebug* aIParserDebug=0);
virtual PRInt32 WillBuildModel(const char* aFilename=0);
/**
*
@ -681,7 +687,7 @@ protected:
PRBool mHasOpenMap;
nsDeque mTokenDeque;
char* mFilename;
nsIParserDebug* mParserDebug;
nsIDTDDebug* mDTDDebug;
};

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

@ -24,7 +24,7 @@ DEFINES = -D_IMPL_NS_HTMLPARS
CPPSRCS = \
nsHTMLContentSink.cpp \
nsParserNode.cpp \
nsParserDebug.cpp \
nsDTDDebug.cpp \
nsScanner.cpp \
nsToken.cpp \
nsTokenHandler.cpp \

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

@ -32,7 +32,7 @@ CPPSRCS=nsHTMLContentSink.cpp \
EXPORTS=nshtmlpars.h nsIContentSink.h nsIHTMLContentSink.h \
nsHTMLTokens.h nsIParserNode.h nsIParser.h nsToken.h \
nsIParserDebug.h nsIParserFilter.h
nsIDTDDebug.h nsIParserFilter.h
CPP_OBJS=.\$(OBJDIR)\nsHTMLContentSink.obj \
.\$(OBJDIR)\CNavDTD.obj \
@ -40,7 +40,7 @@ CPP_OBJS=.\$(OBJDIR)\nsHTMLContentSink.obj \
.\$(OBJDIR)\nsParser.obj \
.\$(OBJDIR)\nsHTMLTokens.obj .\$(OBJDIR)\nsParserNode.obj \
.\$(OBJDIR)\nsScanner.obj .\$(OBJDIR)\nsToken.obj \
.\$(OBJDIR)\nsTokenHandler.obj .\$(OBJDIR)\nsParserDebug.obj \
.\$(OBJDIR)\nsTokenHandler.obj .\$(OBJDIR)\nsDTDDebug.obj \
.\$(OBJDIR)\prstrm.obj
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\netlib

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

@ -37,7 +37,7 @@
class nsIParser;
class CToken;
class nsIContentSink;
class nsIParserDebug;
class nsIDTDDebug;
class nsIURL;
class nsIDTD : public nsISupports {
@ -69,7 +69,7 @@ class nsIDTD : public nsISupports {
* @param
* @return
*/
virtual PRInt32 WillBuildModel(const char* aFilename=0, nsIParserDebug* aParserDebug=0)=0;
virtual PRInt32 WillBuildModel(const char* aFilename=0)=0;
/**
*
@ -124,6 +124,13 @@ class nsIDTD : public nsISupports {
*/
virtual PRBool CanContain(PRInt32 aParent, PRInt32 aChild) = 0;
/**
*
* @update jevering6/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug) = 0;
};

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

@ -0,0 +1,57 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/**
* MODULE NOTES:
* @update gess 4/8/98
*
*
*/
#ifndef NS_IDTDDEBUG__
#define NS_IDTDDEBUG__
#include "nsISupports.h"
#include "nsHTMLTokens.h"
#include "prtypes.h"
#define NS_IDTDDEBUG_IID \
{0x7b68c220, 0x0685, 0x11d2, \
{0xa4, 0xb5, 0x00, 0x80, 0x5f, 0x2a, 0x0e, 0xd2}}
class nsIDTD;
class nsParser;
class nsIDTDDebug : public nsISupports {
public:
virtual void SetVerificationDirectory(char * verify_dir) = 0;
virtual void SetRecordStatistics(PRBool bval) = 0;
virtual PRBool Verify(nsIDTD * aDTD, nsParser * aParser, int ContextStackPos, eHTMLTags aContextStack[], char * aURLRef) = 0;
virtual void DumpVectorRecord(void) = 0;
};
extern NS_EXPORT nsresult NS_NewDTDDebug(nsIDTDDebug** aInstancePtrResult);
#endif /* NS_IDTDDEBUG__ */

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

@ -34,7 +34,7 @@ class nsString;
class CToken;
class nsIURL;
class nsIDTD;
class nsIParserDebug;
class nsIDTDDebug;
/**
* This class defines the iparser interface. This XPCOM
@ -48,6 +48,7 @@ class nsIParser : public nsISupports {
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
virtual void SetDTD(nsIDTD* aDTD)=0;
virtual nsIDTD* GetDTD(void)=0;
/**
@ -62,9 +63,9 @@ class nsIParser : public nsISupports {
virtual PRInt32 Parse(nsIURL* aURL,
nsIStreamListener* aListener,
nsIParserDebug * aDebug = 0) = 0;
nsIDTDDebug * aDTDDebug = 0) = 0;
virtual PRInt32 Parse(const char* aFilename,nsIParserDebug * aDebug = 0)=0;
virtual PRInt32 Parse(const char* aFilename)=0;
virtual PRInt32 Parse(nsString& anHTMLString,PRBool appendTokens)=0;

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

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

@ -30,7 +30,7 @@
#include <fstream.h>
#include "nsIInputStream.h"
#include "nsIParserFilter.h"
#include "nsIParserDebug.h"
#include "nsIDTDDebug.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kClassIID, NS_PARSER_IID);
@ -86,8 +86,8 @@ CTokenDeallocator gTokenKiller;
*/
nsParser::nsParser() : mTokenDeque(gTokenKiller) {
NS_INIT_REFCNT();
mDTDDebug = 0;
mParserFilter = 0;
mParserDebug = 0;
mListener = 0;
mTransferBuffer=0;
mSink=0;
@ -108,6 +108,7 @@ nsParser::nsParser() : mTokenDeque(gTokenKiller) {
*/
nsParser::~nsParser() {
NS_IF_RELEASE(mListener);
NS_IF_RELEASE(mDTDDebug);
if(mTransferBuffer)
delete [] mTransferBuffer;
mTransferBuffer=0;
@ -120,7 +121,6 @@ nsParser::~nsParser() {
mScanner=0;
NS_IF_RELEASE(mDTD);
NS_IF_RELEASE(mParserDebug);
NS_IF_RELEASE(mURL);
}
@ -334,16 +334,17 @@ PRBool nsParser::DetermineContentType(const char* aContentType) {
* @param
* @return
*/
PRInt32 nsParser::WillBuildModel(const char* aFilename, const char* aContentType, nsIParserDebug * aDebug){
PRInt32 nsParser::WillBuildModel(const char* aFilename, const char* aContentType){
mMajorIteration=-1;
mMinorIteration=-1;
mParseMode=DetermineParseMode();
mDTD=(0==mDTD) ? CreateDTD(mParseMode,aContentType) : mDTD;
if(mDTD) {
mDTD->SetDTDDebug(mDTDDebug);
mDTD->SetParser(this);
mDTD->SetContentSink(mSink);
mDTD->WillBuildModel(aFilename,mParserDebug);
mDTD->WillBuildModel(aFilename);
}
#ifdef DEBUG_SAVE_SOURCE_DOC
@ -394,20 +395,17 @@ PRInt32 nsParser::DidBuildModel(PRInt32 anErrorCode) {
* @param aFilename -- const char* containing file to be parsed.
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
*/
PRBool nsParser::Parse(const char* aFilename,nsIParserDebug* aParserDebug){
PRBool nsParser::Parse(const char* aFilename){
NS_PRECONDITION(0!=aFilename,kNullFilename);
PRInt32 status=kBadFilename;
if(aFilename) {
mParserDebug = aParserDebug;
NS_IF_ADDREF(mParserDebug);
//ok, time to create our tokenizer and begin the process
mScanner=new CScanner(aFilename,mParseMode);
char theContentType[600];
DetermineContentType(theContentType);
WillBuildModel(aFilename,theContentType,aParserDebug);
WillBuildModel(aFilename,theContentType);
status=ResumeParse();
DidBuildModel(status);
@ -429,14 +427,13 @@ PRBool nsParser::Parse(const char* aFilename,nsIParserDebug* aParserDebug){
* @param aFilename -- const char* containing file to be parsed.
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
*/
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamListener* aListener,nsIParserDebug* aParserDebug) {
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamListener* aListener, nsIDTDDebug * aDTDDebug) {
NS_PRECONDITION(0!=aURL,kNullURL);
PRInt32 status=kBadURL;
NS_IF_RELEASE(mParserDebug);
mParserDebug = aParserDebug;
NS_IF_ADDREF(mParserDebug);
mDTDDebug = aDTDDebug;
NS_IF_ADDREF(mDTDDebug);
NS_IF_RELEASE(mURL);
mURL = aURL;
@ -594,7 +591,7 @@ nsresult nsParser::OnStartBinding(const char* aContentType){
if (nsnull != mListener) {
mListener->OnStartBinding(aContentType);
}
nsresult result=WillBuildModel(mURL->GetSpec(),aContentType,mParserDebug);
nsresult result=WillBuildModel(mURL->GetSpec(),aContentType);
if(!mTransferBuffer) {
mTransferBuffer=new char[gTransferBufferSize+1];
}

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

@ -72,9 +72,9 @@ class IContentSink;
class nsIHTMLContentSink;
class nsIURL;
class nsIDTD;
class nsIDTDDebug;
class CScanner;
class nsIParserFilter;
class nsIParserDebug;
class nsParser : public nsIParser, public nsIStreamListener {
@ -129,8 +129,7 @@ friend class CTokenHandler;
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(nsIURL* aURL,
nsIStreamListener* aListener,
nsIParserDebug * aDebug = 0);
nsIStreamListener* aListener, nsIDTDDebug * aDTDDebug = 0);
/**
* Cause parser to parse input from given file in given mode
@ -139,7 +138,7 @@ friend class CTokenHandler;
* @param aMode is the desired parser mode (Nav, other, etc.)
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(const char* aFilename,nsIParserDebug * aDebug = 0);
virtual PRInt32 Parse(const char* aFilename);
/**
* @update gess5/11/98
@ -205,7 +204,7 @@ protected:
* @param
* @return
*/
PRInt32 WillBuildModel(const char* aFilename=0,const char* aContentType=0, nsIParserDebug* aDebug=0);
PRInt32 WillBuildModel(const char* aFilename=0,const char* aContentType=0);
/**
*
@ -324,8 +323,8 @@ protected:
nsDeque mTokenDeque;
CScanner* mScanner;
nsIParserDebug* mParserDebug;
nsIURL* mURL;
nsIDTDDebug* mDTDDebug;
};

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