diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 79483478457..f0d803e138c 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -51,6 +51,7 @@ #endif +static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID); static NS_DEFINE_IID(kClassIID, NS_INAVHTML_DTD_IID); @@ -498,15 +499,14 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString mHadFrameset=PR_FALSE; mLineNumber=1; mHasOpenScript=PR_FALSE; - mSink=(nsIHTMLContentSink*)aSink; - if((aNotifySink) && (mSink)) { + if((aNotifySink) && (aSink)) { #ifdef RGESS_DEBUG gStartTime = PR_Now(); printf("Begin parsing...\n"); #endif - result = mSink->WillBuildModel(); + result = aSink->WillBuildModel(); CStartToken theToken(eHTMLTag_html); HandleStartToken(&theToken); @@ -525,29 +525,35 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString * * @update gess5/18/98 * @param aParser is the parser object that's driving this process - * @return error code (almost always 0) + * @return error code (almost always NS_OK) */ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink) { nsresult result=NS_OK; - NS_ADDREF(aSink); if(aTokenizer) { nsITokenizer* oldTokenizer=mTokenizer; mTokenizer=aTokenizer; mParser=(nsParser*)aParser; - mSink=(nsIHTMLContentSink*)aSink; - gRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler(); - while(NS_SUCCEEDED(result)){ - CToken* theToken=mTokenizer->PopToken(); - if(theToken) { - result=HandleToken(theToken,aParser); - } - else break; - }//while - mTokenizer=oldTokenizer; + + mSink=nsnull; + result=aSink->QueryInterface(kIHTMLContentSinkIID, (void **)&mSink); + + if(mSink) { + NS_ADDREF(mSink); + gRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler(); + while(NS_SUCCEEDED(result)){ + CToken* theToken=mTokenizer->PopToken(); + if(theToken) { + result=HandleToken(theToken,aParser); + } + else break; + }//while + mTokenizer=oldTokenizer; + NS_IF_RELEASE(mSink); + mSink=nsnull; + } } else result=NS_ERROR_HTMLPARSER_BADTOKENIZER; - NS_IF_RELEASE(aSink); return result; } @@ -568,8 +574,7 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse } if(aParser){ - mSink=(nsIHTMLContentSink*)aSink; - if(aNotifySink && mSink){ + if(aNotifySink && aSink){ if((NS_OK==anErrorCode) && (mBodyContext->GetCount()>0)) { eHTMLTags theTarget; while(mBodyContext->GetCount() > 0) { @@ -605,16 +610,16 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse if(mComputedCRC32!=mExpectedCRC32) { if(mExpectedCRC32!=0) { printf("CRC Computed: %u Expected CRC: %u\n,",mComputedCRC32,mExpectedCRC32); - result = mSink->DidBuildModel(2); + result = aSink->DidBuildModel(2); } else { printf("Computed CRC: %u.\n",mComputedCRC32); - result = mSink->DidBuildModel(3); + result = aSink->DidBuildModel(3); } } - else result = mSink->DidBuildModel(0); + else result = aSink->DidBuildModel(0); } - else result=mSink->DidBuildModel(0); + else result=aSink->DidBuildModel(0); if(mDTDDebug) { mDTDDebug->DumpVectorRecord(); diff --git a/mozilla/htmlparser/src/CRtfDTD.cpp b/mozilla/htmlparser/src/CRtfDTD.cpp index 45a641c2131..82b4f2dd5a9 100644 --- a/mozilla/htmlparser/src/CRtfDTD.cpp +++ b/mozilla/htmlparser/src/CRtfDTD.cpp @@ -65,7 +65,7 @@ struct RTFEntry { eRTFTags mTagID; }; - +#if 0 static RTFEntry gRTFTable[] = { {"$",eRTFCtrl_unknown}, @@ -127,7 +127,7 @@ static const char* GetTagName(eRTFTags aTag) { } return ""; } - +#endif /** * This method gets called as part of our COM-like interfaces. diff --git a/mozilla/htmlparser/src/nsElementTable.cpp b/mozilla/htmlparser/src/nsElementTable.cpp index a1ace7f3a57..2cf30f6b6ac 100644 --- a/mozilla/htmlparser/src/nsElementTable.cpp +++ b/mozilla/htmlparser/src/nsElementTable.cpp @@ -121,7 +121,7 @@ CTagList gInTR(1,0,eHTMLTag_tr); CTagList gInDL(2,0,eHTMLTag_dl,eHTMLTag_body); CTagList gInFrameset(1,0,eHTMLTag_frameset); CTagList gInNoframes(1,0,eHTMLTag_noframes); -CTagList gInP(2,0,eHTMLTag_address,eHTMLTag_form); +CTagList gInP(3,0,eHTMLTag_address,eHTMLTag_form,eHTMLTag_span); CTagList gOptgroupParents(2,0,eHTMLTag_optgroup,eHTMLTag_select); CTagList gBodyParents(2,0,eHTMLTag_html,eHTMLTag_noframes); CTagList gColParents(2,0,eHTMLTag_table,eHTMLTag_colgroup); diff --git a/mozilla/htmlparser/src/nsExpatDTD.cpp b/mozilla/htmlparser/src/nsExpatDTD.cpp index 7c909eda4c0..7bfbe70f49a 100644 --- a/mozilla/htmlparser/src/nsExpatDTD.cpp +++ b/mozilla/htmlparser/src/nsExpatDTD.cpp @@ -112,13 +112,12 @@ NS_IMPL_RELEASE(nsExpatDTD) * @param * @return */ -nsExpatDTD::nsExpatDTD() : nsIDTD() { +nsExpatDTD::nsExpatDTD() : nsIDTD(), mFilename("") { NS_INIT_REFCNT(); mExpatParser=0; mParser=0; mSink=0; - mFilename; mLineNumber=0; mTokenizer=0; } @@ -446,12 +445,12 @@ NS_IMETHODIMP nsExpatDTD::HandleToken(CToken* aToken,nsIParser* aParser) { if(0PeekToken(); - if(theToken) { - eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); - if(eToken_attribute==theType){ + CToken* theAttrToken=mTokenizer->PeekToken(); + if(theAttrToken) { + eHTMLTokenTypes theAttrType=eHTMLTokenTypes(theAttrToken->GetTokenType()); + if(eToken_attribute==theAttrType){ mTokenizer->PopToken(); //pop it for real... - theNode.AddAttribute(theToken); + theNode.AddAttribute(theAttrToken); } } else return kEOF; diff --git a/mozilla/htmlparser/src/nsHTMLTokens.cpp b/mozilla/htmlparser/src/nsHTMLTokens.cpp index e4e1dbb2b35..cf478a2b678 100644 --- a/mozilla/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokens.cpp @@ -788,6 +788,9 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString) static nsAutoString gEdibles("!-"); static nsAutoString gMinus("-"); static nsAutoString gWhitespace("\b\t\n\r "); + + static nsAutoString gDfltEndComment("-->"); + nsresult result=NS_OK; /********************************************************* @@ -797,7 +800,9 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString) *********************************************************/ aString=" aString+=aChar; PRInt32 findpos=kNotFound; - result=aScanner.ReadWhile(aString,gMinus,PR_TRUE,PR_TRUE); //get all available '---' - findpos=aString.RFind("-->"); - while((kNotFound==findpos) && (NS_OK==result)) { - result=aScanner.ReadUntil(aString,kMinus,PR_TRUE); - - if(NS_OK==result) { - result=aScanner.ReadWhile(aString,gMinus,PR_TRUE,PR_FALSE); //get all available '---' - if(NS_OK==result) - result=aScanner.ReadWhile(aString,gWhitespace,PR_TRUE,PR_FALSE); //get all available whitespace - } - - if(NS_OK==result) { - result=aScanner.GetChar(aChar); - aString+=aChar; - } - + result=aScanner.ReadUntil(aString,kGreaterThan,PR_TRUE); if(NS_OK==result){ - theRightChars.Truncate(0); - aString.Right(theRightChars,5); - theRightChars.StripChars(" "); - - findpos=theRightChars.RFind("-->"); - if(kNotFound==findpos) - findpos=theRightChars.RFind("!>"); + + if(kNotFound==theBestAltPos) { + const PRUnichar* theBuf=aString.GetUnicode(); + findpos=aString.Length()-3; + theBuf=(PRUnichar*)&theBuf[findpos]; + if(!gDfltEndComment.Equals(theBuf,PR_FALSE,3)) { + //we didn't find the dflt end comment delimiter, so look for alternatives... + findpos=kNotFound; + theRightChars.Truncate(0); + aString.Right(theRightChars,15); + theRightChars.StripChars(" "); + + int rclen=theRightChars.Length(); + aChar=theRightChars[rclen-2]; + if(('!'==aChar) || ('-'==aChar)) { + theBestAltPos=aString.Length(); + theStartOffset=aScanner.GetOffset(); + } + } + } + } } //while + if((kNotFound==findpos) && (!aScanner.IsIncremental())) { + //if you're here, then we're in a special state. + //The problem at hand is that we've hit the end of the document without finding the normal endcomment delimiter "-->". + //In this case, the first thing we try is to see if we found one of the alternate endcomment delimiters "->" or "!>". + //If so, rewind just pass than, and use everything up to that point as your comment. + //If not, the document has no end comment and should be treated as one big comment. + if(kNotFound'==mTextValue.Last()) + mTextValue.Truncate(mTextValue.Length()-1); + } +#endif return result; } diff --git a/mozilla/htmlparser/src/nsIParser.h b/mozilla/htmlparser/src/nsIParser.h index 910579964ae..e9797f6a4b7 100644 --- a/mozilla/htmlparser/src/nsIParser.h +++ b/mozilla/htmlparser/src/nsIParser.h @@ -95,7 +95,7 @@ public: * * @update gess 3/25/98 */ -class nsIParser : public nsISupports { +CLASS_EXPORT_HTMLPARS nsIParser : public nsISupports { public: static const nsIID& GetIID() { static nsIID iid = NS_IPARSER_IID; return iid; } @@ -167,13 +167,13 @@ class nsIParser : public nsISupports { ******************************************************************************************/ virtual PRBool EnableParser(PRBool aState) = 0; virtual PRBool IsParserEnabled() = 0; - virtual nsresult Parse(nsIURI* aURL,nsIStreamObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE, void* aKey=0) = 0; - virtual nsresult Parse(nsIInputStream& aStream, PRBool aEnableVerify=PR_FALSE, void* aKey=0) = 0; - virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall) = 0; + virtual nsresult Parse(nsIURI* aURL,nsIStreamObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE, void* aKey=0,eParseMode aMode=eParseMode_autodetect) = 0; + virtual nsresult Parse(nsIInputStream& aStream, PRBool aEnableVerify=PR_FALSE, void* aKey=0,eParseMode aMode=eParseMode_autodetect) = 0; + virtual nsresult Parse(const nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall,eParseMode aMode=eParseMode_autodetect) = 0; virtual nsresult Terminate(void) = 0; - virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0; - virtual nsresult ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0; + virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode=eParseMode_autodetect)=0; + virtual nsresult ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode=eParseMode_autodetect)=0; /** * This method gets called when the tokens have been consumed, and it's time diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index 0465de6bee5..de922574d69 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -644,7 +644,7 @@ nsParser::IsParserEnabled() * @param aFilename -- const char* containing file to be parsed. * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aVerifyEnabled, void* aKey) { +nsresult nsParser::Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aVerifyEnabled, void* aKey,eParseMode aMode) { NS_PRECONDITION(0!=aURL,kNullURL); nsresult result=kBadURL; @@ -683,7 +683,7 @@ nsresult nsParser::Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aVerif * @param aStream is the i/o source * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aKey){ +nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aKey,eParseMode aMode){ mDTDVerification=aVerifyEnabled; nsresult result=NS_ERROR_OUT_OF_MEMORY; @@ -692,7 +692,7 @@ nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aK nsAutoString theUnknownFilename("unknown"); nsInputStream input(&aStream); - CParserContext* pc=new CParserContext(new nsScanner(theUnknownFilename, input, mCharset, mCharsetSource,PR_FALSE),aKey,0); + CParserContext* pc=new CParserContext(new nsScanner(theUnknownFilename, input, mCharset, mCharsetSource),aKey,0); if(pc) { PushContext(*pc); pc->mSourceType=kHTMLTextContentType; @@ -721,7 +721,7 @@ nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aK * @param aContentType tells us what type of content to expect in the given string * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aVerifyEnabled,PRBool aLastCall){ +nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aVerifyEnabled,PRBool aLastCall,eParseMode aMode){ //NOTE: Make sure that updates to this method don't cause // bug #2361 to break again! @@ -780,7 +780,7 @@ nsresult nsParser::Parse(nsString& aSourceBuffer,void* aKey,const nsString& aCon * @param aContentType tells us what kind of stuff you're inserting * @return TRUE if valid, otherwise FALSE */ -PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){ +PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode){ /************************************************************************************ This method works like this: @@ -833,7 +833,7 @@ PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aSta * @param * @return */ -nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){ +nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode){ nsresult result=NS_OK; nsAutoString theContext; @@ -1140,7 +1140,7 @@ nsresult nsParser::OnDataAvailable(nsIURI* aURL, nsIInputStream *pIStream, PRUin mParserContext->mScanner->Append(mParserContext->mTransferBuffer,theNumRead); nsString& theBuffer=mParserContext->mScanner->GetBuffer(); - theBuffer.ToUCS2(theStartPos); + // theBuffer.ToUCS2(theStartPos); #ifdef rickgdebug (*gDumpFile) << mParserContext->mTransferBuffer; @@ -1175,6 +1175,7 @@ nsresult nsParser::OnStopRequest(nsIURI* aURL, nsresult status, const PRUnichar* if(mParserFilter) mParserFilter->Finish(); + mParserContext->mScanner->SetIncremental(PR_FALSE); nsresult result=ResumeParse(nsnull, PR_TRUE); // If the parser isn't enabled, we don't finish parsing till // it is reenabled. diff --git a/mozilla/htmlparser/src/nsParser.h b/mozilla/htmlparser/src/nsParser.h index 0d8dc858675..ddbddf64d06 100644 --- a/mozilla/htmlparser/src/nsParser.h +++ b/mozilla/htmlparser/src/nsParser.h @@ -174,7 +174,7 @@ friend class CTokenHandler; * @param aListener is a listener to forward notifications to * @return TRUE if all went well -- FALSE otherwise */ - virtual nsresult Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE,void* aKey=0); + virtual nsresult Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE,void* aKey=0,eParseMode aMode=eParseMode_autodetect); /** * Cause parser to parse input from given stream @@ -182,7 +182,7 @@ friend class CTokenHandler; * @param aStream is the i/o source * @return TRUE if all went well -- FALSE otherwise */ - virtual nsresult Parse(nsIInputStream& aStream,PRBool aEnableVerify=PR_FALSE,void* aKey=0); + virtual nsresult Parse(nsIInputStream& aStream,PRBool aEnableVerify=PR_FALSE,void* aKey=0,eParseMode aMode=eParseMode_autodetect); /** * @update gess5/11/98 @@ -190,10 +190,10 @@ 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 nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE); + virtual nsresult Parse(const nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE,eParseMode aMode=eParseMode_autodetect); - virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType); - virtual nsresult ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType); + virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode=eParseMode_autodetect); + virtual nsresult ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode=eParseMode_autodetect); /** diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp index c8dea76dba7..b22f867ed3e 100644 --- a/mozilla/htmlparser/src/nsScanner.cpp +++ b/mozilla/htmlparser/src/nsScanner.cpp @@ -51,7 +51,7 @@ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharset mBuffer(anHTMLString), mFilename("") { mTotalRead=mBuffer.Length(); - mIncremental=PR_TRUE; + mIncremental=PR_FALSE; mOwnsStream=PR_FALSE; mOffset=0; mMarkPos=0; @@ -99,14 +99,14 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a * @param aFilename -- * @return */ -nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& aCharset, nsCharsetSource aSource, PRBool assumeOwnership) : +nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& aCharset, nsCharsetSource aSource) : mBuffer(""), mFilename(aFilename) { - mIncremental=PR_TRUE; + mIncremental=PR_FALSE; mOffset=0; mMarkPos=0; mTotalRead=0; - mOwnsStream=assumeOwnership; + mOwnsStream=PR_FALSE; mInputStream=&aStream; mUnicodeDecoder = 0; mCharset = ""; @@ -114,8 +114,8 @@ nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& SetDocumentCharset(aCharset, aSource); } -nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSource aSource) -{ + +nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSource aSource) { nsresult res = NS_OK; @@ -212,12 +212,15 @@ PRUint32 nsScanner::RewindToMark(void){ * @param * @return */ -PRUint32 nsScanner::Mark(void){ - if((mOffset>0) && (mOffset>eBufferSizeThreshold)) { - mBuffer.Cut(0,mOffset); //delete chars up to mark position - mOffset=0; +PRUint32 nsScanner::Mark(PRInt32 anIndex){ + if(kNotFound==anIndex) { + if((mOffset>0) && (mOffset>eBufferSizeThreshold)) { + mBuffer.Cut(0,mOffset); //delete chars up to mark position + mOffset=0; + } + mMarkPos=mOffset; } - mMarkPos=mOffset; + else mOffset=(PRUint32)anIndex; return 0; } @@ -229,7 +232,7 @@ PRUint32 nsScanner::Mark(void){ * @update gess4/3/98 * @return error code */ -PRBool nsScanner::Append(nsString& aBuffer) { +PRBool nsScanner::Append(const nsString& aBuffer) { mBuffer.Append(aBuffer); mTotalRead+=aBuffer.Length(); return PR_TRUE; diff --git a/mozilla/htmlparser/src/nsScanner.h b/mozilla/htmlparser/src/nsScanner.h index 025db1883d2..461158933b7 100644 --- a/mozilla/htmlparser/src/nsScanner.h +++ b/mozilla/htmlparser/src/nsScanner.h @@ -76,7 +76,7 @@ class nsScanner { * @param aMode represents the parser mode (nav, other) * @return */ - nsScanner(nsString& aFilename, nsInputStream& aStream, const nsString& aCharset, nsCharsetSource aSource,PRBool assumeOwnership=PR_TRUE); + nsScanner(nsString& aFilename, nsInputStream& aStream, const nsString& aCharset, nsCharsetSource aSource); ~nsScanner(); @@ -206,7 +206,7 @@ class nsScanner { * @param * @return */ - PRUint32 Mark(void); + PRUint32 Mark(PRInt32 anIndex=-1); /** * Resets current offset position of input stream to marked position. @@ -228,7 +228,7 @@ class nsScanner { * @param * @return */ - PRBool Append(nsString& aBuffer); + PRBool Append(const nsString& aBuffer); /** * @@ -282,6 +282,17 @@ class nsScanner { */ nsresult SetDocumentCharset(const nsString& aCharset, nsCharsetSource aSource); + /** + * Internal method used to cause the internal buffer to + * be filled with data. + * + * @update gess4/3/98 + */ + PRBool IsIncremental(void) {return mIncremental;} + void SetIncremental(PRBool anIncrValue) {mIncremental=anIncrValue;} + + PRUint32 GetOffset(void) {return mOffset;} + protected: enum {eBufferSizeThreshold=512}; diff --git a/mozilla/htmlparser/src/nsViewSourceHTML.cpp b/mozilla/htmlparser/src/nsViewSourceHTML.cpp index 7b29d637aec..dc22e0b5fcd 100644 --- a/mozilla/htmlparser/src/nsViewSourceHTML.cpp +++ b/mozilla/htmlparser/src/nsViewSourceHTML.cpp @@ -883,7 +883,9 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { nsString& theText=aToken->GetStringValueXXX(); //if the comment has had it's markup stripped, then write it out seperately... - if(0!=theText.Find("WillBuildModel(); + result = aSink->WillBuildModel(); CStartToken theToken(eHTMLTag_html); HandleStartToken(&theToken); @@ -525,29 +525,35 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString * * @update gess5/18/98 * @param aParser is the parser object that's driving this process - * @return error code (almost always 0) + * @return error code (almost always NS_OK) */ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink) { nsresult result=NS_OK; - NS_ADDREF(aSink); if(aTokenizer) { nsITokenizer* oldTokenizer=mTokenizer; mTokenizer=aTokenizer; mParser=(nsParser*)aParser; - mSink=(nsIHTMLContentSink*)aSink; - gRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler(); - while(NS_SUCCEEDED(result)){ - CToken* theToken=mTokenizer->PopToken(); - if(theToken) { - result=HandleToken(theToken,aParser); - } - else break; - }//while - mTokenizer=oldTokenizer; + + mSink=nsnull; + result=aSink->QueryInterface(kIHTMLContentSinkIID, (void **)&mSink); + + if(mSink) { + NS_ADDREF(mSink); + gRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler(); + while(NS_SUCCEEDED(result)){ + CToken* theToken=mTokenizer->PopToken(); + if(theToken) { + result=HandleToken(theToken,aParser); + } + else break; + }//while + mTokenizer=oldTokenizer; + NS_IF_RELEASE(mSink); + mSink=nsnull; + } } else result=NS_ERROR_HTMLPARSER_BADTOKENIZER; - NS_IF_RELEASE(aSink); return result; } @@ -568,8 +574,7 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse } if(aParser){ - mSink=(nsIHTMLContentSink*)aSink; - if(aNotifySink && mSink){ + if(aNotifySink && aSink){ if((NS_OK==anErrorCode) && (mBodyContext->GetCount()>0)) { eHTMLTags theTarget; while(mBodyContext->GetCount() > 0) { @@ -605,16 +610,16 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse if(mComputedCRC32!=mExpectedCRC32) { if(mExpectedCRC32!=0) { printf("CRC Computed: %u Expected CRC: %u\n,",mComputedCRC32,mExpectedCRC32); - result = mSink->DidBuildModel(2); + result = aSink->DidBuildModel(2); } else { printf("Computed CRC: %u.\n",mComputedCRC32); - result = mSink->DidBuildModel(3); + result = aSink->DidBuildModel(3); } } - else result = mSink->DidBuildModel(0); + else result = aSink->DidBuildModel(0); } - else result=mSink->DidBuildModel(0); + else result=aSink->DidBuildModel(0); if(mDTDDebug) { mDTDDebug->DumpVectorRecord(); diff --git a/mozilla/parser/htmlparser/src/CRtfDTD.cpp b/mozilla/parser/htmlparser/src/CRtfDTD.cpp index 45a641c2131..82b4f2dd5a9 100644 --- a/mozilla/parser/htmlparser/src/CRtfDTD.cpp +++ b/mozilla/parser/htmlparser/src/CRtfDTD.cpp @@ -65,7 +65,7 @@ struct RTFEntry { eRTFTags mTagID; }; - +#if 0 static RTFEntry gRTFTable[] = { {"$",eRTFCtrl_unknown}, @@ -127,7 +127,7 @@ static const char* GetTagName(eRTFTags aTag) { } return ""; } - +#endif /** * This method gets called as part of our COM-like interfaces. diff --git a/mozilla/parser/htmlparser/src/nsElementTable.cpp b/mozilla/parser/htmlparser/src/nsElementTable.cpp index a1ace7f3a57..2cf30f6b6ac 100644 --- a/mozilla/parser/htmlparser/src/nsElementTable.cpp +++ b/mozilla/parser/htmlparser/src/nsElementTable.cpp @@ -121,7 +121,7 @@ CTagList gInTR(1,0,eHTMLTag_tr); CTagList gInDL(2,0,eHTMLTag_dl,eHTMLTag_body); CTagList gInFrameset(1,0,eHTMLTag_frameset); CTagList gInNoframes(1,0,eHTMLTag_noframes); -CTagList gInP(2,0,eHTMLTag_address,eHTMLTag_form); +CTagList gInP(3,0,eHTMLTag_address,eHTMLTag_form,eHTMLTag_span); CTagList gOptgroupParents(2,0,eHTMLTag_optgroup,eHTMLTag_select); CTagList gBodyParents(2,0,eHTMLTag_html,eHTMLTag_noframes); CTagList gColParents(2,0,eHTMLTag_table,eHTMLTag_colgroup); diff --git a/mozilla/parser/htmlparser/src/nsExpatDTD.cpp b/mozilla/parser/htmlparser/src/nsExpatDTD.cpp index 7c909eda4c0..7bfbe70f49a 100644 --- a/mozilla/parser/htmlparser/src/nsExpatDTD.cpp +++ b/mozilla/parser/htmlparser/src/nsExpatDTD.cpp @@ -112,13 +112,12 @@ NS_IMPL_RELEASE(nsExpatDTD) * @param * @return */ -nsExpatDTD::nsExpatDTD() : nsIDTD() { +nsExpatDTD::nsExpatDTD() : nsIDTD(), mFilename("") { NS_INIT_REFCNT(); mExpatParser=0; mParser=0; mSink=0; - mFilename; mLineNumber=0; mTokenizer=0; } @@ -446,12 +445,12 @@ NS_IMETHODIMP nsExpatDTD::HandleToken(CToken* aToken,nsIParser* aParser) { if(0PeekToken(); - if(theToken) { - eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); - if(eToken_attribute==theType){ + CToken* theAttrToken=mTokenizer->PeekToken(); + if(theAttrToken) { + eHTMLTokenTypes theAttrType=eHTMLTokenTypes(theAttrToken->GetTokenType()); + if(eToken_attribute==theAttrType){ mTokenizer->PopToken(); //pop it for real... - theNode.AddAttribute(theToken); + theNode.AddAttribute(theAttrToken); } } else return kEOF; diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index e4e1dbb2b35..cf478a2b678 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -788,6 +788,9 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString) static nsAutoString gEdibles("!-"); static nsAutoString gMinus("-"); static nsAutoString gWhitespace("\b\t\n\r "); + + static nsAutoString gDfltEndComment("-->"); + nsresult result=NS_OK; /********************************************************* @@ -797,7 +800,9 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString) *********************************************************/ aString=" aString+=aChar; PRInt32 findpos=kNotFound; - result=aScanner.ReadWhile(aString,gMinus,PR_TRUE,PR_TRUE); //get all available '---' - findpos=aString.RFind("-->"); - while((kNotFound==findpos) && (NS_OK==result)) { - result=aScanner.ReadUntil(aString,kMinus,PR_TRUE); - - if(NS_OK==result) { - result=aScanner.ReadWhile(aString,gMinus,PR_TRUE,PR_FALSE); //get all available '---' - if(NS_OK==result) - result=aScanner.ReadWhile(aString,gWhitespace,PR_TRUE,PR_FALSE); //get all available whitespace - } - - if(NS_OK==result) { - result=aScanner.GetChar(aChar); - aString+=aChar; - } - + result=aScanner.ReadUntil(aString,kGreaterThan,PR_TRUE); if(NS_OK==result){ - theRightChars.Truncate(0); - aString.Right(theRightChars,5); - theRightChars.StripChars(" "); - - findpos=theRightChars.RFind("-->"); - if(kNotFound==findpos) - findpos=theRightChars.RFind("!>"); + + if(kNotFound==theBestAltPos) { + const PRUnichar* theBuf=aString.GetUnicode(); + findpos=aString.Length()-3; + theBuf=(PRUnichar*)&theBuf[findpos]; + if(!gDfltEndComment.Equals(theBuf,PR_FALSE,3)) { + //we didn't find the dflt end comment delimiter, so look for alternatives... + findpos=kNotFound; + theRightChars.Truncate(0); + aString.Right(theRightChars,15); + theRightChars.StripChars(" "); + + int rclen=theRightChars.Length(); + aChar=theRightChars[rclen-2]; + if(('!'==aChar) || ('-'==aChar)) { + theBestAltPos=aString.Length(); + theStartOffset=aScanner.GetOffset(); + } + } + } + } } //while + if((kNotFound==findpos) && (!aScanner.IsIncremental())) { + //if you're here, then we're in a special state. + //The problem at hand is that we've hit the end of the document without finding the normal endcomment delimiter "-->". + //In this case, the first thing we try is to see if we found one of the alternate endcomment delimiters "->" or "!>". + //If so, rewind just pass than, and use everything up to that point as your comment. + //If not, the document has no end comment and should be treated as one big comment. + if(kNotFound'==mTextValue.Last()) + mTextValue.Truncate(mTextValue.Length()-1); + } +#endif return result; } diff --git a/mozilla/parser/htmlparser/src/nsIParser.h b/mozilla/parser/htmlparser/src/nsIParser.h index 910579964ae..e9797f6a4b7 100644 --- a/mozilla/parser/htmlparser/src/nsIParser.h +++ b/mozilla/parser/htmlparser/src/nsIParser.h @@ -95,7 +95,7 @@ public: * * @update gess 3/25/98 */ -class nsIParser : public nsISupports { +CLASS_EXPORT_HTMLPARS nsIParser : public nsISupports { public: static const nsIID& GetIID() { static nsIID iid = NS_IPARSER_IID; return iid; } @@ -167,13 +167,13 @@ class nsIParser : public nsISupports { ******************************************************************************************/ virtual PRBool EnableParser(PRBool aState) = 0; virtual PRBool IsParserEnabled() = 0; - virtual nsresult Parse(nsIURI* aURL,nsIStreamObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE, void* aKey=0) = 0; - virtual nsresult Parse(nsIInputStream& aStream, PRBool aEnableVerify=PR_FALSE, void* aKey=0) = 0; - virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall) = 0; + virtual nsresult Parse(nsIURI* aURL,nsIStreamObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE, void* aKey=0,eParseMode aMode=eParseMode_autodetect) = 0; + virtual nsresult Parse(nsIInputStream& aStream, PRBool aEnableVerify=PR_FALSE, void* aKey=0,eParseMode aMode=eParseMode_autodetect) = 0; + virtual nsresult Parse(const nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall,eParseMode aMode=eParseMode_autodetect) = 0; virtual nsresult Terminate(void) = 0; - virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0; - virtual nsresult ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0; + virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode=eParseMode_autodetect)=0; + virtual nsresult ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode=eParseMode_autodetect)=0; /** * This method gets called when the tokens have been consumed, and it's time diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index 0465de6bee5..de922574d69 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -644,7 +644,7 @@ nsParser::IsParserEnabled() * @param aFilename -- const char* containing file to be parsed. * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aVerifyEnabled, void* aKey) { +nsresult nsParser::Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aVerifyEnabled, void* aKey,eParseMode aMode) { NS_PRECONDITION(0!=aURL,kNullURL); nsresult result=kBadURL; @@ -683,7 +683,7 @@ nsresult nsParser::Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aVerif * @param aStream is the i/o source * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aKey){ +nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aKey,eParseMode aMode){ mDTDVerification=aVerifyEnabled; nsresult result=NS_ERROR_OUT_OF_MEMORY; @@ -692,7 +692,7 @@ nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aK nsAutoString theUnknownFilename("unknown"); nsInputStream input(&aStream); - CParserContext* pc=new CParserContext(new nsScanner(theUnknownFilename, input, mCharset, mCharsetSource,PR_FALSE),aKey,0); + CParserContext* pc=new CParserContext(new nsScanner(theUnknownFilename, input, mCharset, mCharsetSource),aKey,0); if(pc) { PushContext(*pc); pc->mSourceType=kHTMLTextContentType; @@ -721,7 +721,7 @@ nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aK * @param aContentType tells us what type of content to expect in the given string * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aVerifyEnabled,PRBool aLastCall){ +nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aVerifyEnabled,PRBool aLastCall,eParseMode aMode){ //NOTE: Make sure that updates to this method don't cause // bug #2361 to break again! @@ -780,7 +780,7 @@ nsresult nsParser::Parse(nsString& aSourceBuffer,void* aKey,const nsString& aCon * @param aContentType tells us what kind of stuff you're inserting * @return TRUE if valid, otherwise FALSE */ -PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){ +PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode){ /************************************************************************************ This method works like this: @@ -833,7 +833,7 @@ PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aSta * @param * @return */ -nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){ +nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode){ nsresult result=NS_OK; nsAutoString theContext; @@ -1140,7 +1140,7 @@ nsresult nsParser::OnDataAvailable(nsIURI* aURL, nsIInputStream *pIStream, PRUin mParserContext->mScanner->Append(mParserContext->mTransferBuffer,theNumRead); nsString& theBuffer=mParserContext->mScanner->GetBuffer(); - theBuffer.ToUCS2(theStartPos); + // theBuffer.ToUCS2(theStartPos); #ifdef rickgdebug (*gDumpFile) << mParserContext->mTransferBuffer; @@ -1175,6 +1175,7 @@ nsresult nsParser::OnStopRequest(nsIURI* aURL, nsresult status, const PRUnichar* if(mParserFilter) mParserFilter->Finish(); + mParserContext->mScanner->SetIncremental(PR_FALSE); nsresult result=ResumeParse(nsnull, PR_TRUE); // If the parser isn't enabled, we don't finish parsing till // it is reenabled. diff --git a/mozilla/parser/htmlparser/src/nsParser.h b/mozilla/parser/htmlparser/src/nsParser.h index 0d8dc858675..ddbddf64d06 100644 --- a/mozilla/parser/htmlparser/src/nsParser.h +++ b/mozilla/parser/htmlparser/src/nsParser.h @@ -174,7 +174,7 @@ friend class CTokenHandler; * @param aListener is a listener to forward notifications to * @return TRUE if all went well -- FALSE otherwise */ - virtual nsresult Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE,void* aKey=0); + virtual nsresult Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE,void* aKey=0,eParseMode aMode=eParseMode_autodetect); /** * Cause parser to parse input from given stream @@ -182,7 +182,7 @@ friend class CTokenHandler; * @param aStream is the i/o source * @return TRUE if all went well -- FALSE otherwise */ - virtual nsresult Parse(nsIInputStream& aStream,PRBool aEnableVerify=PR_FALSE,void* aKey=0); + virtual nsresult Parse(nsIInputStream& aStream,PRBool aEnableVerify=PR_FALSE,void* aKey=0,eParseMode aMode=eParseMode_autodetect); /** * @update gess5/11/98 @@ -190,10 +190,10 @@ 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 nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE); + virtual nsresult Parse(const nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE,eParseMode aMode=eParseMode_autodetect); - virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType); - virtual nsresult ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType); + virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode=eParseMode_autodetect); + virtual nsresult ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,eParseMode aMode=eParseMode_autodetect); /** diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp index c8dea76dba7..b22f867ed3e 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.cpp +++ b/mozilla/parser/htmlparser/src/nsScanner.cpp @@ -51,7 +51,7 @@ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharset mBuffer(anHTMLString), mFilename("") { mTotalRead=mBuffer.Length(); - mIncremental=PR_TRUE; + mIncremental=PR_FALSE; mOwnsStream=PR_FALSE; mOffset=0; mMarkPos=0; @@ -99,14 +99,14 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a * @param aFilename -- * @return */ -nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& aCharset, nsCharsetSource aSource, PRBool assumeOwnership) : +nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& aCharset, nsCharsetSource aSource) : mBuffer(""), mFilename(aFilename) { - mIncremental=PR_TRUE; + mIncremental=PR_FALSE; mOffset=0; mMarkPos=0; mTotalRead=0; - mOwnsStream=assumeOwnership; + mOwnsStream=PR_FALSE; mInputStream=&aStream; mUnicodeDecoder = 0; mCharset = ""; @@ -114,8 +114,8 @@ nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& SetDocumentCharset(aCharset, aSource); } -nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSource aSource) -{ + +nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSource aSource) { nsresult res = NS_OK; @@ -212,12 +212,15 @@ PRUint32 nsScanner::RewindToMark(void){ * @param * @return */ -PRUint32 nsScanner::Mark(void){ - if((mOffset>0) && (mOffset>eBufferSizeThreshold)) { - mBuffer.Cut(0,mOffset); //delete chars up to mark position - mOffset=0; +PRUint32 nsScanner::Mark(PRInt32 anIndex){ + if(kNotFound==anIndex) { + if((mOffset>0) && (mOffset>eBufferSizeThreshold)) { + mBuffer.Cut(0,mOffset); //delete chars up to mark position + mOffset=0; + } + mMarkPos=mOffset; } - mMarkPos=mOffset; + else mOffset=(PRUint32)anIndex; return 0; } @@ -229,7 +232,7 @@ PRUint32 nsScanner::Mark(void){ * @update gess4/3/98 * @return error code */ -PRBool nsScanner::Append(nsString& aBuffer) { +PRBool nsScanner::Append(const nsString& aBuffer) { mBuffer.Append(aBuffer); mTotalRead+=aBuffer.Length(); return PR_TRUE; diff --git a/mozilla/parser/htmlparser/src/nsScanner.h b/mozilla/parser/htmlparser/src/nsScanner.h index 025db1883d2..461158933b7 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.h +++ b/mozilla/parser/htmlparser/src/nsScanner.h @@ -76,7 +76,7 @@ class nsScanner { * @param aMode represents the parser mode (nav, other) * @return */ - nsScanner(nsString& aFilename, nsInputStream& aStream, const nsString& aCharset, nsCharsetSource aSource,PRBool assumeOwnership=PR_TRUE); + nsScanner(nsString& aFilename, nsInputStream& aStream, const nsString& aCharset, nsCharsetSource aSource); ~nsScanner(); @@ -206,7 +206,7 @@ class nsScanner { * @param * @return */ - PRUint32 Mark(void); + PRUint32 Mark(PRInt32 anIndex=-1); /** * Resets current offset position of input stream to marked position. @@ -228,7 +228,7 @@ class nsScanner { * @param * @return */ - PRBool Append(nsString& aBuffer); + PRBool Append(const nsString& aBuffer); /** * @@ -282,6 +282,17 @@ class nsScanner { */ nsresult SetDocumentCharset(const nsString& aCharset, nsCharsetSource aSource); + /** + * Internal method used to cause the internal buffer to + * be filled with data. + * + * @update gess4/3/98 + */ + PRBool IsIncremental(void) {return mIncremental;} + void SetIncremental(PRBool anIncrValue) {mIncremental=anIncrValue;} + + PRUint32 GetOffset(void) {return mOffset;} + protected: enum {eBufferSizeThreshold=512}; diff --git a/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp b/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp index 7b29d637aec..dc22e0b5fcd 100644 --- a/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp +++ b/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp @@ -883,7 +883,9 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { nsString& theText=aToken->GetStringValueXXX(); //if the comment has had it's markup stripped, then write it out seperately... - if(0!=theText.Find("