зеркало из https://github.com/mozilla/pjs.git
Fix for Bug# 3571.
Added Terminate() method in nsIDTD.
This commit is contained in:
Родитель
dc722f8296
Коммит
fcf7c10c28
|
@ -347,6 +347,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0), mSkippedContent(0), mShared
|
|||
mComputedCRC32=0;
|
||||
mExpectedCRC32=0;
|
||||
mSaveBadTokens = PR_FALSE;
|
||||
mDTDState=NS_OK;
|
||||
// DebugDumpContainmentRules2(*this,"c:/temp/DTDRules.new","New CNavDTD Containment Rules");
|
||||
#ifdef RICKG_DEBUG
|
||||
nsHTMLElement::DebugDumpContainment("c:/temp/rules.new","ElementTable Rules");
|
||||
|
@ -542,11 +543,17 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke
|
|||
NS_ADDREF(mSink);
|
||||
gRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler();
|
||||
while(NS_SUCCEEDED(result)){
|
||||
if(mDTDState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||
CToken* theToken=mTokenizer->PopToken();
|
||||
if(theToken) {
|
||||
result=HandleToken(theToken,aParser);
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else {
|
||||
result=mDTDState;
|
||||
break;
|
||||
}
|
||||
}//while
|
||||
mTokenizer=oldTokenizer;
|
||||
NS_IF_RELEASE(mSink);
|
||||
|
@ -636,6 +643,7 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This big dispatch method is used to route token handler calls to the right place.
|
||||
* What's wrong with it? This table, and the dispatch methods themselves need to be
|
||||
|
|
|
@ -369,6 +369,18 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
|
|||
*/
|
||||
virtual PRInt32 GetTopmostIndexOf(eHTMLTags aTagSet[],PRInt32 aCount) const;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void) { return mDTDState=NS_ERROR_HTMLPARSER_STOPPARSING; }
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
@ -520,6 +532,7 @@ protected:
|
|||
PRBool mHasOpenBody;
|
||||
PRBool mHadFrameset;
|
||||
PRBool mHadBody;
|
||||
PRBool mDTDState;
|
||||
nsString mFilename;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
PRInt32 mLineNumber;
|
||||
|
|
|
@ -478,6 +478,21 @@ nsITokenRecycler* CRtfDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult CRtfDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Heres's the RTFControlWord subclass...
|
||||
***************************************************************/
|
||||
|
|
|
@ -338,6 +338,18 @@ class CRtfDTD : public nsIDTD {
|
|||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -279,6 +279,20 @@ nsITokenRecycler* nsExpatDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult nsExpatDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the callbacks for the expat parser
|
||||
|
|
|
@ -213,6 +213,18 @@ class nsExpatDTD : public nsIDTD {
|
|||
*/
|
||||
virtual PRBool IsContainer(PRInt32 aTag) const;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -200,6 +200,18 @@ class nsIDTD : public nsISupports {
|
|||
*/
|
||||
virtual PRBool Verify(nsString& aURLRef,nsIParser* aParser)=0;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void) = 0;
|
||||
|
||||
/* XXX Temporary measure, pending further work by RickG */
|
||||
|
||||
/**
|
||||
|
@ -207,6 +219,7 @@ class nsIDTD : public nsISupports {
|
|||
* become useful.
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const =0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -191,7 +191,6 @@ nsParser::nsParser(nsITokenObserver* anObserver) : mCommand(""), mUnusedInput(""
|
|||
mTokenObserver=anObserver;
|
||||
mStreamStatus=0;
|
||||
mDTDVerification=PR_FALSE;
|
||||
mParserTerminated=PR_FALSE;
|
||||
mCharsetSource=kCharsetUninitialized;
|
||||
mInternalState=NS_OK;
|
||||
}
|
||||
|
@ -585,8 +584,11 @@ void nsParser::SetUnusedInput(nsString& aBuffer) {
|
|||
* @return should return NS_OK once implemented
|
||||
*/
|
||||
nsresult nsParser::Terminate(void){
|
||||
mParserTerminated=PR_TRUE;
|
||||
return NS_OK;
|
||||
nsresult result=NS_OK;
|
||||
if(mParserContext && mParserContext->mDTD)
|
||||
result=mParserContext->mDTD->Terminate();
|
||||
mInternalState=result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -612,7 +614,12 @@ PRBool nsParser::EnableParser(PRBool aState){
|
|||
|
||||
// If we're reenabling the parser
|
||||
mParserContext->mParserEnabled=aState;
|
||||
nsresult result=(aState) ? ResumeParse() : NS_OK;
|
||||
nsresult result=NS_OK;
|
||||
if(aState) {
|
||||
result=ResumeParse();
|
||||
if(result!=NS_OK)
|
||||
result=mInternalState;
|
||||
}
|
||||
|
||||
// Release reference if we added one at the top of this routine
|
||||
NS_IF_RELEASE(me);
|
||||
|
@ -870,7 +877,7 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag
|
|||
nsresult nsParser::ResumeParse(nsIDTD* aDefaultDTD, PRBool aIsFinalChunk) {
|
||||
|
||||
nsresult result=NS_OK;
|
||||
if(mParserContext->mParserEnabled && !mParserTerminated) {
|
||||
if(mParserContext->mParserEnabled && mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||
result=WillBuildModel(mParserContext->mScanner->GetFilename(),aDefaultDTD);
|
||||
if(mParserContext->mDTD) {
|
||||
mParserContext->mDTD->WillResumeParse();
|
||||
|
@ -878,9 +885,12 @@ nsresult nsParser::ResumeParse(nsIDTD* aDefaultDTD, PRBool aIsFinalChunk) {
|
|||
result=Tokenize(aIsFinalChunk);
|
||||
result=BuildModel();
|
||||
|
||||
if((!mParserContext->mMultipart) || (mParserTerminated) ||
|
||||
if(result==NS_ERROR_HTMLPARSER_STOPPARSING) mInternalState=result;
|
||||
|
||||
if((!mParserContext->mMultipart) || (mInternalState==NS_ERROR_HTMLPARSER_STOPPARSING) ||
|
||||
((eOnStop==mParserContext->mStreamListenerState) && (NS_OK==result))){
|
||||
DidBuildModel(mStreamStatus);
|
||||
return mInternalState;
|
||||
}
|
||||
else {
|
||||
mParserContext->mDTD->WillInterruptParse();
|
||||
|
@ -928,11 +938,8 @@ nsresult nsParser::BuildModel() {
|
|||
}
|
||||
|
||||
nsIDTD* theRootDTD=theRootContext->mDTD;
|
||||
if(theRootDTD) {
|
||||
if(theRootDTD)
|
||||
result=theRootDTD->BuildModel(this,theTokenizer,mTokenObserver,mSink);
|
||||
if(NS_ERROR_HTMLPARSER_STOPPARSING==result)
|
||||
Terminate();
|
||||
}
|
||||
}
|
||||
else{
|
||||
mInternalState=result=NS_ERROR_HTMLPARSER_BADTOKENIZER;
|
||||
|
@ -1254,7 +1261,7 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){
|
|||
break;
|
||||
}
|
||||
else if(NS_ERROR_HTMLPARSER_STOPPARSING==result)
|
||||
Terminate();
|
||||
return Terminate();
|
||||
}
|
||||
}
|
||||
DidTokenize(aIsFinalChunk);
|
||||
|
|
|
@ -370,7 +370,6 @@ protected:
|
|||
nsIContentSink* mSink;
|
||||
nsIParserFilter* mParserFilter;
|
||||
PRBool mDTDVerification;
|
||||
PRBool mParserTerminated;
|
||||
nsString mCommand;
|
||||
PRInt32 mStreamStatus;
|
||||
nsITokenObserver* mTokenObserver;
|
||||
|
|
|
@ -366,3 +366,17 @@ nsITokenRecycler* CValidDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult CValidDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
|
@ -231,6 +231,18 @@ class CValidDTD : public nsIDTD {
|
|||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -467,6 +467,21 @@ nsITokenRecycler* CViewSourceHTML::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult CViewSourceHTML::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the preferred tokenizer for use by this DTD.
|
||||
* @update gess12/28/98
|
||||
|
|
|
@ -214,6 +214,18 @@ class CViewSourceHTML: public nsIDTD {
|
|||
*/
|
||||
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -320,6 +320,21 @@ nsITokenRecycler* CWellFormedDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult CWellFormedDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the preferred tokenizer for use by this DTD.
|
||||
* @update gess12/28/98
|
||||
|
|
|
@ -216,6 +216,18 @@ class CWellFormedDTD : public nsIDTD {
|
|||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -1556,6 +1556,21 @@ nsITokenRecycler* nsXIFDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult nsXIFDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the attributes for this node, and add then into
|
||||
* the node.
|
||||
|
|
|
@ -254,6 +254,18 @@ class nsXIFDTD : public nsIDTD {
|
|||
*/
|
||||
virtual PRBool Verify(nsString& aURLRef,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -347,6 +347,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0), mSkippedContent(0), mShared
|
|||
mComputedCRC32=0;
|
||||
mExpectedCRC32=0;
|
||||
mSaveBadTokens = PR_FALSE;
|
||||
mDTDState=NS_OK;
|
||||
// DebugDumpContainmentRules2(*this,"c:/temp/DTDRules.new","New CNavDTD Containment Rules");
|
||||
#ifdef RICKG_DEBUG
|
||||
nsHTMLElement::DebugDumpContainment("c:/temp/rules.new","ElementTable Rules");
|
||||
|
@ -542,11 +543,17 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke
|
|||
NS_ADDREF(mSink);
|
||||
gRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler();
|
||||
while(NS_SUCCEEDED(result)){
|
||||
if(mDTDState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||
CToken* theToken=mTokenizer->PopToken();
|
||||
if(theToken) {
|
||||
result=HandleToken(theToken,aParser);
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else {
|
||||
result=mDTDState;
|
||||
break;
|
||||
}
|
||||
}//while
|
||||
mTokenizer=oldTokenizer;
|
||||
NS_IF_RELEASE(mSink);
|
||||
|
@ -636,6 +643,7 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This big dispatch method is used to route token handler calls to the right place.
|
||||
* What's wrong with it? This table, and the dispatch methods themselves need to be
|
||||
|
|
|
@ -369,6 +369,18 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
|
|||
*/
|
||||
virtual PRInt32 GetTopmostIndexOf(eHTMLTags aTagSet[],PRInt32 aCount) const;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void) { return mDTDState=NS_ERROR_HTMLPARSER_STOPPARSING; }
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
@ -520,6 +532,7 @@ protected:
|
|||
PRBool mHasOpenBody;
|
||||
PRBool mHadFrameset;
|
||||
PRBool mHadBody;
|
||||
PRBool mDTDState;
|
||||
nsString mFilename;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
PRInt32 mLineNumber;
|
||||
|
|
|
@ -478,6 +478,21 @@ nsITokenRecycler* CRtfDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult CRtfDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Heres's the RTFControlWord subclass...
|
||||
***************************************************************/
|
||||
|
|
|
@ -338,6 +338,18 @@ class CRtfDTD : public nsIDTD {
|
|||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -279,6 +279,20 @@ nsITokenRecycler* nsExpatDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult nsExpatDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the callbacks for the expat parser
|
||||
|
|
|
@ -213,6 +213,18 @@ class nsExpatDTD : public nsIDTD {
|
|||
*/
|
||||
virtual PRBool IsContainer(PRInt32 aTag) const;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -200,6 +200,18 @@ class nsIDTD : public nsISupports {
|
|||
*/
|
||||
virtual PRBool Verify(nsString& aURLRef,nsIParser* aParser)=0;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void) = 0;
|
||||
|
||||
/* XXX Temporary measure, pending further work by RickG */
|
||||
|
||||
/**
|
||||
|
@ -207,6 +219,7 @@ class nsIDTD : public nsISupports {
|
|||
* become useful.
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const =0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -191,7 +191,6 @@ nsParser::nsParser(nsITokenObserver* anObserver) : mCommand(""), mUnusedInput(""
|
|||
mTokenObserver=anObserver;
|
||||
mStreamStatus=0;
|
||||
mDTDVerification=PR_FALSE;
|
||||
mParserTerminated=PR_FALSE;
|
||||
mCharsetSource=kCharsetUninitialized;
|
||||
mInternalState=NS_OK;
|
||||
}
|
||||
|
@ -585,8 +584,11 @@ void nsParser::SetUnusedInput(nsString& aBuffer) {
|
|||
* @return should return NS_OK once implemented
|
||||
*/
|
||||
nsresult nsParser::Terminate(void){
|
||||
mParserTerminated=PR_TRUE;
|
||||
return NS_OK;
|
||||
nsresult result=NS_OK;
|
||||
if(mParserContext && mParserContext->mDTD)
|
||||
result=mParserContext->mDTD->Terminate();
|
||||
mInternalState=result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -612,7 +614,12 @@ PRBool nsParser::EnableParser(PRBool aState){
|
|||
|
||||
// If we're reenabling the parser
|
||||
mParserContext->mParserEnabled=aState;
|
||||
nsresult result=(aState) ? ResumeParse() : NS_OK;
|
||||
nsresult result=NS_OK;
|
||||
if(aState) {
|
||||
result=ResumeParse();
|
||||
if(result!=NS_OK)
|
||||
result=mInternalState;
|
||||
}
|
||||
|
||||
// Release reference if we added one at the top of this routine
|
||||
NS_IF_RELEASE(me);
|
||||
|
@ -870,7 +877,7 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag
|
|||
nsresult nsParser::ResumeParse(nsIDTD* aDefaultDTD, PRBool aIsFinalChunk) {
|
||||
|
||||
nsresult result=NS_OK;
|
||||
if(mParserContext->mParserEnabled && !mParserTerminated) {
|
||||
if(mParserContext->mParserEnabled && mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||
result=WillBuildModel(mParserContext->mScanner->GetFilename(),aDefaultDTD);
|
||||
if(mParserContext->mDTD) {
|
||||
mParserContext->mDTD->WillResumeParse();
|
||||
|
@ -878,9 +885,12 @@ nsresult nsParser::ResumeParse(nsIDTD* aDefaultDTD, PRBool aIsFinalChunk) {
|
|||
result=Tokenize(aIsFinalChunk);
|
||||
result=BuildModel();
|
||||
|
||||
if((!mParserContext->mMultipart) || (mParserTerminated) ||
|
||||
if(result==NS_ERROR_HTMLPARSER_STOPPARSING) mInternalState=result;
|
||||
|
||||
if((!mParserContext->mMultipart) || (mInternalState==NS_ERROR_HTMLPARSER_STOPPARSING) ||
|
||||
((eOnStop==mParserContext->mStreamListenerState) && (NS_OK==result))){
|
||||
DidBuildModel(mStreamStatus);
|
||||
return mInternalState;
|
||||
}
|
||||
else {
|
||||
mParserContext->mDTD->WillInterruptParse();
|
||||
|
@ -928,11 +938,8 @@ nsresult nsParser::BuildModel() {
|
|||
}
|
||||
|
||||
nsIDTD* theRootDTD=theRootContext->mDTD;
|
||||
if(theRootDTD) {
|
||||
if(theRootDTD)
|
||||
result=theRootDTD->BuildModel(this,theTokenizer,mTokenObserver,mSink);
|
||||
if(NS_ERROR_HTMLPARSER_STOPPARSING==result)
|
||||
Terminate();
|
||||
}
|
||||
}
|
||||
else{
|
||||
mInternalState=result=NS_ERROR_HTMLPARSER_BADTOKENIZER;
|
||||
|
@ -1254,7 +1261,7 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){
|
|||
break;
|
||||
}
|
||||
else if(NS_ERROR_HTMLPARSER_STOPPARSING==result)
|
||||
Terminate();
|
||||
return Terminate();
|
||||
}
|
||||
}
|
||||
DidTokenize(aIsFinalChunk);
|
||||
|
|
|
@ -370,7 +370,6 @@ protected:
|
|||
nsIContentSink* mSink;
|
||||
nsIParserFilter* mParserFilter;
|
||||
PRBool mDTDVerification;
|
||||
PRBool mParserTerminated;
|
||||
nsString mCommand;
|
||||
PRInt32 mStreamStatus;
|
||||
nsITokenObserver* mTokenObserver;
|
||||
|
|
|
@ -366,3 +366,17 @@ nsITokenRecycler* CValidDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult CValidDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
|
@ -231,6 +231,18 @@ class CValidDTD : public nsIDTD {
|
|||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -467,6 +467,21 @@ nsITokenRecycler* CViewSourceHTML::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult CViewSourceHTML::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the preferred tokenizer for use by this DTD.
|
||||
* @update gess12/28/98
|
||||
|
|
|
@ -214,6 +214,18 @@ class CViewSourceHTML: public nsIDTD {
|
|||
*/
|
||||
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -320,6 +320,21 @@ nsITokenRecycler* CWellFormedDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult CWellFormedDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the preferred tokenizer for use by this DTD.
|
||||
* @update gess12/28/98
|
||||
|
|
|
@ -216,6 +216,18 @@ class CWellFormedDTD : public nsIDTD {
|
|||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
|
@ -1556,6 +1556,21 @@ nsITokenRecycler* nsXIFDTD::GetTokenRecycler(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsresult nsXIFDTD::Terminate(void)
|
||||
{
|
||||
return NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the attributes for this node, and add then into
|
||||
* the node.
|
||||
|
|
|
@ -254,6 +254,18 @@ class nsXIFDTD : public nsIDTD {
|
|||
*/
|
||||
virtual PRBool Verify(nsString& aURLRef,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void);
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
|
|
Загрузка…
Ссылка в новой задаче