зеркало из https://github.com/mozilla/pjs.git
added support for XML processing instructions
This commit is contained in:
Родитель
b0c25b7bf1
Коммит
908e54f161
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ const PRUint32 kLeftParen = '(';
|
|||
const PRUint32 kRightParen = ')';
|
||||
const PRUint32 kLeftBrace = '{';
|
||||
const PRUint32 kRightBrace = '}';
|
||||
const PRUint32 kQuestionMark = '?';
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ const PRUint32 kLeftParen = '(';
|
|||
const PRUint32 kRightParen = ')';
|
||||
const PRUint32 kLeftBrace = '{';
|
||||
const PRUint32 kRightBrace = '}';
|
||||
const PRUint32 kQuestionMark = '?';
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче