diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 90fffca3394..e526c6d364f 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -2933,6 +2933,11 @@ nsresult CNavDTD::ConsumeToken(CToken*& aToken){ result=theScanner->GetChar(theChar); switch(result) { case kEOF: + //We convert from eof to complete here, because we never really tried to get data. + //All we did was try to see if data was available, which it wasn't. + //It's important to return process complete, so that controlling logic can know that + //everything went well, but we're done with token processing. + result=kProcessComplete; break; case kInterrupted: diff --git a/mozilla/htmlparser/src/nsIParserNode.h b/mozilla/htmlparser/src/nsIParserNode.h index 670031435a4..db048d22686 100644 --- a/mozilla/htmlparser/src/nsIParserNode.h +++ b/mozilla/htmlparser/src/nsIParserNode.h @@ -119,6 +119,15 @@ class nsIParserNode { * @return int (unicode char or unicode index from table) */ virtual PRInt32 TranslateToUnicodeStr(nsString& aString) const = 0; + + /** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ + virtual PRUint16 GetSourceLineNumber(void)=0; + }; #endif diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index 803f9f16ba4..9b2348b8157 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -851,6 +851,8 @@ PRInt32 nsParser::Tokenize(){ mParserContext->mScanner->RewindToMark(); } } + if(result=kProcessComplete) + result=NS_OK; DidTokenize(); return result; } diff --git a/mozilla/htmlparser/src/nsParserNode.cpp b/mozilla/htmlparser/src/nsParserNode.cpp index f0053ada255..d748347ffa7 100644 --- a/mozilla/htmlparser/src/nsParserNode.cpp +++ b/mozilla/htmlparser/src/nsParserNode.cpp @@ -203,4 +203,13 @@ PRInt32 nsCParserNode::TranslateToUnicodeStr(nsString& aString) const return -1; } +/** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ +PRUint16 nsCParserNode::GetSourceLineNumber(void){ + return mToken->GetSourceLineNumber(); +} diff --git a/mozilla/htmlparser/src/nsParserNode.h b/mozilla/htmlparser/src/nsParserNode.h index 5c8aa3b6749..22c1a8bd984 100644 --- a/mozilla/htmlparser/src/nsParserNode.h +++ b/mozilla/htmlparser/src/nsParserNode.h @@ -146,6 +146,13 @@ class nsCParserNode : public nsIParserNode { */ virtual void SetSkippedContent(CToken* aToken); + /** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ + virtual PRUint16 GetSourceLineNumber(void); protected: PRInt32 mAttributeCount; diff --git a/mozilla/htmlparser/src/nsParserTypes.h b/mozilla/htmlparser/src/nsParserTypes.h index 9bad92f2a14..3cc5f343452 100644 --- a/mozilla/htmlparser/src/nsParserTypes.h +++ b/mozilla/htmlparser/src/nsParserTypes.h @@ -50,6 +50,7 @@ const PRInt32 kContextMismatch = 10003; const PRInt32 kBadFilename = 10004; const PRInt32 kBadURL = 10005; const PRInt32 kInterrupted = 10006; +const PRInt32 kProcessComplete = 10007; const PRInt32 kNotFound = -1; const PRInt32 kNoError = NS_OK; diff --git a/mozilla/htmlparser/src/nsToken.cpp b/mozilla/htmlparser/src/nsToken.cpp index 425e736b17d..c2e4e51b8cd 100644 --- a/mozilla/htmlparser/src/nsToken.cpp +++ b/mozilla/htmlparser/src/nsToken.cpp @@ -27,7 +27,7 @@ CToken::CToken(PRInt32 aTag) : mTextValue() { mTypeID=aTag; mStringInit=PR_FALSE; - mUnused=PR_FALSE; + mLineNumber=1; mAttrCount=0; } @@ -40,7 +40,7 @@ CToken::CToken(PRInt32 aTag) : mTextValue() { CToken::CToken(const nsString& aName) : mTextValue(aName) { mTypeID=0; mStringInit=PR_TRUE; - mUnused=PR_FALSE; + mLineNumber=1; mAttrCount=0; } @@ -53,7 +53,7 @@ CToken::CToken(const nsString& aName) : mTextValue(aName) { CToken::CToken(const char* aName) : mTextValue(aName) { mTypeID=0; mStringInit=PR_TRUE; - mUnused=PR_FALSE; + mLineNumber=1; mAttrCount=0; } @@ -204,6 +204,16 @@ const char* CToken::GetClassName(void) { return "token"; } +/** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ +PRUint16 CToken::GetSourceLineNumber(void){ + return mLineNumber; +} + /** * * @update gess 3/25/98 diff --git a/mozilla/htmlparser/src/nsToken.h b/mozilla/htmlparser/src/nsToken.h index 4ef8b563868..5fc75bd5568 100644 --- a/mozilla/htmlparser/src/nsToken.h +++ b/mozilla/htmlparser/src/nsToken.h @@ -167,6 +167,15 @@ class CToken { */ virtual const char* GetClassName(void); + + /** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ + virtual PRUint16 GetSourceLineNumber(void); + /** * perform self test. * @update gess5/11/98 @@ -177,7 +186,7 @@ protected: PRInt32 mTypeID; PRInt16 mAttrCount; PRBool mStringInit; - PRBool mUnused; + PRUint16 mLineNumber; nsAutoString mTextValue; }; diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index 90fffca3394..e526c6d364f 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -2933,6 +2933,11 @@ nsresult CNavDTD::ConsumeToken(CToken*& aToken){ result=theScanner->GetChar(theChar); switch(result) { case kEOF: + //We convert from eof to complete here, because we never really tried to get data. + //All we did was try to see if data was available, which it wasn't. + //It's important to return process complete, so that controlling logic can know that + //everything went well, but we're done with token processing. + result=kProcessComplete; break; case kInterrupted: diff --git a/mozilla/parser/htmlparser/src/nsIParserNode.h b/mozilla/parser/htmlparser/src/nsIParserNode.h index 670031435a4..db048d22686 100644 --- a/mozilla/parser/htmlparser/src/nsIParserNode.h +++ b/mozilla/parser/htmlparser/src/nsIParserNode.h @@ -119,6 +119,15 @@ class nsIParserNode { * @return int (unicode char or unicode index from table) */ virtual PRInt32 TranslateToUnicodeStr(nsString& aString) const = 0; + + /** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ + virtual PRUint16 GetSourceLineNumber(void)=0; + }; #endif diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index 803f9f16ba4..9b2348b8157 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -851,6 +851,8 @@ PRInt32 nsParser::Tokenize(){ mParserContext->mScanner->RewindToMark(); } } + if(result=kProcessComplete) + result=NS_OK; DidTokenize(); return result; } diff --git a/mozilla/parser/htmlparser/src/nsParserNode.cpp b/mozilla/parser/htmlparser/src/nsParserNode.cpp index f0053ada255..d748347ffa7 100644 --- a/mozilla/parser/htmlparser/src/nsParserNode.cpp +++ b/mozilla/parser/htmlparser/src/nsParserNode.cpp @@ -203,4 +203,13 @@ PRInt32 nsCParserNode::TranslateToUnicodeStr(nsString& aString) const return -1; } +/** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ +PRUint16 nsCParserNode::GetSourceLineNumber(void){ + return mToken->GetSourceLineNumber(); +} diff --git a/mozilla/parser/htmlparser/src/nsParserNode.h b/mozilla/parser/htmlparser/src/nsParserNode.h index 5c8aa3b6749..22c1a8bd984 100644 --- a/mozilla/parser/htmlparser/src/nsParserNode.h +++ b/mozilla/parser/htmlparser/src/nsParserNode.h @@ -146,6 +146,13 @@ class nsCParserNode : public nsIParserNode { */ virtual void SetSkippedContent(CToken* aToken); + /** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ + virtual PRUint16 GetSourceLineNumber(void); protected: PRInt32 mAttributeCount; diff --git a/mozilla/parser/htmlparser/src/nsParserTypes.h b/mozilla/parser/htmlparser/src/nsParserTypes.h index 9bad92f2a14..3cc5f343452 100644 --- a/mozilla/parser/htmlparser/src/nsParserTypes.h +++ b/mozilla/parser/htmlparser/src/nsParserTypes.h @@ -50,6 +50,7 @@ const PRInt32 kContextMismatch = 10003; const PRInt32 kBadFilename = 10004; const PRInt32 kBadURL = 10005; const PRInt32 kInterrupted = 10006; +const PRInt32 kProcessComplete = 10007; const PRInt32 kNotFound = -1; const PRInt32 kNoError = NS_OK; diff --git a/mozilla/parser/htmlparser/src/nsToken.cpp b/mozilla/parser/htmlparser/src/nsToken.cpp index 425e736b17d..c2e4e51b8cd 100644 --- a/mozilla/parser/htmlparser/src/nsToken.cpp +++ b/mozilla/parser/htmlparser/src/nsToken.cpp @@ -27,7 +27,7 @@ CToken::CToken(PRInt32 aTag) : mTextValue() { mTypeID=aTag; mStringInit=PR_FALSE; - mUnused=PR_FALSE; + mLineNumber=1; mAttrCount=0; } @@ -40,7 +40,7 @@ CToken::CToken(PRInt32 aTag) : mTextValue() { CToken::CToken(const nsString& aName) : mTextValue(aName) { mTypeID=0; mStringInit=PR_TRUE; - mUnused=PR_FALSE; + mLineNumber=1; mAttrCount=0; } @@ -53,7 +53,7 @@ CToken::CToken(const nsString& aName) : mTextValue(aName) { CToken::CToken(const char* aName) : mTextValue(aName) { mTypeID=0; mStringInit=PR_TRUE; - mUnused=PR_FALSE; + mLineNumber=1; mAttrCount=0; } @@ -204,6 +204,16 @@ const char* CToken::GetClassName(void) { return "token"; } +/** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ +PRUint16 CToken::GetSourceLineNumber(void){ + return mLineNumber; +} + /** * * @update gess 3/25/98 diff --git a/mozilla/parser/htmlparser/src/nsToken.h b/mozilla/parser/htmlparser/src/nsToken.h index 4ef8b563868..5fc75bd5568 100644 --- a/mozilla/parser/htmlparser/src/nsToken.h +++ b/mozilla/parser/htmlparser/src/nsToken.h @@ -167,6 +167,15 @@ class CToken { */ virtual const char* GetClassName(void); + + /** + * This getter retrieves the line number from the input source where + * the token occured. Lines are interpreted as occuring between \n characters. + * @update gess7/24/98 + * @return int containing the line number the token was found on + */ + virtual PRUint16 GetSourceLineNumber(void); + /** * perform self test. * @update gess5/11/98 @@ -177,7 +186,7 @@ protected: PRInt32 mTypeID; PRInt16 mAttrCount; PRBool mStringInit; - PRBool mUnused; + PRUint16 mLineNumber; nsAutoString mTextValue; };