Some random code cleanup:

1)  Make SetContentSink and SetParserFilter not claim to return stuff
2)  Clean up nsIParser to use NS_IMETHOD_() where needed.  Sync up with nsParser
3)  Removed some never-used code

Bug 40149, r=harishd, sr=jst
This commit is contained in:
bzbarsky@mit.edu
2003-04-08 21:23:34 +00:00
parent ced51c92b0
commit 98f570e17d
7 changed files with 365 additions and 366 deletions

View File

@@ -734,11 +734,8 @@ nsHTMLDocument::StartAutodetection(nsIDocShell *aDocShell, nsAString& aCharset,
rv_detect = adp->Init(wss, cdet, this, mParser, rv_detect = adp->Init(wss, cdet, this, mParser,
PromiseFlatString(aCharset).get(), aCommand); PromiseFlatString(aCharset).get(), aCommand);
// The current implementation for SetParserFilter needs to
// be changed to be more XPCOM friendly. See bug #40149
if (mParser) if (mParser)
nsCOMPtr<nsIParserFilter> oldFilter = mParser->SetParserFilter(cdetflt);
getter_AddRefs(mParser->SetParserFilter(cdetflt));
} }
} }
} }

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK ***** /* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
* *
@@ -154,18 +154,17 @@ class nsIParser : public nsISupports {
* Select given content sink into parser for parser output * Select given content sink into parser for parser output
* @update gess5/11/98 * @update gess5/11/98
* @param aSink is the new sink to be used by parser * @param aSink is the new sink to be used by parser
* @return old sink, or NULL * @return
*/ */
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink)=0; NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink)=0;
/** /**
* retrive the sink set into the parser * retrieve the sink set into the parser
* @update gess5/11/98 * @update gess5/11/98
* @param aSink is the new sink to be used by parser * @return current sink
* @return old sink, or NULL
*/ */
virtual nsIContentSink* GetContentSink(void)=0; NS_IMETHOD_(nsIContentSink*) GetContentSink(void)=0;
/** /**
* Call this method once you've created a parser, and want to instruct it * Call this method once you've created a parser, and want to instruct it
@@ -176,9 +175,9 @@ class nsIParser : public nsISupports {
* @param aCommand -- ptrs to string that contains command * @param aCommand -- ptrs to string that contains command
* @return nada * @return nada
*/ */
virtual void GetCommand(nsString& aCommand)=0; NS_IMETHOD_(void) GetCommand(nsString& aCommand)=0;
virtual void SetCommand(const char* aCommand)=0; NS_IMETHOD_(void) SetCommand(const char* aCommand)=0;
virtual void SetCommand(eParserCommands aParserCommand)=0; NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand)=0;
/** /**
* Call this method once you've created a parser, and want to instruct it * Call this method once you've created a parser, and want to instruct it
@@ -189,10 +188,10 @@ class nsIParser : public nsISupports {
* @param aCharsetSource- the soure of the chares * @param aCharsetSource- the soure of the chares
* @return nada * @return nada
*/ */
virtual void SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource)=0; NS_IMETHOD_(void) SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource)=0;
virtual void GetDocumentCharset(nsAString& oCharset, PRInt32& oSource)=0; NS_IMETHOD_(void) GetDocumentCharset(nsAString& oCharset, PRInt32& oSource)=0;
virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter) = 0; NS_IMETHOD_(void) SetParserFilter(nsIParserFilter* aFilter) = 0;
/** /**
* Get the channel associated with this parser * Get the channel associated with this parser
@@ -217,32 +216,45 @@ class nsIParser : public nsISupports {
******************************************************************************************/ ******************************************************************************************/
// Call this method to resume the parser from the blocked state.. // Call this method to resume the parser from the blocked state..
virtual nsresult ContinueParsing() =0; NS_IMETHOD ContinueParsing() = 0;
// Stops parsing temporarily. // Stops parsing temporarily.
virtual void BlockParser() =0; NS_IMETHOD_(void) BlockParser() = 0;
// Open up the parser for tokenization, building up content // Open up the parser for tokenization, building up content
// model..etc. However, this method does not resume parsing // model..etc. However, this method does not resume parsing
// automatically. It's the callers' responsibility to restart // automatically. It's the callers' responsibility to restart
// the parsing engine. // the parsing engine.
virtual void UnblockParser() =0; NS_IMETHOD_(void) UnblockParser() = 0;
virtual PRBool IsParserEnabled() =0; NS_IMETHOD_(PRBool) IsParserEnabled() = 0;
virtual PRBool IsComplete() =0; NS_IMETHOD_(PRBool) IsComplete() = 0;
virtual nsresult Parse(nsIURI* aURL,nsIRequestObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE, void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect) = 0; NS_IMETHOD Parse(nsIURI* aURL,
virtual nsresult Parse(nsIInputStream* aStream, const nsACString& aMimeType,PRBool aEnableVerify=PR_FALSE, void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect) = 0; nsIRequestObserver* aListener = nsnull,
virtual nsresult Parse(const nsAString& aSourceBuffer,void* aKey,const nsACString& aMimeType,PRBool aEnableVerify,PRBool aLastCall,nsDTDMode aMode=eDTDMode_autodetect) = 0; PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect) = 0;
NS_IMETHOD Parse(nsIInputStream* aStream,
const nsACString& aMimeType,
PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect) = 0;
NS_IMETHOD Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aMimeType,
PRBool aEnableVerify,
PRBool aLastCall,
nsDTDMode aMode = eDTDMode_autodetect) = 0;
virtual nsresult Terminate(void) = 0; NS_IMETHOD Terminate(void) = 0;
virtual nsresult ParseFragment(const nsAString& aSourceBuffer, NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
void* aKey, void* aKey,
nsVoidArray& aTagStack, nsVoidArray& aTagStack,
PRUint32 anInsertPos, PRUint32 anInsertPos,
const nsACString& aContentType, const nsACString& aContentType,
nsDTDMode aMode=eDTDMode_autodetect) = 0; nsDTDMode aMode = eDTDMode_autodetect) = 0;
/** /**
* This method gets called when the tokens have been consumed, and it's time * This method gets called when the tokens have been consumed, and it's time
@@ -250,7 +262,7 @@ class nsIParser : public nsISupports {
* @update gess5/11/98 * @update gess5/11/98
* @return error code -- 0 if model building went well . * @return error code -- 0 if model building went well .
*/ */
virtual nsresult BuildModel(void)=0; NS_IMETHOD BuildModel(void) = 0;
/** /**
@@ -259,7 +271,7 @@ class nsIParser : public nsISupports {
* @update gess 6/9/98 * @update gess 6/9/98
* @return ptr to scanner * @return ptr to scanner
*/ */
virtual nsDTDMode GetParseMode(void)=0; NS_IMETHOD_(nsDTDMode) GetParseMode(void) = 0;
/** /**
* Call this method to cancel any pending parsing events. * Call this method to cancel any pending parsing events.
@@ -271,7 +283,7 @@ class nsIParser : public nsISupports {
* @return NS_OK if succeeded else ERROR. * @return NS_OK if succeeded else ERROR.
*/ */
NS_IMETHOD CancelParsingEvents()=0; NS_IMETHOD CancelParsingEvents() = 0;
}; };
/* ===========================================================* /* ===========================================================*

View File

@@ -44,12 +44,10 @@
#include "nsIAtom.h" #include "nsIAtom.h"
#include "nsParser.h" #include "nsParser.h"
#include "nsIContentSink.h"
#include "nsString.h" #include "nsString.h"
#include "nsCRT.h" #include "nsCRT.h"
#include "nsScanner.h" #include "nsScanner.h"
#include "plstr.h" #include "plstr.h"
#include "nsIParserFilter.h"
#include "nsViewSourceHTML.h" #include "nsViewSourceHTML.h"
#include "nsIStringStream.h" #include "nsIStringStream.h"
#include "nsIChannel.h" #include "nsIChannel.h"
@@ -300,7 +298,7 @@ static PRBool gDumpContent=PR_FALSE;
* @param * @param
* @return * @return
*/ */
nsParser::nsParser(nsITokenObserver* anObserver) { nsParser::nsParser() {
#ifdef NS_DEBUG #ifdef NS_DEBUG
if(!gDumpContent) { if(!gDumpContent) {
gDumpContent=(PR_GetEnv("PARSER_DUMP_CONTENT"))? PR_TRUE:PR_FALSE; gDumpContent=(PR_GetEnv("PARSER_DUMP_CONTENT"))? PR_TRUE:PR_FALSE;
@@ -308,11 +306,7 @@ nsParser::nsParser(nsITokenObserver* anObserver) {
#endif #endif
mCharset.Assign(NS_LITERAL_STRING("ISO-8859-1")); mCharset.Assign(NS_LITERAL_STRING("ISO-8859-1"));
mParserFilter = 0;
mObserver = 0;
mSink=0;
mParserContext=0; mParserContext=0;
mTokenObserver=anObserver;
mStreamStatus=0; mStreamStatus=0;
mCharsetSource=kCharsetUninitialized; mCharsetSource=kCharsetUninitialized;
mInternalState=NS_OK;; mInternalState=NS_OK;;
@@ -360,10 +354,6 @@ nsParser::~nsParser() {
} }
#endif #endif
NS_IF_RELEASE(mObserver);
NS_IF_RELEASE(mSink);
NS_IF_RELEASE(mParserFilter);
//don't forget to add code here to delete //don't forget to add code here to delete
//what may be several contexts... //what may be several contexts...
delete mParserContext; delete mParserContext;
@@ -443,20 +433,13 @@ nsParser::PostContinueEvent()
* @param * @param
* @return * @return
*/ */
nsIParserFilter * nsParser::SetParserFilter(nsIParserFilter * aFilter) NS_IMETHODIMP_(void) nsParser::SetParserFilter(nsIParserFilter * aFilter)
{ {
nsIParserFilter* old=mParserFilter; mParserFilter = aFilter;
if(old)
NS_RELEASE(old);
if(aFilter) {
mParserFilter=aFilter;
NS_ADDREF(aFilter);
}
return old;
} }
void nsParser::GetCommand(nsString& aCommand) NS_IMETHODIMP_(void) nsParser::GetCommand(nsString& aCommand)
{ {
aCommand = mCommandStr; aCommand = mCommandStr;
} }
@@ -467,10 +450,10 @@ void nsParser::GetCommand(nsString& aCommand)
* this allows us to select a DTD which can do, say, view-source. * this allows us to select a DTD which can do, say, view-source.
* *
* @update gess 01/04/99 * @update gess 01/04/99
* @param aContentSink -- ptr to content sink that will receive output * @param aCommand the command string to set
* @return ptr to previously set contentsink (usually null)
*/ */
void nsParser::SetCommand(const char* aCommand){ NS_IMETHODIMP_(void) nsParser::SetCommand(const char* aCommand)
{
nsCAutoString theCommand(aCommand); nsCAutoString theCommand(aCommand);
if(theCommand.Equals(kViewSourceCommand)) if(theCommand.Equals(kViewSourceCommand))
mCommand=eViewSource; mCommand=eViewSource;
@@ -486,11 +469,11 @@ void nsParser::SetCommand(const char* aCommand){
* this allows us to select a DTD which can do, say, view-source. * this allows us to select a DTD which can do, say, view-source.
* *
* @update gess 01/04/99 * @update gess 01/04/99
* @param aContentSink -- ptr to content sink that will receive output * @param aParserCommand the command to set
* @return ptr to previously set contentsink (usually null)
*/ */
void nsParser::SetCommand(eParserCommands aParserCommand){ NS_IMETHODIMP_(void) nsParser::SetCommand(eParserCommands aParserCommand)
mCommand=aParserCommand; {
mCommand = aParserCommand;
} }
@@ -499,11 +482,13 @@ void nsParser::SetCommand(eParserCommands aParserCommand){
* about what charset to load * about what charset to load
* *
* @update ftang 4/23/99 * @update ftang 4/23/99
* @param aCharset- the charest of a document * @param aCharset- the charset of a document
* @param aCharsetSource- the soure of the chares * @param aCharsetSource- the source of the charset
* @return nada * @return nada
*/ */
void nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource){ NS_IMETHODIMP_(void)
nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource)
{
mCharset = aCharset; mCharset = aCharset;
mCharsetSource = aCharsetSource; mCharsetSource = aCharsetSource;
if(mParserContext && mParserContext->mScanner) if(mParserContext && mParserContext->mScanner)
@@ -525,26 +510,23 @@ void nsParser::SetSinkCharset(nsAString& aCharset)
* @param nsIContentSink interface for node receiver * @param nsIContentSink interface for node receiver
* @return * @return
*/ */
nsIContentSink* nsParser::SetContentSink(nsIContentSink* aSink) { NS_IMETHODIMP_(void) nsParser::SetContentSink(nsIContentSink* aSink)
NS_PRECONDITION(0!=aSink,"sink cannot be null!"); {
nsIContentSink* old=mSink; NS_PRECONDITION(aSink,"sink cannot be null!");
mSink = aSink;
NS_IF_RELEASE(old);
if(aSink) { if (mSink) {
mSink=aSink;
NS_ADDREF(aSink);
mSink->SetParser(this); mSink->SetParser(this);
} }
return old;
} }
/** /**
* retrive the sink set into the parser * retrive the sink set into the parser
* @update gess5/11/98 * @update gess5/11/98
* @param aSink is the new sink to be used by parser * @return current sink
* @return old sink, or NULL
*/ */
nsIContentSink* nsParser::GetContentSink(void){ NS_IMETHODIMP_(nsIContentSink*) nsParser::GetContentSink(void)
{
return mSink; return mSink;
} }
@@ -556,34 +538,23 @@ nsIContentSink* nsParser::GetContentSink(void){
* @param aDTD is the object to be registered. * @param aDTD is the object to be registered.
* @return nothing. * @return nothing.
*/ */
nsresult NS_IMETHODIMP
nsParser::RegisterDTD(nsIDTD* aDTD){ nsParser::RegisterDTD(nsIDTD* aDTD)
{
CSharedParserObjects* sharedObjects; CSharedParserObjects* sharedObjects;
nsresult rv = GetSharedObjects(&sharedObjects); nsresult rv = GetSharedObjects(&sharedObjects);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return sharedObjects->RegisterDTD(aDTD); return sharedObjects->RegisterDTD(aDTD);
} }
/**
* Retrieve scanner from topmost parsecontext
*
* @update gess 01/04/99
* @return ptr to internal scanner
*/
nsScanner* nsParser::GetScanner(void){
if(mParserContext)
return mParserContext->mScanner;
return 0;
}
/** /**
* Retrieve parsemode from topmost parser context * Retrieve parsemode from topmost parser context
* *
* @update gess 01/04/99 * @update gess 01/04/99
* @return parsemode * @return parsemode
*/ */
nsDTDMode nsParser::GetParseMode(void){ NS_IMETHODIMP_(nsDTDMode) nsParser::GetParseMode(void)
{
if(mParserContext) if(mParserContext)
return mParserContext->mDTDMode; return mParserContext->mDTDMode;
NS_NOTREACHED("no parser context"); NS_NOTREACHED("no parser context");
@@ -1207,7 +1178,8 @@ FindSuitableDTD(CParserContext& aParserContext,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsParser::CancelParsingEvents() { nsParser::CancelParsingEvents()
{
if (mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT) { if (mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT) {
NS_ASSERTION(mEventQueue,"Event queue is null"); NS_ASSERTION(mEventQueue,"Event queue is null");
// Revoke all pending continue parsing events // Revoke all pending continue parsing events
@@ -1334,7 +1306,8 @@ CParserContext* nsParser::PopContext() {
* @param aState determines whether we parse/tokenize or just cache. * @param aState determines whether we parse/tokenize or just cache.
* @return current state * @return current state
*/ */
void nsParser::SetUnusedInput(nsString& aBuffer) { void nsParser::SetUnusedInput(nsString& aBuffer)
{
mUnusedInput=aBuffer; mUnusedInput=aBuffer;
} }
@@ -1346,7 +1319,8 @@ void nsParser::SetUnusedInput(nsString& aBuffer) {
* @update gess 7/4/99 * @update gess 7/4/99
* @return should return NS_OK once implemented * @return should return NS_OK once implemented
*/ */
nsresult nsParser::Terminate(void){ NS_IMETHODIMP nsParser::Terminate(void)
{
nsresult result = NS_OK; nsresult result = NS_OK;
if (mParserContext && mParserContext->mDTD) { if (mParserContext && mParserContext->mDTD) {
mParserContext->mDTD->Terminate(); mParserContext->mDTD->Terminate();
@@ -1373,8 +1347,8 @@ nsresult nsParser::Terminate(void){
* @param aState determines whether we parse/tokenize or just cache. * @param aState determines whether we parse/tokenize or just cache.
* @return current state * @return current state
*/ */
nsresult nsParser::ContinueParsing(){ NS_IMETHODIMP nsParser::ContinueParsing()
{
// If the stream has already finished, there's a good chance // If the stream has already finished, there's a good chance
// that we might start closing things down when the parser // that we might start closing things down when the parser
// is reenabled. To make sure that we're not deleted across // is reenabled. To make sure that we're not deleted across
@@ -1401,7 +1375,8 @@ nsresult nsParser::ContinueParsing(){
* @update * @update
* @return * @return
*/ */
void nsParser::BlockParser() { NS_IMETHODIMP_(void) nsParser::BlockParser()
{
mFlags &= ~NS_PARSER_FLAG_PARSER_ENABLED; mFlags &= ~NS_PARSER_FLAG_PARSER_ENABLED;
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: nsParser::BlockParser(), this=%p\n", this)); MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: nsParser::BlockParser(), this=%p\n", this));
MOZ_TIMER_STOP(mParseTime); MOZ_TIMER_STOP(mParseTime);
@@ -1416,7 +1391,8 @@ void nsParser::BlockParser() {
* @update * @update
* @return * @return
*/ */
void nsParser::UnblockParser() { NS_IMETHODIMP_(void) nsParser::UnblockParser()
{
mFlags |= NS_PARSER_FLAG_PARSER_ENABLED; mFlags |= NS_PARSER_FLAG_PARSER_ENABLED;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: nsParser::UnblockParser(), this=%p\n", this)); MOZ_TIMER_DEBUGLOG(("Start: Parse Time: nsParser::UnblockParser(), this=%p\n", this));
MOZ_TIMER_START(mParseTime); MOZ_TIMER_START(mParseTime);
@@ -1428,7 +1404,8 @@ void nsParser::UnblockParser() {
* @update vidur 4/12/99 * @update vidur 4/12/99
* @return current state * @return current state
*/ */
PRBool nsParser::IsParserEnabled() { NS_IMETHODIMP_(PRBool) nsParser::IsParserEnabled()
{
return mFlags & NS_PARSER_FLAG_PARSER_ENABLED; return mFlags & NS_PARSER_FLAG_PARSER_ENABLED;
} }
@@ -1438,7 +1415,8 @@ PRBool nsParser::IsParserEnabled() {
* @update rickg 5/12/01 * @update rickg 5/12/01
* @return complete state * @return complete state
*/ */
PRBool nsParser::IsComplete() { NS_IMETHODIMP_(PRBool) nsParser::IsComplete()
{
return !(mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT); return !(mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT);
} }
@@ -1472,13 +1450,18 @@ void nsParser::SetCanInterrupt(PRBool aCanInterrupt) {
* @param aFilename -- const char* containing file to be parsed. * @param aFilename -- const char* containing file to be parsed.
* @return error code -- 0 if ok, non-zero if error. * @return error code -- 0 if ok, non-zero if error.
*/ */
nsresult nsParser::Parse(nsIURI* aURL,nsIRequestObserver* aListener,PRBool aVerifyEnabled, void* aKey,nsDTDMode aMode) { NS_IMETHODIMP
nsParser::Parse(nsIURI* aURL,
nsIRequestObserver* aListener,
PRBool aVerifyEnabled,
void* aKey,
nsDTDMode aMode)
{
NS_PRECONDITION(aURL, "Error: Null URL given"); NS_PRECONDITION(aURL, "Error: Null URL given");
nsresult result=kBadURL; nsresult result=kBadURL;
mObserver = aListener; mObserver = aListener;
NS_IF_ADDREF(mObserver);
if (aVerifyEnabled) { if (aVerifyEnabled) {
mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION; mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION;
@@ -1518,7 +1501,13 @@ nsresult nsParser::Parse(nsIURI* aURL,nsIRequestObserver* aListener,PRBool aVeri
* @param aStream is the i/o source * @param aStream is the i/o source
* @return error code -- 0 if ok, non-zero if error. * @return error code -- 0 if ok, non-zero if error.
*/ */
nsresult nsParser::Parse(nsIInputStream* aStream,const nsACString& aMimeType,PRBool aVerifyEnabled, void* aKey,nsDTDMode aMode){ NS_IMETHODIMP
nsParser::Parse(nsIInputStream* aStream,
const nsACString& aMimeType,
PRBool aVerifyEnabled,
void* aKey,
nsDTDMode aMode)
{
if (aVerifyEnabled) { if (aVerifyEnabled) {
mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION; mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION;
} }
@@ -1564,10 +1553,14 @@ nsresult nsParser::Parse(nsIInputStream* aStream,const nsACString& aMimeType,PRB
* @param aMimeType tells us what type of content to expect in the given string * @param aMimeType tells us what type of content to expect in the given string
* @return error code -- 0 if ok, non-zero if error. * @return error code -- 0 if ok, non-zero if error.
*/ */
nsresult nsParser::Parse(const nsAString& aSourceBuffer, void* aKey, NS_IMETHODIMP
const nsACString& aMimeType, nsParser::Parse(const nsAString& aSourceBuffer,
PRBool aVerifyEnabled, PRBool aLastCall, void* aKey,
nsDTDMode aMode){ const nsACString& aMimeType,
PRBool aVerifyEnabled,
PRBool aLastCall,
nsDTDMode aMode)
{
//NOTE: Make sure that updates to this method don't cause //NOTE: Make sure that updates to this method don't cause
// bug #2361 to break again! // bug #2361 to break again!
@@ -1676,13 +1669,14 @@ nsresult nsParser::Parse(const nsAString& aSourceBuffer, void* aKey,
* @param * @param
* @return * @return
*/ */
nsresult nsParser::ParseFragment(const nsAString& aSourceBuffer, NS_IMETHODIMP
void* aKey, nsParser::ParseFragment(const nsAString& aSourceBuffer,
nsVoidArray& aTagStack, void* aKey,
PRUint32 anInsertPos, nsVoidArray& aTagStack,
const nsACString& aMimeType, PRUint32 anInsertPos,
nsDTDMode aMode){ const nsACString& aMimeType,
nsDTDMode aMode)
{
nsresult result = NS_OK; nsresult result = NS_OK;
nsAutoString theContext; nsAutoString theContext;
PRUint32 theCount = aTagStack.Count(); PRUint32 theCount = aTagStack.Count();
@@ -1901,7 +1895,7 @@ nsresult nsParser::BuildModel() {
if (theRootDTD) { if (theRootDTD) {
MOZ_TIMER_START(mDTDTime); MOZ_TIMER_START(mDTDTime);
result = theRootDTD->BuildModel(this, theTokenizer, mTokenObserver, mSink); result = theRootDTD->BuildModel(this, theTokenizer, nsnull, mSink);
MOZ_TIMER_STOP(mDTDTime); MOZ_TIMER_STOP(mDTDTime);
} }
@@ -1951,7 +1945,7 @@ nsresult nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) {
"Parser's nsIStreamListener API was not setup " "Parser's nsIStreamListener API was not setup "
"correctly in constructor."); "correctly in constructor.");
if (nsnull != mObserver) { if (mObserver) {
mObserver->OnStartRequest(request, aContext); mObserver->OnStartRequest(request, aContext);
} }
mParserContext->mStreamListenerState = eOnStart; mParserContext->mStreamListenerState = eOnStart;
@@ -2454,7 +2448,7 @@ nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext,
// XXX Should we wait to notify our observers as well if the // XXX Should we wait to notify our observers as well if the
// parser isn't yet enabled? // parser isn't yet enabled?
if (nsnull != mObserver) { if (mObserver) {
mObserver->OnStopRequest(request, aContext, status); mObserver->OnStopRequest(request, aContext, status);
} }
@@ -2591,15 +2585,6 @@ PRBool nsParser::DidTokenize(PRBool aIsFinalChunk){
if (NS_SUCCEEDED(rv) && theTokenizer) { if (NS_SUCCEEDED(rv) && theTokenizer) {
result = theTokenizer->DidTokenize(aIsFinalChunk); result = theTokenizer->DidTokenize(aIsFinalChunk);
if(mTokenObserver) {
PRInt32 theCount=theTokenizer->GetCount();
PRInt32 theIndex;
for(theIndex=0;theIndex<theCount;++theIndex){
if((*mTokenObserver)(theTokenizer->GetTokenAt(theIndex))){
//add code here to pull unwanted tokens out of the stack...
}
}//for
}//if
} }
return result; return result;
} }

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK ***** /* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
* *
@@ -86,11 +86,11 @@
#include "nsDTDUtils.h" #include "nsDTDUtils.h"
#include "nsTimer.h" #include "nsTimer.h"
#include "nsIEventQueue.h" #include "nsIEventQueue.h"
#include "nsIContentSink.h"
#include "nsIParserFilter.h"
class IContentSink;
class nsIDTD; class nsIDTD;
class nsScanner; class nsScanner;
class nsIParserFilter;
class nsIProgressEventSink; class nsIProgressEventSink;
#ifdef XP_WIN #ifdef XP_WIN
@@ -113,7 +113,7 @@ class nsParser : public nsIParser,
* default constructor * default constructor
* @update gess5/11/98 * @update gess5/11/98
*/ */
nsParser(nsITokenObserver* anObserver=0); nsParser();
/** /**
@@ -128,7 +128,7 @@ class nsParser : public nsIParser,
* @param aSink is the new sink to be used by parser * @param aSink is the new sink to be used by parser
* @return old sink, or NULL * @return old sink, or NULL
*/ */
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink); NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink);
/** /**
* retrive the sink set into the parser * retrive the sink set into the parser
@@ -136,40 +136,40 @@ class nsParser : public nsIParser,
* @param aSink is the new sink to be used by parser * @param aSink is the new sink to be used by parser
* @return old sink, or NULL * @return old sink, or NULL
*/ */
virtual nsIContentSink* GetContentSink(void); NS_IMETHOD_(nsIContentSink*) GetContentSink(void);
/** /**
* Call this method once you've created a parser, and want to instruct it * Call this method once you've created a parser, and want to instruct it
* about the command which caused the parser to be constructed. For example, * about the command which caused the parser to be constructed. For example,
* this allows us to select a DTD which can do, say, view-source. * this allows us to select a DTD which can do, say, view-source.
* *
* @update gess 3/25/98 * @update gess 3/25/98
* @param aContentSink -- ptr to content sink that will receive output * @param aCommand -- ptrs to string that contains command
* @return ptr to previously set contentsink (usually null) * @return nada
*/ */
virtual void GetCommand(nsString& aCommand); NS_IMETHOD_(void) GetCommand(nsString& aCommand);
virtual void SetCommand(const char* aCommand); NS_IMETHOD_(void) SetCommand(const char* aCommand);
virtual void SetCommand(eParserCommands aParserCommand); NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand);
/** /**
* Call this method once you've created a parser, and want to instruct it * Call this method once you've created a parser, and want to instruct it
* about what charset to load * about what charset to load
* *
* @update ftang 4/23/99 * @update ftang 4/23/99
* @param aCharset- the charest of a document * @param aCharset- the charset of a document
* @param aCharsetSource- the soure of the chares * @param aCharsetSource- the source of the charset
* @return nada * @return nada
*/ */
virtual void SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource); NS_IMETHOD_(void) SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource);
void GetDocumentCharset(nsAString& aCharset, PRInt32& aSource) NS_IMETHOD_(void) GetDocumentCharset(nsAString& aCharset, PRInt32& aSource)
{ {
aCharset = mCharset; aCharset = mCharset;
aSource = mCharsetSource; aSource = mCharsetSource;
} }
virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter); NS_IMETHOD_(void) SetParserFilter(nsIParserFilter* aFilter);
NS_IMETHOD RegisterDTD(nsIDTD* aDTD); NS_IMETHOD RegisterDTD(nsIDTD* aDTD);
@@ -179,15 +179,7 @@ class nsParser : public nsIParser,
* @update gess 6/9/98 * @update gess 6/9/98
* @return ptr to scanner * @return ptr to scanner
*/ */
virtual nsDTDMode GetParseMode(void); NS_IMETHOD_(nsDTDMode) GetParseMode(void);
/**
* Retrieve the scanner from the topmost parser context
*
* @update gess 6/9/98
* @return ptr to scanner
*/
virtual nsScanner* GetScanner(void);
/** /**
* Cause parser to parse input from given URL * Cause parser to parse input from given URL
@@ -196,7 +188,11 @@ class nsParser : public nsIParser,
* @param aListener is a listener to forward notifications to * @param aListener is a listener to forward notifications to
* @return TRUE if all went well -- FALSE otherwise * @return TRUE if all went well -- FALSE otherwise
*/ */
virtual nsresult Parse(nsIURI* aURL,nsIRequestObserver* aListener,PRBool aEnableVerify=PR_FALSE,void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect); NS_IMETHOD Parse(nsIURI* aURL,
nsIRequestObserver* aListener = nsnull,
PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect);
/** /**
* Cause parser to parse input from given stream * Cause parser to parse input from given stream
@@ -204,7 +200,11 @@ class nsParser : public nsIParser,
* @param aStream is the i/o source * @param aStream is the i/o source
* @return TRUE if all went well -- FALSE otherwise * @return TRUE if all went well -- FALSE otherwise
*/ */
virtual nsresult Parse(nsIInputStream* aStream,const nsACString& aMimeType,PRBool aEnableVerify=PR_FALSE,void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect); NS_IMETHOD Parse(nsIInputStream* aStream,
const nsACString& aMimeType,
PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect);
/** /**
* @update gess5/11/98 * @update gess5/11/98
@@ -212,16 +212,29 @@ class nsParser : public nsIParser,
* @param appendTokens tells us whether we should insert tokens inline, or append them. * @param appendTokens tells us whether we should insert tokens inline, or append them.
* @return TRUE if all went well -- FALSE otherwise * @return TRUE if all went well -- FALSE otherwise
*/ */
virtual nsresult Parse(const nsAString& aSourceBuffer,void* aKey,const nsACString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE,nsDTDMode aMode=eDTDMode_autodetect); NS_IMETHOD Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aContentType,
PRBool aEnableVerify,
PRBool aLastCall,
nsDTDMode aMode = eDTDMode_autodetect);
virtual nsresult ParseFragment(const nsAString& aSourceBuffer, NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
void* aKey, void* aKey,
nsVoidArray& aTagStack, nsVoidArray& aTagStack,
PRUint32 anInsertPos, PRUint32 anInsertPos,
const nsACString& aContentType, const nsACString& aContentType,
nsDTDMode aMode=eDTDMode_autodetect); nsDTDMode aMode = eDTDMode_autodetect);
/**
* 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.
*/
NS_IMETHOD BuildModel(void);
/** /**
* Call this when you want control whether or not the parser will parse * Call this when you want control whether or not the parser will parse
* and tokenize input (TRUE), or whether it just caches input to be * and tokenize input (TRUE), or whether it just caches input to be
@@ -231,10 +244,10 @@ class nsParser : public nsIParser,
* @param aState determines whether we parse/tokenize or just cache. * @param aState determines whether we parse/tokenize or just cache.
* @return current state * @return current state
*/ */
virtual nsresult ContinueParsing(); NS_IMETHOD ContinueParsing();
virtual void BlockParser(); NS_IMETHOD_(void) BlockParser();
virtual void UnblockParser(); NS_IMETHOD_(void) UnblockParser();
virtual nsresult Terminate(void); NS_IMETHOD Terminate(void);
/** /**
* Call this to query whether the parser is enabled or not. * Call this to query whether the parser is enabled or not.
@@ -242,7 +255,7 @@ class nsParser : public nsIParser,
* @update vidur 4/12/99 * @update vidur 4/12/99
* @return current state * @return current state
*/ */
virtual PRBool IsParserEnabled(); NS_IMETHOD_(PRBool) IsParserEnabled();
/** /**
* Call this to query whether the parser thinks it's done with parsing. * Call this to query whether the parser thinks it's done with parsing.
@@ -250,7 +263,7 @@ class nsParser : public nsIParser,
* @update rickg 5/12/01 * @update rickg 5/12/01
* @return complete state * @return complete state
*/ */
virtual PRBool IsComplete(); NS_IMETHOD_(PRBool) IsComplete();
/** /**
* This rather arcane method (hack) is used as a signal between the * This rather arcane method (hack) is used as a signal between the
@@ -377,14 +390,6 @@ protected:
* @return * @return
*/ */
nsresult DidBuildModel(nsresult anErrorCode); nsresult DidBuildModel(nsresult 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.
*/
virtual nsresult BuildModel(void);
private: private:
@@ -432,14 +437,13 @@ protected:
//********************************************* //*********************************************
nsCOMPtr<nsIEventQueue> mEventQueue; nsCOMPtr<nsIEventQueue> mEventQueue;
CParserContext* mParserContext; CParserContext* mParserContext;
nsIRequestObserver* mObserver; nsCOMPtr<nsIRequestObserver> mObserver;
nsIContentSink* mSink; nsCOMPtr<nsIContentSink> mSink;
nsIParserFilter* mParserFilter; nsCOMPtr<nsIParserFilter> mParserFilter;
nsITokenObserver* mTokenObserver; nsTokenAllocator mTokenAllocator;
nsTokenAllocator mTokenAllocator;
eParserCommands mCommand; eParserCommands mCommand;
nsresult mInternalState; nsresult mInternalState;

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK ***** /* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
* *
@@ -154,18 +154,17 @@ class nsIParser : public nsISupports {
* Select given content sink into parser for parser output * Select given content sink into parser for parser output
* @update gess5/11/98 * @update gess5/11/98
* @param aSink is the new sink to be used by parser * @param aSink is the new sink to be used by parser
* @return old sink, or NULL * @return
*/ */
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink)=0; NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink)=0;
/** /**
* retrive the sink set into the parser * retrieve the sink set into the parser
* @update gess5/11/98 * @update gess5/11/98
* @param aSink is the new sink to be used by parser * @return current sink
* @return old sink, or NULL
*/ */
virtual nsIContentSink* GetContentSink(void)=0; NS_IMETHOD_(nsIContentSink*) GetContentSink(void)=0;
/** /**
* Call this method once you've created a parser, and want to instruct it * Call this method once you've created a parser, and want to instruct it
@@ -176,9 +175,9 @@ class nsIParser : public nsISupports {
* @param aCommand -- ptrs to string that contains command * @param aCommand -- ptrs to string that contains command
* @return nada * @return nada
*/ */
virtual void GetCommand(nsString& aCommand)=0; NS_IMETHOD_(void) GetCommand(nsString& aCommand)=0;
virtual void SetCommand(const char* aCommand)=0; NS_IMETHOD_(void) SetCommand(const char* aCommand)=0;
virtual void SetCommand(eParserCommands aParserCommand)=0; NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand)=0;
/** /**
* Call this method once you've created a parser, and want to instruct it * Call this method once you've created a parser, and want to instruct it
@@ -189,10 +188,10 @@ class nsIParser : public nsISupports {
* @param aCharsetSource- the soure of the chares * @param aCharsetSource- the soure of the chares
* @return nada * @return nada
*/ */
virtual void SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource)=0; NS_IMETHOD_(void) SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource)=0;
virtual void GetDocumentCharset(nsAString& oCharset, PRInt32& oSource)=0; NS_IMETHOD_(void) GetDocumentCharset(nsAString& oCharset, PRInt32& oSource)=0;
virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter) = 0; NS_IMETHOD_(void) SetParserFilter(nsIParserFilter* aFilter) = 0;
/** /**
* Get the channel associated with this parser * Get the channel associated with this parser
@@ -217,32 +216,45 @@ class nsIParser : public nsISupports {
******************************************************************************************/ ******************************************************************************************/
// Call this method to resume the parser from the blocked state.. // Call this method to resume the parser from the blocked state..
virtual nsresult ContinueParsing() =0; NS_IMETHOD ContinueParsing() = 0;
// Stops parsing temporarily. // Stops parsing temporarily.
virtual void BlockParser() =0; NS_IMETHOD_(void) BlockParser() = 0;
// Open up the parser for tokenization, building up content // Open up the parser for tokenization, building up content
// model..etc. However, this method does not resume parsing // model..etc. However, this method does not resume parsing
// automatically. It's the callers' responsibility to restart // automatically. It's the callers' responsibility to restart
// the parsing engine. // the parsing engine.
virtual void UnblockParser() =0; NS_IMETHOD_(void) UnblockParser() = 0;
virtual PRBool IsParserEnabled() =0; NS_IMETHOD_(PRBool) IsParserEnabled() = 0;
virtual PRBool IsComplete() =0; NS_IMETHOD_(PRBool) IsComplete() = 0;
virtual nsresult Parse(nsIURI* aURL,nsIRequestObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE, void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect) = 0; NS_IMETHOD Parse(nsIURI* aURL,
virtual nsresult Parse(nsIInputStream* aStream, const nsACString& aMimeType,PRBool aEnableVerify=PR_FALSE, void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect) = 0; nsIRequestObserver* aListener = nsnull,
virtual nsresult Parse(const nsAString& aSourceBuffer,void* aKey,const nsACString& aMimeType,PRBool aEnableVerify,PRBool aLastCall,nsDTDMode aMode=eDTDMode_autodetect) = 0; PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect) = 0;
NS_IMETHOD Parse(nsIInputStream* aStream,
const nsACString& aMimeType,
PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect) = 0;
NS_IMETHOD Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aMimeType,
PRBool aEnableVerify,
PRBool aLastCall,
nsDTDMode aMode = eDTDMode_autodetect) = 0;
virtual nsresult Terminate(void) = 0; NS_IMETHOD Terminate(void) = 0;
virtual nsresult ParseFragment(const nsAString& aSourceBuffer, NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
void* aKey, void* aKey,
nsVoidArray& aTagStack, nsVoidArray& aTagStack,
PRUint32 anInsertPos, PRUint32 anInsertPos,
const nsACString& aContentType, const nsACString& aContentType,
nsDTDMode aMode=eDTDMode_autodetect) = 0; nsDTDMode aMode = eDTDMode_autodetect) = 0;
/** /**
* This method gets called when the tokens have been consumed, and it's time * This method gets called when the tokens have been consumed, and it's time
@@ -250,7 +262,7 @@ class nsIParser : public nsISupports {
* @update gess5/11/98 * @update gess5/11/98
* @return error code -- 0 if model building went well . * @return error code -- 0 if model building went well .
*/ */
virtual nsresult BuildModel(void)=0; NS_IMETHOD BuildModel(void) = 0;
/** /**
@@ -259,7 +271,7 @@ class nsIParser : public nsISupports {
* @update gess 6/9/98 * @update gess 6/9/98
* @return ptr to scanner * @return ptr to scanner
*/ */
virtual nsDTDMode GetParseMode(void)=0; NS_IMETHOD_(nsDTDMode) GetParseMode(void) = 0;
/** /**
* Call this method to cancel any pending parsing events. * Call this method to cancel any pending parsing events.
@@ -271,7 +283,7 @@ class nsIParser : public nsISupports {
* @return NS_OK if succeeded else ERROR. * @return NS_OK if succeeded else ERROR.
*/ */
NS_IMETHOD CancelParsingEvents()=0; NS_IMETHOD CancelParsingEvents() = 0;
}; };
/* ===========================================================* /* ===========================================================*

View File

@@ -44,12 +44,10 @@
#include "nsIAtom.h" #include "nsIAtom.h"
#include "nsParser.h" #include "nsParser.h"
#include "nsIContentSink.h"
#include "nsString.h" #include "nsString.h"
#include "nsCRT.h" #include "nsCRT.h"
#include "nsScanner.h" #include "nsScanner.h"
#include "plstr.h" #include "plstr.h"
#include "nsIParserFilter.h"
#include "nsViewSourceHTML.h" #include "nsViewSourceHTML.h"
#include "nsIStringStream.h" #include "nsIStringStream.h"
#include "nsIChannel.h" #include "nsIChannel.h"
@@ -300,7 +298,7 @@ static PRBool gDumpContent=PR_FALSE;
* @param * @param
* @return * @return
*/ */
nsParser::nsParser(nsITokenObserver* anObserver) { nsParser::nsParser() {
#ifdef NS_DEBUG #ifdef NS_DEBUG
if(!gDumpContent) { if(!gDumpContent) {
gDumpContent=(PR_GetEnv("PARSER_DUMP_CONTENT"))? PR_TRUE:PR_FALSE; gDumpContent=(PR_GetEnv("PARSER_DUMP_CONTENT"))? PR_TRUE:PR_FALSE;
@@ -308,11 +306,7 @@ nsParser::nsParser(nsITokenObserver* anObserver) {
#endif #endif
mCharset.Assign(NS_LITERAL_STRING("ISO-8859-1")); mCharset.Assign(NS_LITERAL_STRING("ISO-8859-1"));
mParserFilter = 0;
mObserver = 0;
mSink=0;
mParserContext=0; mParserContext=0;
mTokenObserver=anObserver;
mStreamStatus=0; mStreamStatus=0;
mCharsetSource=kCharsetUninitialized; mCharsetSource=kCharsetUninitialized;
mInternalState=NS_OK;; mInternalState=NS_OK;;
@@ -360,10 +354,6 @@ nsParser::~nsParser() {
} }
#endif #endif
NS_IF_RELEASE(mObserver);
NS_IF_RELEASE(mSink);
NS_IF_RELEASE(mParserFilter);
//don't forget to add code here to delete //don't forget to add code here to delete
//what may be several contexts... //what may be several contexts...
delete mParserContext; delete mParserContext;
@@ -443,20 +433,13 @@ nsParser::PostContinueEvent()
* @param * @param
* @return * @return
*/ */
nsIParserFilter * nsParser::SetParserFilter(nsIParserFilter * aFilter) NS_IMETHODIMP_(void) nsParser::SetParserFilter(nsIParserFilter * aFilter)
{ {
nsIParserFilter* old=mParserFilter; mParserFilter = aFilter;
if(old)
NS_RELEASE(old);
if(aFilter) {
mParserFilter=aFilter;
NS_ADDREF(aFilter);
}
return old;
} }
void nsParser::GetCommand(nsString& aCommand) NS_IMETHODIMP_(void) nsParser::GetCommand(nsString& aCommand)
{ {
aCommand = mCommandStr; aCommand = mCommandStr;
} }
@@ -467,10 +450,10 @@ void nsParser::GetCommand(nsString& aCommand)
* this allows us to select a DTD which can do, say, view-source. * this allows us to select a DTD which can do, say, view-source.
* *
* @update gess 01/04/99 * @update gess 01/04/99
* @param aContentSink -- ptr to content sink that will receive output * @param aCommand the command string to set
* @return ptr to previously set contentsink (usually null)
*/ */
void nsParser::SetCommand(const char* aCommand){ NS_IMETHODIMP_(void) nsParser::SetCommand(const char* aCommand)
{
nsCAutoString theCommand(aCommand); nsCAutoString theCommand(aCommand);
if(theCommand.Equals(kViewSourceCommand)) if(theCommand.Equals(kViewSourceCommand))
mCommand=eViewSource; mCommand=eViewSource;
@@ -486,11 +469,11 @@ void nsParser::SetCommand(const char* aCommand){
* this allows us to select a DTD which can do, say, view-source. * this allows us to select a DTD which can do, say, view-source.
* *
* @update gess 01/04/99 * @update gess 01/04/99
* @param aContentSink -- ptr to content sink that will receive output * @param aParserCommand the command to set
* @return ptr to previously set contentsink (usually null)
*/ */
void nsParser::SetCommand(eParserCommands aParserCommand){ NS_IMETHODIMP_(void) nsParser::SetCommand(eParserCommands aParserCommand)
mCommand=aParserCommand; {
mCommand = aParserCommand;
} }
@@ -499,11 +482,13 @@ void nsParser::SetCommand(eParserCommands aParserCommand){
* about what charset to load * about what charset to load
* *
* @update ftang 4/23/99 * @update ftang 4/23/99
* @param aCharset- the charest of a document * @param aCharset- the charset of a document
* @param aCharsetSource- the soure of the chares * @param aCharsetSource- the source of the charset
* @return nada * @return nada
*/ */
void nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource){ NS_IMETHODIMP_(void)
nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource)
{
mCharset = aCharset; mCharset = aCharset;
mCharsetSource = aCharsetSource; mCharsetSource = aCharsetSource;
if(mParserContext && mParserContext->mScanner) if(mParserContext && mParserContext->mScanner)
@@ -525,26 +510,23 @@ void nsParser::SetSinkCharset(nsAString& aCharset)
* @param nsIContentSink interface for node receiver * @param nsIContentSink interface for node receiver
* @return * @return
*/ */
nsIContentSink* nsParser::SetContentSink(nsIContentSink* aSink) { NS_IMETHODIMP_(void) nsParser::SetContentSink(nsIContentSink* aSink)
NS_PRECONDITION(0!=aSink,"sink cannot be null!"); {
nsIContentSink* old=mSink; NS_PRECONDITION(aSink,"sink cannot be null!");
mSink = aSink;
NS_IF_RELEASE(old);
if(aSink) { if (mSink) {
mSink=aSink;
NS_ADDREF(aSink);
mSink->SetParser(this); mSink->SetParser(this);
} }
return old;
} }
/** /**
* retrive the sink set into the parser * retrive the sink set into the parser
* @update gess5/11/98 * @update gess5/11/98
* @param aSink is the new sink to be used by parser * @return current sink
* @return old sink, or NULL
*/ */
nsIContentSink* nsParser::GetContentSink(void){ NS_IMETHODIMP_(nsIContentSink*) nsParser::GetContentSink(void)
{
return mSink; return mSink;
} }
@@ -556,34 +538,23 @@ nsIContentSink* nsParser::GetContentSink(void){
* @param aDTD is the object to be registered. * @param aDTD is the object to be registered.
* @return nothing. * @return nothing.
*/ */
nsresult NS_IMETHODIMP
nsParser::RegisterDTD(nsIDTD* aDTD){ nsParser::RegisterDTD(nsIDTD* aDTD)
{
CSharedParserObjects* sharedObjects; CSharedParserObjects* sharedObjects;
nsresult rv = GetSharedObjects(&sharedObjects); nsresult rv = GetSharedObjects(&sharedObjects);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return sharedObjects->RegisterDTD(aDTD); return sharedObjects->RegisterDTD(aDTD);
} }
/**
* Retrieve scanner from topmost parsecontext
*
* @update gess 01/04/99
* @return ptr to internal scanner
*/
nsScanner* nsParser::GetScanner(void){
if(mParserContext)
return mParserContext->mScanner;
return 0;
}
/** /**
* Retrieve parsemode from topmost parser context * Retrieve parsemode from topmost parser context
* *
* @update gess 01/04/99 * @update gess 01/04/99
* @return parsemode * @return parsemode
*/ */
nsDTDMode nsParser::GetParseMode(void){ NS_IMETHODIMP_(nsDTDMode) nsParser::GetParseMode(void)
{
if(mParserContext) if(mParserContext)
return mParserContext->mDTDMode; return mParserContext->mDTDMode;
NS_NOTREACHED("no parser context"); NS_NOTREACHED("no parser context");
@@ -1207,7 +1178,8 @@ FindSuitableDTD(CParserContext& aParserContext,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsParser::CancelParsingEvents() { nsParser::CancelParsingEvents()
{
if (mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT) { if (mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT) {
NS_ASSERTION(mEventQueue,"Event queue is null"); NS_ASSERTION(mEventQueue,"Event queue is null");
// Revoke all pending continue parsing events // Revoke all pending continue parsing events
@@ -1334,7 +1306,8 @@ CParserContext* nsParser::PopContext() {
* @param aState determines whether we parse/tokenize or just cache. * @param aState determines whether we parse/tokenize or just cache.
* @return current state * @return current state
*/ */
void nsParser::SetUnusedInput(nsString& aBuffer) { void nsParser::SetUnusedInput(nsString& aBuffer)
{
mUnusedInput=aBuffer; mUnusedInput=aBuffer;
} }
@@ -1346,7 +1319,8 @@ void nsParser::SetUnusedInput(nsString& aBuffer) {
* @update gess 7/4/99 * @update gess 7/4/99
* @return should return NS_OK once implemented * @return should return NS_OK once implemented
*/ */
nsresult nsParser::Terminate(void){ NS_IMETHODIMP nsParser::Terminate(void)
{
nsresult result = NS_OK; nsresult result = NS_OK;
if (mParserContext && mParserContext->mDTD) { if (mParserContext && mParserContext->mDTD) {
mParserContext->mDTD->Terminate(); mParserContext->mDTD->Terminate();
@@ -1373,8 +1347,8 @@ nsresult nsParser::Terminate(void){
* @param aState determines whether we parse/tokenize or just cache. * @param aState determines whether we parse/tokenize or just cache.
* @return current state * @return current state
*/ */
nsresult nsParser::ContinueParsing(){ NS_IMETHODIMP nsParser::ContinueParsing()
{
// If the stream has already finished, there's a good chance // If the stream has already finished, there's a good chance
// that we might start closing things down when the parser // that we might start closing things down when the parser
// is reenabled. To make sure that we're not deleted across // is reenabled. To make sure that we're not deleted across
@@ -1401,7 +1375,8 @@ nsresult nsParser::ContinueParsing(){
* @update * @update
* @return * @return
*/ */
void nsParser::BlockParser() { NS_IMETHODIMP_(void) nsParser::BlockParser()
{
mFlags &= ~NS_PARSER_FLAG_PARSER_ENABLED; mFlags &= ~NS_PARSER_FLAG_PARSER_ENABLED;
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: nsParser::BlockParser(), this=%p\n", this)); MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: nsParser::BlockParser(), this=%p\n", this));
MOZ_TIMER_STOP(mParseTime); MOZ_TIMER_STOP(mParseTime);
@@ -1416,7 +1391,8 @@ void nsParser::BlockParser() {
* @update * @update
* @return * @return
*/ */
void nsParser::UnblockParser() { NS_IMETHODIMP_(void) nsParser::UnblockParser()
{
mFlags |= NS_PARSER_FLAG_PARSER_ENABLED; mFlags |= NS_PARSER_FLAG_PARSER_ENABLED;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: nsParser::UnblockParser(), this=%p\n", this)); MOZ_TIMER_DEBUGLOG(("Start: Parse Time: nsParser::UnblockParser(), this=%p\n", this));
MOZ_TIMER_START(mParseTime); MOZ_TIMER_START(mParseTime);
@@ -1428,7 +1404,8 @@ void nsParser::UnblockParser() {
* @update vidur 4/12/99 * @update vidur 4/12/99
* @return current state * @return current state
*/ */
PRBool nsParser::IsParserEnabled() { NS_IMETHODIMP_(PRBool) nsParser::IsParserEnabled()
{
return mFlags & NS_PARSER_FLAG_PARSER_ENABLED; return mFlags & NS_PARSER_FLAG_PARSER_ENABLED;
} }
@@ -1438,7 +1415,8 @@ PRBool nsParser::IsParserEnabled() {
* @update rickg 5/12/01 * @update rickg 5/12/01
* @return complete state * @return complete state
*/ */
PRBool nsParser::IsComplete() { NS_IMETHODIMP_(PRBool) nsParser::IsComplete()
{
return !(mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT); return !(mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT);
} }
@@ -1472,13 +1450,18 @@ void nsParser::SetCanInterrupt(PRBool aCanInterrupt) {
* @param aFilename -- const char* containing file to be parsed. * @param aFilename -- const char* containing file to be parsed.
* @return error code -- 0 if ok, non-zero if error. * @return error code -- 0 if ok, non-zero if error.
*/ */
nsresult nsParser::Parse(nsIURI* aURL,nsIRequestObserver* aListener,PRBool aVerifyEnabled, void* aKey,nsDTDMode aMode) { NS_IMETHODIMP
nsParser::Parse(nsIURI* aURL,
nsIRequestObserver* aListener,
PRBool aVerifyEnabled,
void* aKey,
nsDTDMode aMode)
{
NS_PRECONDITION(aURL, "Error: Null URL given"); NS_PRECONDITION(aURL, "Error: Null URL given");
nsresult result=kBadURL; nsresult result=kBadURL;
mObserver = aListener; mObserver = aListener;
NS_IF_ADDREF(mObserver);
if (aVerifyEnabled) { if (aVerifyEnabled) {
mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION; mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION;
@@ -1518,7 +1501,13 @@ nsresult nsParser::Parse(nsIURI* aURL,nsIRequestObserver* aListener,PRBool aVeri
* @param aStream is the i/o source * @param aStream is the i/o source
* @return error code -- 0 if ok, non-zero if error. * @return error code -- 0 if ok, non-zero if error.
*/ */
nsresult nsParser::Parse(nsIInputStream* aStream,const nsACString& aMimeType,PRBool aVerifyEnabled, void* aKey,nsDTDMode aMode){ NS_IMETHODIMP
nsParser::Parse(nsIInputStream* aStream,
const nsACString& aMimeType,
PRBool aVerifyEnabled,
void* aKey,
nsDTDMode aMode)
{
if (aVerifyEnabled) { if (aVerifyEnabled) {
mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION; mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION;
} }
@@ -1564,10 +1553,14 @@ nsresult nsParser::Parse(nsIInputStream* aStream,const nsACString& aMimeType,PRB
* @param aMimeType tells us what type of content to expect in the given string * @param aMimeType tells us what type of content to expect in the given string
* @return error code -- 0 if ok, non-zero if error. * @return error code -- 0 if ok, non-zero if error.
*/ */
nsresult nsParser::Parse(const nsAString& aSourceBuffer, void* aKey, NS_IMETHODIMP
const nsACString& aMimeType, nsParser::Parse(const nsAString& aSourceBuffer,
PRBool aVerifyEnabled, PRBool aLastCall, void* aKey,
nsDTDMode aMode){ const nsACString& aMimeType,
PRBool aVerifyEnabled,
PRBool aLastCall,
nsDTDMode aMode)
{
//NOTE: Make sure that updates to this method don't cause //NOTE: Make sure that updates to this method don't cause
// bug #2361 to break again! // bug #2361 to break again!
@@ -1676,13 +1669,14 @@ nsresult nsParser::Parse(const nsAString& aSourceBuffer, void* aKey,
* @param * @param
* @return * @return
*/ */
nsresult nsParser::ParseFragment(const nsAString& aSourceBuffer, NS_IMETHODIMP
void* aKey, nsParser::ParseFragment(const nsAString& aSourceBuffer,
nsVoidArray& aTagStack, void* aKey,
PRUint32 anInsertPos, nsVoidArray& aTagStack,
const nsACString& aMimeType, PRUint32 anInsertPos,
nsDTDMode aMode){ const nsACString& aMimeType,
nsDTDMode aMode)
{
nsresult result = NS_OK; nsresult result = NS_OK;
nsAutoString theContext; nsAutoString theContext;
PRUint32 theCount = aTagStack.Count(); PRUint32 theCount = aTagStack.Count();
@@ -1901,7 +1895,7 @@ nsresult nsParser::BuildModel() {
if (theRootDTD) { if (theRootDTD) {
MOZ_TIMER_START(mDTDTime); MOZ_TIMER_START(mDTDTime);
result = theRootDTD->BuildModel(this, theTokenizer, mTokenObserver, mSink); result = theRootDTD->BuildModel(this, theTokenizer, nsnull, mSink);
MOZ_TIMER_STOP(mDTDTime); MOZ_TIMER_STOP(mDTDTime);
} }
@@ -1951,7 +1945,7 @@ nsresult nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) {
"Parser's nsIStreamListener API was not setup " "Parser's nsIStreamListener API was not setup "
"correctly in constructor."); "correctly in constructor.");
if (nsnull != mObserver) { if (mObserver) {
mObserver->OnStartRequest(request, aContext); mObserver->OnStartRequest(request, aContext);
} }
mParserContext->mStreamListenerState = eOnStart; mParserContext->mStreamListenerState = eOnStart;
@@ -2454,7 +2448,7 @@ nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext,
// XXX Should we wait to notify our observers as well if the // XXX Should we wait to notify our observers as well if the
// parser isn't yet enabled? // parser isn't yet enabled?
if (nsnull != mObserver) { if (mObserver) {
mObserver->OnStopRequest(request, aContext, status); mObserver->OnStopRequest(request, aContext, status);
} }
@@ -2591,15 +2585,6 @@ PRBool nsParser::DidTokenize(PRBool aIsFinalChunk){
if (NS_SUCCEEDED(rv) && theTokenizer) { if (NS_SUCCEEDED(rv) && theTokenizer) {
result = theTokenizer->DidTokenize(aIsFinalChunk); result = theTokenizer->DidTokenize(aIsFinalChunk);
if(mTokenObserver) {
PRInt32 theCount=theTokenizer->GetCount();
PRInt32 theIndex;
for(theIndex=0;theIndex<theCount;++theIndex){
if((*mTokenObserver)(theTokenizer->GetTokenAt(theIndex))){
//add code here to pull unwanted tokens out of the stack...
}
}//for
}//if
} }
return result; return result;
} }

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK ***** /* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
* *
@@ -86,11 +86,11 @@
#include "nsDTDUtils.h" #include "nsDTDUtils.h"
#include "nsTimer.h" #include "nsTimer.h"
#include "nsIEventQueue.h" #include "nsIEventQueue.h"
#include "nsIContentSink.h"
#include "nsIParserFilter.h"
class IContentSink;
class nsIDTD; class nsIDTD;
class nsScanner; class nsScanner;
class nsIParserFilter;
class nsIProgressEventSink; class nsIProgressEventSink;
#ifdef XP_WIN #ifdef XP_WIN
@@ -113,7 +113,7 @@ class nsParser : public nsIParser,
* default constructor * default constructor
* @update gess5/11/98 * @update gess5/11/98
*/ */
nsParser(nsITokenObserver* anObserver=0); nsParser();
/** /**
@@ -128,7 +128,7 @@ class nsParser : public nsIParser,
* @param aSink is the new sink to be used by parser * @param aSink is the new sink to be used by parser
* @return old sink, or NULL * @return old sink, or NULL
*/ */
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink); NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink);
/** /**
* retrive the sink set into the parser * retrive the sink set into the parser
@@ -136,40 +136,40 @@ class nsParser : public nsIParser,
* @param aSink is the new sink to be used by parser * @param aSink is the new sink to be used by parser
* @return old sink, or NULL * @return old sink, or NULL
*/ */
virtual nsIContentSink* GetContentSink(void); NS_IMETHOD_(nsIContentSink*) GetContentSink(void);
/** /**
* Call this method once you've created a parser, and want to instruct it * Call this method once you've created a parser, and want to instruct it
* about the command which caused the parser to be constructed. For example, * about the command which caused the parser to be constructed. For example,
* this allows us to select a DTD which can do, say, view-source. * this allows us to select a DTD which can do, say, view-source.
* *
* @update gess 3/25/98 * @update gess 3/25/98
* @param aContentSink -- ptr to content sink that will receive output * @param aCommand -- ptrs to string that contains command
* @return ptr to previously set contentsink (usually null) * @return nada
*/ */
virtual void GetCommand(nsString& aCommand); NS_IMETHOD_(void) GetCommand(nsString& aCommand);
virtual void SetCommand(const char* aCommand); NS_IMETHOD_(void) SetCommand(const char* aCommand);
virtual void SetCommand(eParserCommands aParserCommand); NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand);
/** /**
* Call this method once you've created a parser, and want to instruct it * Call this method once you've created a parser, and want to instruct it
* about what charset to load * about what charset to load
* *
* @update ftang 4/23/99 * @update ftang 4/23/99
* @param aCharset- the charest of a document * @param aCharset- the charset of a document
* @param aCharsetSource- the soure of the chares * @param aCharsetSource- the source of the charset
* @return nada * @return nada
*/ */
virtual void SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource); NS_IMETHOD_(void) SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource);
void GetDocumentCharset(nsAString& aCharset, PRInt32& aSource) NS_IMETHOD_(void) GetDocumentCharset(nsAString& aCharset, PRInt32& aSource)
{ {
aCharset = mCharset; aCharset = mCharset;
aSource = mCharsetSource; aSource = mCharsetSource;
} }
virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter); NS_IMETHOD_(void) SetParserFilter(nsIParserFilter* aFilter);
NS_IMETHOD RegisterDTD(nsIDTD* aDTD); NS_IMETHOD RegisterDTD(nsIDTD* aDTD);
@@ -179,15 +179,7 @@ class nsParser : public nsIParser,
* @update gess 6/9/98 * @update gess 6/9/98
* @return ptr to scanner * @return ptr to scanner
*/ */
virtual nsDTDMode GetParseMode(void); NS_IMETHOD_(nsDTDMode) GetParseMode(void);
/**
* Retrieve the scanner from the topmost parser context
*
* @update gess 6/9/98
* @return ptr to scanner
*/
virtual nsScanner* GetScanner(void);
/** /**
* Cause parser to parse input from given URL * Cause parser to parse input from given URL
@@ -196,7 +188,11 @@ class nsParser : public nsIParser,
* @param aListener is a listener to forward notifications to * @param aListener is a listener to forward notifications to
* @return TRUE if all went well -- FALSE otherwise * @return TRUE if all went well -- FALSE otherwise
*/ */
virtual nsresult Parse(nsIURI* aURL,nsIRequestObserver* aListener,PRBool aEnableVerify=PR_FALSE,void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect); NS_IMETHOD Parse(nsIURI* aURL,
nsIRequestObserver* aListener = nsnull,
PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect);
/** /**
* Cause parser to parse input from given stream * Cause parser to parse input from given stream
@@ -204,7 +200,11 @@ class nsParser : public nsIParser,
* @param aStream is the i/o source * @param aStream is the i/o source
* @return TRUE if all went well -- FALSE otherwise * @return TRUE if all went well -- FALSE otherwise
*/ */
virtual nsresult Parse(nsIInputStream* aStream,const nsACString& aMimeType,PRBool aEnableVerify=PR_FALSE,void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect); NS_IMETHOD Parse(nsIInputStream* aStream,
const nsACString& aMimeType,
PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect);
/** /**
* @update gess5/11/98 * @update gess5/11/98
@@ -212,16 +212,29 @@ class nsParser : public nsIParser,
* @param appendTokens tells us whether we should insert tokens inline, or append them. * @param appendTokens tells us whether we should insert tokens inline, or append them.
* @return TRUE if all went well -- FALSE otherwise * @return TRUE if all went well -- FALSE otherwise
*/ */
virtual nsresult Parse(const nsAString& aSourceBuffer,void* aKey,const nsACString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE,nsDTDMode aMode=eDTDMode_autodetect); NS_IMETHOD Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aContentType,
PRBool aEnableVerify,
PRBool aLastCall,
nsDTDMode aMode = eDTDMode_autodetect);
virtual nsresult ParseFragment(const nsAString& aSourceBuffer, NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
void* aKey, void* aKey,
nsVoidArray& aTagStack, nsVoidArray& aTagStack,
PRUint32 anInsertPos, PRUint32 anInsertPos,
const nsACString& aContentType, const nsACString& aContentType,
nsDTDMode aMode=eDTDMode_autodetect); nsDTDMode aMode = eDTDMode_autodetect);
/**
* 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.
*/
NS_IMETHOD BuildModel(void);
/** /**
* Call this when you want control whether or not the parser will parse * Call this when you want control whether or not the parser will parse
* and tokenize input (TRUE), or whether it just caches input to be * and tokenize input (TRUE), or whether it just caches input to be
@@ -231,10 +244,10 @@ class nsParser : public nsIParser,
* @param aState determines whether we parse/tokenize or just cache. * @param aState determines whether we parse/tokenize or just cache.
* @return current state * @return current state
*/ */
virtual nsresult ContinueParsing(); NS_IMETHOD ContinueParsing();
virtual void BlockParser(); NS_IMETHOD_(void) BlockParser();
virtual void UnblockParser(); NS_IMETHOD_(void) UnblockParser();
virtual nsresult Terminate(void); NS_IMETHOD Terminate(void);
/** /**
* Call this to query whether the parser is enabled or not. * Call this to query whether the parser is enabled or not.
@@ -242,7 +255,7 @@ class nsParser : public nsIParser,
* @update vidur 4/12/99 * @update vidur 4/12/99
* @return current state * @return current state
*/ */
virtual PRBool IsParserEnabled(); NS_IMETHOD_(PRBool) IsParserEnabled();
/** /**
* Call this to query whether the parser thinks it's done with parsing. * Call this to query whether the parser thinks it's done with parsing.
@@ -250,7 +263,7 @@ class nsParser : public nsIParser,
* @update rickg 5/12/01 * @update rickg 5/12/01
* @return complete state * @return complete state
*/ */
virtual PRBool IsComplete(); NS_IMETHOD_(PRBool) IsComplete();
/** /**
* This rather arcane method (hack) is used as a signal between the * This rather arcane method (hack) is used as a signal between the
@@ -377,14 +390,6 @@ protected:
* @return * @return
*/ */
nsresult DidBuildModel(nsresult anErrorCode); nsresult DidBuildModel(nsresult 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.
*/
virtual nsresult BuildModel(void);
private: private:
@@ -432,14 +437,13 @@ protected:
//********************************************* //*********************************************
nsCOMPtr<nsIEventQueue> mEventQueue; nsCOMPtr<nsIEventQueue> mEventQueue;
CParserContext* mParserContext; CParserContext* mParserContext;
nsIRequestObserver* mObserver; nsCOMPtr<nsIRequestObserver> mObserver;
nsIContentSink* mSink; nsCOMPtr<nsIContentSink> mSink;
nsIParserFilter* mParserFilter; nsCOMPtr<nsIParserFilter> mParserFilter;
nsITokenObserver* mTokenObserver; nsTokenAllocator mTokenAllocator;
nsTokenAllocator mTokenAllocator;
eParserCommands mCommand; eParserCommands mCommand;
nsresult mInternalState; nsresult mInternalState;