diff --git a/mozilla/htmlparser/src/CNavDelegate.cpp b/mozilla/htmlparser/src/CNavDelegate.cpp index 6bdd5784c48..857a233b1c6 100644 --- a/mozilla/htmlparser/src/CNavDelegate.cpp +++ b/mozilla/htmlparser/src/CNavDelegate.cpp @@ -81,42 +81,49 @@ nsIDTD* CNavDelegate::GetDTD(void) const{ * and we know we're at the start of some kind of tagged * element. We don't know yet if it's a tag or a comment. * - * @update gess 3/25/98 - * @param - * @return + * @update gess 5/12/98 + * @param aChar is the last char read + * @param aScanner is represents our input source + * @param aToken is the out arg holding our new token + * @return error code (may return kInterrupted). */ PRInt32 CNavDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) { nsAutoString empty(""); PRInt32 result=aScanner.GetChar(aChar); - switch(aChar) { - case kForwardSlash: - PRUnichar ch; - result=aScanner.Peek(ch); - if(nsString::IsAlpha(ch)) - aToken=new CEndToken(empty); - else aToken=new CCommentToken(empty); //Special case: is treated as a comment - break; - case kExclamation: - aToken=new CCommentToken(empty); - break; - default: - if(nsString::IsAlpha(aChar)) - return ConsumeStartTag(aChar,aScanner,aToken); - else if(kEOF!=aChar) { - nsAutoString temp("<"); - return ConsumeText(temp,aScanner,aToken); - } - } //switch + if(kNoError==result) { - if(0!=aToken) { - result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... - if(result) { - delete aToken; - aToken=0; - } - } + switch(aChar) { + case kForwardSlash: + PRUnichar ch; + result=aScanner.Peek(ch); + if(kNoError==result) { + if(nsString::IsAlpha(ch)) + aToken=new CEndToken(empty); + else aToken=new CCommentToken(empty); //Special case: is treated as a comment + }//if + break; + case kExclamation: + aToken=new CCommentToken(empty); + break; + default: + if(nsString::IsAlpha(aChar)) + return ConsumeStartTag(aChar,aScanner,aToken); + else if(kEOF!=aChar) { + nsAutoString temp("<"); + return ConsumeText(temp,aScanner,aToken); + } + } //switch + + if((0!=aToken) && (kNoError==result)) { + result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... + if(result) { + delete aToken; + aToken=0; + } + } //if + } //if return result; } @@ -131,20 +138,26 @@ PRInt32 CNavDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& aTo */ PRInt32 CNavDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner) { PRBool done=PR_FALSE; - nsAutoString as(""); PRInt32 result=kNoError; + nsAutoString as(""); + while((!done) && (result==kNoError)) { - CToken* theToken= new CAttributeToken(as); - if(theToken){ - result= theToken->Consume(aChar,aScanner); //tell new token to finish consuming text... + CToken* theToken= new CAttributeToken(as); + if(theToken){ + result=theToken->Consume(aChar,aScanner); //tell new token to finish consuming text... + if(kNoError==result){ mTokenDeque.Push(theToken); - } - aScanner.Peek(aChar); - if(aChar==kGreaterThan) { //you just ate the '>' - aScanner.GetChar(aChar); //skip the '>' - done=PR_TRUE; - } - } + }//if + }//if + + if(kNoError==result){ + result=aScanner.Peek(aChar); + if(aChar==kGreaterThan) { //you just ate the '>' + aScanner.GetChar(aChar); //skip the '>' + done=PR_TRUE; + }//if + }//if + }//while return result; } @@ -166,8 +179,7 @@ PRInt32 CNavDelegate::ConsumeContentToEndTag(const nsString& aString,PRUnichar a endTag.Append(aString); endTag.Append(">"); aToken=new CSkippedContentToken(endTag); - PRInt32 result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... - return result; + return aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... } /** @@ -183,38 +195,43 @@ PRInt32 CNavDelegate::ConsumeContentToEndTag(const nsString& aString,PRUnichar a PRInt32 CNavDelegate::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) { aToken=new CStartToken(nsAutoString("")); PRInt32 result=kNoError; + if(aToken) { result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... - if(((CStartToken*)aToken)->IsAttributed()) { - result=ConsumeAttributes(aChar,aScanner); - } - //now that that's over with, we have one more problem to solve. - //In the case that we just read a