incremental parsing; xml support; token handler dispatching; performance

This commit is contained in:
rickg 1998-05-21 20:38:32 +00:00
Родитель c13fe13cdd
Коммит 181ee968bb
44 изменённых файлов: 1476 добавлений и 2488 удалений

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

@ -136,18 +136,21 @@ PRInt32 CNavDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& aTo
* @param aScanner: see nsScanner.h
* @return
*/
PRInt32 CNavDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner) {
PRInt32 CNavDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRBool done=PR_FALSE;
PRInt32 result=kNoError;
nsAutoString as("");
PRInt16 theAttrCount=0;
while((!done) && (result==kNoError)) {
CToken* theToken= new CAttributeToken(as);
if(theToken){
result=theToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
if(kNoError==result){
theAttrCount++;
mTokenDeque.Push(theToken);
}//if
else delete theToken; //we can't keep it...
}//if
if(kNoError==result){
@ -158,6 +161,24 @@ PRInt32 CNavDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner) {
}//if
}//if
}//while
//ok, this is a bit complicated, so follow closely.
//Since we're incremental (but pessimistic), it is possible that even though
//we've eaten a few delicious attributes, we can't keep them because
//we couldn't eat all of them (up to an including the close > for this tag).
//Therefore, we need to remove the ones we just created from the tokendeque,
//and destroy them. (They'll get reconsumed on the next incremental pass).
//NOTE: This process can be enhanced later on by adding state to the delegate
// telling us that we're in the attribute consumption phase.
// Remember the mantra: Crawl, Walk, Run!
if(kNoError==result) {
aToken->SetAttributeCount(theAttrCount);
}
else {
while(theAttrCount--) {
delete mTokenDeque.PopBack();
}
}
return result;
}
@ -200,7 +221,7 @@ PRInt32 CNavDelegate::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,CToken*
result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
if(kNoError==result) {
if(((CStartToken*)aToken)->IsAttributed()) {
result=ConsumeAttributes(aChar,aScanner);
result=ConsumeAttributes(aChar,aScanner,aToken);
}
//now that that's over with, we have one more problem to solve.
//In the case that we just read a <SCRIPT> or <STYLE> tags, we should go and
@ -319,7 +340,7 @@ PRInt32 CNavDelegate::ConsumeText(const nsString& aString,CScanner& aScanner,CTo
PRInt32 result=kNoError;
if(aToken=new CTextToken(aString)) {
PRUnichar ch;
PRUnichar ch=0;
result=aToken->Consume(ch,aScanner);
}
return result;

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

@ -150,7 +150,7 @@ protected:
* @param aToken is the next token (or null)
* @return error code
*/
PRInt32 ConsumeAttributes(PRUnichar aChar,CScanner& aScanner);
PRInt32 ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CToken*& aToken);
/**
* Retrieve a sequence of text from given scanner.

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

@ -129,7 +129,7 @@ PRInt32 COtherDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& a
* @param aScanner: see nsScanner.h
* @return
*/
PRInt32 COtherDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner) {
PRInt32 COtherDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRBool done=PR_FALSE;
nsAutoString as("");
PRInt32 result=kNoError;
@ -186,7 +186,7 @@ PRInt32 COtherDelegate::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,CToke
if(aToken) {
result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
if(((CStartToken*)aToken)->IsAttributed()) {
result=ConsumeAttributes(aChar,aScanner);
result=ConsumeAttributes(aChar,aScanner,aToken);
}
//now that that's over with, we have one more problem to solve.
//In the case that we just read a <SCRIPT> or <STYLE> tags, we should go and

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

@ -150,7 +150,7 @@ protected:
* @param aToken is the next token (or null)
* @return error code
*/
PRInt32 ConsumeAttributes(PRUnichar aChar,CScanner& aScanner);
PRInt32 ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CToken*& aToken);
/**
* Retrieve a sequence of text from given scanner.

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

@ -18,6 +18,7 @@
#include "nsHTMLContentSink.h"
#include "nsHTMLTokens.h"
#include "nsParserTypes.h"
#include "prtypes.h"
#include <iostream.h>
@ -143,9 +144,9 @@ nsresult nsHTMLContentSink::QueryInterface(const nsIID& aIID, void** aInstancePt
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
PRInt32 nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -162,11 +163,11 @@ PRBool nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -186,8 +187,8 @@ PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -205,10 +206,10 @@ PRBool nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
PRInt32 nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -226,8 +227,8 @@ PRBool nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::SetTitle(const nsString& aValue){
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::SetTitle(const nsString& aValue){
PRInt32 result=kNoError;
mTitle=aValue;
return result;
}
@ -240,8 +241,8 @@ PRBool nsHTMLContentSink::SetTitle(const nsString& aValue){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -259,9 +260,9 @@ PRBool nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -279,8 +280,8 @@ PRBool nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -298,10 +299,10 @@ PRBool nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -319,8 +320,8 @@ PRBool nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -338,10 +339,10 @@ PRBool nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -360,8 +361,8 @@ PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -379,10 +380,10 @@ PRBool nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -400,9 +401,9 @@ PRBool nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseTopmostContainer(){
PRInt32 nsHTMLContentSink::CloseTopmostContainer(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos--]=eHTMLTag_unknown;
return result;
}
@ -416,8 +417,8 @@ PRBool nsHTMLContentSink::CloseTopmostContainer(){
* @param
* @return
*/
PRBool nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
PRInt32 result=kNoError;
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);

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

@ -87,33 +87,33 @@ class nsHTMLContentSink : public nsIHTMLContentSink {
PRBool SetTitle(const nsString& aValue);
// Called when Opening or closing the main HTML container
PRBool OpenHTML(const nsIParserNode& aNode);
PRBool CloseHTML(const nsIParserNode& aNode);
PRInt32 OpenHTML(const nsIParserNode& aNode);
PRInt32 CloseHTML(const nsIParserNode& aNode);
// Called when Opening or closing the main HEAD container
PRBool OpenHead(const nsIParserNode& aNode);
PRBool CloseHead(const nsIParserNode& aNode);
PRInt32 OpenHead(const nsIParserNode& aNode);
PRInt32 CloseHead(const nsIParserNode& aNode);
// Called when Opening or closing the main BODY container
PRBool OpenBody(const nsIParserNode& aNode);
PRBool CloseBody(const nsIParserNode& aNode);
PRInt32 OpenBody(const nsIParserNode& aNode);
PRInt32 CloseBody(const nsIParserNode& aNode);
// Called when Opening or closing FORM containers
PRBool OpenForm(const nsIParserNode& aNode);
PRBool CloseForm(const nsIParserNode& aNode);
PRInt32 OpenForm(const nsIParserNode& aNode);
PRInt32 CloseForm(const nsIParserNode& aNode);
// Called when Opening or closing the main FRAMESET container
PRBool OpenFrameset(const nsIParserNode& aNode);
PRBool CloseFrameset(const nsIParserNode& aNode);
PRInt32 OpenFrameset(const nsIParserNode& aNode);
PRInt32 CloseFrameset(const nsIParserNode& aNode);
// Called when Opening or closing a general container
// This includes: OL,UL,DIR,SPAN,TABLE,H[1..6],etc.
// Until proven otherwise, I also plan to toss STYLE,
// FRAME, SCRIPT, etc. here too!
virtual PRBool OpenContainer(const nsIParserNode& aNode);
virtual PRBool CloseContainer(const nsIParserNode& aNode);
virtual PRBool CloseTopmostContainer();
virtual PRBool AddLeaf(const nsIParserNode& aNode);
virtual PRInt32 OpenContainer(const nsIParserNode& aNode);
virtual PRInt32 CloseContainer(const nsIParserNode& aNode);
virtual PRInt32 CloseTopmostContainer();
virtual PRInt32 AddLeaf(const nsIParserNode& aNode);
/**
* This method gets called when the parser begins the process

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -15,7 +15,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/**
* MODULE NOTES:
* @update gess 4/1/98
@ -114,7 +114,7 @@ friend class CTokenHandler;
* @param aMode is the desired parser mode (Nav, other, etc.)
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(nsIURL* aURL,PRBool aIncremental=PR_FALSE);
virtual PRInt32 Parse(nsIURL* aURL,PRBool aIncremental=PR_TRUE);
/**
* Cause parser to parse input from given file in given mode
@ -138,7 +138,7 @@ friend class CTokenHandler;
* @update gess5/11/98
* @return TRUE if all went well, otherwise FALSE
*/
virtual PRInt32 ResumeParse(PRInt32 anIteration);
virtual PRInt32 ResumeParse(void);
/**
* Retrieve ptr to internal context vector stack
@ -164,7 +164,7 @@ friend class CTokenHandler;
* @param aToken is the start token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleStartToken(CToken* aToken);
PRInt32 HandleStartToken(CToken* aToken);
/**
* This method gets called when a start token has been consumed, and
@ -177,7 +177,7 @@ friend class CTokenHandler;
* @param aNode is a node be updated with info from given token
* @return TRUE if the token was handled.
*/
PRBool HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
/**
* This method gets called when an end token has been consumed and needs
@ -186,7 +186,7 @@ friend class CTokenHandler;
* @param aToken is the end token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleEndToken(CToken* aToken);
PRInt32 HandleEndToken(CToken* aToken);
/**
* This method gets called when an entity token has been consumed and needs
@ -195,7 +195,7 @@ friend class CTokenHandler;
* @param aToken is the entity token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleEntityToken(CToken* aToken);
PRInt32 HandleEntityToken(CToken* aToken);
/**
* This method gets called when a comment token has been consumed and needs
@ -204,7 +204,7 @@ friend class CTokenHandler;
* @param aToken is the comment token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleCommentToken(CToken* aToken);
PRInt32 HandleCommentToken(CToken* aToken);
/**
* This method gets called when a skipped-content token has been consumed and needs
@ -213,7 +213,7 @@ friend class CTokenHandler;
* @param aToken is the skipped-content token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleSkippedContentToken(CToken* aToken);
PRInt32 HandleSkippedContentToken(CToken* aToken);
/**
* This method gets called when an attribute token has been consumed and needs
@ -222,7 +222,7 @@ friend class CTokenHandler;
* @param aToken is the attribute token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleAttributeToken(CToken* aToken);
PRInt32 HandleAttributeToken(CToken* aToken);
/**
* This method gets called when a script token has been consumed and needs
@ -231,7 +231,7 @@ friend class CTokenHandler;
* @param aToken is the script token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleScriptToken(CToken* aToken);
PRInt32 HandleScriptToken(CToken* aToken);
/**
* This method gets called when a style token has been consumed and needs
@ -240,7 +240,7 @@ friend class CTokenHandler;
* @param aToken is the style token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleStyleToken(CToken* aToken);
PRInt32 HandleStyleToken(CToken* aToken);
//*********************************************
// These methods are callback methods used by
@ -254,21 +254,29 @@ friend class CTokenHandler;
protected:
/**
*
* @update gess5/18/98
* @param
* @return
*/
PRInt32 WillBuildModel(void);
/**
*
* @update gess5/18/98
* @param
* @return
*/
PRInt32 DidBuildModel(PRInt32 anErrorCode);
/**
* This method gets called when the tokens have been consumed, and it's time
* to build the model via the content sink.
* @update gess5/11/98
* @return YES if model building went well -- NO otherwise.
*/
PRBool IterateTokens();
/**
* Retrieves the tag type for the element on the context vector stack at given pos.
* @update gess5/11/98
* @param pos of item you want to retrieve
* @return tag type (may be unknown)
*/
eHTMLTags NodeAt(PRInt32 aPos) const;
PRInt32 IterateTokens(void);
/**
* Retrieve the tag type of the topmost item on context vector stack
@ -277,13 +285,6 @@ protected:
*/
eHTMLTags GetTopNode() const;
/**
* Retrieve the number of items on context vector stack
* @update gess5/11/98
* @return count of items on stack -- may be 0
*/
PRInt32 GetStackPos() const;
/**
* Causes the parser to scan foward, collecting nearby (sequential)
* attribute tokens into the given node.
@ -291,7 +292,7 @@ protected:
* @param node to store attributes
* @return number of attributes added to node.
*/
PRInt32 CollectAttributes(nsCParserNode& aNode);
PRInt32 CollectAttributes(nsCParserNode& aNode,PRInt32 aCount);
/**
* Causes the next skipped-content token (if any) to
@ -309,12 +310,7 @@ protected:
*/
void InitializeDefaultTokenHandlers();
/**
* DEPRECATED
* @update gess5/11/98
*/
CTokenHandler* GetTokenHandler(const nsString& aString) const;
/**
* DEPRECATED
* @update gess5/11/98
@ -345,7 +341,7 @@ protected:
* @param HTML (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenHTML(const nsIParserNode& aNode);
PRInt32 OpenHTML(const nsIParserNode& aNode);
/**
*
@ -353,7 +349,7 @@ protected:
* @param
* @return
*/
PRBool CloseHTML(const nsIParserNode& aNode);
PRInt32 CloseHTML(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a head item in
@ -362,7 +358,7 @@ protected:
* @param HEAD (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenHead(const nsIParserNode& aNode);
PRInt32 OpenHead(const nsIParserNode& aNode);
/**
* This cover method causes the content-sink head to be closed
@ -370,7 +366,7 @@ protected:
* @param aNode is the node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseHead(const nsIParserNode& aNode);
PRInt32 CloseHead(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a body item in
@ -379,7 +375,7 @@ protected:
* @param BODY (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenBody(const nsIParserNode& aNode);
PRInt32 OpenBody(const nsIParserNode& aNode);
/**
* This cover method causes the content-sink body to be closed
@ -387,7 +383,7 @@ protected:
* @param aNode is the body node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseBody(const nsIParserNode& aNode);
PRInt32 CloseBody(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a form item in
@ -396,7 +392,7 @@ protected:
* @param FORM (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenForm(const nsIParserNode& aNode);
PRInt32 OpenForm(const nsIParserNode& aNode);
/**
* This cover method causes the content-sink form to be closed
@ -404,7 +400,7 @@ protected:
* @param aNode is the form node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseForm(const nsIParserNode& aNode);
PRInt32 CloseForm(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a frameset item in
@ -413,7 +409,7 @@ protected:
* @param FRAMESET (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenFrameset(const nsIParserNode& aNode);
PRInt32 OpenFrameset(const nsIParserNode& aNode);
/**
* This cover method causes the content-sink frameset to be closed
@ -421,7 +417,7 @@ protected:
* @param aNode is the frameeset node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseFrameset(const nsIParserNode& aNode);
PRInt32 CloseFrameset(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a generic container in
@ -430,7 +426,7 @@ protected:
* @param generic container (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenContainer(const nsIParserNode& aNode);
PRInt32 OpenContainer(const nsIParserNode& aNode);
/**
* This cover method causes a generic containre in the content-sink to be closed
@ -438,14 +434,14 @@ protected:
* @param aNode is the node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseContainer(const nsIParserNode& aNode);
PRInt32 CloseContainer(const nsIParserNode& aNode);
/**
* This cover method causes the topmost container to be closed in sink
* @update gess5/11/98
* @return TRUE if all went well.
*/
PRBool CloseTopmostContainer();
PRInt32 CloseTopmostContainer();
/**
* Cause all containers down to topmost given tag to be closed
@ -453,7 +449,7 @@ protected:
* @param aTag is the tag at which auto-closure should stop (inclusive)
* @return TRUE if all went well -- otherwise FALSE
*/
PRBool CloseContainersTo(eHTMLTags aTag);
PRInt32 CloseContainersTo(eHTMLTags aTag);
/**
* Cause all containers down to given position to be closed
@ -461,7 +457,7 @@ protected:
* @param anIndex is the stack pos at which auto-closure should stop (inclusive)
* @return TRUE if all went well -- otherwise FALSE
*/
PRBool CloseContainersTo(PRInt32 anIndex);
PRInt32 CloseContainersTo(PRInt32 anIndex);
/**
* Causes leaf to be added to sink at current vector pos.
@ -469,15 +465,8 @@ protected:
* @param aNode is leaf node to be added.
* @return TRUE if all went well -- FALSE otherwise.
*/
PRBool AddLeaf(const nsIParserNode& aNode);
PRInt32 AddLeaf(const nsIParserNode& aNode);
/**
* Determine if the given tag is open in the context vector stack.
* @update gess5/11/98
* @param aTag is the type of tag you want to test for openness
* @return TRUE if open, FALSE otherwise.
*/
PRBool IsOpen(eHTMLTags aTag) const;
/**
* Finds the topmost occurance of given tag within context vector stack.
@ -495,7 +484,7 @@ protected:
* @param child to be added (somewhere) to context vector stack.
* @return TRUE if succeeds, otherwise FALSE
*/
PRBool ReduceContextStackFor(PRInt32 aChildTag);
PRInt32 ReduceContextStackFor(PRInt32 aChildTag);
/**
* Attempt forward and/or backward propagation for the given
@ -504,7 +493,7 @@ protected:
* @param type of child to be propagated.
* @return TRUE if succeeds, otherwise FALSE
*/
PRBool CreateContextStackFor(PRInt32 aChildTag);
PRInt32 CreateContextStackFor(PRInt32 aChildTag);
private:
PRInt32 ParseFileIncrementally(const char* aFilename); //XXX ONLY FOR DEBUG PURPOSES...
@ -520,19 +509,20 @@ protected:
PRInt32 mContextStack[50];
PRInt32 mContextStackPos;
CTokenHandler* mTokenHandlers[100];
PRInt32 mTokenHandlerCount;
CTokenHandler* mTokenHandlers[eToken_last];
nsDequeIterator* mCurrentPos;
nsDequeIterator* mMarkPos;
nsIDTD* mDTD;
eParseMode mParseMode;
PRBool mHasOpenForm;
PRBool mIncremental;
ITokenizerDelegate* mDelegate;
PRInt32 mIteration;
char* mTransferBuffer;
};
#endif

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

@ -368,21 +368,26 @@ PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
//Stop consuming as soon as you see a space or a '>'.
//NOTE: We don't Consume the tag attributes here, nor do we eat the ">"
mTextValue=aChar;
mTextValue=aChar;
PRInt32 result=aScanner.ReadWhile(mTextValue,gIdentChars,PR_FALSE);
//Good. Now, let's skip whitespace after the identifier,
//and see if the next char is ">". If so, we have a complete
//tag without attributes.
aScanner.SkipWhite();
result=aScanner.GetChar(aChar);
if(kGreaterThan!=aChar) { //look for '>'
//push that char back, since we apparently have attributes...
aScanner.PutBack(aChar);
mAttributed=PR_TRUE;
}
return result;
if(kNoError==result) {
result=aScanner.SkipWhite();
if(kNoError==result) {
result=aScanner.GetChar(aChar);
if(kNoError==result) {
if(kGreaterThan!=aChar) { //look for '>'
//push that char back, since we apparently have attributes...
aScanner.PutBack(aChar);
mAttributed=PR_TRUE;
} //if
} //if
}//if
}
return result;
};
@ -431,7 +436,8 @@ PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue="";
static nsAutoString terminals(">");
PRInt32 result=aScanner.ReadUntil(mTextValue,terminals,PR_FALSE);
aScanner.GetChar(aChar); //eat the closing '>;
if(kNoError==result)
result=aScanner.GetChar(aChar); //eat the closing '>;
return result;
};
@ -567,17 +573,19 @@ PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner& aScanner) {
aScanner.GetChar(ch);
mTextValue="<!";
if(kMinus==ch) {
aScanner.GetChar(ch2);
if(kMinus==ch2) {
//in this case, we're reading a long-form comment <-- xxx -->
mTextValue+="--";
PRInt32 findpos=-1;
while((findpos==kNotFound) && (!result)) {
result=aScanner.ReadUntil(mTextValue,terminals,PR_TRUE);
findpos=mTextValue.RFind("-->");
result=aScanner.GetChar(ch2);
if(kNoError==result) {
if(kMinus==ch2) {
//in this case, we're reading a long-form comment <-- xxx -->
mTextValue+="--";
PRInt32 findpos=-1;
while((findpos==kNotFound) && (kNoError==result)) {
result=aScanner.ReadUntil(mTextValue,terminals,PR_TRUE);
findpos=mTextValue.RFind("-->");
}
}
return result;
}
return result;
}
//if you're here, we're consuming a "short-form" comment
mTextValue+=ch;
@ -667,25 +675,26 @@ PRInt32 CNewlineToken::Consume(PRUnichar aChar, CScanner& aScanner) {
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;
}
if(kNoError==result) {
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
@ -798,16 +807,20 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
aScanner.SkipWhite(); //skip leading whitespace
PRInt32 result=aScanner.Peek(aChar);
if(kEOF!=result) {
if(kNoError==result) {
if(kQuote==aChar) { //if you're here, handle quoted key...
aScanner.GetChar(aChar); //skip the quote sign...
mTextKey=aChar;
result=ConsumeQuotedString(aChar,mTextKey,aScanner);
result=aScanner.GetChar(aChar); //skip the quote sign...
if(kNoError==result) {
mTextKey=aChar;
result=ConsumeQuotedString(aChar,mTextKey,aScanner);
}
}
else if(kHashsign==aChar) {
aScanner.GetChar(aChar); //skip the hash sign...
mTextKey=aChar;
result=aScanner.ReadWhile(mTextKey,gDigits,PR_TRUE);
result=aScanner.GetChar(aChar); //skip the hash sign...
if(kNoError==result) {
mTextKey=aChar;
result=aScanner.ReadWhile(mTextKey,gDigits,PR_TRUE);
}
}
else {
//If you're here, handle an unquoted key.
@ -820,28 +833,35 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
if(!(result=aScanner.SkipWhite())) {
if(!(result=aScanner.Peek(aChar))) {
if(kEqual==aChar){
aScanner.GetChar(aChar); //skip the equal sign...
aScanner.SkipWhite(); //now skip any intervening whitespace
aScanner.GetChar(aChar); //and grab the next char.
if((kQuote==aChar) || (kApostrophe==aChar)) {
mTextValue=aChar;
result=ConsumeQuotedString(aChar,mTextValue,aScanner);
}
else {
mTextValue=aChar; //it's an alphanum attribute...
result=ConsumeAttributeValueText(aChar,mTextValue,aScanner);
}
aScanner.SkipWhite();
}
}
result=aScanner.GetChar(aChar); //skip the equal sign...
if(kNoError==result) {
result=aScanner.SkipWhite(); //now skip any intervening whitespace
if(kNoError==result) {
result=aScanner.GetChar(aChar); //and grab the next char.
if(kNoError==result) {
if((kQuote==aChar) || (kApostrophe==aChar)) {
mTextValue=aChar;
result=ConsumeQuotedString(aChar,mTextValue,aScanner);
}
else {
mTextValue=aChar; //it's an alphanum attribute...
result=ConsumeAttributeValueText(aChar,mTextValue,aScanner);
}
}//if
if(kNoError==result)
result=aScanner.SkipWhite();
}//if
}//if
}//if
}//if
}
if(kNoError==result) {
result=aScanner.Peek(aChar);
mLastAttribute= PRBool((kGreaterThan==aChar) || (kEOF==result));
}
aScanner.Peek(aChar);
mLastAttribute= PRBool((kGreaterThan==aChar) || (kEOF==result));
}
return result;
};
}
/*
* Dump contents of this token to givne output stream
@ -907,12 +927,15 @@ PRInt32 CWhitespaceToken::GetTokenType(void) {
* @return error result
*/
PRInt32 CWhitespaceToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
PRInt32 result=aScanner.ReadWhile(mTextValue,gWhitespace,PR_FALSE);
mTextValue.StripChars("\r");
if(kNoError==result) {
mTextValue.StripChars("\r");
}
return result;
};
}
/*
* default constructor
@ -943,7 +966,7 @@ PRInt32 CEntityToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
PRInt32 result=ConsumeEntity(aChar,mTextValue,aScanner);
return result;
};
}
/*
*
@ -979,27 +1002,35 @@ PRInt32 CEntityToken::GetTokenType(void) {
*/
PRInt32 CEntityToken::ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner& aScanner){
PRInt32 result=kNotFound;
aScanner.Peek(aChar);
if(kLeftBrace==aChar) {
//you're consuming a script entity...
static nsAutoString terminals("}>");
result=aScanner.ReadUntil(aString,terminals,PR_FALSE);
aScanner.Peek(aChar);
if(kRightBrace==aChar) {
aString+=kRightBrace; //append rightbrace, and...
aScanner.GetChar(aChar);//yank the closing right-brace
}
}
else
{
result=aScanner.ReadWhile(aString,gIdentChars,PR_FALSE);
aScanner.Peek(aChar);
if (kSemicolon == aChar) {
// consume semicolon that stopped the scan
aScanner.GetChar(aChar);
}
}
PRInt32 result=aScanner.Peek(aChar);
if(kNoError==result) {
if(kLeftBrace==aChar) {
//you're consuming a script entity...
static nsAutoString terminals("}>");
result=aScanner.ReadUntil(aString,terminals,PR_FALSE);
if(kNoError==result) {
result=aScanner.Peek(aChar);
if(kNoError==result) {
if(kRightBrace==aChar) {
aString+=kRightBrace; //append rightbrace, and...
result=aScanner.GetChar(aChar);//yank the closing right-brace
}
}
}
} //if
else {
result=aScanner.ReadWhile(aString,gIdentChars,PR_FALSE);
if(kNoError==result) {
result=aScanner.Peek(aChar);
if(kNoError==result) {
if (kSemicolon == aChar) {
// consume semicolon that stopped the scan
result=aScanner.GetChar(aChar);
}
}
}//if
} //else
} //if
return result;
}
@ -1238,7 +1269,8 @@ PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
PRInt32 result=kNoError;
nsString temp;
while((!done) && (!aScanner.Eof())) {
// while((!done) && (!aScanner.Eof())) {
while((!done) && (kNoError==result)) {
static nsAutoString terminals(">");
result=aScanner.ReadUntil(temp,terminals,PR_TRUE);
done=PRBool(kNotFound!=temp.RFind(mTextValue,PR_TRUE));
@ -1328,7 +1360,8 @@ const char* GetTagName(PRInt32 aTag) {
const char* result=0;
PRInt32 cnt=sizeof(gHTMLTagTable)/sizeof(HTMLTagEntry);
for(int i=0;i<cnt;i++){
int i=0;
for(i=0;i<cnt;i++){
if(aTag==gHTMLTagTable[i].fTagID)
return gHTMLTagTable[i].fName;
}

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

@ -39,12 +39,12 @@
class CScanner;
enum eHTMLTokenTypes {
eToken_unknown=2000,
eToken_start, eToken_end, eToken_comment, eToken_entity,
eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
eToken_script, eToken_style, eToken_skippedcontent, //used in cases like <SCRIPT> where we skip over script content.
eToken_last
eToken_unknown=0,
eToken_start=1, eToken_end, eToken_comment, eToken_entity,
eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
eToken_script, eToken_style, eToken_skippedcontent,
eToken_last //make sure this stays the last token...
};
//*** This enum is used to define the known universe of HTML tags.

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

@ -48,7 +48,7 @@ class nsIContentSink : public nsISupports {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenContainer(const nsIParserNode& aNode) = 0;
virtual PRInt32 OpenContainer(const nsIParserNode& aNode) = 0;
/**
* This method gets called by the parser when a close
@ -58,7 +58,7 @@ class nsIContentSink : public nsISupports {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseContainer(const nsIParserNode& aNode) = 0;
virtual PRInt32 CloseContainer(const nsIParserNode& aNode) = 0;
/**
* This method gets called by the parser when a the
@ -67,7 +67,7 @@ class nsIContentSink : public nsISupports {
* @update 4/1/98 gess
* @return PR_TRUE if successful.
*/
virtual PRBool CloseTopmostContainer() = 0;
virtual PRInt32 CloseTopmostContainer() = 0;
/**
* This gets called by the parser when you want to add
@ -78,7 +78,7 @@ class nsIContentSink : public nsISupports {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool AddLeaf(const nsIParserNode& aNode) = 0;
virtual PRInt32 AddLeaf(const nsIParserNode& aNode) = 0;
/**
* This method gets called when the parser begins the process

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

@ -92,7 +92,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenHTML(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenHTML(const nsIParserNode& aNode)=0;
/**
* This method is used to close the outer HTML container.
@ -101,7 +101,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseHTML(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseHTML(const nsIParserNode& aNode)=0;
/**
* This method is used to open the only HEAD container.
@ -110,7 +110,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenHead(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenHead(const nsIParserNode& aNode)=0;
/**
* This method is used to close the only HEAD container.
@ -119,7 +119,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseHead(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseHead(const nsIParserNode& aNode)=0;
/**
* This method is used to open the main BODY container.
@ -128,7 +128,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenBody(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenBody(const nsIParserNode& aNode)=0;
/**
* This method is used to close the main BODY container.
@ -137,7 +137,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseBody(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseBody(const nsIParserNode& aNode)=0;
/**
* This method is used to open a new FORM container.
@ -146,7 +146,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenForm(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenForm(const nsIParserNode& aNode)=0;
/**
* This method is used to close the outer FORM container.
@ -155,7 +155,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseForm(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseForm(const nsIParserNode& aNode)=0;
/**
* This method is used to open the FRAMESET container.
@ -164,7 +164,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenFrameset(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenFrameset(const nsIParserNode& aNode)=0;
/**
* This method is used to close the FRAMESET container.
@ -173,7 +173,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseFrameset(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseFrameset(const nsIParserNode& aNode)=0;
/**
* This method is used to a general container.
@ -183,7 +183,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenContainer(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenContainer(const nsIParserNode& aNode)=0;
/**
* This method is used to close a generic container.
@ -192,7 +192,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseContainer(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseContainer(const nsIParserNode& aNode)=0;
/**
* This method is used to close the topmost container, regardless
@ -202,7 +202,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseTopmostContainer()=0;
virtual PRInt32 CloseTopmostContainer()=0;
/**
* This method is used to add a leaf to the currently
@ -212,7 +212,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool AddLeaf(const nsIParserNode& aNode)=0;
virtual PRInt32 AddLeaf(const nsIParserNode& aNode)=0;
/**
* This method gets called when the parser begins the process

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

@ -54,11 +54,11 @@ class nsIParser : public nsISupports {
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
virtual PRInt32 Parse(nsIURL* aURL,PRBool aIncremental=PR_FALSE)=0;
virtual PRInt32 Parse(nsIURL* aURL,PRBool aIncremental=PR_TRUE)=0;
virtual PRInt32 Parse(const char* aFilename,PRBool aIncremental)=0;
virtual PRInt32 Parse(nsString& anHTMLString,PRBool appendTokens)=0;
virtual PRInt32 ResumeParse(PRInt32 anIterator)=0;
virtual PRInt32 ResumeParse(void)=0;
virtual PRInt32 GetStack(PRInt32* aStackPtr)=0;
virtual PRBool HasOpenContainer(PRInt32 aContainer) const=0;
};

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

@ -42,6 +42,8 @@ enum eParseMode {
};
const PRInt32 kEOF = 1000000L;
const PRInt32 kUnknownError = -1000;
const PRInt32 kContextMismatch = -5;
const PRInt32 kBadFilename = -4;
const PRInt32 kBadURL = -3;
const PRInt32 kInterrupted = -2;

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

@ -154,6 +154,8 @@ void _PreCompressBuffer(nsString& aBuffer,PRInt32& anOffset,PRInt32& aMarkPos){
//we should check mMarkPos. That represents the point at which
//we've guaranteed the client we can back up to, so make sure
//you don't lose any of the data beyond that point.
/*
if((anOffset!=aMarkPos) && (0<=aMarkPos)) {
if(aMarkPos>0) {
aBuffer.Cut(0,aMarkPos);
@ -162,6 +164,16 @@ void _PreCompressBuffer(nsString& aBuffer,PRInt32& anOffset,PRInt32& aMarkPos){
}
}
else aBuffer.Truncate();
*/
PRInt32 len=aBuffer.Length();
if((aMarkPos<len) && (aMarkPos>=0)) {
aBuffer.Cut(0,aMarkPos);
anOffset-=aMarkPos;
}
else {
aBuffer.Truncate();
anOffset=0;
}
aMarkPos=0;
}
@ -204,6 +216,19 @@ PRBool CScanner::Append(nsString& aBuffer) {
return PR_TRUE;
}
/**
*
*
* @update gess 5/21/98
* @param
* @return
*/
PRBool CScanner::Append(const char* aBuffer, PRInt32 aLen){
_PreCompressBuffer(mBuffer,mOffset,mMarkPos);
mBuffer.Append(aBuffer,aLen);
return PR_TRUE;
}
/**
* Grab data from underlying stream.
*

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

@ -39,8 +39,7 @@
#include <fstream.h>
class nsIURL;
//class ifstream; XXX mac didn't like this, but this doesn't seem to be needed
// for the pc either...
class ifstream;
class CScanner {
public:
@ -216,6 +215,15 @@ class CScanner {
*/
PRBool Append(nsString& aBuffer);
/**
*
*
* @update gess 5/21/98
* @param
* @return
*/
PRBool Append(const char* aBuffer, PRInt32 aLen);
/**
*
*

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

@ -27,6 +27,7 @@
*/
CToken::CToken(const nsString& aName) : mTextValue(aName) {
mOrdinalValue=0;
mAttrCount=0;
}
/**
@ -71,7 +72,8 @@ void CToken::SetStringValue(const char* aValue) {
*/
void CToken::DebugDumpToken(ostream& anOutputStream) {
anOutputStream << "[" << GetClassName() << "] ";
for(int i=0;i<mTextValue.Length();i++){
int i=0;
for(i=0;i<mTextValue.Length();i++){
anOutputStream << char(mTextValue[i]);
}
anOutputStream << ": " << mOrdinalValue << endl;
@ -116,7 +118,7 @@ nsString& CToken::GetText(void) {
* @update gess 3/25/98
* @param value -- new ordinal value for this token
*/
void CToken::SetOrdinal(PRInt32 value) {
void CToken::SetOrdinal(PRInt16 value) {
mOrdinalValue=value;
}
@ -127,10 +129,31 @@ void CToken::SetOrdinal(PRInt32 value) {
* @update gess 3/25/98
* @return int containing ordinal value
*/
PRInt32 CToken::GetOrdinal(void) {
PRInt16 CToken::GetOrdinal(void) {
return mOrdinalValue;
}
/**
* Sets the attribute count for this token
*
* @update gess 3/25/98
* @param value -- new attr count
*/
void CToken::SetAttributeCount(PRInt16 value) {
mAttrCount=value;
}
/**
* Retrieves copy of attr count for this token
*
* @update gess 3/25/98
* @return int containing attribute count
*/
PRInt16 CToken::GetAttributeCount(void) {
return mAttrCount;
}
/**
* Retrieve type of token. This class returns -1, but
* subclasses return something more meaningful.

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

@ -92,14 +92,28 @@ class CToken {
* @update gess5/11/98
* @param value is the new ord value for this token
*/
virtual void SetOrdinal(PRInt32 value);
virtual void SetOrdinal(PRInt16 value);
/**
* Getter which retrieves the current ordinal value for this token
* @update gess5/11/98
* @return current ordinal value
*/
virtual PRInt32 GetOrdinal(void);
virtual PRInt16 GetOrdinal(void);
/**
* Sets the # of attributes found for this token.
* @update gess5/11/98
* @param value is the attr count
*/
virtual void SetAttributeCount(PRInt16 aValue);
/**
* Getter which retrieves the current attribute count for this token
* @update gess5/11/98
* @return current attribute count
*/
virtual PRInt16 GetAttributeCount(void);
/**
* Causes token to consume data from given scanner.
@ -147,7 +161,8 @@ class CToken {
virtual void SelfTest(void);
protected:
PRInt32 mOrdinalValue;
PRInt16 mOrdinalValue;
PRInt16 mAttrCount;
nsString mTextValue;
};

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

@ -38,8 +38,9 @@ static const char* kNullParserGiven = "Error: Null parser given as argument";
* @param
* @return
*/
CTokenHandler::CTokenHandler(eHTMLTokenTypes aType) {
CTokenHandler::CTokenHandler(dispatchFP aFP,eHTMLTokenTypes aType){
mType=aType;
mFP=aFP;
}
@ -65,18 +66,6 @@ eHTMLTokenTypes CTokenHandler::GetTokenType(void){
return mType;
}
/**
*
*
* @update gess 4/2/98
* @param
* @return
*/
PRBool CTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**
*
@ -85,555 +74,12 @@ PRBool CTokenHandler::CanHandle(eHTMLTokenTypes aType){
* @param
* @return
*/
PRBool CTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
PRBool result=PR_FALSE;
if(aParser){
result=PR_TRUE;
PRInt32 CTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
PRInt32 result=kNoError;
if((0!=aParser) && (0!=mFP)) {
result=(*mFP)(mType,aToken,aParser);
}
return result;
}
/**
*
*
* @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){
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(): 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){
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() : 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){
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() : 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){
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() : 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){
return aParser->HandleStartToken(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() : 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){
return aParser->HandleStartToken(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() : 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){
return aParser->HandleStartToken(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() : 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){
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() : 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){
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() : 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){
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() : 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){
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;
}

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

@ -33,130 +33,22 @@
class CToken;
class nsHTMLParser;
typedef PRInt32 (*dispatchFP)(eHTMLTokenTypes,CToken*,nsHTMLParser*);
class CTokenHandler : public CITokenHandler {
public:
CTokenHandler(eHTMLTokenTypes aType=eToken_unknown);
virtual ~CTokenHandler();
CTokenHandler(dispatchFP aFP,eHTMLTokenTypes aType=eToken_unknown);
virtual ~CTokenHandler();
virtual eHTMLTokenTypes GetTokenType(void);
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
virtual PRInt32 operator()(CToken* aToken,nsHTMLParser* aParser);
protected:
eHTMLTokenTypes mType;
dispatchFP mFP;
};
class CStartTokenHandler : public CTokenHandler {
public:
CStartTokenHandler();
virtual ~CStartTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CEndTokenHandler : public CTokenHandler {
public:
CEndTokenHandler();
virtual ~CEndTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CCommentTokenHandler : public CTokenHandler {
public:
CCommentTokenHandler();
virtual ~CCommentTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CEntityTokenHandler : public CTokenHandler {
public:
CEntityTokenHandler();
virtual ~CEntityTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CWhitespaceTokenHandler : public CTokenHandler {
public:
CWhitespaceTokenHandler();
virtual ~CWhitespaceTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CNewlineTokenHandler : public CTokenHandler {
public:
CNewlineTokenHandler();
virtual ~CNewlineTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CTextTokenHandler : public CTokenHandler {
public:
CTextTokenHandler();
virtual ~CTextTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CAttributeTokenHandler : public CTokenHandler {
public:
CAttributeTokenHandler();
virtual ~CAttributeTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CScriptTokenHandler : public CTokenHandler {
public:
CScriptTokenHandler();
virtual ~CScriptTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CStyleTokenHandler : public CTokenHandler {
public:
CStyleTokenHandler();
virtual ~CStyleTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CSkippedContentTokenHandler : public CTokenHandler {
public:
CSkippedContentTokenHandler();
virtual ~CSkippedContentTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
#endif

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

@ -96,6 +96,20 @@ PRBool CTokenizer::Append(nsString& aBuffer) {
return PR_FALSE;
}
/**
*
*
* @update gess 5/21/98
* @param
* @return
*/
PRBool CTokenizer::Append(const char* aBuffer, PRInt32 aLen){
if(mScanner)
return mScanner->Append(aBuffer,aLen);
return PR_FALSE;
}
/**
* Retrieve a reference to the internal token deque.
*

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

@ -106,6 +106,13 @@ class CTokenizer {
*/
PRBool Append(nsString& aBuffer);
/**
*
* @update gess 4/20/98
* @return deque reference
*/
PRBool Append(const char* aBuffer, PRInt32 aLen);
/**
*

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

@ -136,18 +136,21 @@ PRInt32 CNavDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& aTo
* @param aScanner: see nsScanner.h
* @return
*/
PRInt32 CNavDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner) {
PRInt32 CNavDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRBool done=PR_FALSE;
PRInt32 result=kNoError;
nsAutoString as("");
PRInt16 theAttrCount=0;
while((!done) && (result==kNoError)) {
CToken* theToken= new CAttributeToken(as);
if(theToken){
result=theToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
if(kNoError==result){
theAttrCount++;
mTokenDeque.Push(theToken);
}//if
else delete theToken; //we can't keep it...
}//if
if(kNoError==result){
@ -158,6 +161,24 @@ PRInt32 CNavDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner) {
}//if
}//if
}//while
//ok, this is a bit complicated, so follow closely.
//Since we're incremental (but pessimistic), it is possible that even though
//we've eaten a few delicious attributes, we can't keep them because
//we couldn't eat all of them (up to an including the close > for this tag).
//Therefore, we need to remove the ones we just created from the tokendeque,
//and destroy them. (They'll get reconsumed on the next incremental pass).
//NOTE: This process can be enhanced later on by adding state to the delegate
// telling us that we're in the attribute consumption phase.
// Remember the mantra: Crawl, Walk, Run!
if(kNoError==result) {
aToken->SetAttributeCount(theAttrCount);
}
else {
while(theAttrCount--) {
delete mTokenDeque.PopBack();
}
}
return result;
}
@ -200,7 +221,7 @@ PRInt32 CNavDelegate::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,CToken*
result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
if(kNoError==result) {
if(((CStartToken*)aToken)->IsAttributed()) {
result=ConsumeAttributes(aChar,aScanner);
result=ConsumeAttributes(aChar,aScanner,aToken);
}
//now that that's over with, we have one more problem to solve.
//In the case that we just read a <SCRIPT> or <STYLE> tags, we should go and
@ -319,7 +340,7 @@ PRInt32 CNavDelegate::ConsumeText(const nsString& aString,CScanner& aScanner,CTo
PRInt32 result=kNoError;
if(aToken=new CTextToken(aString)) {
PRUnichar ch;
PRUnichar ch=0;
result=aToken->Consume(ch,aScanner);
}
return result;

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

@ -150,7 +150,7 @@ protected:
* @param aToken is the next token (or null)
* @return error code
*/
PRInt32 ConsumeAttributes(PRUnichar aChar,CScanner& aScanner);
PRInt32 ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CToken*& aToken);
/**
* Retrieve a sequence of text from given scanner.

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

@ -129,7 +129,7 @@ PRInt32 COtherDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& a
* @param aScanner: see nsScanner.h
* @return
*/
PRInt32 COtherDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner) {
PRInt32 COtherDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) {
PRBool done=PR_FALSE;
nsAutoString as("");
PRInt32 result=kNoError;
@ -186,7 +186,7 @@ PRInt32 COtherDelegate::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,CToke
if(aToken) {
result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
if(((CStartToken*)aToken)->IsAttributed()) {
result=ConsumeAttributes(aChar,aScanner);
result=ConsumeAttributes(aChar,aScanner,aToken);
}
//now that that's over with, we have one more problem to solve.
//In the case that we just read a <SCRIPT> or <STYLE> tags, we should go and

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

@ -150,7 +150,7 @@ protected:
* @param aToken is the next token (or null)
* @return error code
*/
PRInt32 ConsumeAttributes(PRUnichar aChar,CScanner& aScanner);
PRInt32 ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CToken*& aToken);
/**
* Retrieve a sequence of text from given scanner.

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

@ -18,6 +18,7 @@
#include "nsHTMLContentSink.h"
#include "nsHTMLTokens.h"
#include "nsParserTypes.h"
#include "prtypes.h"
#include <iostream.h>
@ -143,9 +144,9 @@ nsresult nsHTMLContentSink::QueryInterface(const nsIID& aIID, void** aInstancePt
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
PRInt32 nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -162,11 +163,11 @@ PRBool nsHTMLContentSink::OpenHTML(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -186,8 +187,8 @@ PRBool nsHTMLContentSink::CloseHTML(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -205,10 +206,10 @@ PRBool nsHTMLContentSink::OpenHead(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
PRInt32 nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -226,8 +227,8 @@ PRBool nsHTMLContentSink::CloseHead(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::SetTitle(const nsString& aValue){
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::SetTitle(const nsString& aValue){
PRInt32 result=kNoError;
mTitle=aValue;
return result;
}
@ -240,8 +241,8 @@ PRBool nsHTMLContentSink::SetTitle(const nsString& aValue){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -259,9 +260,9 @@ PRBool nsHTMLContentSink::OpenBody(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -279,8 +280,8 @@ PRBool nsHTMLContentSink::CloseBody(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -298,10 +299,10 @@ PRBool nsHTMLContentSink::OpenForm(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -319,8 +320,8 @@ PRBool nsHTMLContentSink::CloseForm(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -338,10 +339,10 @@ PRBool nsHTMLContentSink::OpenFrameset(const nsIParserNode& aNode) {
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -360,8 +361,8 @@ PRBool nsHTMLContentSink::CloseFrameset(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos++]=(eHTMLTags)aNode.GetNodeType();
#ifdef VERBOSE_DEBUG
@ -379,10 +380,10 @@ PRBool nsHTMLContentSink::OpenContainer(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
PRInt32 nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
@ -400,9 +401,9 @@ PRBool nsHTMLContentSink::CloseContainer(const nsIParserNode& aNode){
* @param
* @return
*/
PRBool nsHTMLContentSink::CloseTopmostContainer(){
PRInt32 nsHTMLContentSink::CloseTopmostContainer(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
PRBool result=PR_TRUE;
PRInt32 result=kNoError;
mNodeStack[mNodeStackPos--]=eHTMLTag_unknown;
return result;
}
@ -416,8 +417,8 @@ PRBool nsHTMLContentSink::CloseTopmostContainer(){
* @param
* @return
*/
PRBool nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
PRBool result=PR_TRUE;
PRInt32 nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
PRInt32 result=kNoError;
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);

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

@ -87,33 +87,33 @@ class nsHTMLContentSink : public nsIHTMLContentSink {
PRBool SetTitle(const nsString& aValue);
// Called when Opening or closing the main HTML container
PRBool OpenHTML(const nsIParserNode& aNode);
PRBool CloseHTML(const nsIParserNode& aNode);
PRInt32 OpenHTML(const nsIParserNode& aNode);
PRInt32 CloseHTML(const nsIParserNode& aNode);
// Called when Opening or closing the main HEAD container
PRBool OpenHead(const nsIParserNode& aNode);
PRBool CloseHead(const nsIParserNode& aNode);
PRInt32 OpenHead(const nsIParserNode& aNode);
PRInt32 CloseHead(const nsIParserNode& aNode);
// Called when Opening or closing the main BODY container
PRBool OpenBody(const nsIParserNode& aNode);
PRBool CloseBody(const nsIParserNode& aNode);
PRInt32 OpenBody(const nsIParserNode& aNode);
PRInt32 CloseBody(const nsIParserNode& aNode);
// Called when Opening or closing FORM containers
PRBool OpenForm(const nsIParserNode& aNode);
PRBool CloseForm(const nsIParserNode& aNode);
PRInt32 OpenForm(const nsIParserNode& aNode);
PRInt32 CloseForm(const nsIParserNode& aNode);
// Called when Opening or closing the main FRAMESET container
PRBool OpenFrameset(const nsIParserNode& aNode);
PRBool CloseFrameset(const nsIParserNode& aNode);
PRInt32 OpenFrameset(const nsIParserNode& aNode);
PRInt32 CloseFrameset(const nsIParserNode& aNode);
// Called when Opening or closing a general container
// This includes: OL,UL,DIR,SPAN,TABLE,H[1..6],etc.
// Until proven otherwise, I also plan to toss STYLE,
// FRAME, SCRIPT, etc. here too!
virtual PRBool OpenContainer(const nsIParserNode& aNode);
virtual PRBool CloseContainer(const nsIParserNode& aNode);
virtual PRBool CloseTopmostContainer();
virtual PRBool AddLeaf(const nsIParserNode& aNode);
virtual PRInt32 OpenContainer(const nsIParserNode& aNode);
virtual PRInt32 CloseContainer(const nsIParserNode& aNode);
virtual PRInt32 CloseTopmostContainer();
virtual PRInt32 AddLeaf(const nsIParserNode& aNode);
/**
* This method gets called when the parser begins the process

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -15,7 +15,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/**
* MODULE NOTES:
* @update gess 4/1/98
@ -114,7 +114,7 @@ friend class CTokenHandler;
* @param aMode is the desired parser mode (Nav, other, etc.)
* @return TRUE if all went well -- FALSE otherwise
*/
virtual PRInt32 Parse(nsIURL* aURL,PRBool aIncremental=PR_FALSE);
virtual PRInt32 Parse(nsIURL* aURL,PRBool aIncremental=PR_TRUE);
/**
* Cause parser to parse input from given file in given mode
@ -138,7 +138,7 @@ friend class CTokenHandler;
* @update gess5/11/98
* @return TRUE if all went well, otherwise FALSE
*/
virtual PRInt32 ResumeParse(PRInt32 anIteration);
virtual PRInt32 ResumeParse(void);
/**
* Retrieve ptr to internal context vector stack
@ -164,7 +164,7 @@ friend class CTokenHandler;
* @param aToken is the start token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleStartToken(CToken* aToken);
PRInt32 HandleStartToken(CToken* aToken);
/**
* This method gets called when a start token has been consumed, and
@ -177,7 +177,7 @@ friend class CTokenHandler;
* @param aNode is a node be updated with info from given token
* @return TRUE if the token was handled.
*/
PRBool HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
/**
* This method gets called when an end token has been consumed and needs
@ -186,7 +186,7 @@ friend class CTokenHandler;
* @param aToken is the end token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleEndToken(CToken* aToken);
PRInt32 HandleEndToken(CToken* aToken);
/**
* This method gets called when an entity token has been consumed and needs
@ -195,7 +195,7 @@ friend class CTokenHandler;
* @param aToken is the entity token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleEntityToken(CToken* aToken);
PRInt32 HandleEntityToken(CToken* aToken);
/**
* This method gets called when a comment token has been consumed and needs
@ -204,7 +204,7 @@ friend class CTokenHandler;
* @param aToken is the comment token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleCommentToken(CToken* aToken);
PRInt32 HandleCommentToken(CToken* aToken);
/**
* This method gets called when a skipped-content token has been consumed and needs
@ -213,7 +213,7 @@ friend class CTokenHandler;
* @param aToken is the skipped-content token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleSkippedContentToken(CToken* aToken);
PRInt32 HandleSkippedContentToken(CToken* aToken);
/**
* This method gets called when an attribute token has been consumed and needs
@ -222,7 +222,7 @@ friend class CTokenHandler;
* @param aToken is the attribute token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleAttributeToken(CToken* aToken);
PRInt32 HandleAttributeToken(CToken* aToken);
/**
* This method gets called when a script token has been consumed and needs
@ -231,7 +231,7 @@ friend class CTokenHandler;
* @param aToken is the script token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleScriptToken(CToken* aToken);
PRInt32 HandleScriptToken(CToken* aToken);
/**
* This method gets called when a style token has been consumed and needs
@ -240,7 +240,7 @@ friend class CTokenHandler;
* @param aToken is the style token to be handled
* @return TRUE if the token was handled.
*/
PRBool HandleStyleToken(CToken* aToken);
PRInt32 HandleStyleToken(CToken* aToken);
//*********************************************
// These methods are callback methods used by
@ -254,21 +254,29 @@ friend class CTokenHandler;
protected:
/**
*
* @update gess5/18/98
* @param
* @return
*/
PRInt32 WillBuildModel(void);
/**
*
* @update gess5/18/98
* @param
* @return
*/
PRInt32 DidBuildModel(PRInt32 anErrorCode);
/**
* This method gets called when the tokens have been consumed, and it's time
* to build the model via the content sink.
* @update gess5/11/98
* @return YES if model building went well -- NO otherwise.
*/
PRBool IterateTokens();
/**
* Retrieves the tag type for the element on the context vector stack at given pos.
* @update gess5/11/98
* @param pos of item you want to retrieve
* @return tag type (may be unknown)
*/
eHTMLTags NodeAt(PRInt32 aPos) const;
PRInt32 IterateTokens(void);
/**
* Retrieve the tag type of the topmost item on context vector stack
@ -277,13 +285,6 @@ protected:
*/
eHTMLTags GetTopNode() const;
/**
* Retrieve the number of items on context vector stack
* @update gess5/11/98
* @return count of items on stack -- may be 0
*/
PRInt32 GetStackPos() const;
/**
* Causes the parser to scan foward, collecting nearby (sequential)
* attribute tokens into the given node.
@ -291,7 +292,7 @@ protected:
* @param node to store attributes
* @return number of attributes added to node.
*/
PRInt32 CollectAttributes(nsCParserNode& aNode);
PRInt32 CollectAttributes(nsCParserNode& aNode,PRInt32 aCount);
/**
* Causes the next skipped-content token (if any) to
@ -309,12 +310,7 @@ protected:
*/
void InitializeDefaultTokenHandlers();
/**
* DEPRECATED
* @update gess5/11/98
*/
CTokenHandler* GetTokenHandler(const nsString& aString) const;
/**
* DEPRECATED
* @update gess5/11/98
@ -345,7 +341,7 @@ protected:
* @param HTML (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenHTML(const nsIParserNode& aNode);
PRInt32 OpenHTML(const nsIParserNode& aNode);
/**
*
@ -353,7 +349,7 @@ protected:
* @param
* @return
*/
PRBool CloseHTML(const nsIParserNode& aNode);
PRInt32 CloseHTML(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a head item in
@ -362,7 +358,7 @@ protected:
* @param HEAD (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenHead(const nsIParserNode& aNode);
PRInt32 OpenHead(const nsIParserNode& aNode);
/**
* This cover method causes the content-sink head to be closed
@ -370,7 +366,7 @@ protected:
* @param aNode is the node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseHead(const nsIParserNode& aNode);
PRInt32 CloseHead(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a body item in
@ -379,7 +375,7 @@ protected:
* @param BODY (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenBody(const nsIParserNode& aNode);
PRInt32 OpenBody(const nsIParserNode& aNode);
/**
* This cover method causes the content-sink body to be closed
@ -387,7 +383,7 @@ protected:
* @param aNode is the body node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseBody(const nsIParserNode& aNode);
PRInt32 CloseBody(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a form item in
@ -396,7 +392,7 @@ protected:
* @param FORM (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenForm(const nsIParserNode& aNode);
PRInt32 OpenForm(const nsIParserNode& aNode);
/**
* This cover method causes the content-sink form to be closed
@ -404,7 +400,7 @@ protected:
* @param aNode is the form node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseForm(const nsIParserNode& aNode);
PRInt32 CloseForm(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a frameset item in
@ -413,7 +409,7 @@ protected:
* @param FRAMESET (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenFrameset(const nsIParserNode& aNode);
PRInt32 OpenFrameset(const nsIParserNode& aNode);
/**
* This cover method causes the content-sink frameset to be closed
@ -421,7 +417,7 @@ protected:
* @param aNode is the frameeset node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseFrameset(const nsIParserNode& aNode);
PRInt32 CloseFrameset(const nsIParserNode& aNode);
/**
* This cover method opens the given node as a generic container in
@ -430,7 +426,7 @@ protected:
* @param generic container (node) to be opened in content sink.
* @return TRUE if all went well.
*/
PRBool OpenContainer(const nsIParserNode& aNode);
PRInt32 OpenContainer(const nsIParserNode& aNode);
/**
* This cover method causes a generic containre in the content-sink to be closed
@ -438,14 +434,14 @@ protected:
* @param aNode is the node to be closed in sink (usually ignored)
* @return TRUE if all went well.
*/
PRBool CloseContainer(const nsIParserNode& aNode);
PRInt32 CloseContainer(const nsIParserNode& aNode);
/**
* This cover method causes the topmost container to be closed in sink
* @update gess5/11/98
* @return TRUE if all went well.
*/
PRBool CloseTopmostContainer();
PRInt32 CloseTopmostContainer();
/**
* Cause all containers down to topmost given tag to be closed
@ -453,7 +449,7 @@ protected:
* @param aTag is the tag at which auto-closure should stop (inclusive)
* @return TRUE if all went well -- otherwise FALSE
*/
PRBool CloseContainersTo(eHTMLTags aTag);
PRInt32 CloseContainersTo(eHTMLTags aTag);
/**
* Cause all containers down to given position to be closed
@ -461,7 +457,7 @@ protected:
* @param anIndex is the stack pos at which auto-closure should stop (inclusive)
* @return TRUE if all went well -- otherwise FALSE
*/
PRBool CloseContainersTo(PRInt32 anIndex);
PRInt32 CloseContainersTo(PRInt32 anIndex);
/**
* Causes leaf to be added to sink at current vector pos.
@ -469,15 +465,8 @@ protected:
* @param aNode is leaf node to be added.
* @return TRUE if all went well -- FALSE otherwise.
*/
PRBool AddLeaf(const nsIParserNode& aNode);
PRInt32 AddLeaf(const nsIParserNode& aNode);
/**
* Determine if the given tag is open in the context vector stack.
* @update gess5/11/98
* @param aTag is the type of tag you want to test for openness
* @return TRUE if open, FALSE otherwise.
*/
PRBool IsOpen(eHTMLTags aTag) const;
/**
* Finds the topmost occurance of given tag within context vector stack.
@ -495,7 +484,7 @@ protected:
* @param child to be added (somewhere) to context vector stack.
* @return TRUE if succeeds, otherwise FALSE
*/
PRBool ReduceContextStackFor(PRInt32 aChildTag);
PRInt32 ReduceContextStackFor(PRInt32 aChildTag);
/**
* Attempt forward and/or backward propagation for the given
@ -504,7 +493,7 @@ protected:
* @param type of child to be propagated.
* @return TRUE if succeeds, otherwise FALSE
*/
PRBool CreateContextStackFor(PRInt32 aChildTag);
PRInt32 CreateContextStackFor(PRInt32 aChildTag);
private:
PRInt32 ParseFileIncrementally(const char* aFilename); //XXX ONLY FOR DEBUG PURPOSES...
@ -520,19 +509,20 @@ protected:
PRInt32 mContextStack[50];
PRInt32 mContextStackPos;
CTokenHandler* mTokenHandlers[100];
PRInt32 mTokenHandlerCount;
CTokenHandler* mTokenHandlers[eToken_last];
nsDequeIterator* mCurrentPos;
nsDequeIterator* mMarkPos;
nsIDTD* mDTD;
eParseMode mParseMode;
PRBool mHasOpenForm;
PRBool mIncremental;
ITokenizerDelegate* mDelegate;
PRInt32 mIteration;
char* mTransferBuffer;
};
#endif

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

@ -368,21 +368,26 @@ PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
//Stop consuming as soon as you see a space or a '>'.
//NOTE: We don't Consume the tag attributes here, nor do we eat the ">"
mTextValue=aChar;
mTextValue=aChar;
PRInt32 result=aScanner.ReadWhile(mTextValue,gIdentChars,PR_FALSE);
//Good. Now, let's skip whitespace after the identifier,
//and see if the next char is ">". If so, we have a complete
//tag without attributes.
aScanner.SkipWhite();
result=aScanner.GetChar(aChar);
if(kGreaterThan!=aChar) { //look for '>'
//push that char back, since we apparently have attributes...
aScanner.PutBack(aChar);
mAttributed=PR_TRUE;
}
return result;
if(kNoError==result) {
result=aScanner.SkipWhite();
if(kNoError==result) {
result=aScanner.GetChar(aChar);
if(kNoError==result) {
if(kGreaterThan!=aChar) { //look for '>'
//push that char back, since we apparently have attributes...
aScanner.PutBack(aChar);
mAttributed=PR_TRUE;
} //if
} //if
}//if
}
return result;
};
@ -431,7 +436,8 @@ PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue="";
static nsAutoString terminals(">");
PRInt32 result=aScanner.ReadUntil(mTextValue,terminals,PR_FALSE);
aScanner.GetChar(aChar); //eat the closing '>;
if(kNoError==result)
result=aScanner.GetChar(aChar); //eat the closing '>;
return result;
};
@ -567,17 +573,19 @@ PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner& aScanner) {
aScanner.GetChar(ch);
mTextValue="<!";
if(kMinus==ch) {
aScanner.GetChar(ch2);
if(kMinus==ch2) {
//in this case, we're reading a long-form comment <-- xxx -->
mTextValue+="--";
PRInt32 findpos=-1;
while((findpos==kNotFound) && (!result)) {
result=aScanner.ReadUntil(mTextValue,terminals,PR_TRUE);
findpos=mTextValue.RFind("-->");
result=aScanner.GetChar(ch2);
if(kNoError==result) {
if(kMinus==ch2) {
//in this case, we're reading a long-form comment <-- xxx -->
mTextValue+="--";
PRInt32 findpos=-1;
while((findpos==kNotFound) && (kNoError==result)) {
result=aScanner.ReadUntil(mTextValue,terminals,PR_TRUE);
findpos=mTextValue.RFind("-->");
}
}
return result;
}
return result;
}
//if you're here, we're consuming a "short-form" comment
mTextValue+=ch;
@ -667,25 +675,26 @@ PRInt32 CNewlineToken::Consume(PRUnichar aChar, CScanner& aScanner) {
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;
}
if(kNoError==result) {
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
@ -798,16 +807,20 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
aScanner.SkipWhite(); //skip leading whitespace
PRInt32 result=aScanner.Peek(aChar);
if(kEOF!=result) {
if(kNoError==result) {
if(kQuote==aChar) { //if you're here, handle quoted key...
aScanner.GetChar(aChar); //skip the quote sign...
mTextKey=aChar;
result=ConsumeQuotedString(aChar,mTextKey,aScanner);
result=aScanner.GetChar(aChar); //skip the quote sign...
if(kNoError==result) {
mTextKey=aChar;
result=ConsumeQuotedString(aChar,mTextKey,aScanner);
}
}
else if(kHashsign==aChar) {
aScanner.GetChar(aChar); //skip the hash sign...
mTextKey=aChar;
result=aScanner.ReadWhile(mTextKey,gDigits,PR_TRUE);
result=aScanner.GetChar(aChar); //skip the hash sign...
if(kNoError==result) {
mTextKey=aChar;
result=aScanner.ReadWhile(mTextKey,gDigits,PR_TRUE);
}
}
else {
//If you're here, handle an unquoted key.
@ -820,28 +833,35 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
if(!(result=aScanner.SkipWhite())) {
if(!(result=aScanner.Peek(aChar))) {
if(kEqual==aChar){
aScanner.GetChar(aChar); //skip the equal sign...
aScanner.SkipWhite(); //now skip any intervening whitespace
aScanner.GetChar(aChar); //and grab the next char.
if((kQuote==aChar) || (kApostrophe==aChar)) {
mTextValue=aChar;
result=ConsumeQuotedString(aChar,mTextValue,aScanner);
}
else {
mTextValue=aChar; //it's an alphanum attribute...
result=ConsumeAttributeValueText(aChar,mTextValue,aScanner);
}
aScanner.SkipWhite();
}
}
result=aScanner.GetChar(aChar); //skip the equal sign...
if(kNoError==result) {
result=aScanner.SkipWhite(); //now skip any intervening whitespace
if(kNoError==result) {
result=aScanner.GetChar(aChar); //and grab the next char.
if(kNoError==result) {
if((kQuote==aChar) || (kApostrophe==aChar)) {
mTextValue=aChar;
result=ConsumeQuotedString(aChar,mTextValue,aScanner);
}
else {
mTextValue=aChar; //it's an alphanum attribute...
result=ConsumeAttributeValueText(aChar,mTextValue,aScanner);
}
}//if
if(kNoError==result)
result=aScanner.SkipWhite();
}//if
}//if
}//if
}//if
}
if(kNoError==result) {
result=aScanner.Peek(aChar);
mLastAttribute= PRBool((kGreaterThan==aChar) || (kEOF==result));
}
aScanner.Peek(aChar);
mLastAttribute= PRBool((kGreaterThan==aChar) || (kEOF==result));
}
return result;
};
}
/*
* Dump contents of this token to givne output stream
@ -907,12 +927,15 @@ PRInt32 CWhitespaceToken::GetTokenType(void) {
* @return error result
*/
PRInt32 CWhitespaceToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
PRInt32 result=aScanner.ReadWhile(mTextValue,gWhitespace,PR_FALSE);
mTextValue.StripChars("\r");
if(kNoError==result) {
mTextValue.StripChars("\r");
}
return result;
};
}
/*
* default constructor
@ -943,7 +966,7 @@ PRInt32 CEntityToken::Consume(PRUnichar aChar, CScanner& aScanner) {
mTextValue=aChar;
PRInt32 result=ConsumeEntity(aChar,mTextValue,aScanner);
return result;
};
}
/*
*
@ -979,27 +1002,35 @@ PRInt32 CEntityToken::GetTokenType(void) {
*/
PRInt32 CEntityToken::ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner& aScanner){
PRInt32 result=kNotFound;
aScanner.Peek(aChar);
if(kLeftBrace==aChar) {
//you're consuming a script entity...
static nsAutoString terminals("}>");
result=aScanner.ReadUntil(aString,terminals,PR_FALSE);
aScanner.Peek(aChar);
if(kRightBrace==aChar) {
aString+=kRightBrace; //append rightbrace, and...
aScanner.GetChar(aChar);//yank the closing right-brace
}
}
else
{
result=aScanner.ReadWhile(aString,gIdentChars,PR_FALSE);
aScanner.Peek(aChar);
if (kSemicolon == aChar) {
// consume semicolon that stopped the scan
aScanner.GetChar(aChar);
}
}
PRInt32 result=aScanner.Peek(aChar);
if(kNoError==result) {
if(kLeftBrace==aChar) {
//you're consuming a script entity...
static nsAutoString terminals("}>");
result=aScanner.ReadUntil(aString,terminals,PR_FALSE);
if(kNoError==result) {
result=aScanner.Peek(aChar);
if(kNoError==result) {
if(kRightBrace==aChar) {
aString+=kRightBrace; //append rightbrace, and...
result=aScanner.GetChar(aChar);//yank the closing right-brace
}
}
}
} //if
else {
result=aScanner.ReadWhile(aString,gIdentChars,PR_FALSE);
if(kNoError==result) {
result=aScanner.Peek(aChar);
if(kNoError==result) {
if (kSemicolon == aChar) {
// consume semicolon that stopped the scan
result=aScanner.GetChar(aChar);
}
}
}//if
} //else
} //if
return result;
}
@ -1238,7 +1269,8 @@ PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
PRInt32 result=kNoError;
nsString temp;
while((!done) && (!aScanner.Eof())) {
// while((!done) && (!aScanner.Eof())) {
while((!done) && (kNoError==result)) {
static nsAutoString terminals(">");
result=aScanner.ReadUntil(temp,terminals,PR_TRUE);
done=PRBool(kNotFound!=temp.RFind(mTextValue,PR_TRUE));
@ -1328,7 +1360,8 @@ const char* GetTagName(PRInt32 aTag) {
const char* result=0;
PRInt32 cnt=sizeof(gHTMLTagTable)/sizeof(HTMLTagEntry);
for(int i=0;i<cnt;i++){
int i=0;
for(i=0;i<cnt;i++){
if(aTag==gHTMLTagTable[i].fTagID)
return gHTMLTagTable[i].fName;
}

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

@ -39,12 +39,12 @@
class CScanner;
enum eHTMLTokenTypes {
eToken_unknown=2000,
eToken_start, eToken_end, eToken_comment, eToken_entity,
eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
eToken_script, eToken_style, eToken_skippedcontent, //used in cases like <SCRIPT> where we skip over script content.
eToken_last
eToken_unknown=0,
eToken_start=1, eToken_end, eToken_comment, eToken_entity,
eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
eToken_script, eToken_style, eToken_skippedcontent,
eToken_last //make sure this stays the last token...
};
//*** This enum is used to define the known universe of HTML tags.

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

@ -48,7 +48,7 @@ class nsIContentSink : public nsISupports {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenContainer(const nsIParserNode& aNode) = 0;
virtual PRInt32 OpenContainer(const nsIParserNode& aNode) = 0;
/**
* This method gets called by the parser when a close
@ -58,7 +58,7 @@ class nsIContentSink : public nsISupports {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseContainer(const nsIParserNode& aNode) = 0;
virtual PRInt32 CloseContainer(const nsIParserNode& aNode) = 0;
/**
* This method gets called by the parser when a the
@ -67,7 +67,7 @@ class nsIContentSink : public nsISupports {
* @update 4/1/98 gess
* @return PR_TRUE if successful.
*/
virtual PRBool CloseTopmostContainer() = 0;
virtual PRInt32 CloseTopmostContainer() = 0;
/**
* This gets called by the parser when you want to add
@ -78,7 +78,7 @@ class nsIContentSink : public nsISupports {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool AddLeaf(const nsIParserNode& aNode) = 0;
virtual PRInt32 AddLeaf(const nsIParserNode& aNode) = 0;
/**
* This method gets called when the parser begins the process

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

@ -92,7 +92,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenHTML(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenHTML(const nsIParserNode& aNode)=0;
/**
* This method is used to close the outer HTML container.
@ -101,7 +101,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseHTML(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseHTML(const nsIParserNode& aNode)=0;
/**
* This method is used to open the only HEAD container.
@ -110,7 +110,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenHead(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenHead(const nsIParserNode& aNode)=0;
/**
* This method is used to close the only HEAD container.
@ -119,7 +119,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseHead(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseHead(const nsIParserNode& aNode)=0;
/**
* This method is used to open the main BODY container.
@ -128,7 +128,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenBody(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenBody(const nsIParserNode& aNode)=0;
/**
* This method is used to close the main BODY container.
@ -137,7 +137,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseBody(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseBody(const nsIParserNode& aNode)=0;
/**
* This method is used to open a new FORM container.
@ -146,7 +146,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenForm(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenForm(const nsIParserNode& aNode)=0;
/**
* This method is used to close the outer FORM container.
@ -155,7 +155,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseForm(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseForm(const nsIParserNode& aNode)=0;
/**
* This method is used to open the FRAMESET container.
@ -164,7 +164,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenFrameset(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenFrameset(const nsIParserNode& aNode)=0;
/**
* This method is used to close the FRAMESET container.
@ -173,7 +173,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseFrameset(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseFrameset(const nsIParserNode& aNode)=0;
/**
* This method is used to a general container.
@ -183,7 +183,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool OpenContainer(const nsIParserNode& aNode)=0;
virtual PRInt32 OpenContainer(const nsIParserNode& aNode)=0;
/**
* This method is used to close a generic container.
@ -192,7 +192,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseContainer(const nsIParserNode& aNode)=0;
virtual PRInt32 CloseContainer(const nsIParserNode& aNode)=0;
/**
* This method is used to close the topmost container, regardless
@ -202,7 +202,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool CloseTopmostContainer()=0;
virtual PRInt32 CloseTopmostContainer()=0;
/**
* This method is used to add a leaf to the currently
@ -212,7 +212,7 @@ class nsIHTMLContentSink : public nsIContentSink {
* @param nsIParserNode reference to parser node interface
* @return PR_TRUE if successful.
*/
virtual PRBool AddLeaf(const nsIParserNode& aNode)=0;
virtual PRInt32 AddLeaf(const nsIParserNode& aNode)=0;
/**
* This method gets called when the parser begins the process

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

@ -54,11 +54,11 @@ class nsIParser : public nsISupports {
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
virtual PRInt32 Parse(nsIURL* aURL,PRBool aIncremental=PR_FALSE)=0;
virtual PRInt32 Parse(nsIURL* aURL,PRBool aIncremental=PR_TRUE)=0;
virtual PRInt32 Parse(const char* aFilename,PRBool aIncremental)=0;
virtual PRInt32 Parse(nsString& anHTMLString,PRBool appendTokens)=0;
virtual PRInt32 ResumeParse(PRInt32 anIterator)=0;
virtual PRInt32 ResumeParse(void)=0;
virtual PRInt32 GetStack(PRInt32* aStackPtr)=0;
virtual PRBool HasOpenContainer(PRInt32 aContainer) const=0;
};

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

@ -42,6 +42,8 @@ enum eParseMode {
};
const PRInt32 kEOF = 1000000L;
const PRInt32 kUnknownError = -1000;
const PRInt32 kContextMismatch = -5;
const PRInt32 kBadFilename = -4;
const PRInt32 kBadURL = -3;
const PRInt32 kInterrupted = -2;

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

@ -154,6 +154,8 @@ void _PreCompressBuffer(nsString& aBuffer,PRInt32& anOffset,PRInt32& aMarkPos){
//we should check mMarkPos. That represents the point at which
//we've guaranteed the client we can back up to, so make sure
//you don't lose any of the data beyond that point.
/*
if((anOffset!=aMarkPos) && (0<=aMarkPos)) {
if(aMarkPos>0) {
aBuffer.Cut(0,aMarkPos);
@ -162,6 +164,16 @@ void _PreCompressBuffer(nsString& aBuffer,PRInt32& anOffset,PRInt32& aMarkPos){
}
}
else aBuffer.Truncate();
*/
PRInt32 len=aBuffer.Length();
if((aMarkPos<len) && (aMarkPos>=0)) {
aBuffer.Cut(0,aMarkPos);
anOffset-=aMarkPos;
}
else {
aBuffer.Truncate();
anOffset=0;
}
aMarkPos=0;
}
@ -204,6 +216,19 @@ PRBool CScanner::Append(nsString& aBuffer) {
return PR_TRUE;
}
/**
*
*
* @update gess 5/21/98
* @param
* @return
*/
PRBool CScanner::Append(const char* aBuffer, PRInt32 aLen){
_PreCompressBuffer(mBuffer,mOffset,mMarkPos);
mBuffer.Append(aBuffer,aLen);
return PR_TRUE;
}
/**
* Grab data from underlying stream.
*

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

@ -39,8 +39,7 @@
#include <fstream.h>
class nsIURL;
//class ifstream; XXX mac didn't like this, but this doesn't seem to be needed
// for the pc either...
class ifstream;
class CScanner {
public:
@ -216,6 +215,15 @@ class CScanner {
*/
PRBool Append(nsString& aBuffer);
/**
*
*
* @update gess 5/21/98
* @param
* @return
*/
PRBool Append(const char* aBuffer, PRInt32 aLen);
/**
*
*

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

@ -27,6 +27,7 @@
*/
CToken::CToken(const nsString& aName) : mTextValue(aName) {
mOrdinalValue=0;
mAttrCount=0;
}
/**
@ -71,7 +72,8 @@ void CToken::SetStringValue(const char* aValue) {
*/
void CToken::DebugDumpToken(ostream& anOutputStream) {
anOutputStream << "[" << GetClassName() << "] ";
for(int i=0;i<mTextValue.Length();i++){
int i=0;
for(i=0;i<mTextValue.Length();i++){
anOutputStream << char(mTextValue[i]);
}
anOutputStream << ": " << mOrdinalValue << endl;
@ -116,7 +118,7 @@ nsString& CToken::GetText(void) {
* @update gess 3/25/98
* @param value -- new ordinal value for this token
*/
void CToken::SetOrdinal(PRInt32 value) {
void CToken::SetOrdinal(PRInt16 value) {
mOrdinalValue=value;
}
@ -127,10 +129,31 @@ void CToken::SetOrdinal(PRInt32 value) {
* @update gess 3/25/98
* @return int containing ordinal value
*/
PRInt32 CToken::GetOrdinal(void) {
PRInt16 CToken::GetOrdinal(void) {
return mOrdinalValue;
}
/**
* Sets the attribute count for this token
*
* @update gess 3/25/98
* @param value -- new attr count
*/
void CToken::SetAttributeCount(PRInt16 value) {
mAttrCount=value;
}
/**
* Retrieves copy of attr count for this token
*
* @update gess 3/25/98
* @return int containing attribute count
*/
PRInt16 CToken::GetAttributeCount(void) {
return mAttrCount;
}
/**
* Retrieve type of token. This class returns -1, but
* subclasses return something more meaningful.

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

@ -92,14 +92,28 @@ class CToken {
* @update gess5/11/98
* @param value is the new ord value for this token
*/
virtual void SetOrdinal(PRInt32 value);
virtual void SetOrdinal(PRInt16 value);
/**
* Getter which retrieves the current ordinal value for this token
* @update gess5/11/98
* @return current ordinal value
*/
virtual PRInt32 GetOrdinal(void);
virtual PRInt16 GetOrdinal(void);
/**
* Sets the # of attributes found for this token.
* @update gess5/11/98
* @param value is the attr count
*/
virtual void SetAttributeCount(PRInt16 aValue);
/**
* Getter which retrieves the current attribute count for this token
* @update gess5/11/98
* @return current attribute count
*/
virtual PRInt16 GetAttributeCount(void);
/**
* Causes token to consume data from given scanner.
@ -147,7 +161,8 @@ class CToken {
virtual void SelfTest(void);
protected:
PRInt32 mOrdinalValue;
PRInt16 mOrdinalValue;
PRInt16 mAttrCount;
nsString mTextValue;
};

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

@ -38,8 +38,9 @@ static const char* kNullParserGiven = "Error: Null parser given as argument";
* @param
* @return
*/
CTokenHandler::CTokenHandler(eHTMLTokenTypes aType) {
CTokenHandler::CTokenHandler(dispatchFP aFP,eHTMLTokenTypes aType){
mType=aType;
mFP=aFP;
}
@ -65,18 +66,6 @@ eHTMLTokenTypes CTokenHandler::GetTokenType(void){
return mType;
}
/**
*
*
* @update gess 4/2/98
* @param
* @return
*/
PRBool CTokenHandler::CanHandle(eHTMLTokenTypes aType){
PRBool result=PR_FALSE;
return result;
}
/**
*
@ -85,555 +74,12 @@ PRBool CTokenHandler::CanHandle(eHTMLTokenTypes aType){
* @param
* @return
*/
PRBool CTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
NS_ASSERTION(0!=aParser,kNullParserGiven);
PRBool result=PR_FALSE;
if(aParser){
result=PR_TRUE;
PRInt32 CTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
PRInt32 result=kNoError;
if((0!=aParser) && (0!=mFP)) {
result=(*mFP)(mType,aToken,aParser);
}
return result;
}
/**
*
*
* @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){
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(): 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){
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() : 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){
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() : 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){
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() : 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){
return aParser->HandleStartToken(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() : 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){
return aParser->HandleStartToken(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() : 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){
return aParser->HandleStartToken(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() : 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){
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() : 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){
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() : 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){
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() : 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){
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;
}

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

@ -33,130 +33,22 @@
class CToken;
class nsHTMLParser;
typedef PRInt32 (*dispatchFP)(eHTMLTokenTypes,CToken*,nsHTMLParser*);
class CTokenHandler : public CITokenHandler {
public:
CTokenHandler(eHTMLTokenTypes aType=eToken_unknown);
virtual ~CTokenHandler();
CTokenHandler(dispatchFP aFP,eHTMLTokenTypes aType=eToken_unknown);
virtual ~CTokenHandler();
virtual eHTMLTokenTypes GetTokenType(void);
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
virtual PRInt32 operator()(CToken* aToken,nsHTMLParser* aParser);
protected:
eHTMLTokenTypes mType;
dispatchFP mFP;
};
class CStartTokenHandler : public CTokenHandler {
public:
CStartTokenHandler();
virtual ~CStartTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CEndTokenHandler : public CTokenHandler {
public:
CEndTokenHandler();
virtual ~CEndTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CCommentTokenHandler : public CTokenHandler {
public:
CCommentTokenHandler();
virtual ~CCommentTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CEntityTokenHandler : public CTokenHandler {
public:
CEntityTokenHandler();
virtual ~CEntityTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CWhitespaceTokenHandler : public CTokenHandler {
public:
CWhitespaceTokenHandler();
virtual ~CWhitespaceTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CNewlineTokenHandler : public CTokenHandler {
public:
CNewlineTokenHandler();
virtual ~CNewlineTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CTextTokenHandler : public CTokenHandler {
public:
CTextTokenHandler();
virtual ~CTextTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CAttributeTokenHandler : public CTokenHandler {
public:
CAttributeTokenHandler();
virtual ~CAttributeTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CScriptTokenHandler : public CTokenHandler {
public:
CScriptTokenHandler();
virtual ~CScriptTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CStyleTokenHandler : public CTokenHandler {
public:
CStyleTokenHandler();
virtual ~CStyleTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
class CSkippedContentTokenHandler : public CTokenHandler {
public:
CSkippedContentTokenHandler();
virtual ~CSkippedContentTokenHandler();
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
virtual PRBool CanHandle(eHTMLTokenTypes aType);
};
#endif

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

@ -96,6 +96,20 @@ PRBool CTokenizer::Append(nsString& aBuffer) {
return PR_FALSE;
}
/**
*
*
* @update gess 5/21/98
* @param
* @return
*/
PRBool CTokenizer::Append(const char* aBuffer, PRInt32 aLen){
if(mScanner)
return mScanner->Append(aBuffer,aLen);
return PR_FALSE;
}
/**
* Retrieve a reference to the internal token deque.
*

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

@ -106,6 +106,13 @@ class CTokenizer {
*/
PRBool Append(nsString& aBuffer);
/**
*
* @update gess 4/20/98
* @return deque reference
*/
PRBool Append(const char* aBuffer, PRInt32 aLen);
/**
*