From 55ada9fcc7d67dd727ca9de0a6f961a0a8cead2b Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Thu, 23 Jul 1998 21:10:19 +0000 Subject: [PATCH] bug fixes; more docs; lots of new testing git-svn-id: svn://10.0.0.236/trunk@6315 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/CNavDTD.cpp | 7 +++- mozilla/htmlparser/src/nsIParser.h | 11 ------ mozilla/htmlparser/src/nsParser.cpp | 23 +++--------- mozilla/htmlparser/src/nsParser.h | 37 -------------------- mozilla/htmlparser/src/nsParserNode.h | 2 +- mozilla/htmlparser/src/nsScanner.cpp | 12 +++++-- mozilla/parser/htmlparser/src/CNavDTD.cpp | 7 +++- mozilla/parser/htmlparser/src/nsIParser.h | 11 ------ mozilla/parser/htmlparser/src/nsParser.cpp | 23 +++--------- mozilla/parser/htmlparser/src/nsParser.h | 37 -------------------- mozilla/parser/htmlparser/src/nsParserNode.h | 2 +- mozilla/parser/htmlparser/src/nsScanner.cpp | 12 +++++-- 12 files changed, 44 insertions(+), 140 deletions(-) diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 5ff6dfec13e..e064fa9f2c3 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -1505,7 +1505,12 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const { case eHTMLTag_comment: result=PR_TRUE; break; - + + case eHTMLTag_html: + case eHTMLTag_body: + result=HasOpenContainer(aChild); //don't bother if they're already open... + break; + case eHTMLTag_newline: case eHTMLTag_whitespace: diff --git a/mozilla/htmlparser/src/nsIParser.h b/mozilla/htmlparser/src/nsIParser.h index 1cfe9303c87..33b6a6a8c40 100644 --- a/mozilla/htmlparser/src/nsIParser.h +++ b/mozilla/htmlparser/src/nsIParser.h @@ -45,7 +45,6 @@ class nsIContentSink; class nsIStreamObserver; class nsString; -class CToken; class nsIURL; class nsIDTDDebug; @@ -88,16 +87,6 @@ class nsIParser : public nsISupports { */ virtual eAutoDetectResult AutoDetectContentType(nsString& aBuffer,nsString& aType)=0; - /** - * Cause the tokenizer to consume the next token, and - * return an error result. - * - * @update gess 3/25/98 - * @param anError -- ref to error code - * @return new token or null - */ - virtual PRInt32 ConsumeToken(CToken*& aToken)=0; - /****************************************************************************************** * Parse methods always begin with an input source, and perform conversions diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index 955191e96da..cdb8b905133 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -578,11 +578,11 @@ PRInt32 nsParser::BuildModel() { And guess what? It worked the first time! Uncomment the following code to enable the test: - int recurse=0; - if(recurse){ - nsString theString("
cell
"); - Parse(theString,PR_TRUE); - } + int recurse=0; + if(recurse){ + nsString theString("
cell
"); + Parse(theString,PR_TRUE); + } **************************************************************************/ theMarkPos=*mParserContext->mCurrentPos; @@ -770,19 +770,6 @@ nsresult nsParser::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& a Here comes the tokenization methods... *******************************************************************/ -/** - * Cause the tokenizer to consume the next token, and - * return an error result. - * - * @update gess 3/25/98 - * @param anError -- ref to error code - * @return new token or null - */ -PRInt32 nsParser::ConsumeToken(CToken*& aToken) { - PRInt32 result=mParserContext->mDTD->ConsumeToken(aToken); - return result; -} - /** * Part of the code sandwich, this gets called right before diff --git a/mozilla/htmlparser/src/nsParser.h b/mozilla/htmlparser/src/nsParser.h index 1ffc5895f39..befcd2843d9 100644 --- a/mozilla/htmlparser/src/nsParser.h +++ b/mozilla/htmlparser/src/nsParser.h @@ -224,16 +224,6 @@ private: These are the tokenization methods... *******************************************/ - /** - * Cause the tokenizer to consume the next token, and - * return an error result. - * - * @update gess 3/25/98 - * @param anError -- ref to error code - * @return new token or null - */ - virtual PRInt32 ConsumeToken(CToken*& aToken); - /** * Part of the code sandwich, this gets called right before * the tokenization process begins. The main reason for @@ -299,42 +289,15 @@ protected: // And now, some data members... //********************************************* - /***************************************************** - All of these moved into the parse-context object: - - PRInt32 mMajorIteration; - PRInt32 mMinorIteration; - - nsIURL* mURL; - nsString mSourceType; - nsString mTargetType; - eAutoDetectResult mAutoDetectStatus; - - nsDequeIterator* mCurrentPos; - nsDequeIterator* mMarkPos; - nsDeque mTokenDeque; - CScanner* mScanner; - nsIDTD* mDTD; - - eParseMode mParseMode; - char* mTransferBuffer; - *****************************************************/ - CParserContext* mParserContext; PRInt32 mMajorIteration; PRInt32 mMinorIteration; - /***************************************************** - The above fields are moving into parse-context - *****************************************************/ - - nsIStreamObserver* mObserver; nsIContentSink* mSink; nsIParserFilter* mParserFilter; - nsIDTDDebug* mDTDDebug; diff --git a/mozilla/htmlparser/src/nsParserNode.h b/mozilla/htmlparser/src/nsParserNode.h index a490e6d9519..5c8aa3b6749 100644 --- a/mozilla/htmlparser/src/nsParserNode.h +++ b/mozilla/htmlparser/src/nsParserNode.h @@ -57,7 +57,7 @@ class nsCParserNode : public nsIParserNode { * Destructor * @update gess5/11/98 */ - ~nsCParserNode(); + virtual ~nsCParserNode(); /** * Retrieve the name of the node diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp index b257e6cf64d..93ce54eea57 100644 --- a/mozilla/htmlparser/src/nsScanner.cpp +++ b/mozilla/htmlparser/src/nsScanner.cpp @@ -257,7 +257,11 @@ nsresult CScanner::Eof() { * @return error code reflecting read status */ nsresult CScanner::GetChar(PRUnichar& aChar) { - nsresult result=Eof(); + nsresult result=NS_OK; + + if(mOffset>=mBuffer.Length()) + result=Eof(); + if(NS_OK == result) { aChar=mBuffer[mOffset++]; } @@ -274,7 +278,11 @@ nsresult CScanner::GetChar(PRUnichar& aChar) { * @return */ nsresult CScanner::Peek(PRUnichar& aChar) { - nsresult result=Eof(); + nsresult result=NS_OK; + + if(mOffset>=mBuffer.Length()) + result=Eof(); + if(NS_OK == result) { aChar=mBuffer[mOffset]; } diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index 5ff6dfec13e..e064fa9f2c3 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -1505,7 +1505,12 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const { case eHTMLTag_comment: result=PR_TRUE; break; - + + case eHTMLTag_html: + case eHTMLTag_body: + result=HasOpenContainer(aChild); //don't bother if they're already open... + break; + case eHTMLTag_newline: case eHTMLTag_whitespace: diff --git a/mozilla/parser/htmlparser/src/nsIParser.h b/mozilla/parser/htmlparser/src/nsIParser.h index 1cfe9303c87..33b6a6a8c40 100644 --- a/mozilla/parser/htmlparser/src/nsIParser.h +++ b/mozilla/parser/htmlparser/src/nsIParser.h @@ -45,7 +45,6 @@ class nsIContentSink; class nsIStreamObserver; class nsString; -class CToken; class nsIURL; class nsIDTDDebug; @@ -88,16 +87,6 @@ class nsIParser : public nsISupports { */ virtual eAutoDetectResult AutoDetectContentType(nsString& aBuffer,nsString& aType)=0; - /** - * Cause the tokenizer to consume the next token, and - * return an error result. - * - * @update gess 3/25/98 - * @param anError -- ref to error code - * @return new token or null - */ - virtual PRInt32 ConsumeToken(CToken*& aToken)=0; - /****************************************************************************************** * Parse methods always begin with an input source, and perform conversions diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index 955191e96da..cdb8b905133 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -578,11 +578,11 @@ PRInt32 nsParser::BuildModel() { And guess what? It worked the first time! Uncomment the following code to enable the test: - int recurse=0; - if(recurse){ - nsString theString("
cell
"); - Parse(theString,PR_TRUE); - } + int recurse=0; + if(recurse){ + nsString theString("
cell
"); + Parse(theString,PR_TRUE); + } **************************************************************************/ theMarkPos=*mParserContext->mCurrentPos; @@ -770,19 +770,6 @@ nsresult nsParser::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& a Here comes the tokenization methods... *******************************************************************/ -/** - * Cause the tokenizer to consume the next token, and - * return an error result. - * - * @update gess 3/25/98 - * @param anError -- ref to error code - * @return new token or null - */ -PRInt32 nsParser::ConsumeToken(CToken*& aToken) { - PRInt32 result=mParserContext->mDTD->ConsumeToken(aToken); - return result; -} - /** * Part of the code sandwich, this gets called right before diff --git a/mozilla/parser/htmlparser/src/nsParser.h b/mozilla/parser/htmlparser/src/nsParser.h index 1ffc5895f39..befcd2843d9 100644 --- a/mozilla/parser/htmlparser/src/nsParser.h +++ b/mozilla/parser/htmlparser/src/nsParser.h @@ -224,16 +224,6 @@ private: These are the tokenization methods... *******************************************/ - /** - * Cause the tokenizer to consume the next token, and - * return an error result. - * - * @update gess 3/25/98 - * @param anError -- ref to error code - * @return new token or null - */ - virtual PRInt32 ConsumeToken(CToken*& aToken); - /** * Part of the code sandwich, this gets called right before * the tokenization process begins. The main reason for @@ -299,42 +289,15 @@ protected: // And now, some data members... //********************************************* - /***************************************************** - All of these moved into the parse-context object: - - PRInt32 mMajorIteration; - PRInt32 mMinorIteration; - - nsIURL* mURL; - nsString mSourceType; - nsString mTargetType; - eAutoDetectResult mAutoDetectStatus; - - nsDequeIterator* mCurrentPos; - nsDequeIterator* mMarkPos; - nsDeque mTokenDeque; - CScanner* mScanner; - nsIDTD* mDTD; - - eParseMode mParseMode; - char* mTransferBuffer; - *****************************************************/ - CParserContext* mParserContext; PRInt32 mMajorIteration; PRInt32 mMinorIteration; - /***************************************************** - The above fields are moving into parse-context - *****************************************************/ - - nsIStreamObserver* mObserver; nsIContentSink* mSink; nsIParserFilter* mParserFilter; - nsIDTDDebug* mDTDDebug; diff --git a/mozilla/parser/htmlparser/src/nsParserNode.h b/mozilla/parser/htmlparser/src/nsParserNode.h index a490e6d9519..5c8aa3b6749 100644 --- a/mozilla/parser/htmlparser/src/nsParserNode.h +++ b/mozilla/parser/htmlparser/src/nsParserNode.h @@ -57,7 +57,7 @@ class nsCParserNode : public nsIParserNode { * Destructor * @update gess5/11/98 */ - ~nsCParserNode(); + virtual ~nsCParserNode(); /** * Retrieve the name of the node diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp index b257e6cf64d..93ce54eea57 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.cpp +++ b/mozilla/parser/htmlparser/src/nsScanner.cpp @@ -257,7 +257,11 @@ nsresult CScanner::Eof() { * @return error code reflecting read status */ nsresult CScanner::GetChar(PRUnichar& aChar) { - nsresult result=Eof(); + nsresult result=NS_OK; + + if(mOffset>=mBuffer.Length()) + result=Eof(); + if(NS_OK == result) { aChar=mBuffer[mOffset++]; } @@ -274,7 +278,11 @@ nsresult CScanner::GetChar(PRUnichar& aChar) { * @return */ nsresult CScanner::Peek(PRUnichar& aChar) { - nsresult result=Eof(); + nsresult result=NS_OK; + + if(mOffset>=mBuffer.Length()) + result=Eof(); + if(NS_OK == result) { aChar=mBuffer[mOffset]; }