got newlines working much better; Kipp still won't be happy, but the, he never is.

This commit is contained in:
rickg 1998-04-30 20:23:07 +00:00
Родитель 40b762ad14
Коммит 7117b051c5
28 изменённых файлов: 936 добавлений и 2094 удалений

Просмотреть файл

@ -1,639 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/**
* MODULE NOTES:
* @update gess 4/1/98
*
*/
#include "nsDefaultTokenHandler.h"
#include "nsHTMLParser.h"
#include "nsHTMLTokens.h"
#include "nsDebug.h"
static const char* kNullParserGiven = "Error: Null parser given as argument";
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CDefaultTokenHandler::CDefaultTokenHandler(eHTMLTokenTypes aType) {
mType=aType;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CDefaultTokenHandler::~CDefaultTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
eHTMLTokenTypes CDefaultTokenHandler::GetTokenType(void){
return mType;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CDefaultTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CDefaultTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
PRBool result=PR_FALSE;
if(aParser){
result=PR_TRUE;
}
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CStartTokenHandler::CStartTokenHandler() : CDefaultTokenHandler(eToken_start) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CStartTokenHandler::~CStartTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CStartTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleStartToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CStartTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CEndTokenHandler::CEndTokenHandler(): CDefaultTokenHandler(eToken_end) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CEndTokenHandler::~CEndTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CEndTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleEndToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CEndTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CCommentTokenHandler::CCommentTokenHandler() : CDefaultTokenHandler(eToken_comment) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CCommentTokenHandler::~CCommentTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CCommentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleCommentToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CCommentTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CEntityTokenHandler::CEntityTokenHandler() : CDefaultTokenHandler(eToken_entity) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CEntityTokenHandler::~CEntityTokenHandler() {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CEntityTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleEntityToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CEntityTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CWhitespaceTokenHandler::CWhitespaceTokenHandler() : CDefaultTokenHandler(eToken_whitespace) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CWhitespaceTokenHandler::~CWhitespaceTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CWhitespaceTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleWhitespaceToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CWhitespaceTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CNewlineTokenHandler::CNewlineTokenHandler() : CDefaultTokenHandler(eToken_newline) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CNewlineTokenHandler::~CNewlineTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CNewlineTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleNewlineToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CNewlineTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CTextTokenHandler::CTextTokenHandler() : CDefaultTokenHandler(eToken_text) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CTextTokenHandler::~CTextTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CTextTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleTextToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CTextTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CAttributeTokenHandler::CAttributeTokenHandler() : CDefaultTokenHandler(eToken_attribute) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CAttributeTokenHandler::~CAttributeTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CAttributeTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleAttributeToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CAttributeTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CScriptTokenHandler::CScriptTokenHandler() : CDefaultTokenHandler(eToken_script) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CScriptTokenHandler::~CScriptTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CScriptTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleScriptToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CScriptTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CStyleTokenHandler::CStyleTokenHandler() : CDefaultTokenHandler(eToken_style) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CStyleTokenHandler::~CStyleTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CStyleTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleStyleToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CStyleTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CSkippedContentTokenHandler::CSkippedContentTokenHandler() : CDefaultTokenHandler(eToken_skippedcontent) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CSkippedContentTokenHandler::~CSkippedContentTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CSkippedContentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleSkippedContentToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CSkippedContentTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}

Просмотреть файл

@ -30,14 +30,14 @@ static NS_DEFINE_IID(kClassIID, NS_HTMLCONTENTSINK_IID);
/**-------------------------------------------------------
/**
* "Fakey" factory method used to create an instance of
* this class.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsresult NS_NewHTMLContentSink(nsIContentSink** aInstancePtrResult)
{
nsHTMLContentSink *it = new nsHTMLContentSink();
@ -50,27 +50,27 @@ nsresult NS_NewHTMLContentSink(nsIContentSink** aInstancePtrResult)
}
/**-------------------------------------------------------
/**
* Default constructor
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsHTMLContentSink::nsHTMLContentSink() : nsIHTMLContentSink(), mTitle("") {
mNodeStackPos=0;
memset(mNodeStack,0,sizeof(mNodeStack));
}
/**-------------------------------------------------------
/**
* Default destructor. Probably not a good idea to call
* this if you created your instance via the factor method.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsHTMLContentSink::~nsHTMLContentSink() {
}
@ -85,20 +85,20 @@ static void DebugDump(const char* str1,const nsString& str2,PRInt32 tabs) {
#endif
/**-------------------------------------------------------
/**
* This bit of magic creates the addref and release
* methods for this class.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
NS_IMPL_ADDREF(nsHTMLContentSink)
NS_IMPL_RELEASE(nsHTMLContentSink)
/**-------------------------------------------------------
/**
* Standard XPCOM query interface implementation. I used
* my own version because this class is a subclass of both
* ISupports and IContentSink. Perhaps there's a macro for
@ -107,7 +107,7 @@ NS_IMPL_RELEASE(nsHTMLContentSink)
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsresult nsHTMLContentSink::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
@ -135,14 +135,14 @@ nsresult nsHTMLContentSink::QueryInterface(const nsIID& aIID, void** aInstancePt
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a <HTML>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
@ -155,13 +155,13 @@ PRBool nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </HTML>
* tag has been consumed.
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -176,7 +176,7 @@ PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser <i>any time</i>
* head data gets consumed by the parser. Currently, that
* list includes <META>, <ISINDEX>, <LINK>, <SCRIPT>,
@ -185,7 +185,7 @@ PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -197,14 +197,14 @@ PRBool nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </HEAD>
* tag has been seen (either implicitly or explicitly).
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -218,28 +218,28 @@ PRBool nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This gets called by the parser when a <TITLE> tag
* gets consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::SetTitle(const nsString& aValue){
PRBool result=PR_TRUE;
mTitle=aValue;
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a <BODY>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -251,14 +251,14 @@ PRBool nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </BODY>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
@ -271,14 +271,14 @@ PRBool nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a <FORM>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -290,14 +290,14 @@ PRBool nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </FORM>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -311,14 +311,14 @@ PRBool nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a <FRAMESET>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -330,14 +330,14 @@ PRBool nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </FRAMESET>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -351,7 +351,7 @@ PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when any general
* type of container has been consumed and needs to be
* opened. This includes things like <OL>, <Hn>, etc...
@ -359,7 +359,7 @@ PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -371,14 +371,14 @@ PRBool nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a close
* container tag has been consumed and needs to be closed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -392,14 +392,14 @@ PRBool nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This causes the topmost container to be closed,
* regardless of its type.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseTopmostContainer(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
@ -407,7 +407,7 @@ PRBool nsHTMLContentSink::CloseTopmostContainer(){
return result;
}
/**-------------------------------------------------------
/**
* This gets called by the parser when you want to add
* a leaf node to the current container in the content
* model.
@ -415,7 +415,7 @@ PRBool nsHTMLContentSink::CloseTopmostContainer(){
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
PRBool result=PR_TRUE;

Просмотреть файл

@ -459,10 +459,11 @@ PRBool nsHTMLParser::IterateTokens() {
*/
PRBool nsHTMLParser::Parse(nsIURL* aURL){
eParseMode theMode=eParseMode_navigator;
char* theModeStr= PR_GetEnv("PARSE_MODE");
const char* theModeStr= PR_GetEnv("PARSE_MODE");
const char* other="other";
if(theModeStr)
if(0==nsCRT::strncasecmp("other",theModeStr,5))
if(0==nsCRT::strcasecmp(other,theModeStr))
theMode=eParseMode_other;
return Parse(aURL,theMode);

Просмотреть файл

@ -35,7 +35,7 @@ static nsString gIdentChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU
static nsString gAttrTextChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-%.");
static nsString gAlphaChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static nsAutoString gDigits("0123456789");
static nsAutoString gWhitespace(" \n\r\t\b");
static nsAutoString gWhitespace(" \t\b");
static nsAutoString gOperatorChars("/?.<>[]{}~^+=-!%&*(),|:");
//debug error messages...
@ -94,9 +94,7 @@ static StrToUnicodeStruct gStrToUnicodeTable[] =
};
struct HTMLTagEntry
{
struct HTMLTagEntry {
char fName[12];
eHTMLTags fTagID;
};
@ -253,116 +251,116 @@ HTMLAttrEntry gHTMLAttributeTable[] =
};
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CHTMLToken::CHTMLToken(const nsString& aName) : CToken(aName) {
mTagType=eHTMLTag_unknown;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
eHTMLTags CHTMLToken::GetHTMLTag() {
return mTagType;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CHTMLToken::SetHTMLTag(eHTMLTags aTagType) {
mTagType=aTagType;
return;
}
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CStartToken::CStartToken(const nsString& aName) : CHTMLToken(aName) {
mAttributed=PR_FALSE;
}
/**-------------------------------------------------------
/*
* default destructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
eHTMLTags CStartToken::GetHTMLTag(){
if(eHTMLTag_unknown==mTagType)
mTagType=DetermineHTMLTagType(mTextValue);
return mTagType;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CStartToken::GetClassName(void) {
return "start";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CStartToken::GetTokenType(void) {
return eToken_start;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CStartToken::SetAttributed(PRBool aValue) {
mAttributed=aValue;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStartToken::IsAttributed(void) {
return mAttributed;
}
/**-------------------------------------------------------
/*
* Consume the identifier portion of the start tag
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
//if you're here, we've already Consumed the < char, and are
@ -388,13 +386,13 @@ PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
};
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CStartToken::DebugDumpSource(ostream& out) {
char* cp=mTextValue.ToNewCString();
out << "<" << *cp;
@ -404,25 +402,25 @@ void CStartToken::DebugDumpSource(ostream& out) {
}
/**-------------------------------------------------------
/*
* default constructor for end token
*
* @update gess 3/25/98
* @param aName -- char* containing token name
* @return
*------------------------------------------------------*/
*/
CEndToken::CEndToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_end;
}
/**-------------------------------------------------------
/*
* Consume the identifier portion of the end tag
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
//if you're here, we've already Consumed the <! chars, and are
@ -438,7 +436,7 @@ PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
};
/**-------------------------------------------------------
/*
* Asks the token to determine the <i>HTMLTag type</i> of
* the token. This turns around and looks up the tag name
* in the tag dictionary.
@ -446,42 +444,42 @@ PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
* @update gess 3/25/98
* @param
* @return eHTMLTag id of this endtag
*------------------------------------------------------*/
*/
eHTMLTags CEndToken::GetHTMLTag(){
if(eHTMLTag_unknown==mTagType)
mTagType=DetermineHTMLTagType(mTextValue);
return mTagType;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CEndToken::GetClassName(void) {
return "/end";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CEndToken::GetTokenType(void) {
return eToken_end;
}
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CEndToken::DebugDumpSource(ostream& out) {
char* cp=mTextValue.ToNewCString();
out << "</" << *cp << ">";
@ -489,48 +487,48 @@ void CEndToken::DebugDumpSource(ostream& out) {
}
/**-------------------------------------------------------
/*
* Default constructor
*
* @update gess 3/25/98
* @param aName -- string to init token name with
* @return
*------------------------------------------------------*/
*/
CTextToken::CTextToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_text;
mTagType=eHTMLTag_text;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CTextToken::GetClassName(void) {
return "text";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CTextToken::GetTokenType(void) {
return eToken_text;
}
/**-------------------------------------------------------
/*
* Consume as much clear text from scanner as possible.
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CTextToken::Consume(PRUnichar aChar, CScanner& aScanner) {
static nsAutoString terminals("&<\r\n");
PRInt32 result=aScanner.ReadUntil(mTextValue,terminals,PR_FALSE);
@ -538,19 +536,19 @@ PRInt32 CTextToken::Consume(PRUnichar aChar, CScanner& aScanner) {
};
/**-------------------------------------------------------
/*
* Default constructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CCommentToken::CCommentToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_comment;
mTagType=eHTMLTag_comment;
}
/**-------------------------------------------------------
/*
* Consume the identifier portion of the comment.
* Note that we've already eaten the "<!" portion.
*
@ -558,7 +556,7 @@ CCommentToken::CCommentToken(const nsString& aName) : CHTMLToken(aName) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner& aScanner) {
PRUnichar ch,ch2;
@ -587,120 +585,150 @@ PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner& aScanner) {
return result;
};
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CCommentToken::GetClassName(void){
return "/**/";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CCommentToken::GetTokenType(void) {
return eToken_comment;
}
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CNewlineToken::CNewlineToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_newline;
mTagType=eHTMLTag_newline;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CNewlineToken::GetClassName(void) {
return "crlf";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CNewlineToken::GetTokenType(void) {
return eToken_newline;
}
/**-------------------------------------------------------
/**
* This method retrieves the value of this internal string.
*
* @update gess 3/25/98
* @return nsString reference to internal string value
*/
nsString& CNewlineToken::GetText(void) {
static nsAutoString theStr("\n");
return theStr;
}
/*
* Consume as many cr/lf pairs as you can find.
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CNewlineToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
static nsAutoString crlfChars("\r\n");
PRInt32 result=aScanner.ReadWhile(mTextValue,crlfChars,PR_FALSE);
mTextValue.StripChars("\r");
//we already read the \r or \n, let's see what's next!
PRUnichar nextChar;
PRInt32 result=aScanner.Peek(nextChar);
switch(aChar) {
case kNewLine:
if(kCR==nextChar) {
result=aScanner.GetChar(nextChar);
mTextValue+=nextChar;
}
break;
case kCR:
if(kNewLine==nextChar) {
result=aScanner.GetChar(nextChar);
mTextValue+=nextChar;
}
break;
default:
break;
}
return result;
};
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CAttributeToken::CAttributeToken(const nsString& aName) : CHTMLToken(aName),
mTextKey() {
mLastAttribute=PR_FALSE;
mOrdinalValue=eToken_attribute;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CAttributeToken::GetClassName(void) {
return "attr";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CAttributeToken::GetTokenType(void) {
return eToken_attribute;
}
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CAttributeToken::DebugDumpToken(ostream& out) {
char* cp=mTextKey.ToNewCString();
out << "[" << GetClassName() << "] " << *cp << "=";
@ -710,7 +738,7 @@ void CAttributeToken::DebugDumpToken(ostream& out) {
}
/**-------------------------------------------------------
/*
* This general purpose method is used when you want to
* consume a known quoted string.
*
@ -718,7 +746,7 @@ void CAttributeToken::DebugDumpToken(ostream& out) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 ConsumeQuotedString(PRUnichar aChar,nsString& aString,CScanner& aScanner){
static nsAutoString terminals1(">'");
static nsAutoString terminals2(">\"");
@ -740,7 +768,7 @@ PRInt32 ConsumeQuotedString(PRUnichar aChar,nsString& aString,CScanner& aScanner
return result;
}
/**-------------------------------------------------------
/*
* This general purpose method is used when you want to
* consume attributed text value.
*
@ -748,7 +776,7 @@ PRInt32 ConsumeQuotedString(PRUnichar aChar,nsString& aString,CScanner& aScanner
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 ConsumeAttributeValueText(PRUnichar aChar,nsString& aString,CScanner& aScanner){
PRInt32 result=kNotFound;
@ -758,14 +786,14 @@ PRInt32 ConsumeAttributeValueText(PRUnichar aChar,nsString& aString,CScanner& aS
}
/**-------------------------------------------------------
/*
* Consume the key and value portions of the attribute.
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
aScanner.SkipWhite(); //skip leading whitespace
@ -815,13 +843,13 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
return result;
};
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CAttributeToken::DebugDumpSource(ostream& out) {
char* cp=mTextKey.ToNewCString();
out << " " << *cp;
@ -835,41 +863,41 @@ void CAttributeToken::DebugDumpSource(ostream& out) {
out<<">";
}
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CWhitespaceToken::CWhitespaceToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_whitespace;
mTagType=eHTMLTag_whitespace;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CWhitespaceToken::GetClassName(void) {
return "ws";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CWhitespaceToken::GetTokenType(void) {
return eToken_whitespace;
}
/**-------------------------------------------------------
/*
* This general purpose method is used when you want to
* consume an aribrary sequence of whitespace.
*
@ -877,7 +905,7 @@ PRInt32 CWhitespaceToken::GetTokenType(void) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CWhitespaceToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
@ -886,13 +914,13 @@ PRInt32 CWhitespaceToken::Consume(PRUnichar aChar, CScanner& aScanner) {
return result;
};
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CEntityToken::CEntityToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_entity;
#ifdef VERBOSE_DEBUG
@ -902,14 +930,14 @@ CEntityToken::CEntityToken(const nsString& aName) : CHTMLToken(aName) {
#endif
}
/**-------------------------------------------------------
/*
* Consume the rest of the entity. We've already eaten the "&".
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
@ -917,29 +945,29 @@ PRInt32 CEntityToken::Consume(PRUnichar aChar, CScanner& aScanner) {
return result;
};
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CEntityToken::GetClassName(void) {
return "&entity";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::GetTokenType(void) {
return eToken_entity;
}
/**-------------------------------------------------------
/*
* This general purpose method is used when you want to
* consume an entity &xxxx;. Keep in mind that entities
* are <i>not</i> reduced inline.
@ -948,7 +976,7 @@ PRInt32 CEntityToken::GetTokenType(void) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner& aScanner){
PRInt32 result=kNotFound;
@ -976,14 +1004,14 @@ PRInt32 CEntityToken::ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner&
}
/**-------------------------------------------------------
/*
* This method converts this entity into its underlying
* unicode equivalent.
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) {
char* cp = mTextValue.ToNewCString();
PRInt32 index=FindEntityIndex(cp);
@ -1000,13 +1028,13 @@ PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) {
}
/**-------------------------------------------------------
/*
* This method ensures that the entity table doesn't get
* out of sync. Make sure you call this at least once.
*
* @update gess 3/25/98
* @return PR_TRUE if valid (ordered correctly)
*------------------------------------------------------*/
*/
PRBool CEntityToken::VerifyEntityTable(){
PRInt32 count=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
PRInt32 i,j;
@ -1020,7 +1048,7 @@ PRBool CEntityToken::VerifyEntityTable(){
}
/**-------------------------------------------------------
/*
* This method is used to convert from a given string (char*)
* into a entity index (offset within entity table).
*
@ -1028,7 +1056,7 @@ PRBool CEntityToken::VerifyEntityTable(){
* @param aBuffer -- string to be converted
* @param aBuflen -- optional string length
* @return integer offset of string in table, or kNotFound
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
PRInt32 result=kNotFound;
PRInt32 cnt=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
@ -1059,14 +1087,14 @@ PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
}
/**-------------------------------------------------------
/*
* This method reduces all text entities into their char
* representation.
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::ReduceEntities(nsString& aString) {
PRInt32 result=0;
PRInt32 amppos=0;
@ -1094,99 +1122,99 @@ PRInt32 CEntityToken::ReduceEntities(nsString& aString) {
return result;
}
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CEntityToken::DebugDumpSource(ostream& out) {
char* cp=mTextValue.ToNewCString();
out << "&" << *cp;
delete cp;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CScriptToken::GetClassName(void) {
return "script";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CScriptToken::GetTokenType(void) {
return eToken_script;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CStyleToken::GetClassName(void) {
return "style";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CStyleToken::GetTokenType(void) {
return eToken_style;
}
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CSkippedContentToken::CSkippedContentToken(const nsString& aName) : CAttributeToken(aName) {
mTextKey = "$skipped-content";/* XXX need a better answer! */
mOrdinalValue=eToken_skippedcontent;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CSkippedContentToken::GetClassName(void) {
return "skipped";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CSkippedContentToken::GetTokenType(void) {
return eToken_skippedcontent;
}
/**-------------------------------------------------------
/*
* Consume content until you find a sequence that matches
* this objects mTextValue.
*
@ -1194,7 +1222,7 @@ PRInt32 CSkippedContentToken::GetTokenType(void) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
PRBool done=PR_FALSE;
PRInt32 result=kNoError;
@ -1210,7 +1238,7 @@ PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
}
/**-------------------------------------------------------
/*
* This method iterates the tagtable to ensure that is
* is proper sort order. This method only needs to be
* called once.
@ -1218,7 +1246,7 @@ PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
class CTagTableVerifier {
public:
CTagTableVerifier::CTagTableVerifier(){
@ -1244,19 +1272,19 @@ public:
* @update gess4/6/98
* @param
* @return
*------------------------------------------------------*/
*/
eHTMLTokenTypes DetermineTokenType(const nsString& aString){
return eToken_unknown;
}
/**-------------------------------------------------------
/*
* This method accepts a string (and optionally, its length)
* and determines the eHTMLTag (id) value.
*
* @update gess 3/25/98
* @param aString -- string to be convered to id
* @return valid id, or user_defined.
*------------------------------------------------------*/
*/
eHTMLTags DetermineHTMLTagType(const nsString& aString)
{
PRInt32 result=-1;
@ -1297,7 +1325,7 @@ const char* GetTagName(PRInt32 aTag) {
return result;
}
/**-------------------------------------------------------
/*
* This method iterates the attribute-table to ensure that is
* is proper sort order. This method only needs to be
* called once.
@ -1305,7 +1333,7 @@ const char* GetTagName(PRInt32 aTag) {
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
class CAttributeTableVerifier {
public:
CAttributeTableVerifier::CAttributeTableVerifier(){
@ -1326,10 +1354,10 @@ public:
};
/**-------------------------------------------------------
/*
* These objects are here to force the validation of the
* tag and attribute tables.
*------------------------------------------------------*/
*/
CAttributeTableVerifier gAttributeTableVerifier;
CTagTableVerifier gTableVerifier;

Просмотреть файл

@ -117,12 +117,12 @@ eHTMLTokenTypes DetermineTokenType(const nsString& aString);
const char* GetTagName(PRInt32 aTag);
/** -----------------------------------------------------
/**
* This declares the basic token type used in the html-
* parser.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CHTMLToken : public CToken {
public:
CHTMLToken(const nsString& aString);
@ -133,13 +133,13 @@ protected:
};
/** -----------------------------------------------------
/**
* This declares start tokens, which always take the
* form <xxxx>. This class also knows how to consume
* related attributes.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CStartToken: public CHTMLToken {
public:
CStartToken(const nsString& aString);
@ -157,32 +157,32 @@ class CStartToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* This declares end tokens, which always take the
* form </xxxx>. This class also knows how to consume
* related attributes.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CEndToken: public CHTMLToken {
public:
CEndToken(const nsString& aString);
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
virtual eHTMLTags GetHTMLTag();
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual void DebugDumpSource(ostream& out);
};
/** -----------------------------------------------------
/**
* This declares comment tokens. Comments are usually
* thought of as tokens, but we treat them that way
* here so that the parser can have a consistent view
* of all tokens.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CCommentToken: public CHTMLToken {
public:
CCommentToken(const nsString& aString);
@ -193,13 +193,13 @@ class CCommentToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* This class declares entity tokens, which always take
* the form &xxxx;. This class also offers a few utility
* methods that allow you to easily reduce entities.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CEntityToken : public CHTMLToken {
public:
CEntityToken(const nsString& aString);
@ -219,13 +219,13 @@ class CEntityToken : public CHTMLToken {
};
/** -----------------------------------------------------
/**
* 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 CWhitespaceToken: public CHTMLToken {
public:
CWhitespaceToken(const nsString& aString);
@ -234,13 +234,13 @@ class CWhitespaceToken: public CHTMLToken {
virtual PRInt32 GetTokenType(void);
};
/** -----------------------------------------------------
/**
* Text tokens contain the normalized form of html text.
* These tokens are guaranteed not to contain entities,
* start or end tags, or newlines.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CTextToken: public CHTMLToken {
public:
CTextToken(const nsString& aString);
@ -250,14 +250,14 @@ class CTextToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* Attribute tokens are used to contain attribute key/value
* pairs whereever they may occur. Typically, they should
* occur only in start tokens. However, we may expand that
* ability when XML tokens become commonplace.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CAttributeToken: public CHTMLToken {
public:
CAttributeToken(const nsString& aString);
@ -274,22 +274,23 @@ class CAttributeToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* Newline tokens contain, you guessed it, newlines.
* They consume newline (CR/LF) either alone or in pairs.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CNewlineToken: public CHTMLToken {
public:
CNewlineToken(const nsString& aString);
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual nsString& GetText(void);
};
/** -----------------------------------------------------
/**
* Script tokens contain sequences of javascript (or, gulp,
* any other script you care to send). We don't tokenize
* it here, nor validate it. We just wrap it up, and pass
@ -297,7 +298,7 @@ class CNewlineToken: public CHTMLToken {
* to the scripting engine.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CScriptToken: public CHTMLToken {
public:
@ -308,14 +309,14 @@ class CScriptToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* Style tokens contain sequences of css style. We don't
* tokenize it here, nor validate it. We just wrap it up,
* and pass it along to the html parser, who sends it
* (later on) to the style engine.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CStyleToken: public CHTMLToken {
public:
CStyleToken(const nsString& aString);
@ -325,12 +326,12 @@ class CStyleToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* This is a placeholder token, which is being deprecated.
* Don't bother paying attention to this.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CSkippedContentToken: public CAttributeToken {
public:
CSkippedContentToken(const nsString& aString);

Просмотреть файл

@ -41,12 +41,12 @@
class nsIContentSink;
/**-------------------------------------------------------
/**
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
class nsIParser : public nsISupports {
public:

Просмотреть файл

@ -40,14 +40,14 @@
#include "nsString.h"
#include "nsDebug.h"
/**-------------------------------------------------------
/**
* Parser nodes are the unit of exchange between the
* parser and the content sink. Nodes offer access to
* the current token, its attributes, and its skipped-
* content if applicable.
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
class nsIParserNode {
public:

Просмотреть файл

@ -22,13 +22,13 @@
#include "string.h"
/**-------------------------------------------------------
/**
* Default constructor
*
* @update gess 3/25/98
* @param aToken -- token to init internal token
* @return
*------------------------------------------------------*/
*/
nsCParserNode::nsCParserNode(CHTMLToken* aToken): nsIParserNode(),
mName(), mEmptyString() {
NS_PRECONDITION(0!=aToken, "Null Token");
@ -38,25 +38,25 @@ nsCParserNode::nsCParserNode(CHTMLToken* aToken): nsIParserNode(),
}
/**-------------------------------------------------------
/**
* default destructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsCParserNode::~nsCParserNode() {
}
/**-------------------------------------------------------
/**
* Causes the given attribute to be added to internal
* mAttributes list, and mAttributeCount to be incremented.
*
* @update gess 3/25/98
* @param aToken -- token to be added to attr list
* @return
*------------------------------------------------------*/
*/
void nsCParserNode::AddAttribute(CHTMLToken* aToken) {
NS_PRECONDITION(mAttributeCount<sizeof(mAttributes), "Buffer overrun!");
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
@ -66,7 +66,7 @@ void nsCParserNode::AddAttribute(CHTMLToken* aToken) {
}
/**-------------------------------------------------------
/**
* This method gets called when the parser encounters
* skipped content after a start token.
* NOTE: To determine if we have skipped content, simply
@ -75,7 +75,7 @@ void nsCParserNode::AddAttribute(CHTMLToken* aToken) {
* @update gess 3/26/98
* @param aToken -- really a skippedcontent token
* @return nada
*------------------------------------------------------*/
*/
void nsCParserNode::SetSkippedContent(CHTMLToken* aToken){
NS_PRECONDITION(mAttributeCount<sizeof(mAttributes)-1, "Buffer overrun!");
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
@ -85,38 +85,38 @@ void nsCParserNode::SetSkippedContent(CHTMLToken* aToken){
}
/**-------------------------------------------------------
/**
* Gets the name of this node. Currently unused.
*
* @update gess 3/25/98
* @param
* @return string ref containing node name
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetName() const {
return mName;
}
/**-------------------------------------------------------
/**
* Get text value of this node, which translates into
* getting the text value of the underlying token
*
* @update gess 3/25/98
* @param
* @return string ref of text from internal token
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetText() const {
return mToken->GetText();
}
/**-------------------------------------------------------
/**
* Get text value of this node, which translates into
* getting the text value of the underlying token
*
* @update gess 3/25/98
* @param
* @return string ref of text from internal token
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetSkippedContent() const {
if (0 < mAttributeCount) {
if(mAttributes[mAttributeCount-1]) {
@ -129,51 +129,51 @@ const nsString& nsCParserNode::GetSkippedContent() const {
return mEmptyString;
}
/**-------------------------------------------------------
/**
* Get node type, meaning, get the tag type of the
* underlying token
*
* @update gess 3/25/98
* @param
* @return int value that represents tag type
*------------------------------------------------------*/
*/
PRInt32 nsCParserNode::GetNodeType(void) const{
return mToken->GetHTMLTag();
}
/**-------------------------------------------------------
/**
* Gets the token type, which corresponds to a value from
* eHTMLTags_xxx.
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 nsCParserNode::GetTokenType(void) const{
return mToken->GetTokenType();
}
/**-------------------------------------------------------
/**
* Retrieve the number of attributes on this node
*
* @update gess 3/25/98
* @param
* @return int -- representing attribute count
*------------------------------------------------------*/
*/
PRInt32 nsCParserNode::GetAttributeCount(void) const{
return mAttributeCount;
}
/**-------------------------------------------------------
/**
* Retrieve the string rep of the attribute key at the
* given index.
*
* @update gess 3/25/98
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text key
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
CAttributeToken* tkn=(CAttributeToken*)(mAttributes[anIndex]);
@ -181,13 +181,13 @@ const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
}
/**-------------------------------------------------------
/**
* Retrieve the string rep of the attribute at given offset
*
* @update gess 3/25/98
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetValueAt(PRInt32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
return (mAttributes[anIndex])->GetText();

Просмотреть файл

@ -25,13 +25,13 @@ const char* gURLRef;
const char* kBadHTMLText1="<HTML><BODY><H3>Oops...</H3>You just tried to read a non-existent document: <BR>";
const char* kBadHTMLText2="</BODY></HTML>";
/**-------------------------------------------------------
/**
* default constructor
*
* @update gess 3/25/98
* @param aURL -- pointer to URL to be loaded
* @return
*------------------------------------------------------*/
*/
CScanner::CScanner(nsIURL* aURL,eParseMode aMode) : mBuffer("") {
NS_ASSERTION(0!=aURL,"Error: Null URL!");
mOffset=0;
@ -45,13 +45,13 @@ CScanner::CScanner(nsIURL* aURL,eParseMode aMode) : mBuffer("") {
}
}
/**-------------------------------------------------------
/**
* default destructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CScanner::~CScanner() {
mStream->Close();
delete mStream;
@ -63,7 +63,7 @@ CScanner::~CScanner() {
* @update gess4/3/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CScanner::FillBuffer(PRInt32& anError) {
mBuffer.Cut(0,mBuffer.Length());
if(!mStream) {
@ -91,13 +91,13 @@ PRInt32 CScanner::FillBuffer(PRInt32& anError) {
return mBuffer.Length();
}
/**-------------------------------------------------------
/**
* determine if the scanner has reached EOF
*
* @update gess 3/25/98
* @param
* @return PR_TRUE upon eof condition
*------------------------------------------------------*/
*/
PRBool CScanner::Eof() {
PRInt32 theError=0;
if(mOffset>=mBuffer.Length()) {
@ -114,13 +114,13 @@ PRBool CScanner::Eof() {
return result;
}
/**-------------------------------------------------------
/**
* retrieve next char from scanners internal input stream
*
* @update gess 3/25/98
* @param
* @return error code reflecting read status
*------------------------------------------------------*/
*/
PRInt32 CScanner::GetChar(PRUnichar& aChar) {
if(!Eof()) {
aChar=mBuffer[mOffset++];
@ -130,14 +130,14 @@ PRInt32 CScanner::GetChar(PRUnichar& aChar) {
}
/**-------------------------------------------------------
/**
* peek ahead to consume next char from scanner's internal
* input buffer
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CScanner::Peek(PRUnichar& aChar){
if(!Eof()) {
aChar=mBuffer[mOffset];
@ -147,13 +147,13 @@ PRInt32 CScanner::Peek(PRUnichar& aChar){
}
/**-------------------------------------------------------
/**
* Push the given char back onto the scanner
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::PutBack(PRUnichar aChar) {
mOffset--;
return kNoError;
@ -161,33 +161,57 @@ PRInt32 CScanner::PutBack(PRUnichar aChar) {
/**-------------------------------------------------------
/**
* Skip whitespace on scanner input stream
*
* @update gess 3/25/98
* @param
* @return error status
*------------------------------------------------------*/
*/
PRInt32 CScanner::SkipWhite(void) {
static nsAutoString chars(" \n\r\t");
return SkipOver(chars);
}
/**-------------------------------------------------------
* Skip over chars as long as they're in aValidSet
/**
* Skip over chars as long as they equal given char
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
PRInt32 CScanner::SkipOver(nsString& aValidSet){
*/
PRInt32 CScanner::SkipOver(PRUnichar aSkipChar){
PRUnichar ch=0;
PRInt32 result=kNoError;
while(kNoError==result) {
result=GetChar(ch);
if(!result) {
PRInt32 pos=aValidSet.Find(ch);
if(ch!=aSkipChar) {
PutBack(ch);
break;
}
}
else break;
} //while
return result;
}
/**
* Skip over chars as long as they're in aSkipSet
*
* @update gess 3/25/98
* @param
* @return error code
*/
PRInt32 CScanner::SkipOver(nsString& aSkipSet){
PRUnichar ch=0;
PRInt32 result=kNoError;
while(kNoError==result) {
result=GetChar(ch);
if(!result) {
PRInt32 pos=aSkipSet.Find(ch);
if(kNotFound==pos) {
PutBack(ch);
break;
@ -198,26 +222,26 @@ PRInt32 CScanner::SkipOver(nsString& aValidSet){
return result;
}
/**-------------------------------------------------------
/**
* Skip over chars as long as they're in aValidSet
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::SkipPast(nsString& aValidSet){
NS_NOTYETIMPLEMENTED("Error: SkipPast not yet implemented.");
return kNoError;
}
/**-------------------------------------------------------
/**
* Consume chars as long as they are <i>in</i> the
* given validSet of input chars.
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::ReadWhile(nsString& aString,nsString& aValidSet,PRBool addTerminal){
PRUnichar ch=0;
PRInt32 result=kNoError;
@ -240,14 +264,14 @@ PRInt32 CScanner::ReadWhile(nsString& aString,nsString& aValidSet,PRBool addTerm
}
/**-------------------------------------------------------
/**
* Consume characters until you find one contained in given
* input set.
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::ReadUntil(nsString& aString,nsString& aTerminalSet,PRBool addTerminal){
PRUnichar ch=0;
PRInt32 result=kNoError;
@ -269,13 +293,13 @@ PRInt32 CScanner::ReadUntil(nsString& aString,nsString& aTerminalSet,PRBool addT
}
/**-------------------------------------------------------
/**
* Consumes chars until you see the given terminalChar
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::ReadUntil(nsString& aString,PRUnichar aTerminalChar,PRBool addTerminal){
PRUnichar ch=0;
PRInt32 result=kNoError;
@ -294,14 +318,14 @@ PRInt32 CScanner::ReadUntil(nsString& aString,PRUnichar aTerminalChar,PRBool add
}
/**-------------------------------------------------------
/**
* Conduct self test. Actually, selftesting for this class
* occurs in the parser selftest.
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CScanner::SelfTest(void) {
#ifdef _DEBUG

Просмотреть файл

@ -49,10 +49,10 @@ class CScanner {
PRInt32 GetChar(PRUnichar& ch);
PRInt32 Peek(PRUnichar& ch);
PRInt32 PutBack(PRUnichar ch);
PRInt32 SkipOver(nsString& SkipChars);
PRInt32 SkipOver(nsString& SkipChars);
PRInt32 SkipOver(PRUnichar aSkipChar);
PRInt32 SkipPast(nsString& aSequence);
PRInt32 SkipPast(PRUnichar aChar);
PRInt32 SkipWhite(void);
PRInt32 SkipWhite(void);
PRBool Eof(void);
PRInt32 ReadUntil(nsString& aString,PRUnichar aTerminal,PRBool addTerminal);

Просмотреть файл

@ -19,26 +19,26 @@
#include "nsToken.h"
#include "nsScanner.h"
/**-------------------------------------------------------
/**
* Default constructor
*
* @update gess 3/25/98
* @param nsString--name of token
*------------------------------------------------------*/
*/
CToken::CToken(const nsString& aName) : mTextValue(aName) {
mOrdinalValue=0;
}
/**-------------------------------------------------------
/**
* Decstructor
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
CToken::~CToken() {
}
/**-------------------------------------------------------
/**
* Virtual method used to tell this toke to consume his
* valid chars.
*
@ -46,29 +46,29 @@ CToken::~CToken() {
* @param aChar -- first char in sequence
* @param aScanner -- object to retrieve data from
* @return int error code
*------------------------------------------------------*/
*/
PRInt32 CToken::Consume(PRUnichar aChar,CScanner& aScanner) {
PRInt32 result=kNoError;
return result;
}
/**-------------------------------------------------------
/**
* Method used to set the string value of this token
*
* @update gess 3/25/98
* @param aValue -- char* containing new value
*------------------------------------------------------*/
*/
void CToken::SetStringValue(const char* aValue) {
mTextValue=aValue;
}
/**-------------------------------------------------------
/**
* This debug method causes the token to dump its content
* to the given stream (formated for debugging).
*
* @update gess 3/25/98
* @param ostream -- output stream to accept output data
*------------------------------------------------------*/
*/
void CToken::DebugDumpToken(ostream& anOutputStream) {
anOutputStream << "[" << GetClassName() << "] ";
for(int i=0;i<mTextValue.Length();i++){
@ -77,79 +77,85 @@ void CToken::DebugDumpToken(ostream& anOutputStream) {
anOutputStream << ": " << mOrdinalValue << endl;
}
/**-------------------------------------------------------
/**
* This debug method causes the token to dump its content
* to the given stream, formated as text.
*
* @update gess 3/25/98
* @param ostream -- output stream to accept output data
*------------------------------------------------------*/
*/
void CToken::DebugDumpSource(ostream& anOutputStream) {
char buf[256];
anOutputStream << mTextValue.ToCString(buf,256);
}
/**-------------------------------------------------------
/**
* This method retrieves the value of this internal string.
*
* @update gess 3/25/98
* @return nsString reference to internal string value
*------------------------------------------------------*/
*/
nsString& CToken::GetStringValue(void) {
return mTextValue;
}
/**
* This method retrieves the value of this internal string.
*
* @update gess 3/25/98
* @return nsString reference to internal string value
*/
nsString& CToken::GetText(void) {
return mTextValue;
}
/**-------------------------------------------------------
/**
* Sets the internal ordinal value for this token.
* This method is deprecated, and will soon be going away.
*
* @update gess 3/25/98
* @param value -- new ordinal value for this token
*------------------------------------------------------*/
*/
void CToken::SetOrdinal(PRInt32 value) {
mOrdinalValue=value;
}
/**-------------------------------------------------------
/**
* Retrieves copy of internal ordinal value.
* This method is deprecated, and will soon be going away.
*
* @update gess 3/25/98
* @return int containing ordinal value
*------------------------------------------------------*/
*/
PRInt32 CToken::GetOrdinal(void) {
return mOrdinalValue;
}
/**-------------------------------------------------------
/**
* Retrieve type of token. This class returns -1, but
* subclasses return something more meaningful.
*
* @update gess 3/25/98
* @return int value containing token type.
*------------------------------------------------------*/
*/
PRInt32 CToken::GetTokenType(void) {
return -1;
}
/**-------------------------------------------------------
/**
* retrieve this tokens classname.
*
* @update gess 3/25/98
* @return char* containing name of class
*------------------------------------------------------*/
*/
const char* CToken::GetClassName(void) {
return "token";
}
/**-------------------------------------------------------
/**
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
void CToken::SelfTest(void) {
#ifdef _DEBUG
#endif

Просмотреть файл

@ -41,7 +41,7 @@
class CScanner;
/**-------------------------------------------------------
/**
* Token objects represent sequences of characters as they
* are consumed from the input stream (URL). While they're
* pretty general in nature, we use subclasses (found in
@ -49,7 +49,7 @@ class CScanner;
* <comment>, <&entity>, <newline>, and <whitespace> tokens.
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
class CToken {
public:
CToken(const nsString& aName);

Просмотреть файл

@ -31,60 +31,60 @@
static const char* kNullParserGiven = "Error: Null parser given as argument";
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CTokenHandler::CTokenHandler(eHTMLTokenTypes aType) {
mType=aType;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CTokenHandler::~CTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
eHTMLTokenTypes CTokenHandler::GetTokenType(void){
return mType;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
PRBool result=PR_FALSE;
@ -95,35 +95,35 @@ PRBool CTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CStartTokenHandler::CStartTokenHandler() : CTokenHandler(eToken_start) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CStartTokenHandler::~CStartTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStartTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -132,48 +132,48 @@ PRBool CStartTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStartTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CEndTokenHandler::CEndTokenHandler(): CTokenHandler(eToken_end) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CEndTokenHandler::~CEndTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CEndTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -182,48 +182,48 @@ PRBool CEndTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CEndTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CCommentTokenHandler::CCommentTokenHandler() : CTokenHandler(eToken_comment) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CCommentTokenHandler::~CCommentTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CCommentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -232,47 +232,47 @@ PRBool CCommentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CCommentTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CEntityTokenHandler::CEntityTokenHandler() : CTokenHandler(eToken_entity) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CEntityTokenHandler::~CEntityTokenHandler() {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CEntityTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -281,47 +281,47 @@ PRBool CEntityTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CEntityTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CWhitespaceTokenHandler::CWhitespaceTokenHandler() : CTokenHandler(eToken_whitespace) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CWhitespaceTokenHandler::~CWhitespaceTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CWhitespaceTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -330,48 +330,48 @@ PRBool CWhitespaceTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser)
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CWhitespaceTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CNewlineTokenHandler::CNewlineTokenHandler() : CTokenHandler(eToken_newline) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CNewlineTokenHandler::~CNewlineTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CNewlineTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -380,47 +380,47 @@ PRBool CNewlineTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CNewlineTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CTextTokenHandler::CTextTokenHandler() : CTokenHandler(eToken_text) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CTextTokenHandler::~CTextTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CTextTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -429,46 +429,46 @@ PRBool CTextTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CTextTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CAttributeTokenHandler::CAttributeTokenHandler() : CTokenHandler(eToken_attribute) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CAttributeTokenHandler::~CAttributeTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CAttributeTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -477,47 +477,47 @@ PRBool CAttributeTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CAttributeTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CScriptTokenHandler::CScriptTokenHandler() : CTokenHandler(eToken_script) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CScriptTokenHandler::~CScriptTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CScriptTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -526,47 +526,47 @@ PRBool CScriptTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CScriptTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CStyleTokenHandler::CStyleTokenHandler() : CTokenHandler(eToken_style) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CStyleTokenHandler::~CStyleTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStyleTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -575,47 +575,47 @@ PRBool CStyleTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStyleTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CSkippedContentTokenHandler::CSkippedContentTokenHandler() : CTokenHandler(eToken_skippedcontent) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CSkippedContentTokenHandler::~CSkippedContentTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CSkippedContentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -624,13 +624,13 @@ PRBool CSkippedContentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aPar
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CSkippedContentTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;

Просмотреть файл

@ -24,14 +24,14 @@
#include "nsIURL.h"
/**-------------------------------------------------------
/**
* Default constructor
*
* @update gess 3/25/98
* @param aFilename -- name of file to be tokenized
* @param aDelegate -- ref to delegate to be used to tokenize
* @return
*------------------------------------------------------*/
*/
CTokenizer::CTokenizer(nsIURL* aURL,ITokenizerDelegate* aDelegate,eParseMode aMode) :
mTokenDeque() {
mDelegate=aDelegate;
@ -40,13 +40,13 @@ CTokenizer::CTokenizer(nsIURL* aURL,ITokenizerDelegate* aDelegate,eParseMode aMo
}
/**-------------------------------------------------------
/**
* default destructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CTokenizer::~CTokenizer() {
delete mScanner;
delete mDelegate;
@ -64,20 +64,20 @@ nsDeque& CTokenizer::GetDeque(void) {
return mTokenDeque;
}
/**-------------------------------------------------------
/**
* Cause the tokenizer to consume the next token, and
* return an error result.
*
* @update gess 3/25/98
* @param anError -- ref to error code
* @return new token or null
*------------------------------------------------------*/
*/
CToken* CTokenizer::GetToken(PRInt32& anError) {
CToken* nextToken=mDelegate->GetToken(*mScanner,anError);
return nextToken;
}
/**-------------------------------------------------------
/**
* Retrieve the number of elements in the deque
*
* @update gess 3/25/98
@ -89,7 +89,7 @@ PRInt32 CTokenizer::GetSize(void) {
}
/**-------------------------------------------------------
/**
* Part of the code sandwich, this gets called right before
* the tokenization process begins. The main reason for
* this call is to allow the delegate to do initialization.
@ -97,14 +97,14 @@ PRInt32 CTokenizer::GetSize(void) {
* @update gess 3/25/98
* @param
* @return TRUE if it's ok to proceed
*------------------------------------------------------*/
*/
PRBool CTokenizer::WillTokenize(){
PRBool result=PR_TRUE;
result=mDelegate->WillTokenize();
return result;
}
/**-------------------------------------------------------
/**
* This is the primary control routine. It iteratively
* consumes tokens until an error occurs or you run out
* of data.
@ -112,7 +112,7 @@ PRBool CTokenizer::WillTokenize(){
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CTokenizer::Tokenize(void) {
CToken* nextToken;
PRInt32 result;
@ -135,7 +135,7 @@ PRInt32 CTokenizer::Tokenize(void) {
}
/**-------------------------------------------------------
/**
* This is the tail-end of the code sandwich for the
* tokenization process. It gets called once tokenziation
* has completed.
@ -143,7 +143,7 @@ PRInt32 CTokenizer::Tokenize(void) {
* @update gess 3/25/98
* @param
* @return TRUE if all went well
*------------------------------------------------------*/
*/
PRBool CTokenizer::DidTokenize() {
PRBool result=mDelegate->DidTokenize();
@ -154,7 +154,7 @@ PRBool CTokenizer::DidTokenize() {
return result;
}
/**-------------------------------------------------------
/**
* This debug routine is used to cause the tokenizer to
* iterate its token list, asking each token to dump its
* contents to the given output stream.
@ -162,7 +162,7 @@ PRBool CTokenizer::DidTokenize() {
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CTokenizer::DebugDumpTokens(ostream& out) {
nsDequeIterator b=mTokenDeque.Begin();
nsDequeIterator e=mTokenDeque.End();
@ -175,7 +175,7 @@ void CTokenizer::DebugDumpTokens(ostream& out) {
}
/**-------------------------------------------------------
/**
* This debug routine is used to cause the tokenizer to
* iterate its token list, asking each token to dump its
* contents to the given output stream.
@ -183,7 +183,7 @@ void CTokenizer::DebugDumpTokens(ostream& out) {
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CTokenizer::DebugDumpSource(ostream& out) {
nsDequeIterator b=mTokenDeque.Begin();
nsDequeIterator e=mTokenDeque.End();
@ -197,13 +197,13 @@ void CTokenizer::DebugDumpSource(ostream& out) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CTokenizer::SelfTest(void) {
#ifdef _DEBUG
#endif

Просмотреть файл

@ -1,639 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/**
* MODULE NOTES:
* @update gess 4/1/98
*
*/
#include "nsDefaultTokenHandler.h"
#include "nsHTMLParser.h"
#include "nsHTMLTokens.h"
#include "nsDebug.h"
static const char* kNullParserGiven = "Error: Null parser given as argument";
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CDefaultTokenHandler::CDefaultTokenHandler(eHTMLTokenTypes aType) {
mType=aType;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CDefaultTokenHandler::~CDefaultTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
eHTMLTokenTypes CDefaultTokenHandler::GetTokenType(void){
return mType;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CDefaultTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CDefaultTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
PRBool result=PR_FALSE;
if(aParser){
result=PR_TRUE;
}
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CStartTokenHandler::CStartTokenHandler() : CDefaultTokenHandler(eToken_start) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CStartTokenHandler::~CStartTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CStartTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleStartToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CStartTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CEndTokenHandler::CEndTokenHandler(): CDefaultTokenHandler(eToken_end) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CEndTokenHandler::~CEndTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CEndTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleEndToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CEndTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CCommentTokenHandler::CCommentTokenHandler() : CDefaultTokenHandler(eToken_comment) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CCommentTokenHandler::~CCommentTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CCommentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleCommentToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CCommentTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CEntityTokenHandler::CEntityTokenHandler() : CDefaultTokenHandler(eToken_entity) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CEntityTokenHandler::~CEntityTokenHandler() {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CEntityTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleEntityToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CEntityTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CWhitespaceTokenHandler::CWhitespaceTokenHandler() : CDefaultTokenHandler(eToken_whitespace) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CWhitespaceTokenHandler::~CWhitespaceTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CWhitespaceTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleWhitespaceToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CWhitespaceTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CNewlineTokenHandler::CNewlineTokenHandler() : CDefaultTokenHandler(eToken_newline) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CNewlineTokenHandler::~CNewlineTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CNewlineTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleNewlineToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CNewlineTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CTextTokenHandler::CTextTokenHandler() : CDefaultTokenHandler(eToken_text) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CTextTokenHandler::~CTextTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CTextTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleTextToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CTextTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CAttributeTokenHandler::CAttributeTokenHandler() : CDefaultTokenHandler(eToken_attribute) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CAttributeTokenHandler::~CAttributeTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CAttributeTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleAttributeToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CAttributeTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CScriptTokenHandler::CScriptTokenHandler() : CDefaultTokenHandler(eToken_script) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CScriptTokenHandler::~CScriptTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CScriptTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleScriptToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CScriptTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CStyleTokenHandler::CStyleTokenHandler() : CDefaultTokenHandler(eToken_style) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CStyleTokenHandler::~CStyleTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CStyleTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleStyleToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CStyleTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CSkippedContentTokenHandler::CSkippedContentTokenHandler() : CDefaultTokenHandler(eToken_skippedcontent) {
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
CSkippedContentTokenHandler::~CSkippedContentTokenHandler(){
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CSkippedContentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
return aParser->HandleSkippedContentToken(aToken);
}
return PR_FALSE;
}
/**-------------------------------------------------------
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
PRBool CSkippedContentTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}

Просмотреть файл

@ -30,14 +30,14 @@ static NS_DEFINE_IID(kClassIID, NS_HTMLCONTENTSINK_IID);
/**-------------------------------------------------------
/**
* "Fakey" factory method used to create an instance of
* this class.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsresult NS_NewHTMLContentSink(nsIContentSink** aInstancePtrResult)
{
nsHTMLContentSink *it = new nsHTMLContentSink();
@ -50,27 +50,27 @@ nsresult NS_NewHTMLContentSink(nsIContentSink** aInstancePtrResult)
}
/**-------------------------------------------------------
/**
* Default constructor
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsHTMLContentSink::nsHTMLContentSink() : nsIHTMLContentSink(), mTitle("") {
mNodeStackPos=0;
memset(mNodeStack,0,sizeof(mNodeStack));
}
/**-------------------------------------------------------
/**
* Default destructor. Probably not a good idea to call
* this if you created your instance via the factor method.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsHTMLContentSink::~nsHTMLContentSink() {
}
@ -85,20 +85,20 @@ static void DebugDump(const char* str1,const nsString& str2,PRInt32 tabs) {
#endif
/**-------------------------------------------------------
/**
* This bit of magic creates the addref and release
* methods for this class.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
NS_IMPL_ADDREF(nsHTMLContentSink)
NS_IMPL_RELEASE(nsHTMLContentSink)
/**-------------------------------------------------------
/**
* Standard XPCOM query interface implementation. I used
* my own version because this class is a subclass of both
* ISupports and IContentSink. Perhaps there's a macro for
@ -107,7 +107,7 @@ NS_IMPL_RELEASE(nsHTMLContentSink)
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsresult nsHTMLContentSink::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
@ -135,14 +135,14 @@ nsresult nsHTMLContentSink::QueryInterface(const nsIID& aIID, void** aInstancePt
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a <HTML>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
@ -155,13 +155,13 @@ PRBool nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </HTML>
* tag has been consumed.
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -176,7 +176,7 @@ PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser <i>any time</i>
* head data gets consumed by the parser. Currently, that
* list includes <META>, <ISINDEX>, <LINK>, <SCRIPT>,
@ -185,7 +185,7 @@ PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -197,14 +197,14 @@ PRBool nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </HEAD>
* tag has been seen (either implicitly or explicitly).
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -218,28 +218,28 @@ PRBool nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This gets called by the parser when a <TITLE> tag
* gets consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::SetTitle(const nsString& aValue){
PRBool result=PR_TRUE;
mTitle=aValue;
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a <BODY>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -251,14 +251,14 @@ PRBool nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </BODY>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
@ -271,14 +271,14 @@ PRBool nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a <FORM>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -290,14 +290,14 @@ PRBool nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </FORM>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -311,14 +311,14 @@ PRBool nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a <FRAMESET>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -330,14 +330,14 @@ PRBool nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a </FRAMESET>
* tag has been consumed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -351,7 +351,7 @@ PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when any general
* type of container has been consumed and needs to be
* opened. This includes things like <OL>, <Hn>, etc...
@ -359,7 +359,7 @@ PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
PRBool result=PR_TRUE;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
@ -371,14 +371,14 @@ PRBool nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This method gets called by the parser when a close
* container tag has been consumed and needs to be closed.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
@ -392,14 +392,14 @@ PRBool nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
return result;
}
/**-------------------------------------------------------
/**
* This causes the topmost container to be closed,
* regardless of its type.
*
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::CloseTopmostContainer(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
@ -407,7 +407,7 @@ PRBool nsHTMLContentSink::CloseTopmostContainer(){
return result;
}
/**-------------------------------------------------------
/**
* This gets called by the parser when you want to add
* a leaf node to the current container in the content
* model.
@ -415,7 +415,7 @@ PRBool nsHTMLContentSink::CloseTopmostContainer(){
* @updated gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
PRBool result=PR_TRUE;

Просмотреть файл

@ -459,10 +459,11 @@ PRBool nsHTMLParser::IterateTokens() {
*/
PRBool nsHTMLParser::Parse(nsIURL* aURL){
eParseMode theMode=eParseMode_navigator;
char* theModeStr= PR_GetEnv("PARSE_MODE");
const char* theModeStr= PR_GetEnv("PARSE_MODE");
const char* other="other";
if(theModeStr)
if(0==nsCRT::strncasecmp("other",theModeStr,5))
if(0==nsCRT::strcasecmp(other,theModeStr))
theMode=eParseMode_other;
return Parse(aURL,theMode);

Просмотреть файл

@ -35,7 +35,7 @@ static nsString gIdentChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU
static nsString gAttrTextChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-%.");
static nsString gAlphaChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static nsAutoString gDigits("0123456789");
static nsAutoString gWhitespace(" \n\r\t\b");
static nsAutoString gWhitespace(" \t\b");
static nsAutoString gOperatorChars("/?.<>[]{}~^+=-!%&*(),|:");
//debug error messages...
@ -94,9 +94,7 @@ static StrToUnicodeStruct gStrToUnicodeTable[] =
};
struct HTMLTagEntry
{
struct HTMLTagEntry {
char fName[12];
eHTMLTags fTagID;
};
@ -253,116 +251,116 @@ HTMLAttrEntry gHTMLAttributeTable[] =
};
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CHTMLToken::CHTMLToken(const nsString& aName) : CToken(aName) {
mTagType=eHTMLTag_unknown;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
eHTMLTags CHTMLToken::GetHTMLTag() {
return mTagType;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CHTMLToken::SetHTMLTag(eHTMLTags aTagType) {
mTagType=aTagType;
return;
}
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CStartToken::CStartToken(const nsString& aName) : CHTMLToken(aName) {
mAttributed=PR_FALSE;
}
/**-------------------------------------------------------
/*
* default destructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
eHTMLTags CStartToken::GetHTMLTag(){
if(eHTMLTag_unknown==mTagType)
mTagType=DetermineHTMLTagType(mTextValue);
return mTagType;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CStartToken::GetClassName(void) {
return "start";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CStartToken::GetTokenType(void) {
return eToken_start;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CStartToken::SetAttributed(PRBool aValue) {
mAttributed=aValue;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStartToken::IsAttributed(void) {
return mAttributed;
}
/**-------------------------------------------------------
/*
* Consume the identifier portion of the start tag
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
//if you're here, we've already Consumed the < char, and are
@ -388,13 +386,13 @@ PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
};
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CStartToken::DebugDumpSource(ostream& out) {
char* cp=mTextValue.ToNewCString();
out << "<" << *cp;
@ -404,25 +402,25 @@ void CStartToken::DebugDumpSource(ostream& out) {
}
/**-------------------------------------------------------
/*
* default constructor for end token
*
* @update gess 3/25/98
* @param aName -- char* containing token name
* @return
*------------------------------------------------------*/
*/
CEndToken::CEndToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_end;
}
/**-------------------------------------------------------
/*
* Consume the identifier portion of the end tag
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
//if you're here, we've already Consumed the <! chars, and are
@ -438,7 +436,7 @@ PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
};
/**-------------------------------------------------------
/*
* Asks the token to determine the <i>HTMLTag type</i> of
* the token. This turns around and looks up the tag name
* in the tag dictionary.
@ -446,42 +444,42 @@ PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
* @update gess 3/25/98
* @param
* @return eHTMLTag id of this endtag
*------------------------------------------------------*/
*/
eHTMLTags CEndToken::GetHTMLTag(){
if(eHTMLTag_unknown==mTagType)
mTagType=DetermineHTMLTagType(mTextValue);
return mTagType;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CEndToken::GetClassName(void) {
return "/end";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CEndToken::GetTokenType(void) {
return eToken_end;
}
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CEndToken::DebugDumpSource(ostream& out) {
char* cp=mTextValue.ToNewCString();
out << "</" << *cp << ">";
@ -489,48 +487,48 @@ void CEndToken::DebugDumpSource(ostream& out) {
}
/**-------------------------------------------------------
/*
* Default constructor
*
* @update gess 3/25/98
* @param aName -- string to init token name with
* @return
*------------------------------------------------------*/
*/
CTextToken::CTextToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_text;
mTagType=eHTMLTag_text;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CTextToken::GetClassName(void) {
return "text";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CTextToken::GetTokenType(void) {
return eToken_text;
}
/**-------------------------------------------------------
/*
* Consume as much clear text from scanner as possible.
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CTextToken::Consume(PRUnichar aChar, CScanner& aScanner) {
static nsAutoString terminals("&<\r\n");
PRInt32 result=aScanner.ReadUntil(mTextValue,terminals,PR_FALSE);
@ -538,19 +536,19 @@ PRInt32 CTextToken::Consume(PRUnichar aChar, CScanner& aScanner) {
};
/**-------------------------------------------------------
/*
* Default constructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CCommentToken::CCommentToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_comment;
mTagType=eHTMLTag_comment;
}
/**-------------------------------------------------------
/*
* Consume the identifier portion of the comment.
* Note that we've already eaten the "<!" portion.
*
@ -558,7 +556,7 @@ CCommentToken::CCommentToken(const nsString& aName) : CHTMLToken(aName) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner& aScanner) {
PRUnichar ch,ch2;
@ -587,120 +585,150 @@ PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner& aScanner) {
return result;
};
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CCommentToken::GetClassName(void){
return "/**/";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CCommentToken::GetTokenType(void) {
return eToken_comment;
}
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CNewlineToken::CNewlineToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_newline;
mTagType=eHTMLTag_newline;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CNewlineToken::GetClassName(void) {
return "crlf";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CNewlineToken::GetTokenType(void) {
return eToken_newline;
}
/**-------------------------------------------------------
/**
* This method retrieves the value of this internal string.
*
* @update gess 3/25/98
* @return nsString reference to internal string value
*/
nsString& CNewlineToken::GetText(void) {
static nsAutoString theStr("\n");
return theStr;
}
/*
* Consume as many cr/lf pairs as you can find.
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CNewlineToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
static nsAutoString crlfChars("\r\n");
PRInt32 result=aScanner.ReadWhile(mTextValue,crlfChars,PR_FALSE);
mTextValue.StripChars("\r");
//we already read the \r or \n, let's see what's next!
PRUnichar nextChar;
PRInt32 result=aScanner.Peek(nextChar);
switch(aChar) {
case kNewLine:
if(kCR==nextChar) {
result=aScanner.GetChar(nextChar);
mTextValue+=nextChar;
}
break;
case kCR:
if(kNewLine==nextChar) {
result=aScanner.GetChar(nextChar);
mTextValue+=nextChar;
}
break;
default:
break;
}
return result;
};
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CAttributeToken::CAttributeToken(const nsString& aName) : CHTMLToken(aName),
mTextKey() {
mLastAttribute=PR_FALSE;
mOrdinalValue=eToken_attribute;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CAttributeToken::GetClassName(void) {
return "attr";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CAttributeToken::GetTokenType(void) {
return eToken_attribute;
}
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CAttributeToken::DebugDumpToken(ostream& out) {
char* cp=mTextKey.ToNewCString();
out << "[" << GetClassName() << "] " << *cp << "=";
@ -710,7 +738,7 @@ void CAttributeToken::DebugDumpToken(ostream& out) {
}
/**-------------------------------------------------------
/*
* This general purpose method is used when you want to
* consume a known quoted string.
*
@ -718,7 +746,7 @@ void CAttributeToken::DebugDumpToken(ostream& out) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 ConsumeQuotedString(PRUnichar aChar,nsString& aString,CScanner& aScanner){
static nsAutoString terminals1(">'");
static nsAutoString terminals2(">\"");
@ -740,7 +768,7 @@ PRInt32 ConsumeQuotedString(PRUnichar aChar,nsString& aString,CScanner& aScanner
return result;
}
/**-------------------------------------------------------
/*
* This general purpose method is used when you want to
* consume attributed text value.
*
@ -748,7 +776,7 @@ PRInt32 ConsumeQuotedString(PRUnichar aChar,nsString& aString,CScanner& aScanner
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 ConsumeAttributeValueText(PRUnichar aChar,nsString& aString,CScanner& aScanner){
PRInt32 result=kNotFound;
@ -758,14 +786,14 @@ PRInt32 ConsumeAttributeValueText(PRUnichar aChar,nsString& aString,CScanner& aS
}
/**-------------------------------------------------------
/*
* Consume the key and value portions of the attribute.
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
aScanner.SkipWhite(); //skip leading whitespace
@ -815,13 +843,13 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
return result;
};
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CAttributeToken::DebugDumpSource(ostream& out) {
char* cp=mTextKey.ToNewCString();
out << " " << *cp;
@ -835,41 +863,41 @@ void CAttributeToken::DebugDumpSource(ostream& out) {
out<<">";
}
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CWhitespaceToken::CWhitespaceToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_whitespace;
mTagType=eHTMLTag_whitespace;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CWhitespaceToken::GetClassName(void) {
return "ws";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CWhitespaceToken::GetTokenType(void) {
return eToken_whitespace;
}
/**-------------------------------------------------------
/*
* This general purpose method is used when you want to
* consume an aribrary sequence of whitespace.
*
@ -877,7 +905,7 @@ PRInt32 CWhitespaceToken::GetTokenType(void) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CWhitespaceToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
@ -886,13 +914,13 @@ PRInt32 CWhitespaceToken::Consume(PRUnichar aChar, CScanner& aScanner) {
return result;
};
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CEntityToken::CEntityToken(const nsString& aName) : CHTMLToken(aName) {
mOrdinalValue=eToken_entity;
#ifdef VERBOSE_DEBUG
@ -902,14 +930,14 @@ CEntityToken::CEntityToken(const nsString& aName) : CHTMLToken(aName) {
#endif
}
/**-------------------------------------------------------
/*
* Consume the rest of the entity. We've already eaten the "&".
*
* @update gess 3/25/98
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
@ -917,29 +945,29 @@ PRInt32 CEntityToken::Consume(PRUnichar aChar, CScanner& aScanner) {
return result;
};
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CEntityToken::GetClassName(void) {
return "&entity";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::GetTokenType(void) {
return eToken_entity;
}
/**-------------------------------------------------------
/*
* This general purpose method is used when you want to
* consume an entity &xxxx;. Keep in mind that entities
* are <i>not</i> reduced inline.
@ -948,7 +976,7 @@ PRInt32 CEntityToken::GetTokenType(void) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner& aScanner){
PRInt32 result=kNotFound;
@ -976,14 +1004,14 @@ PRInt32 CEntityToken::ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner&
}
/**-------------------------------------------------------
/*
* This method converts this entity into its underlying
* unicode equivalent.
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) {
char* cp = mTextValue.ToNewCString();
PRInt32 index=FindEntityIndex(cp);
@ -1000,13 +1028,13 @@ PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) {
}
/**-------------------------------------------------------
/*
* This method ensures that the entity table doesn't get
* out of sync. Make sure you call this at least once.
*
* @update gess 3/25/98
* @return PR_TRUE if valid (ordered correctly)
*------------------------------------------------------*/
*/
PRBool CEntityToken::VerifyEntityTable(){
PRInt32 count=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
PRInt32 i,j;
@ -1020,7 +1048,7 @@ PRBool CEntityToken::VerifyEntityTable(){
}
/**-------------------------------------------------------
/*
* This method is used to convert from a given string (char*)
* into a entity index (offset within entity table).
*
@ -1028,7 +1056,7 @@ PRBool CEntityToken::VerifyEntityTable(){
* @param aBuffer -- string to be converted
* @param aBuflen -- optional string length
* @return integer offset of string in table, or kNotFound
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
PRInt32 result=kNotFound;
PRInt32 cnt=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
@ -1059,14 +1087,14 @@ PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
}
/**-------------------------------------------------------
/*
* This method reduces all text entities into their char
* representation.
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CEntityToken::ReduceEntities(nsString& aString) {
PRInt32 result=0;
PRInt32 amppos=0;
@ -1094,99 +1122,99 @@ PRInt32 CEntityToken::ReduceEntities(nsString& aString) {
return result;
}
/**-------------------------------------------------------
/*
* Dump contents of this token to givne output stream
*
* @update gess 3/25/98
* @param out -- ostream to output content
* @return
*------------------------------------------------------*/
*/
void CEntityToken::DebugDumpSource(ostream& out) {
char* cp=mTextValue.ToNewCString();
out << "&" << *cp;
delete cp;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CScriptToken::GetClassName(void) {
return "script";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CScriptToken::GetTokenType(void) {
return eToken_script;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CStyleToken::GetClassName(void) {
return "style";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CStyleToken::GetTokenType(void) {
return eToken_style;
}
/**-------------------------------------------------------
/*
* default constructor
*
* @update gess 3/25/98
* @param aName -- string value to init token name with
* @return
*------------------------------------------------------*/
*/
CSkippedContentToken::CSkippedContentToken(const nsString& aName) : CAttributeToken(aName) {
mTextKey = "$skipped-content";/* XXX need a better answer! */
mOrdinalValue=eToken_skippedcontent;
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
const char* CSkippedContentToken::GetClassName(void) {
return "skipped";
}
/**-------------------------------------------------------
/*
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CSkippedContentToken::GetTokenType(void) {
return eToken_skippedcontent;
}
/**-------------------------------------------------------
/*
* Consume content until you find a sequence that matches
* this objects mTextValue.
*
@ -1194,7 +1222,7 @@ PRInt32 CSkippedContentToken::GetTokenType(void) {
* @param aChar -- last char consumed from stream
* @param aScanner -- controller of underlying input source
* @return error result
*------------------------------------------------------*/
*/
PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
PRBool done=PR_FALSE;
PRInt32 result=kNoError;
@ -1210,7 +1238,7 @@ PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
}
/**-------------------------------------------------------
/*
* This method iterates the tagtable to ensure that is
* is proper sort order. This method only needs to be
* called once.
@ -1218,7 +1246,7 @@ PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
class CTagTableVerifier {
public:
CTagTableVerifier::CTagTableVerifier(){
@ -1244,19 +1272,19 @@ public:
* @update gess4/6/98
* @param
* @return
*------------------------------------------------------*/
*/
eHTMLTokenTypes DetermineTokenType(const nsString& aString){
return eToken_unknown;
}
/**-------------------------------------------------------
/*
* This method accepts a string (and optionally, its length)
* and determines the eHTMLTag (id) value.
*
* @update gess 3/25/98
* @param aString -- string to be convered to id
* @return valid id, or user_defined.
*------------------------------------------------------*/
*/
eHTMLTags DetermineHTMLTagType(const nsString& aString)
{
PRInt32 result=-1;
@ -1297,7 +1325,7 @@ const char* GetTagName(PRInt32 aTag) {
return result;
}
/**-------------------------------------------------------
/*
* This method iterates the attribute-table to ensure that is
* is proper sort order. This method only needs to be
* called once.
@ -1305,7 +1333,7 @@ const char* GetTagName(PRInt32 aTag) {
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
class CAttributeTableVerifier {
public:
CAttributeTableVerifier::CAttributeTableVerifier(){
@ -1326,10 +1354,10 @@ public:
};
/**-------------------------------------------------------
/*
* These objects are here to force the validation of the
* tag and attribute tables.
*------------------------------------------------------*/
*/
CAttributeTableVerifier gAttributeTableVerifier;
CTagTableVerifier gTableVerifier;

Просмотреть файл

@ -117,12 +117,12 @@ eHTMLTokenTypes DetermineTokenType(const nsString& aString);
const char* GetTagName(PRInt32 aTag);
/** -----------------------------------------------------
/**
* This declares the basic token type used in the html-
* parser.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CHTMLToken : public CToken {
public:
CHTMLToken(const nsString& aString);
@ -133,13 +133,13 @@ protected:
};
/** -----------------------------------------------------
/**
* This declares start tokens, which always take the
* form <xxxx>. This class also knows how to consume
* related attributes.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CStartToken: public CHTMLToken {
public:
CStartToken(const nsString& aString);
@ -157,32 +157,32 @@ class CStartToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* This declares end tokens, which always take the
* form </xxxx>. This class also knows how to consume
* related attributes.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CEndToken: public CHTMLToken {
public:
CEndToken(const nsString& aString);
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
virtual eHTMLTags GetHTMLTag();
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual void DebugDumpSource(ostream& out);
};
/** -----------------------------------------------------
/**
* This declares comment tokens. Comments are usually
* thought of as tokens, but we treat them that way
* here so that the parser can have a consistent view
* of all tokens.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CCommentToken: public CHTMLToken {
public:
CCommentToken(const nsString& aString);
@ -193,13 +193,13 @@ class CCommentToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* This class declares entity tokens, which always take
* the form &xxxx;. This class also offers a few utility
* methods that allow you to easily reduce entities.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CEntityToken : public CHTMLToken {
public:
CEntityToken(const nsString& aString);
@ -219,13 +219,13 @@ class CEntityToken : public CHTMLToken {
};
/** -----------------------------------------------------
/**
* 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 CWhitespaceToken: public CHTMLToken {
public:
CWhitespaceToken(const nsString& aString);
@ -234,13 +234,13 @@ class CWhitespaceToken: public CHTMLToken {
virtual PRInt32 GetTokenType(void);
};
/** -----------------------------------------------------
/**
* Text tokens contain the normalized form of html text.
* These tokens are guaranteed not to contain entities,
* start or end tags, or newlines.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CTextToken: public CHTMLToken {
public:
CTextToken(const nsString& aString);
@ -250,14 +250,14 @@ class CTextToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* Attribute tokens are used to contain attribute key/value
* pairs whereever they may occur. Typically, they should
* occur only in start tokens. However, we may expand that
* ability when XML tokens become commonplace.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CAttributeToken: public CHTMLToken {
public:
CAttributeToken(const nsString& aString);
@ -274,22 +274,23 @@ class CAttributeToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* Newline tokens contain, you guessed it, newlines.
* They consume newline (CR/LF) either alone or in pairs.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CNewlineToken: public CHTMLToken {
public:
CNewlineToken(const nsString& aString);
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual nsString& GetText(void);
};
/** -----------------------------------------------------
/**
* Script tokens contain sequences of javascript (or, gulp,
* any other script you care to send). We don't tokenize
* it here, nor validate it. We just wrap it up, and pass
@ -297,7 +298,7 @@ class CNewlineToken: public CHTMLToken {
* to the scripting engine.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CScriptToken: public CHTMLToken {
public:
@ -308,14 +309,14 @@ class CScriptToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* Style tokens contain sequences of css style. We don't
* tokenize it here, nor validate it. We just wrap it up,
* and pass it along to the html parser, who sends it
* (later on) to the style engine.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CStyleToken: public CHTMLToken {
public:
CStyleToken(const nsString& aString);
@ -325,12 +326,12 @@ class CStyleToken: public CHTMLToken {
};
/** -----------------------------------------------------
/**
* This is a placeholder token, which is being deprecated.
* Don't bother paying attention to this.
*
* @update gess 3/25/98
*/ //---------------------------------------------------
*/
class CSkippedContentToken: public CAttributeToken {
public:
CSkippedContentToken(const nsString& aString);

Просмотреть файл

@ -41,12 +41,12 @@
class nsIContentSink;
/**-------------------------------------------------------
/**
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
class nsIParser : public nsISupports {
public:

Просмотреть файл

@ -40,14 +40,14 @@
#include "nsString.h"
#include "nsDebug.h"
/**-------------------------------------------------------
/**
* Parser nodes are the unit of exchange between the
* parser and the content sink. Nodes offer access to
* the current token, its attributes, and its skipped-
* content if applicable.
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
class nsIParserNode {
public:

Просмотреть файл

@ -22,13 +22,13 @@
#include "string.h"
/**-------------------------------------------------------
/**
* Default constructor
*
* @update gess 3/25/98
* @param aToken -- token to init internal token
* @return
*------------------------------------------------------*/
*/
nsCParserNode::nsCParserNode(CHTMLToken* aToken): nsIParserNode(),
mName(), mEmptyString() {
NS_PRECONDITION(0!=aToken, "Null Token");
@ -38,25 +38,25 @@ nsCParserNode::nsCParserNode(CHTMLToken* aToken): nsIParserNode(),
}
/**-------------------------------------------------------
/**
* default destructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
nsCParserNode::~nsCParserNode() {
}
/**-------------------------------------------------------
/**
* Causes the given attribute to be added to internal
* mAttributes list, and mAttributeCount to be incremented.
*
* @update gess 3/25/98
* @param aToken -- token to be added to attr list
* @return
*------------------------------------------------------*/
*/
void nsCParserNode::AddAttribute(CHTMLToken* aToken) {
NS_PRECONDITION(mAttributeCount<sizeof(mAttributes), "Buffer overrun!");
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
@ -66,7 +66,7 @@ void nsCParserNode::AddAttribute(CHTMLToken* aToken) {
}
/**-------------------------------------------------------
/**
* This method gets called when the parser encounters
* skipped content after a start token.
* NOTE: To determine if we have skipped content, simply
@ -75,7 +75,7 @@ void nsCParserNode::AddAttribute(CHTMLToken* aToken) {
* @update gess 3/26/98
* @param aToken -- really a skippedcontent token
* @return nada
*------------------------------------------------------*/
*/
void nsCParserNode::SetSkippedContent(CHTMLToken* aToken){
NS_PRECONDITION(mAttributeCount<sizeof(mAttributes)-1, "Buffer overrun!");
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
@ -85,38 +85,38 @@ void nsCParserNode::SetSkippedContent(CHTMLToken* aToken){
}
/**-------------------------------------------------------
/**
* Gets the name of this node. Currently unused.
*
* @update gess 3/25/98
* @param
* @return string ref containing node name
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetName() const {
return mName;
}
/**-------------------------------------------------------
/**
* Get text value of this node, which translates into
* getting the text value of the underlying token
*
* @update gess 3/25/98
* @param
* @return string ref of text from internal token
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetText() const {
return mToken->GetText();
}
/**-------------------------------------------------------
/**
* Get text value of this node, which translates into
* getting the text value of the underlying token
*
* @update gess 3/25/98
* @param
* @return string ref of text from internal token
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetSkippedContent() const {
if (0 < mAttributeCount) {
if(mAttributes[mAttributeCount-1]) {
@ -129,51 +129,51 @@ const nsString& nsCParserNode::GetSkippedContent() const {
return mEmptyString;
}
/**-------------------------------------------------------
/**
* Get node type, meaning, get the tag type of the
* underlying token
*
* @update gess 3/25/98
* @param
* @return int value that represents tag type
*------------------------------------------------------*/
*/
PRInt32 nsCParserNode::GetNodeType(void) const{
return mToken->GetHTMLTag();
}
/**-------------------------------------------------------
/**
* Gets the token type, which corresponds to a value from
* eHTMLTags_xxx.
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 nsCParserNode::GetTokenType(void) const{
return mToken->GetTokenType();
}
/**-------------------------------------------------------
/**
* Retrieve the number of attributes on this node
*
* @update gess 3/25/98
* @param
* @return int -- representing attribute count
*------------------------------------------------------*/
*/
PRInt32 nsCParserNode::GetAttributeCount(void) const{
return mAttributeCount;
}
/**-------------------------------------------------------
/**
* Retrieve the string rep of the attribute key at the
* given index.
*
* @update gess 3/25/98
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text key
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
CAttributeToken* tkn=(CAttributeToken*)(mAttributes[anIndex]);
@ -181,13 +181,13 @@ const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
}
/**-------------------------------------------------------
/**
* Retrieve the string rep of the attribute at given offset
*
* @update gess 3/25/98
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*------------------------------------------------------*/
*/
const nsString& nsCParserNode::GetValueAt(PRInt32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
return (mAttributes[anIndex])->GetText();

Просмотреть файл

@ -25,13 +25,13 @@ const char* gURLRef;
const char* kBadHTMLText1="<HTML><BODY><H3>Oops...</H3>You just tried to read a non-existent document: <BR>";
const char* kBadHTMLText2="</BODY></HTML>";
/**-------------------------------------------------------
/**
* default constructor
*
* @update gess 3/25/98
* @param aURL -- pointer to URL to be loaded
* @return
*------------------------------------------------------*/
*/
CScanner::CScanner(nsIURL* aURL,eParseMode aMode) : mBuffer("") {
NS_ASSERTION(0!=aURL,"Error: Null URL!");
mOffset=0;
@ -45,13 +45,13 @@ CScanner::CScanner(nsIURL* aURL,eParseMode aMode) : mBuffer("") {
}
}
/**-------------------------------------------------------
/**
* default destructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CScanner::~CScanner() {
mStream->Close();
delete mStream;
@ -63,7 +63,7 @@ CScanner::~CScanner() {
* @update gess4/3/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CScanner::FillBuffer(PRInt32& anError) {
mBuffer.Cut(0,mBuffer.Length());
if(!mStream) {
@ -91,13 +91,13 @@ PRInt32 CScanner::FillBuffer(PRInt32& anError) {
return mBuffer.Length();
}
/**-------------------------------------------------------
/**
* determine if the scanner has reached EOF
*
* @update gess 3/25/98
* @param
* @return PR_TRUE upon eof condition
*------------------------------------------------------*/
*/
PRBool CScanner::Eof() {
PRInt32 theError=0;
if(mOffset>=mBuffer.Length()) {
@ -114,13 +114,13 @@ PRBool CScanner::Eof() {
return result;
}
/**-------------------------------------------------------
/**
* retrieve next char from scanners internal input stream
*
* @update gess 3/25/98
* @param
* @return error code reflecting read status
*------------------------------------------------------*/
*/
PRInt32 CScanner::GetChar(PRUnichar& aChar) {
if(!Eof()) {
aChar=mBuffer[mOffset++];
@ -130,14 +130,14 @@ PRInt32 CScanner::GetChar(PRUnichar& aChar) {
}
/**-------------------------------------------------------
/**
* peek ahead to consume next char from scanner's internal
* input buffer
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
PRInt32 CScanner::Peek(PRUnichar& aChar){
if(!Eof()) {
aChar=mBuffer[mOffset];
@ -147,13 +147,13 @@ PRInt32 CScanner::Peek(PRUnichar& aChar){
}
/**-------------------------------------------------------
/**
* Push the given char back onto the scanner
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::PutBack(PRUnichar aChar) {
mOffset--;
return kNoError;
@ -161,33 +161,57 @@ PRInt32 CScanner::PutBack(PRUnichar aChar) {
/**-------------------------------------------------------
/**
* Skip whitespace on scanner input stream
*
* @update gess 3/25/98
* @param
* @return error status
*------------------------------------------------------*/
*/
PRInt32 CScanner::SkipWhite(void) {
static nsAutoString chars(" \n\r\t");
return SkipOver(chars);
}
/**-------------------------------------------------------
* Skip over chars as long as they're in aValidSet
/**
* Skip over chars as long as they equal given char
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
PRInt32 CScanner::SkipOver(nsString& aValidSet){
*/
PRInt32 CScanner::SkipOver(PRUnichar aSkipChar){
PRUnichar ch=0;
PRInt32 result=kNoError;
while(kNoError==result) {
result=GetChar(ch);
if(!result) {
PRInt32 pos=aValidSet.Find(ch);
if(ch!=aSkipChar) {
PutBack(ch);
break;
}
}
else break;
} //while
return result;
}
/**
* Skip over chars as long as they're in aSkipSet
*
* @update gess 3/25/98
* @param
* @return error code
*/
PRInt32 CScanner::SkipOver(nsString& aSkipSet){
PRUnichar ch=0;
PRInt32 result=kNoError;
while(kNoError==result) {
result=GetChar(ch);
if(!result) {
PRInt32 pos=aSkipSet.Find(ch);
if(kNotFound==pos) {
PutBack(ch);
break;
@ -198,26 +222,26 @@ PRInt32 CScanner::SkipOver(nsString& aValidSet){
return result;
}
/**-------------------------------------------------------
/**
* Skip over chars as long as they're in aValidSet
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::SkipPast(nsString& aValidSet){
NS_NOTYETIMPLEMENTED("Error: SkipPast not yet implemented.");
return kNoError;
}
/**-------------------------------------------------------
/**
* Consume chars as long as they are <i>in</i> the
* given validSet of input chars.
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::ReadWhile(nsString& aString,nsString& aValidSet,PRBool addTerminal){
PRUnichar ch=0;
PRInt32 result=kNoError;
@ -240,14 +264,14 @@ PRInt32 CScanner::ReadWhile(nsString& aString,nsString& aValidSet,PRBool addTerm
}
/**-------------------------------------------------------
/**
* Consume characters until you find one contained in given
* input set.
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::ReadUntil(nsString& aString,nsString& aTerminalSet,PRBool addTerminal){
PRUnichar ch=0;
PRInt32 result=kNoError;
@ -269,13 +293,13 @@ PRInt32 CScanner::ReadUntil(nsString& aString,nsString& aTerminalSet,PRBool addT
}
/**-------------------------------------------------------
/**
* Consumes chars until you see the given terminalChar
*
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CScanner::ReadUntil(nsString& aString,PRUnichar aTerminalChar,PRBool addTerminal){
PRUnichar ch=0;
PRInt32 result=kNoError;
@ -294,14 +318,14 @@ PRInt32 CScanner::ReadUntil(nsString& aString,PRUnichar aTerminalChar,PRBool add
}
/**-------------------------------------------------------
/**
* Conduct self test. Actually, selftesting for this class
* occurs in the parser selftest.
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CScanner::SelfTest(void) {
#ifdef _DEBUG

Просмотреть файл

@ -49,10 +49,10 @@ class CScanner {
PRInt32 GetChar(PRUnichar& ch);
PRInt32 Peek(PRUnichar& ch);
PRInt32 PutBack(PRUnichar ch);
PRInt32 SkipOver(nsString& SkipChars);
PRInt32 SkipOver(nsString& SkipChars);
PRInt32 SkipOver(PRUnichar aSkipChar);
PRInt32 SkipPast(nsString& aSequence);
PRInt32 SkipPast(PRUnichar aChar);
PRInt32 SkipWhite(void);
PRInt32 SkipWhite(void);
PRBool Eof(void);
PRInt32 ReadUntil(nsString& aString,PRUnichar aTerminal,PRBool addTerminal);

Просмотреть файл

@ -19,26 +19,26 @@
#include "nsToken.h"
#include "nsScanner.h"
/**-------------------------------------------------------
/**
* Default constructor
*
* @update gess 3/25/98
* @param nsString--name of token
*------------------------------------------------------*/
*/
CToken::CToken(const nsString& aName) : mTextValue(aName) {
mOrdinalValue=0;
}
/**-------------------------------------------------------
/**
* Decstructor
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
CToken::~CToken() {
}
/**-------------------------------------------------------
/**
* Virtual method used to tell this toke to consume his
* valid chars.
*
@ -46,29 +46,29 @@ CToken::~CToken() {
* @param aChar -- first char in sequence
* @param aScanner -- object to retrieve data from
* @return int error code
*------------------------------------------------------*/
*/
PRInt32 CToken::Consume(PRUnichar aChar,CScanner& aScanner) {
PRInt32 result=kNoError;
return result;
}
/**-------------------------------------------------------
/**
* Method used to set the string value of this token
*
* @update gess 3/25/98
* @param aValue -- char* containing new value
*------------------------------------------------------*/
*/
void CToken::SetStringValue(const char* aValue) {
mTextValue=aValue;
}
/**-------------------------------------------------------
/**
* This debug method causes the token to dump its content
* to the given stream (formated for debugging).
*
* @update gess 3/25/98
* @param ostream -- output stream to accept output data
*------------------------------------------------------*/
*/
void CToken::DebugDumpToken(ostream& anOutputStream) {
anOutputStream << "[" << GetClassName() << "] ";
for(int i=0;i<mTextValue.Length();i++){
@ -77,79 +77,85 @@ void CToken::DebugDumpToken(ostream& anOutputStream) {
anOutputStream << ": " << mOrdinalValue << endl;
}
/**-------------------------------------------------------
/**
* This debug method causes the token to dump its content
* to the given stream, formated as text.
*
* @update gess 3/25/98
* @param ostream -- output stream to accept output data
*------------------------------------------------------*/
*/
void CToken::DebugDumpSource(ostream& anOutputStream) {
char buf[256];
anOutputStream << mTextValue.ToCString(buf,256);
}
/**-------------------------------------------------------
/**
* This method retrieves the value of this internal string.
*
* @update gess 3/25/98
* @return nsString reference to internal string value
*------------------------------------------------------*/
*/
nsString& CToken::GetStringValue(void) {
return mTextValue;
}
/**
* This method retrieves the value of this internal string.
*
* @update gess 3/25/98
* @return nsString reference to internal string value
*/
nsString& CToken::GetText(void) {
return mTextValue;
}
/**-------------------------------------------------------
/**
* Sets the internal ordinal value for this token.
* This method is deprecated, and will soon be going away.
*
* @update gess 3/25/98
* @param value -- new ordinal value for this token
*------------------------------------------------------*/
*/
void CToken::SetOrdinal(PRInt32 value) {
mOrdinalValue=value;
}
/**-------------------------------------------------------
/**
* Retrieves copy of internal ordinal value.
* This method is deprecated, and will soon be going away.
*
* @update gess 3/25/98
* @return int containing ordinal value
*------------------------------------------------------*/
*/
PRInt32 CToken::GetOrdinal(void) {
return mOrdinalValue;
}
/**-------------------------------------------------------
/**
* Retrieve type of token. This class returns -1, but
* subclasses return something more meaningful.
*
* @update gess 3/25/98
* @return int value containing token type.
*------------------------------------------------------*/
*/
PRInt32 CToken::GetTokenType(void) {
return -1;
}
/**-------------------------------------------------------
/**
* retrieve this tokens classname.
*
* @update gess 3/25/98
* @return char* containing name of class
*------------------------------------------------------*/
*/
const char* CToken::GetClassName(void) {
return "token";
}
/**-------------------------------------------------------
/**
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
void CToken::SelfTest(void) {
#ifdef _DEBUG
#endif

Просмотреть файл

@ -41,7 +41,7 @@
class CScanner;
/**-------------------------------------------------------
/**
* Token objects represent sequences of characters as they
* are consumed from the input stream (URL). While they're
* pretty general in nature, we use subclasses (found in
@ -49,7 +49,7 @@ class CScanner;
* <comment>, <&entity>, <newline>, and <whitespace> tokens.
*
* @update gess 3/25/98
*------------------------------------------------------*/
*/
class CToken {
public:
CToken(const nsString& aName);

Просмотреть файл

@ -31,60 +31,60 @@
static const char* kNullParserGiven = "Error: Null parser given as argument";
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CTokenHandler::CTokenHandler(eHTMLTokenTypes aType) {
mType=aType;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CTokenHandler::~CTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
eHTMLTokenTypes CTokenHandler::GetTokenType(void){
return mType;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
PRBool result=PR_FALSE;
@ -95,35 +95,35 @@ PRBool CTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CStartTokenHandler::CStartTokenHandler() : CTokenHandler(eToken_start) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CStartTokenHandler::~CStartTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStartTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -132,48 +132,48 @@ PRBool CStartTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStartTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CEndTokenHandler::CEndTokenHandler(): CTokenHandler(eToken_end) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CEndTokenHandler::~CEndTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CEndTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -182,48 +182,48 @@ PRBool CEndTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CEndTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CCommentTokenHandler::CCommentTokenHandler() : CTokenHandler(eToken_comment) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CCommentTokenHandler::~CCommentTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CCommentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -232,47 +232,47 @@ PRBool CCommentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CCommentTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CEntityTokenHandler::CEntityTokenHandler() : CTokenHandler(eToken_entity) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CEntityTokenHandler::~CEntityTokenHandler() {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CEntityTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -281,47 +281,47 @@ PRBool CEntityTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CEntityTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CWhitespaceTokenHandler::CWhitespaceTokenHandler() : CTokenHandler(eToken_whitespace) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CWhitespaceTokenHandler::~CWhitespaceTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CWhitespaceTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -330,48 +330,48 @@ PRBool CWhitespaceTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser)
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CWhitespaceTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CNewlineTokenHandler::CNewlineTokenHandler() : CTokenHandler(eToken_newline) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CNewlineTokenHandler::~CNewlineTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CNewlineTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -380,47 +380,47 @@ PRBool CNewlineTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CNewlineTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CTextTokenHandler::CTextTokenHandler() : CTokenHandler(eToken_text) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CTextTokenHandler::~CTextTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CTextTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -429,46 +429,46 @@ PRBool CTextTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CTextTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CAttributeTokenHandler::CAttributeTokenHandler() : CTokenHandler(eToken_attribute) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CAttributeTokenHandler::~CAttributeTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CAttributeTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -477,47 +477,47 @@ PRBool CAttributeTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CAttributeTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CScriptTokenHandler::CScriptTokenHandler() : CTokenHandler(eToken_script) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CScriptTokenHandler::~CScriptTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CScriptTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -526,47 +526,47 @@ PRBool CScriptTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CScriptTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CStyleTokenHandler::CStyleTokenHandler() : CTokenHandler(eToken_style) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CStyleTokenHandler::~CStyleTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStyleTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -575,47 +575,47 @@ PRBool CStyleTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CStyleTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CSkippedContentTokenHandler::CSkippedContentTokenHandler() : CTokenHandler(eToken_skippedcontent) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
CSkippedContentTokenHandler::~CSkippedContentTokenHandler(){
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CSkippedContentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
if(aParser){
@ -624,13 +624,13 @@ PRBool CSkippedContentTokenHandler::operator()(CToken* aToken,nsHTMLParser* aPar
return PR_FALSE;
}
/**-------------------------------------------------------
/**
*
*
* @update gess 4/2/98
* @param
* @return
*------------------------------------------------------*/
*/
PRBool CSkippedContentTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;

Просмотреть файл

@ -24,14 +24,14 @@
#include "nsIURL.h"
/**-------------------------------------------------------
/**
* Default constructor
*
* @update gess 3/25/98
* @param aFilename -- name of file to be tokenized
* @param aDelegate -- ref to delegate to be used to tokenize
* @return
*------------------------------------------------------*/
*/
CTokenizer::CTokenizer(nsIURL* aURL,ITokenizerDelegate* aDelegate,eParseMode aMode) :
mTokenDeque() {
mDelegate=aDelegate;
@ -40,13 +40,13 @@ CTokenizer::CTokenizer(nsIURL* aURL,ITokenizerDelegate* aDelegate,eParseMode aMo
}
/**-------------------------------------------------------
/**
* default destructor
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
CTokenizer::~CTokenizer() {
delete mScanner;
delete mDelegate;
@ -64,20 +64,20 @@ nsDeque& CTokenizer::GetDeque(void) {
return mTokenDeque;
}
/**-------------------------------------------------------
/**
* Cause the tokenizer to consume the next token, and
* return an error result.
*
* @update gess 3/25/98
* @param anError -- ref to error code
* @return new token or null
*------------------------------------------------------*/
*/
CToken* CTokenizer::GetToken(PRInt32& anError) {
CToken* nextToken=mDelegate->GetToken(*mScanner,anError);
return nextToken;
}
/**-------------------------------------------------------
/**
* Retrieve the number of elements in the deque
*
* @update gess 3/25/98
@ -89,7 +89,7 @@ PRInt32 CTokenizer::GetSize(void) {
}
/**-------------------------------------------------------
/**
* Part of the code sandwich, this gets called right before
* the tokenization process begins. The main reason for
* this call is to allow the delegate to do initialization.
@ -97,14 +97,14 @@ PRInt32 CTokenizer::GetSize(void) {
* @update gess 3/25/98
* @param
* @return TRUE if it's ok to proceed
*------------------------------------------------------*/
*/
PRBool CTokenizer::WillTokenize(){
PRBool result=PR_TRUE;
result=mDelegate->WillTokenize();
return result;
}
/**-------------------------------------------------------
/**
* This is the primary control routine. It iteratively
* consumes tokens until an error occurs or you run out
* of data.
@ -112,7 +112,7 @@ PRBool CTokenizer::WillTokenize(){
* @update gess 3/25/98
* @param
* @return error code
*------------------------------------------------------*/
*/
PRInt32 CTokenizer::Tokenize(void) {
CToken* nextToken;
PRInt32 result;
@ -135,7 +135,7 @@ PRInt32 CTokenizer::Tokenize(void) {
}
/**-------------------------------------------------------
/**
* This is the tail-end of the code sandwich for the
* tokenization process. It gets called once tokenziation
* has completed.
@ -143,7 +143,7 @@ PRInt32 CTokenizer::Tokenize(void) {
* @update gess 3/25/98
* @param
* @return TRUE if all went well
*------------------------------------------------------*/
*/
PRBool CTokenizer::DidTokenize() {
PRBool result=mDelegate->DidTokenize();
@ -154,7 +154,7 @@ PRBool CTokenizer::DidTokenize() {
return result;
}
/**-------------------------------------------------------
/**
* This debug routine is used to cause the tokenizer to
* iterate its token list, asking each token to dump its
* contents to the given output stream.
@ -162,7 +162,7 @@ PRBool CTokenizer::DidTokenize() {
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CTokenizer::DebugDumpTokens(ostream& out) {
nsDequeIterator b=mTokenDeque.Begin();
nsDequeIterator e=mTokenDeque.End();
@ -175,7 +175,7 @@ void CTokenizer::DebugDumpTokens(ostream& out) {
}
/**-------------------------------------------------------
/**
* This debug routine is used to cause the tokenizer to
* iterate its token list, asking each token to dump its
* contents to the given output stream.
@ -183,7 +183,7 @@ void CTokenizer::DebugDumpTokens(ostream& out) {
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CTokenizer::DebugDumpSource(ostream& out) {
nsDequeIterator b=mTokenDeque.Begin();
nsDequeIterator e=mTokenDeque.End();
@ -197,13 +197,13 @@ void CTokenizer::DebugDumpSource(ostream& out) {
}
/**-------------------------------------------------------
/**
*
*
* @update gess 3/25/98
* @param
* @return
*------------------------------------------------------*/
*/
void CTokenizer::SelfTest(void) {
#ifdef _DEBUG
#endif