improvements to entity parsing and viewing

git-svn-id: svn://10.0.0.236/trunk@15159 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rickg%netscape.com 1998-11-23 08:01:14 +00:00
parent e9708a17e4
commit ef03ca1113
6 changed files with 52 additions and 38 deletions

View File

@ -3371,22 +3371,22 @@ CNavDTD::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
*/
nsresult
CNavDTD::ConsumeEntity(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRUnichar ch;
nsresult result=aScanner.GetChar(ch);
PRUnichar theChar;
nsresult result=aScanner.GetChar(theChar);
if(NS_OK==result) {
if(nsString::IsAlpha(ch)) { //handle common enity references &xxx; or &#000.
if(nsString::IsAlpha(theChar)) { //handle common enity references &xxx; or &#000.
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result = aToken->Consume(ch,aScanner); //tell new token to finish consuming text...
result = aToken->Consume(theChar,aScanner); //tell new token to finish consuming text...
}
else if(kHashsign==ch) {
else if(kHashsign==theChar) {
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result=aToken->Consume(0,aScanner);
}
else {
//oops, we're actually looking at plain text...
nsAutoString temp("&");
temp.Append(ch);
aScanner.PutBack(theChar);
result=ConsumeText(temp,aScanner,aToken);
}
}//if

View File

@ -479,22 +479,22 @@ NS_IMETHODIMP CViewSourceHTML::ConsumeAttributes(PRUnichar aChar,CScanner& aScan
* @return new token or null
*/
NS_IMETHODIMP CViewSourceHTML::ConsumeEntity(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRUnichar ch;
nsresult result=aScanner.GetChar(ch);
PRUnichar theChar;
nsresult result=aScanner.GetChar(theChar);
if(NS_OK==result) {
if(nsString::IsAlpha(ch)) { //handle common enity references &xxx; or &#000.
if(nsString::IsAlpha(theChar)) { //handle common enity references &xxx; or &#000.
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result = aToken->Consume(ch,aScanner); //tell new token to finish consuming text...
result = aToken->Consume(theChar,aScanner); //tell new token to finish consuming text...
}
else if(kHashsign==ch) {
else if(kHashsign==theChar) {
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result=aToken->Consume(0,aScanner);
}
else {
//oops, we're actually looking at plain text...
nsAutoString temp("&");
temp.Append(ch);
aScanner.PutBack(theChar);
result=ConsumeText(temp,aScanner,aToken);
}
}//if
@ -952,7 +952,14 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken) {
break;
case eToken_entity:
result=mSink->AddLeaf(theNode);
{
SetColor("maroon",PR_TRUE,*mSink);
nsAutoString theStr("&");
theStr.Append(aToken->GetStringValueXXX());
theStr.Append(";");
WriteText(theStr,*mSink,PR_FALSE);
SetStyle(eHTMLTag_font,PR_FALSE,*mSink);
}
break;
case eToken_comment:

View File

@ -417,22 +417,22 @@ NS_IMETHODIMP CWellFormedDTD::ConsumeAttributes(PRUnichar aChar,CScanner& aScann
* @return new token or null
*/
NS_IMETHODIMP CWellFormedDTD::ConsumeEntity(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRUnichar ch;
nsresult result=aScanner.GetChar(ch);
PRUnichar theChar;
nsresult result=aScanner.GetChar(theChar);
if(NS_OK==result) {
if(nsString::IsAlpha(ch)) { //handle common enity references &xxx; or &#000.
if(nsString::IsAlpha(theChar)) { //handle common enity references &xxx; or &#000.
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result = aToken->Consume(ch,aScanner); //tell new token to finish consuming text...
result = aToken->Consume(theChar,aScanner); //tell new token to finish consuming text...
}
else if(kHashsign==ch) {
else if(kHashsign==theChar) {
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result=aToken->Consume(0,aScanner);
}
else {
//oops, we're actually looking at plain text...
nsAutoString temp("&");
temp.Append(ch);
aScanner.PutBack(theChar);
result=ConsumeText(temp,aScanner,aToken);
}
}//if

View File

@ -3371,22 +3371,22 @@ CNavDTD::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
*/
nsresult
CNavDTD::ConsumeEntity(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRUnichar ch;
nsresult result=aScanner.GetChar(ch);
PRUnichar theChar;
nsresult result=aScanner.GetChar(theChar);
if(NS_OK==result) {
if(nsString::IsAlpha(ch)) { //handle common enity references &xxx; or &#000.
if(nsString::IsAlpha(theChar)) { //handle common enity references &xxx; or &#000.
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result = aToken->Consume(ch,aScanner); //tell new token to finish consuming text...
result = aToken->Consume(theChar,aScanner); //tell new token to finish consuming text...
}
else if(kHashsign==ch) {
else if(kHashsign==theChar) {
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result=aToken->Consume(0,aScanner);
}
else {
//oops, we're actually looking at plain text...
nsAutoString temp("&");
temp.Append(ch);
aScanner.PutBack(theChar);
result=ConsumeText(temp,aScanner,aToken);
}
}//if

View File

@ -479,22 +479,22 @@ NS_IMETHODIMP CViewSourceHTML::ConsumeAttributes(PRUnichar aChar,CScanner& aScan
* @return new token or null
*/
NS_IMETHODIMP CViewSourceHTML::ConsumeEntity(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRUnichar ch;
nsresult result=aScanner.GetChar(ch);
PRUnichar theChar;
nsresult result=aScanner.GetChar(theChar);
if(NS_OK==result) {
if(nsString::IsAlpha(ch)) { //handle common enity references &xxx; or &#000.
if(nsString::IsAlpha(theChar)) { //handle common enity references &xxx; or &#000.
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result = aToken->Consume(ch,aScanner); //tell new token to finish consuming text...
result = aToken->Consume(theChar,aScanner); //tell new token to finish consuming text...
}
else if(kHashsign==ch) {
else if(kHashsign==theChar) {
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result=aToken->Consume(0,aScanner);
}
else {
//oops, we're actually looking at plain text...
nsAutoString temp("&");
temp.Append(ch);
aScanner.PutBack(theChar);
result=ConsumeText(temp,aScanner,aToken);
}
}//if
@ -952,7 +952,14 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken) {
break;
case eToken_entity:
result=mSink->AddLeaf(theNode);
{
SetColor("maroon",PR_TRUE,*mSink);
nsAutoString theStr("&");
theStr.Append(aToken->GetStringValueXXX());
theStr.Append(";");
WriteText(theStr,*mSink,PR_FALSE);
SetStyle(eHTMLTag_font,PR_FALSE,*mSink);
}
break;
case eToken_comment:

View File

@ -417,22 +417,22 @@ NS_IMETHODIMP CWellFormedDTD::ConsumeAttributes(PRUnichar aChar,CScanner& aScann
* @return new token or null
*/
NS_IMETHODIMP CWellFormedDTD::ConsumeEntity(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRUnichar ch;
nsresult result=aScanner.GetChar(ch);
PRUnichar theChar;
nsresult result=aScanner.GetChar(theChar);
if(NS_OK==result) {
if(nsString::IsAlpha(ch)) { //handle common enity references &xxx; or &#000.
if(nsString::IsAlpha(theChar)) { //handle common enity references &xxx; or &#000.
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result = aToken->Consume(ch,aScanner); //tell new token to finish consuming text...
result = aToken->Consume(theChar,aScanner); //tell new token to finish consuming text...
}
else if(kHashsign==ch) {
else if(kHashsign==theChar) {
aToken = gTokenRecycler.CreateTokenOfType(eToken_entity,eHTMLTag_entity,gEmpty);
result=aToken->Consume(0,aScanner);
}
else {
//oops, we're actually looking at plain text...
nsAutoString temp("&");
temp.Append(ch);
aScanner.PutBack(theChar);
result=ConsumeText(temp,aScanner,aToken);
}
}//if