diff --git a/htmlparser/src/CNavDTD.cpp b/htmlparser/src/CNavDTD.cpp
index 5d32a4b9de4..7ff20299cdf 100644
--- a/htmlparser/src/CNavDTD.cpp
+++ b/htmlparser/src/CNavDTD.cpp
@@ -199,6 +199,7 @@ CToken* nsCTokenRecycler::CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag
case eToken_script: result=new CScriptToken(); break;
case eToken_style: result=new CStyleToken(); break;
case eToken_skippedcontent: result=new CSkippedContentToken(aString); break;
+ case eToken_instruction:result=new CInstructionToken(); break;
default:
break;
}
@@ -308,6 +309,8 @@ PRInt32 NavDispatchTokenHandler(CToken* aToken,nsIDTD* aDTD) {
result=theDTD->HandleStyleToken(aToken); break;
case eToken_skippedcontent:
result=theDTD->HandleSkippedContentToken(aToken); break;
+ case eToken_instruction:
+ result=theDTD->HandleProcessingInstructionToken(aToken); break;
default:
result=0;
}//switch
@@ -337,6 +340,7 @@ void CNavDTD::InitializeDefaultTokenHandlers() {
// AddTokenHandler(new CTokenHandler(NavDispatchTokenHandler,eToken_script));
AddTokenHandler(new CTokenHandler(NavDispatchTokenHandler,eToken_style));
AddTokenHandler(new CTokenHandler(NavDispatchTokenHandler,eToken_skippedcontent));
+ AddTokenHandler(new CTokenHandler(NavDispatchTokenHandler,eToken_instruction));
}
@@ -864,6 +868,21 @@ nsresult CNavDTD::HandleStyleToken(CToken* aToken){
}
+/**
+ * This method gets called when an "instruction" token has been
+ * encountered in the parse process.
+ *
+ * @update gess 3/25/98
+ * @param aToken -- next (start) token to be handled
+ * @return PR_TRUE if all went well; PR_FALSE if error occured
+ */
+nsresult CNavDTD::HandleProcessingInstructionToken(CToken* aToken){
+ NS_PRECONDITION(0!=aToken,kNullToken);
+
+// CStyleToken* st = (CStyleToken*)(aToken);
+ return NS_OK;
+}
+
/**
* Retrieve the attributes for this node, and add then into
* the node.
@@ -2698,9 +2717,15 @@ CNavDTD::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
else aToken=gTokenRecycler.CreateTokenOfType(eToken_comment,eHTMLTag_unknown,gEmpty);
}//if
break;
+
case kExclamation:
aToken=gTokenRecycler.CreateTokenOfType(eToken_comment,eHTMLTag_comment,gEmpty);
break;
+
+ case kQuestionMark: //it must be an XML processing instruction...
+ aToken=gTokenRecycler.CreateTokenOfType(eToken_instruction,eHTMLTag_unknown,gEmpty);
+ break;
+
default:
if(nsString::IsAlpha(aChar))
return ConsumeStartTag(aChar,aScanner,aToken);
diff --git a/htmlparser/src/CNavDTD.h b/htmlparser/src/CNavDTD.h
index 5c5798aab0a..084189e0d19 100644
--- a/htmlparser/src/CNavDTD.h
+++ b/htmlparser/src/CNavDTD.h
@@ -416,6 +416,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
nsresult HandleAttributeToken(CToken* aToken);
nsresult HandleScriptToken(nsCParserNode& aNode);
nsresult HandleStyleToken(CToken* aToken);
+ nsresult HandleProcessingInstructionToken(CToken* aToken);
virtual nsITokenRecycler* GetTokenRecycler(void);
diff --git a/htmlparser/src/nsHTMLTokens.cpp b/htmlparser/src/nsHTMLTokens.cpp
index 7604cb8fa6f..a5db062858c 100644
--- a/htmlparser/src/nsHTMLTokens.cpp
+++ b/htmlparser/src/nsHTMLTokens.cpp
@@ -1290,3 +1290,60 @@ const char* GetTagName(PRInt32 aTag) {
}
return result;
}
+
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+CInstructionToken::CInstructionToken() : CHTMLToken(eHTMLTag_unknown) {
+}
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+CInstructionToken::CInstructionToken(const nsString& aString) : CHTMLToken(aString) {
+}
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+nsresult CInstructionToken::Consume(PRUnichar aChar,CScanner& aScanner){
+ mTextValue="";
+ nsresult result=aScanner.ReadUntil(mTextValue,kGreaterThan,PR_TRUE);
+ return result;
+}
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+const char* CInstructionToken::GetClassName(void){
+ return "instruction";
+}
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+PRInt32 CInstructionToken::GetTokenType(void){
+ return eToken_instruction;
+}
+
diff --git a/htmlparser/src/nsHTMLTokens.h b/htmlparser/src/nsHTMLTokens.h
index d4472b877b2..3f3a4aff0d1 100644
--- a/htmlparser/src/nsHTMLTokens.h
+++ b/htmlparser/src/nsHTMLTokens.h
@@ -53,7 +53,7 @@ enum eHTMLTokenTypes {
eToken_unknown=0,
eToken_start=1, eToken_end, eToken_comment, eToken_entity,
eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
- eToken_script, eToken_style, eToken_skippedcontent,
+ eToken_script, eToken_style, eToken_skippedcontent, eToken_instruction,
eToken_last //make sure this stays the last token...
};
@@ -304,6 +304,23 @@ class CSkippedContentToken: public CAttributeToken {
};
+/**
+ * Whitespace tokens are used where whitespace can be
+ * detected as distinct from text. This allows us to
+ * easily skip leading/trailing whitespace when desired.
+ *
+ * @update gess 3/25/98
+ */
+class CInstructionToken: public CHTMLToken {
+ public:
+ CInstructionToken();
+ CInstructionToken(const nsString& aString);
+ virtual nsresult Consume(PRUnichar aChar,CScanner& aScanner);
+ virtual const char* GetClassName(void);
+ virtual PRInt32 GetTokenType(void);
+};
+
+
#endif
diff --git a/htmlparser/src/nsParserTypes.h b/htmlparser/src/nsParserTypes.h
index 9ed17b38d49..2722672c50a 100644
--- a/htmlparser/src/nsParserTypes.h
+++ b/htmlparser/src/nsParserTypes.h
@@ -71,6 +71,7 @@ const PRUint32 kLeftParen = '(';
const PRUint32 kRightParen = ')';
const PRUint32 kLeftBrace = '{';
const PRUint32 kRightBrace = '}';
+const PRUint32 kQuestionMark = '?';
#endif
diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp
index 5d32a4b9de4..7ff20299cdf 100644
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ b/parser/htmlparser/src/CNavDTD.cpp
@@ -199,6 +199,7 @@ CToken* nsCTokenRecycler::CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag
case eToken_script: result=new CScriptToken(); break;
case eToken_style: result=new CStyleToken(); break;
case eToken_skippedcontent: result=new CSkippedContentToken(aString); break;
+ case eToken_instruction:result=new CInstructionToken(); break;
default:
break;
}
@@ -308,6 +309,8 @@ PRInt32 NavDispatchTokenHandler(CToken* aToken,nsIDTD* aDTD) {
result=theDTD->HandleStyleToken(aToken); break;
case eToken_skippedcontent:
result=theDTD->HandleSkippedContentToken(aToken); break;
+ case eToken_instruction:
+ result=theDTD->HandleProcessingInstructionToken(aToken); break;
default:
result=0;
}//switch
@@ -337,6 +340,7 @@ void CNavDTD::InitializeDefaultTokenHandlers() {
// AddTokenHandler(new CTokenHandler(NavDispatchTokenHandler,eToken_script));
AddTokenHandler(new CTokenHandler(NavDispatchTokenHandler,eToken_style));
AddTokenHandler(new CTokenHandler(NavDispatchTokenHandler,eToken_skippedcontent));
+ AddTokenHandler(new CTokenHandler(NavDispatchTokenHandler,eToken_instruction));
}
@@ -864,6 +868,21 @@ nsresult CNavDTD::HandleStyleToken(CToken* aToken){
}
+/**
+ * This method gets called when an "instruction" token has been
+ * encountered in the parse process.
+ *
+ * @update gess 3/25/98
+ * @param aToken -- next (start) token to be handled
+ * @return PR_TRUE if all went well; PR_FALSE if error occured
+ */
+nsresult CNavDTD::HandleProcessingInstructionToken(CToken* aToken){
+ NS_PRECONDITION(0!=aToken,kNullToken);
+
+// CStyleToken* st = (CStyleToken*)(aToken);
+ return NS_OK;
+}
+
/**
* Retrieve the attributes for this node, and add then into
* the node.
@@ -2698,9 +2717,15 @@ CNavDTD::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
else aToken=gTokenRecycler.CreateTokenOfType(eToken_comment,eHTMLTag_unknown,gEmpty);
}//if
break;
+
case kExclamation:
aToken=gTokenRecycler.CreateTokenOfType(eToken_comment,eHTMLTag_comment,gEmpty);
break;
+
+ case kQuestionMark: //it must be an XML processing instruction...
+ aToken=gTokenRecycler.CreateTokenOfType(eToken_instruction,eHTMLTag_unknown,gEmpty);
+ break;
+
default:
if(nsString::IsAlpha(aChar))
return ConsumeStartTag(aChar,aScanner,aToken);
diff --git a/parser/htmlparser/src/CNavDTD.h b/parser/htmlparser/src/CNavDTD.h
index 5c5798aab0a..084189e0d19 100644
--- a/parser/htmlparser/src/CNavDTD.h
+++ b/parser/htmlparser/src/CNavDTD.h
@@ -416,6 +416,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
nsresult HandleAttributeToken(CToken* aToken);
nsresult HandleScriptToken(nsCParserNode& aNode);
nsresult HandleStyleToken(CToken* aToken);
+ nsresult HandleProcessingInstructionToken(CToken* aToken);
virtual nsITokenRecycler* GetTokenRecycler(void);
diff --git a/parser/htmlparser/src/nsHTMLTokens.cpp b/parser/htmlparser/src/nsHTMLTokens.cpp
index 7604cb8fa6f..a5db062858c 100644
--- a/parser/htmlparser/src/nsHTMLTokens.cpp
+++ b/parser/htmlparser/src/nsHTMLTokens.cpp
@@ -1290,3 +1290,60 @@ const char* GetTagName(PRInt32 aTag) {
}
return result;
}
+
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+CInstructionToken::CInstructionToken() : CHTMLToken(eHTMLTag_unknown) {
+}
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+CInstructionToken::CInstructionToken(const nsString& aString) : CHTMLToken(aString) {
+}
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+nsresult CInstructionToken::Consume(PRUnichar aChar,CScanner& aScanner){
+ mTextValue="";
+ nsresult result=aScanner.ReadUntil(mTextValue,kGreaterThan,PR_TRUE);
+ return result;
+}
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+const char* CInstructionToken::GetClassName(void){
+ return "instruction";
+}
+
+/**
+ *
+ *
+ * @update gess 9/23/98
+ * @param
+ * @return
+ */
+PRInt32 CInstructionToken::GetTokenType(void){
+ return eToken_instruction;
+}
+
diff --git a/parser/htmlparser/src/nsHTMLTokens.h b/parser/htmlparser/src/nsHTMLTokens.h
index d4472b877b2..3f3a4aff0d1 100644
--- a/parser/htmlparser/src/nsHTMLTokens.h
+++ b/parser/htmlparser/src/nsHTMLTokens.h
@@ -53,7 +53,7 @@ enum eHTMLTokenTypes {
eToken_unknown=0,
eToken_start=1, eToken_end, eToken_comment, eToken_entity,
eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
- eToken_script, eToken_style, eToken_skippedcontent,
+ eToken_script, eToken_style, eToken_skippedcontent, eToken_instruction,
eToken_last //make sure this stays the last token...
};
@@ -304,6 +304,23 @@ class CSkippedContentToken: public CAttributeToken {
};
+/**
+ * Whitespace tokens are used where whitespace can be
+ * detected as distinct from text. This allows us to
+ * easily skip leading/trailing whitespace when desired.
+ *
+ * @update gess 3/25/98
+ */
+class CInstructionToken: public CHTMLToken {
+ public:
+ CInstructionToken();
+ CInstructionToken(const nsString& aString);
+ virtual nsresult Consume(PRUnichar aChar,CScanner& aScanner);
+ virtual const char* GetClassName(void);
+ virtual PRInt32 GetTokenType(void);
+};
+
+
#endif
diff --git a/parser/htmlparser/src/nsParserTypes.h b/parser/htmlparser/src/nsParserTypes.h
index 9ed17b38d49..2722672c50a 100644
--- a/parser/htmlparser/src/nsParserTypes.h
+++ b/parser/htmlparser/src/nsParserTypes.h
@@ -71,6 +71,7 @@ const PRUint32 kLeftParen = '(';
const PRUint32 kRightParen = ')';
const PRUint32 kLeftBrace = '{';
const PRUint32 kRightBrace = '}';
+const PRUint32 kQuestionMark = '?';
#endif