fixed attribute bug and factored DTDDebug interfaces

This commit is contained in:
rickg%netscape.com 1998-07-29 23:43:20 +00:00
parent e7be25b42f
commit 36395151d9
36 changed files with 396 additions and 246 deletions

View File

@ -169,6 +169,7 @@ extern "C" NS_EXPORT int DebugRobot(
NS_ADDREF(myObserver);
g_workList = workList;
/*
nsIDTDDebug * pIDTDDebug;
nsresult rval = NS_NewDTDDebug(&pIDTDDebug);
if (NS_OK != rval) {
@ -177,6 +178,7 @@ extern "C" NS_EXPORT int DebugRobot(
return -1;
}
pIDTDDebug->SetVerificationDirectory(verify_dir);
*/
for (;;) {
PRInt32 n = g_workList->Count();
@ -193,7 +195,6 @@ extern "C" NS_EXPORT int DebugRobot(
printf("invalid URL: '");
fputs(*urlName, stdout);
printf("'\n");
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -212,7 +213,6 @@ extern "C" NS_EXPORT int DebugRobot(
rv = NS_NewParser(&parser);
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -221,7 +221,6 @@ extern "C" NS_EXPORT int DebugRobot(
rv = NS_NewRobotSink(&sink);
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -229,9 +228,9 @@ extern "C" NS_EXPORT int DebugRobot(
sink->AddObserver(myObserver);
parser->SetContentSink(sink);
g_bReadyForNextUrl = PR_FALSE;
g_bReadyForNextUrl = PR_FALSE;
parser->Parse(url, pl, pIDTDDebug);/* XXX hook up stream listener here! */
parser->Parse(url, pl,PR_TRUE);/* XXX hook up stream listener here! */
while (!g_bReadyForNextUrl) {
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
@ -256,8 +255,8 @@ extern "C" NS_EXPORT int DebugRobot(
NS_RELEASE(pl);
NS_RELEASE(myObserver);
pIDTDDebug->DumpVectorRecord();
NS_RELEASE(pIDTDDebug);
// pIDTDDebug->DumpVectorRecord();
//NS_RELEASE(pIDTDDebug);
return 0;
}

View File

@ -27,7 +27,7 @@
#include "nsParserTypes.h"
#include "nsVoidArray.h"
#include "nsTokenHandler.h"
#include "nsIDTDDebug.h"
#include "prenv.h" //this is here for debug reasons...
#include "prtypes.h" //this is here for debug reasons...
#include "prio.h"
@ -48,6 +48,7 @@ static NS_DEFINE_IID(kClassIID, NS_INAVHTML_DTD_IID);
static const char* kNullToken = "Error: Null token given";
static const char* kInvalidTagStackPos = "Error: invalid tag stack position";
static const char* kHTMLTextContentType = "text/html";
static char* kVerificationDir = "c:/temp";
static nsAutoString gEmpty;
@ -372,22 +373,29 @@ nsresult CNavDTD::CreateNewInstance(nsIDTD** aInstancePtrResult){
}
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool CNavDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
void CNavDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
{
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
mDTDDebug = aDTDDebug;
if (mDTDDebug)
NS_ADDREF(mDTDDebug);
if(!mDTDDebug){;
nsresult rval = NS_NewDTDDebug(&mDTDDebug);
if (NS_OK != rval) {
fputs("Cannot create parser debugger.\n", stdout);
result=-PR_FALSE;
}
else mDTDDebug->SetVerificationDirectory(kVerificationDir);
}
if(mDTDDebug) {
mDTDDebug->Verify(this,mParser,mContextStack.mCount,mContextStack.mTags,aURLRef);
}
return result;
}
/**
* This method is called to determine if the given DTD can parse
* a document in a given source-type.
@ -451,6 +459,9 @@ nsresult CNavDTD::DidBuildModel(PRInt32 anErrorCode,PRBool aNotifySink){
result = mSink->DidBuildModel(1);
}
if(mDTDDebug) {
mDTDDebug->DumpVectorRecord();
}
return result;
}

View File

@ -207,12 +207,15 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
virtual eAutoDetectResult AutoDetectContentType(nsString& aBuffer,nsString& aType);
/**
* Sets a debugger into the DTD to help up debug the process.
* @update jevering6/23/98
* @param aDTDDedug is a ptr to the debug object you want us to use
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* The parser uses a code sandwich to wrap the parsing process. Before
* the process begins, WillBuildModel() is called. Afterwards the parser
@ -603,6 +606,7 @@ protected:
nsString mFilename;
nsIDTDDebug* mDTDDebug;
PRInt32 mLineNumber;
};
extern NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult);

View File

@ -440,12 +440,25 @@ nsresult CRtfDTD::WillInterruptParse(void){
}
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CRtfDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) {
PRBool CRtfDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
return result;
}
/**
* Called by the parser to enable/disable dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CRtfDTD::SetVerification(PRBool aEnabled){
}
/**

View File

@ -319,12 +319,22 @@ class CRtfDTD : public nsIDTD {
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
/**
* This method is called to determine whether or not a tag

View File

@ -859,7 +859,7 @@ nsresult CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
//now it's time to Consume the (optional) value...
if(NS_OK == (result=aScanner.SkipWhitespace())) {
//Skip ahead until you find an equal sign or a '>'...
if(NS_OK == (result=aScanner.SkipTo(kAllButEqualOrGT))) {
// if(NS_OK == (result=aScanner.SkipTo(kAllButEqualOrGT))) {
if(NS_OK == (result=aScanner.Peek(aChar))) {
if(kEqual==aChar){
result=aScanner.GetChar(aChar); //skip the equal sign...
@ -883,7 +883,7 @@ nsresult CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
}//if
}//if
}//if
}//if
// }if
}
if(NS_OK==result) {
result=aScanner.Peek(aChar);

View File

@ -169,12 +169,14 @@ class nsIDTD : public nsISupports {
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild)=0;
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug) = 0;
virtual PRBool Verify(nsString& aURLRef)=0;
};
#endif /* nsIDTD_h___ */

View File

@ -46,7 +46,6 @@ class nsIContentSink;
class nsIStreamObserver;
class nsString;
class nsIURL;
class nsIDTDDebug;
/**
* This class defines the iparser interface. This XPCOM
@ -93,9 +92,9 @@ class nsIParser : public nsISupports {
* until you wind up being emitted to the given contentsink (which may or may not
* be a proxy for the NGLayout content model).
******************************************************************************************/
virtual PRInt32 Parse(nsIURL* aURL,nsIStreamObserver* aListener = nsnull,nsIDTDDebug * aDTDDebug = 0) = 0;
virtual PRInt32 Parse(fstream& aStream)=0;
virtual PRInt32 Parse(nsString& aSourceBuffer,PRBool anHTMLString)=0;
virtual PRInt32 Parse(nsIURL* aURL,nsIStreamObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE) = 0;
virtual PRInt32 Parse(fstream& aStream,PRBool aEnableVerify=PR_FALSE) = 0;
virtual PRInt32 Parse(nsString& aSourceBuffer,PRBool anHTMLString,PRBool aEnableVerify=PR_FALSE) = 0;
/**
* This method gets called when the tokens have been consumed, and it's time

View File

@ -27,9 +27,10 @@
#include "plstr.h"
#include <fstream.h>
#include "nsIParserFilter.h"
#include "nsIDTDDebug.h"
#include "nshtmlpars.h"
#include "nsHTMLTokens.h"
#undef rickgdebug
#ifdef rickgdebug
#include "CRtfDTD.h"
@ -44,6 +45,7 @@ static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
static const char* kNullURL = "Error: Null URL given";
static nsString kUnknownFilename("unknown");
static nsString kEmptyString("unknown");
static const int gTransferBufferSize=4096; //size of the buffer used in moving data from iistream
@ -137,11 +139,11 @@ CSharedParserObjects gSharedParserObjects;
*/
nsParser::nsParser() {
NS_INIT_REFCNT();
mDTDDebug = 0;
mParserFilter = 0;
mObserver = 0;
mSink=0;
mParserContext=0;
mDTDVerification=PR_FALSE;
}
@ -154,7 +156,6 @@ nsParser::nsParser() {
*/
nsParser::~nsParser() {
NS_IF_RELEASE(mObserver);
// NS_IF_RELEASE(mDTDDebug);
NS_RELEASE(mSink);
//don't forget to add code here to delete
@ -450,15 +451,11 @@ CParserContext* nsParser::PopContext() {
* @param aFilename -- const char* containing file to be parsed.
* @return error code -- 0 if ok, non-zero if error.
*/
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDebug * aDTDDebug) {
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aVerifyEnabled) {
NS_PRECONDITION(0!=aURL,kNullURL);
PRInt32 status=kBadURL;
/* Disable DTD Debug for now...
mDTDDebug = aDTDDebug;
NS_IF_ADDREF(mDTDDebug);
*/
mDTDVerification=aVerifyEnabled;
if(aURL) {
nsAutoString theName(aURL->GetSpec());
@ -476,9 +473,10 @@ PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDebug *
* @param aStream is the i/o source
* @return error code -- 0 if ok, non-zero if error.
*/
PRInt32 nsParser::Parse(fstream& aStream){
PRInt32 nsParser::Parse(fstream& aStream,PRBool aVerifyEnabled){
PRInt32 status=kNoError;
mDTDVerification=aVerifyEnabled;
//ok, time to create our tokenizer and begin the process
CParserContext* pc=new CParserContext(new CScanner(kUnknownFilename,aStream,PR_FALSE),&aStream,0);
@ -509,8 +507,9 @@ PRInt32 nsParser::Parse(fstream& aStream){
* @param anHTMLString tells us whether we should assume the content is HTML (usually true)
* @return error code -- 0 if ok, non-zero if error.
*/
PRInt32 nsParser::Parse(nsString& aSourceBuffer,PRBool anHTMLString){
PRInt32 nsParser::Parse(nsString& aSourceBuffer,PRBool anHTMLString,PRBool aVerifyEnabled){
PRInt32 result=kNoError;
mDTDVerification=aVerifyEnabled;
CParserContext* pc=new CParserContext(new CScanner(aSourceBuffer),&aSourceBuffer,0);
@ -597,7 +596,8 @@ PRInt32 nsParser::BuildModel() {
theMarkPos=*mParserContext->mCurrentPos;
result=theRootDTD->HandleToken(theToken);
// result=mParserContext->mDTD->HandleToken(theToken);
if(mDTDVerification)
theRootDTD->Verify(kEmptyString);
++(*mParserContext->mCurrentPos);
}

View File

@ -70,7 +70,6 @@
class IContentSink;
class nsIHTMLContentSink;
class nsIDTD;
class nsIDTDDebug;
class CScanner;
class nsIParserFilter;
#include <fstream.h>
@ -124,9 +123,7 @@ friend class CTokenHandler;
* @param aListener is a listener to forward notifications to
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(nsIURL* aURL,
nsIStreamObserver* aListener,
nsIDTDDebug* aDTDDebug = 0);
virtual PRInt32 Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE);
/**
* Cause parser to parse input from given stream
@ -134,7 +131,7 @@ friend class CTokenHandler;
* @param aStream is the i/o source
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(fstream& aStream);
virtual PRInt32 Parse(fstream& aStream,PRBool aEnableVerify=PR_FALSE);
/**
* @update gess5/11/98
@ -142,7 +139,7 @@ friend class CTokenHandler;
* @param appendTokens tells us whether we should insert tokens inline, or append them.
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(nsString& aSourceBuffer,PRBool anHTMLString);
virtual PRInt32 Parse(nsString& aSourceBuffer,PRBool anHTMLString,PRBool aEnableVerify=PR_FALSE);
/**
* This method gets called (automatically) during incremental parsing
@ -218,7 +215,7 @@ protected:
* @return YES if model building went well -- NO otherwise.
*/
virtual PRInt32 BuildModel(void);
private:
/*******************************************
@ -298,9 +295,7 @@ protected:
nsIStreamObserver* mObserver;
nsIContentSink* mSink;
nsIParserFilter* mParserFilter;
nsIDTDDebug* mDTDDebug;
PRBool mDTDVerification;
};

View File

@ -61,8 +61,11 @@ nsCParserNode::~nsCParserNode() {
void nsCParserNode::AddAttribute(CToken* aToken) {
NS_PRECONDITION(mAttributeCount<PRInt32(sizeof(mAttributes)), "Buffer overrun!");
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
if(aToken) {
mAttributes[mAttributeCount++]=aToken;
if(mAttributeCount<eMaxAttr) {
if(aToken) {
mAttributes[mAttributeCount++]=aToken;
}
}
}
@ -177,9 +180,11 @@ PRInt32 nsCParserNode::GetAttributeCount(void) const{
* @return string rep of given attribute text key
*/
const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
CAttributeToken* tkn=(CAttributeToken*)(mAttributes[anIndex]);
return tkn->GetKey();
if(anIndex<mAttributeCount) {
CAttributeToken* tkn=(CAttributeToken*)(mAttributes[anIndex]);
return tkn->GetKey();
}
return mEmptyString;
}
@ -192,7 +197,10 @@ const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
*/
const nsString& nsCParserNode::GetValueAt(PRInt32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
return (mAttributes[anIndex])->GetStringValueXXX();
if(anIndex<mAttributeCount){
return (mAttributes[anIndex])->GetStringValueXXX();
}
return mEmptyString;
}

View File

@ -43,7 +43,8 @@
//class nsParser;
class nsCParserNode : public nsIParserNode {
enum {eMaxAttr=20};
public:
/**
@ -158,7 +159,7 @@ class nsCParserNode : public nsIParserNode {
PRInt32 mAttributeCount;
PRInt32 mLineNumber;
CToken* mToken;
CToken* mAttributes[20]; // XXX Ack! This needs to be dynamic!
CToken* mAttributes[eMaxAttr]; // XXX Ack! This needs to be dynamic!
// nsAutoString mName;
static const nsAutoString mEmptyString;

View File

@ -310,12 +310,25 @@ NS_IMETHODIMP CValidDTD::WillInterruptParse(void){
}
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CValidDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) {
PRBool CValidDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
return result;
}
/**
* Called by the parser to enable/disable dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CValidDTD::SetVerification(PRBool aEnabled){
}
/**

View File

@ -183,12 +183,22 @@ class CValidDTD : public nsIDTD {
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
/**
* This method is called to determine whether or not a tag

View File

@ -297,12 +297,25 @@ NS_IMETHODIMP CWellFormedDTD::WillInterruptParse(void){
}
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CWellFormedDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) {
PRBool CWellFormedDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
return result;
}
/**
* Called by the parser to enable/disable dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CWellFormedDTD::SetVerification(PRBool aEnabled){
}
/**

View File

@ -173,12 +173,22 @@ class CWellFormedDTD : public nsIDTD {
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
/**
* This method is called to determine whether or not a tag

View File

@ -1740,18 +1740,25 @@ PRBool nsXIFDTD::VerifyContextVector(void) const {
}
/**
* This debug method allows us to determine whether or not
* we've seen (and can handle) the given context vector.
*
* @update gpk 06/18/98
* @param tags is an array of eXIFTags
* @param count represents the number of items in the tags array
* @param aDTD is the DTD we plan to ask for verification
* @return TRUE if we know how to handle it, else false
* Called by the parser to enable/disable dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool nsXIFDTD::Verify(const char* anOutputDir,PRBool aRecordStats) {
void nsXIFDTD::SetVerification(PRBool aEnabled){
}
PRBool result=PR_TRUE;
/**
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool nsXIFDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
return result;
}
@ -1767,27 +1774,6 @@ void nsXIFDTD::SetURLRef(char * aURLRef)
}
/**
*
* @update jevering6/23/98
* @param
* @return
*/
void nsXIFDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
{
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
mDTDDebug = aDTDDebug;
if (mDTDDebug)
NS_ADDREF(mDTDDebug);
}
/*** CSS Methods ****/
void nsXIFDTD::BeginCSSStyleSheet(const nsIParserNode& aNode)

View File

@ -233,14 +233,23 @@ class nsXIFDTD : public nsIDTD {
virtual PRBool CanContain(PRInt32 aParent, PRInt32 aChild);
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
/**
* Select given content sink into parser for parser output
@ -327,15 +336,7 @@ class nsXIFDTD : public nsIDTD {
*/
virtual PRBool VerifyContextVector(void) const;
/**
*
* @update gpk 06/18/98
* @param
* @return
*/
virtual PRBool Verify(const char* anOutputDir,PRBool aRecordStats);
/**
*
* @update gpk 06/18/98

View File

@ -169,6 +169,7 @@ extern "C" NS_EXPORT int DebugRobot(
NS_ADDREF(myObserver);
g_workList = workList;
/*
nsIDTDDebug * pIDTDDebug;
nsresult rval = NS_NewDTDDebug(&pIDTDDebug);
if (NS_OK != rval) {
@ -177,6 +178,7 @@ extern "C" NS_EXPORT int DebugRobot(
return -1;
}
pIDTDDebug->SetVerificationDirectory(verify_dir);
*/
for (;;) {
PRInt32 n = g_workList->Count();
@ -193,7 +195,6 @@ extern "C" NS_EXPORT int DebugRobot(
printf("invalid URL: '");
fputs(*urlName, stdout);
printf("'\n");
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -212,7 +213,6 @@ extern "C" NS_EXPORT int DebugRobot(
rv = NS_NewParser(&parser);
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -221,7 +221,6 @@ extern "C" NS_EXPORT int DebugRobot(
rv = NS_NewRobotSink(&sink);
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(pIDTDDebug);
NS_RELEASE(myObserver);
return -1;
}
@ -229,9 +228,9 @@ extern "C" NS_EXPORT int DebugRobot(
sink->AddObserver(myObserver);
parser->SetContentSink(sink);
g_bReadyForNextUrl = PR_FALSE;
g_bReadyForNextUrl = PR_FALSE;
parser->Parse(url, pl, pIDTDDebug);/* XXX hook up stream listener here! */
parser->Parse(url, pl,PR_TRUE);/* XXX hook up stream listener here! */
while (!g_bReadyForNextUrl) {
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
@ -256,8 +255,8 @@ extern "C" NS_EXPORT int DebugRobot(
NS_RELEASE(pl);
NS_RELEASE(myObserver);
pIDTDDebug->DumpVectorRecord();
NS_RELEASE(pIDTDDebug);
// pIDTDDebug->DumpVectorRecord();
//NS_RELEASE(pIDTDDebug);
return 0;
}

View File

@ -27,7 +27,7 @@
#include "nsParserTypes.h"
#include "nsVoidArray.h"
#include "nsTokenHandler.h"
#include "nsIDTDDebug.h"
#include "prenv.h" //this is here for debug reasons...
#include "prtypes.h" //this is here for debug reasons...
#include "prio.h"
@ -48,6 +48,7 @@ static NS_DEFINE_IID(kClassIID, NS_INAVHTML_DTD_IID);
static const char* kNullToken = "Error: Null token given";
static const char* kInvalidTagStackPos = "Error: invalid tag stack position";
static const char* kHTMLTextContentType = "text/html";
static char* kVerificationDir = "c:/temp";
static nsAutoString gEmpty;
@ -372,22 +373,29 @@ nsresult CNavDTD::CreateNewInstance(nsIDTD** aInstancePtrResult){
}
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool CNavDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
void CNavDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
{
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
mDTDDebug = aDTDDebug;
if (mDTDDebug)
NS_ADDREF(mDTDDebug);
if(!mDTDDebug){;
nsresult rval = NS_NewDTDDebug(&mDTDDebug);
if (NS_OK != rval) {
fputs("Cannot create parser debugger.\n", stdout);
result=-PR_FALSE;
}
else mDTDDebug->SetVerificationDirectory(kVerificationDir);
}
if(mDTDDebug) {
mDTDDebug->Verify(this,mParser,mContextStack.mCount,mContextStack.mTags,aURLRef);
}
return result;
}
/**
* This method is called to determine if the given DTD can parse
* a document in a given source-type.
@ -451,6 +459,9 @@ nsresult CNavDTD::DidBuildModel(PRInt32 anErrorCode,PRBool aNotifySink){
result = mSink->DidBuildModel(1);
}
if(mDTDDebug) {
mDTDDebug->DumpVectorRecord();
}
return result;
}

View File

@ -207,12 +207,15 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
virtual eAutoDetectResult AutoDetectContentType(nsString& aBuffer,nsString& aType);
/**
* Sets a debugger into the DTD to help up debug the process.
* @update jevering6/23/98
* @param aDTDDedug is a ptr to the debug object you want us to use
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* The parser uses a code sandwich to wrap the parsing process. Before
* the process begins, WillBuildModel() is called. Afterwards the parser
@ -603,6 +606,7 @@ protected:
nsString mFilename;
nsIDTDDebug* mDTDDebug;
PRInt32 mLineNumber;
};
extern NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult);

View File

@ -440,12 +440,25 @@ nsresult CRtfDTD::WillInterruptParse(void){
}
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CRtfDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) {
PRBool CRtfDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
return result;
}
/**
* Called by the parser to enable/disable dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CRtfDTD::SetVerification(PRBool aEnabled){
}
/**

View File

@ -319,12 +319,22 @@ class CRtfDTD : public nsIDTD {
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
/**
* This method is called to determine whether or not a tag

View File

@ -859,7 +859,7 @@ nsresult CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
//now it's time to Consume the (optional) value...
if(NS_OK == (result=aScanner.SkipWhitespace())) {
//Skip ahead until you find an equal sign or a '>'...
if(NS_OK == (result=aScanner.SkipTo(kAllButEqualOrGT))) {
// if(NS_OK == (result=aScanner.SkipTo(kAllButEqualOrGT))) {
if(NS_OK == (result=aScanner.Peek(aChar))) {
if(kEqual==aChar){
result=aScanner.GetChar(aChar); //skip the equal sign...
@ -883,7 +883,7 @@ nsresult CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
}//if
}//if
}//if
}//if
// }if
}
if(NS_OK==result) {
result=aScanner.Peek(aChar);

View File

@ -169,12 +169,14 @@ class nsIDTD : public nsISupports {
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild)=0;
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug) = 0;
virtual PRBool Verify(nsString& aURLRef)=0;
};
#endif /* nsIDTD_h___ */

View File

@ -46,7 +46,6 @@ class nsIContentSink;
class nsIStreamObserver;
class nsString;
class nsIURL;
class nsIDTDDebug;
/**
* This class defines the iparser interface. This XPCOM
@ -93,9 +92,9 @@ class nsIParser : public nsISupports {
* until you wind up being emitted to the given contentsink (which may or may not
* be a proxy for the NGLayout content model).
******************************************************************************************/
virtual PRInt32 Parse(nsIURL* aURL,nsIStreamObserver* aListener = nsnull,nsIDTDDebug * aDTDDebug = 0) = 0;
virtual PRInt32 Parse(fstream& aStream)=0;
virtual PRInt32 Parse(nsString& aSourceBuffer,PRBool anHTMLString)=0;
virtual PRInt32 Parse(nsIURL* aURL,nsIStreamObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE) = 0;
virtual PRInt32 Parse(fstream& aStream,PRBool aEnableVerify=PR_FALSE) = 0;
virtual PRInt32 Parse(nsString& aSourceBuffer,PRBool anHTMLString,PRBool aEnableVerify=PR_FALSE) = 0;
/**
* This method gets called when the tokens have been consumed, and it's time

View File

@ -27,9 +27,10 @@
#include "plstr.h"
#include <fstream.h>
#include "nsIParserFilter.h"
#include "nsIDTDDebug.h"
#include "nshtmlpars.h"
#include "nsHTMLTokens.h"
#undef rickgdebug
#ifdef rickgdebug
#include "CRtfDTD.h"
@ -44,6 +45,7 @@ static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
static const char* kNullURL = "Error: Null URL given";
static nsString kUnknownFilename("unknown");
static nsString kEmptyString("unknown");
static const int gTransferBufferSize=4096; //size of the buffer used in moving data from iistream
@ -137,11 +139,11 @@ CSharedParserObjects gSharedParserObjects;
*/
nsParser::nsParser() {
NS_INIT_REFCNT();
mDTDDebug = 0;
mParserFilter = 0;
mObserver = 0;
mSink=0;
mParserContext=0;
mDTDVerification=PR_FALSE;
}
@ -154,7 +156,6 @@ nsParser::nsParser() {
*/
nsParser::~nsParser() {
NS_IF_RELEASE(mObserver);
// NS_IF_RELEASE(mDTDDebug);
NS_RELEASE(mSink);
//don't forget to add code here to delete
@ -450,15 +451,11 @@ CParserContext* nsParser::PopContext() {
* @param aFilename -- const char* containing file to be parsed.
* @return error code -- 0 if ok, non-zero if error.
*/
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDebug * aDTDDebug) {
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aVerifyEnabled) {
NS_PRECONDITION(0!=aURL,kNullURL);
PRInt32 status=kBadURL;
/* Disable DTD Debug for now...
mDTDDebug = aDTDDebug;
NS_IF_ADDREF(mDTDDebug);
*/
mDTDVerification=aVerifyEnabled;
if(aURL) {
nsAutoString theName(aURL->GetSpec());
@ -476,9 +473,10 @@ PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDebug *
* @param aStream is the i/o source
* @return error code -- 0 if ok, non-zero if error.
*/
PRInt32 nsParser::Parse(fstream& aStream){
PRInt32 nsParser::Parse(fstream& aStream,PRBool aVerifyEnabled){
PRInt32 status=kNoError;
mDTDVerification=aVerifyEnabled;
//ok, time to create our tokenizer and begin the process
CParserContext* pc=new CParserContext(new CScanner(kUnknownFilename,aStream,PR_FALSE),&aStream,0);
@ -509,8 +507,9 @@ PRInt32 nsParser::Parse(fstream& aStream){
* @param anHTMLString tells us whether we should assume the content is HTML (usually true)
* @return error code -- 0 if ok, non-zero if error.
*/
PRInt32 nsParser::Parse(nsString& aSourceBuffer,PRBool anHTMLString){
PRInt32 nsParser::Parse(nsString& aSourceBuffer,PRBool anHTMLString,PRBool aVerifyEnabled){
PRInt32 result=kNoError;
mDTDVerification=aVerifyEnabled;
CParserContext* pc=new CParserContext(new CScanner(aSourceBuffer),&aSourceBuffer,0);
@ -597,7 +596,8 @@ PRInt32 nsParser::BuildModel() {
theMarkPos=*mParserContext->mCurrentPos;
result=theRootDTD->HandleToken(theToken);
// result=mParserContext->mDTD->HandleToken(theToken);
if(mDTDVerification)
theRootDTD->Verify(kEmptyString);
++(*mParserContext->mCurrentPos);
}

View File

@ -70,7 +70,6 @@
class IContentSink;
class nsIHTMLContentSink;
class nsIDTD;
class nsIDTDDebug;
class CScanner;
class nsIParserFilter;
#include <fstream.h>
@ -124,9 +123,7 @@ friend class CTokenHandler;
* @param aListener is a listener to forward notifications to
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(nsIURL* aURL,
nsIStreamObserver* aListener,
nsIDTDDebug* aDTDDebug = 0);
virtual PRInt32 Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE);
/**
* Cause parser to parse input from given stream
@ -134,7 +131,7 @@ friend class CTokenHandler;
* @param aStream is the i/o source
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(fstream& aStream);
virtual PRInt32 Parse(fstream& aStream,PRBool aEnableVerify=PR_FALSE);
/**
* @update gess5/11/98
@ -142,7 +139,7 @@ friend class CTokenHandler;
* @param appendTokens tells us whether we should insert tokens inline, or append them.
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(nsString& aSourceBuffer,PRBool anHTMLString);
virtual PRInt32 Parse(nsString& aSourceBuffer,PRBool anHTMLString,PRBool aEnableVerify=PR_FALSE);
/**
* This method gets called (automatically) during incremental parsing
@ -218,7 +215,7 @@ protected:
* @return YES if model building went well -- NO otherwise.
*/
virtual PRInt32 BuildModel(void);
private:
/*******************************************
@ -298,9 +295,7 @@ protected:
nsIStreamObserver* mObserver;
nsIContentSink* mSink;
nsIParserFilter* mParserFilter;
nsIDTDDebug* mDTDDebug;
PRBool mDTDVerification;
};

View File

@ -61,8 +61,11 @@ nsCParserNode::~nsCParserNode() {
void nsCParserNode::AddAttribute(CToken* aToken) {
NS_PRECONDITION(mAttributeCount<PRInt32(sizeof(mAttributes)), "Buffer overrun!");
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
if(aToken) {
mAttributes[mAttributeCount++]=aToken;
if(mAttributeCount<eMaxAttr) {
if(aToken) {
mAttributes[mAttributeCount++]=aToken;
}
}
}
@ -177,9 +180,11 @@ PRInt32 nsCParserNode::GetAttributeCount(void) const{
* @return string rep of given attribute text key
*/
const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
CAttributeToken* tkn=(CAttributeToken*)(mAttributes[anIndex]);
return tkn->GetKey();
if(anIndex<mAttributeCount) {
CAttributeToken* tkn=(CAttributeToken*)(mAttributes[anIndex]);
return tkn->GetKey();
}
return mEmptyString;
}
@ -192,7 +197,10 @@ const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
*/
const nsString& nsCParserNode::GetValueAt(PRInt32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
return (mAttributes[anIndex])->GetStringValueXXX();
if(anIndex<mAttributeCount){
return (mAttributes[anIndex])->GetStringValueXXX();
}
return mEmptyString;
}

View File

@ -43,7 +43,8 @@
//class nsParser;
class nsCParserNode : public nsIParserNode {
enum {eMaxAttr=20};
public:
/**
@ -158,7 +159,7 @@ class nsCParserNode : public nsIParserNode {
PRInt32 mAttributeCount;
PRInt32 mLineNumber;
CToken* mToken;
CToken* mAttributes[20]; // XXX Ack! This needs to be dynamic!
CToken* mAttributes[eMaxAttr]; // XXX Ack! This needs to be dynamic!
// nsAutoString mName;
static const nsAutoString mEmptyString;

View File

@ -310,12 +310,25 @@ NS_IMETHODIMP CValidDTD::WillInterruptParse(void){
}
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CValidDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) {
PRBool CValidDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
return result;
}
/**
* Called by the parser to enable/disable dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CValidDTD::SetVerification(PRBool aEnabled){
}
/**

View File

@ -183,12 +183,22 @@ class CValidDTD : public nsIDTD {
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
/**
* This method is called to determine whether or not a tag

View File

@ -297,12 +297,25 @@ NS_IMETHODIMP CWellFormedDTD::WillInterruptParse(void){
}
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CWellFormedDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) {
PRBool CWellFormedDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
return result;
}
/**
* Called by the parser to enable/disable dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
void CWellFormedDTD::SetVerification(PRBool aEnabled){
}
/**

View File

@ -173,12 +173,22 @@ class CWellFormedDTD : public nsIDTD {
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
/**
* This method is called to determine whether or not a tag

View File

@ -1740,18 +1740,25 @@ PRBool nsXIFDTD::VerifyContextVector(void) const {
}
/**
* This debug method allows us to determine whether or not
* we've seen (and can handle) the given context vector.
*
* @update gpk 06/18/98
* @param tags is an array of eXIFTags
* @param count represents the number of items in the tags array
* @param aDTD is the DTD we plan to ask for verification
* @return TRUE if we know how to handle it, else false
* Called by the parser to enable/disable dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool nsXIFDTD::Verify(const char* anOutputDir,PRBool aRecordStats) {
void nsXIFDTD::SetVerification(PRBool aEnabled){
}
PRBool result=PR_TRUE;
/**
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool nsXIFDTD::Verify(nsString& aURLRef){
PRBool result=PR_TRUE;
return result;
}
@ -1767,27 +1774,6 @@ void nsXIFDTD::SetURLRef(char * aURLRef)
}
/**
*
* @update jevering6/23/98
* @param
* @return
*/
void nsXIFDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
{
if (mDTDDebug)
NS_RELEASE(mDTDDebug);
mDTDDebug = aDTDDebug;
if (mDTDDebug)
NS_ADDREF(mDTDDebug);
}
/*** CSS Methods ****/
void nsXIFDTD::BeginCSSStyleSheet(const nsIParserNode& aNode)

View File

@ -233,14 +233,23 @@ class nsXIFDTD : public nsIDTD {
virtual PRBool CanContain(PRInt32 aParent, PRInt32 aChild);
/**
*
* @update jevering6/23/98
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
virtual PRBool Verify(nsString& aURLRef);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
/**
* Select given content sink into parser for parser output
@ -327,15 +336,7 @@ class nsXIFDTD : public nsIDTD {
*/
virtual PRBool VerifyContextVector(void) const;
/**
*
* @update gpk 06/18/98
* @param
* @return
*/
virtual PRBool Verify(const char* anOutputDir,PRBool aRecordStats);
/**
*
* @update gpk 06/18/98