mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
fix to PDT+bug 32022; r=harish, rickg, markA, troy; a=jar
This commit is contained in:
parent
078ee91429
commit
c5e420c645
@ -25,6 +25,7 @@
|
|||||||
#include "nsToken.h"
|
#include "nsToken.h"
|
||||||
|
|
||||||
MOZ_DECL_CTOR_COUNTER(CParserContext);
|
MOZ_DECL_CTOR_COUNTER(CParserContext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
|
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
|
||||||
* using it is the parser.
|
* using it is the parser.
|
||||||
@ -33,7 +34,12 @@ MOZ_DECL_CTOR_COUNTER(CParserContext);
|
|||||||
* @param aKey
|
* @param aKey
|
||||||
* @param aListener
|
* @param aListener
|
||||||
*/
|
*/
|
||||||
CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver* aListener,PRBool aCopyUnused) :
|
CParserContext::CParserContext(nsScanner* aScanner,
|
||||||
|
void *aKey,
|
||||||
|
nsIStreamObserver* aListener,
|
||||||
|
nsIDTD *aDTD,
|
||||||
|
eAutoDetectResult aStatus,
|
||||||
|
PRBool aCopyUnused) :
|
||||||
mSourceType()
|
mSourceType()
|
||||||
//,mTokenDeque(gTokenDeallocator)
|
//,mTokenDeque(gTokenDeallocator)
|
||||||
{
|
{
|
||||||
@ -45,9 +51,10 @@ CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver*
|
|||||||
mListener=aListener;
|
mListener=aListener;
|
||||||
NS_IF_ADDREF(mListener);
|
NS_IF_ADDREF(mListener);
|
||||||
mParseMode=eParseMode_unknown;
|
mParseMode=eParseMode_unknown;
|
||||||
mAutoDetectStatus=eUnknownDetect;
|
mAutoDetectStatus=aStatus;
|
||||||
mTransferBuffer=0;
|
mTransferBuffer=0;
|
||||||
mDTD=0;
|
mDTD=aDTD;
|
||||||
|
NS_IF_ADDREF(mDTD);
|
||||||
mTransferBufferSize=eTransferBufferSize;
|
mTransferBufferSize=eTransferBufferSize;
|
||||||
mParserEnabled=PR_TRUE;
|
mParserEnabled=PR_TRUE;
|
||||||
mStreamListenerState=eNone;
|
mStreamListenerState=eNone;
|
||||||
@ -56,6 +63,41 @@ CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver*
|
|||||||
mCopyUnused=aCopyUnused;
|
mCopyUnused=aCopyUnused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
|
||||||
|
* using it is the parser.
|
||||||
|
* @update gess7/23/98
|
||||||
|
* @param aScanner
|
||||||
|
* @param aKey
|
||||||
|
* @param aListener
|
||||||
|
*/
|
||||||
|
CParserContext::CParserContext(const CParserContext &aContext) :
|
||||||
|
mSourceType(aContext.mSourceType)
|
||||||
|
//,mTokenDeque(gTokenDeallocator)
|
||||||
|
{
|
||||||
|
MOZ_COUNT_CTOR(CParserContext);
|
||||||
|
|
||||||
|
mScanner=aContext.mScanner;
|
||||||
|
mKey=aContext.mKey;
|
||||||
|
mPrevContext=0;
|
||||||
|
mListener=aContext.mListener;
|
||||||
|
NS_IF_ADDREF(mListener);
|
||||||
|
|
||||||
|
mParseMode=aContext.mParseMode;
|
||||||
|
mAutoDetectStatus=aContext.mAutoDetectStatus;
|
||||||
|
mTransferBuffer=aContext.mTransferBuffer;
|
||||||
|
mDTD=aContext.mDTD;
|
||||||
|
NS_IF_ADDREF(mDTD);
|
||||||
|
|
||||||
|
mTransferBufferSize=eTransferBufferSize;
|
||||||
|
mParserEnabled=aContext.mParserEnabled;
|
||||||
|
mStreamListenerState=aContext.mStreamListenerState;
|
||||||
|
mMultipart=aContext.mMultipart;
|
||||||
|
mContextType=aContext.mContextType;
|
||||||
|
mCopyUnused;
|
||||||
|
mRefCount=2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor for parser context
|
* Destructor for parser context
|
||||||
@ -66,11 +108,14 @@ CParserContext::~CParserContext(){
|
|||||||
|
|
||||||
MOZ_COUNT_DTOR(CParserContext);
|
MOZ_COUNT_DTOR(CParserContext);
|
||||||
|
|
||||||
|
mRefCount--;
|
||||||
|
if(0==mRefCount) {
|
||||||
if(mScanner)
|
if(mScanner)
|
||||||
delete mScanner;
|
delete mScanner;
|
||||||
|
|
||||||
if(mTransferBuffer)
|
if(mTransferBuffer)
|
||||||
delete [] mTransferBuffer;
|
delete [] mTransferBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IF_RELEASE(mDTD);
|
NS_IF_RELEASE(mDTD);
|
||||||
|
|
||||||
|
@ -52,8 +52,12 @@ public:
|
|||||||
CParserContext( nsScanner* aScanner,
|
CParserContext( nsScanner* aScanner,
|
||||||
void* aKey=0,
|
void* aKey=0,
|
||||||
nsIStreamObserver* aListener=0,
|
nsIStreamObserver* aListener=0,
|
||||||
|
nsIDTD *aDTD=0,
|
||||||
|
eAutoDetectResult aStatus=eUnknownDetect,
|
||||||
PRBool aCopyUnused=PR_FALSE);
|
PRBool aCopyUnused=PR_FALSE);
|
||||||
|
|
||||||
|
CParserContext( const CParserContext& aContext);
|
||||||
|
|
||||||
|
|
||||||
~CParserContext();
|
~CParserContext();
|
||||||
|
|
||||||
@ -64,6 +68,7 @@ public:
|
|||||||
PRBool mMultipart;
|
PRBool mMultipart;
|
||||||
eContextType mContextType;
|
eContextType mContextType;
|
||||||
eAutoDetectResult mAutoDetectStatus;
|
eAutoDetectResult mAutoDetectStatus;
|
||||||
|
PRInt32 mRefCount;
|
||||||
|
|
||||||
nsString mSourceType;
|
nsString mSourceType;
|
||||||
|
|
||||||
|
@ -810,6 +810,9 @@ nsresult nsParser::EnableParser(PRBool aState){
|
|||||||
if(mParserContext) {
|
if(mParserContext) {
|
||||||
mParserContext->mParserEnabled=aState;
|
mParserContext->mParserEnabled=aState;
|
||||||
if(aState) {
|
if(aState) {
|
||||||
|
|
||||||
|
//printf(" Re-enable parser\n");
|
||||||
|
|
||||||
result=ResumeParse();
|
result=ResumeParse();
|
||||||
if(result!=NS_OK)
|
if(result!=NS_OK)
|
||||||
result=mInternalState;
|
result=mInternalState;
|
||||||
@ -926,7 +929,8 @@ nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aK
|
|||||||
* @param aContentType tells us what type of content to expect in the given string
|
* @param aContentType 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 nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aVerifyEnabled,PRBool aLastCall,eParseMode aMode){
|
nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString&
|
||||||
|
aContentType,PRBool aVerifyEnabled,PRBool aLastCall,eParseMode 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!
|
||||||
@ -941,6 +945,7 @@ nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString
|
|||||||
// Maintain a reference to ourselves so we don't go away
|
// Maintain a reference to ourselves so we don't go away
|
||||||
// till we're completely done.
|
// till we're completely done.
|
||||||
NS_ADDREF(me);
|
NS_ADDREF(me);
|
||||||
|
|
||||||
if(aSourceBuffer.Length() || mUnusedInput.Length()) {
|
if(aSourceBuffer.Length() || mUnusedInput.Length()) {
|
||||||
mDTDVerification=aVerifyEnabled;
|
mDTDVerification=aVerifyEnabled;
|
||||||
CParserContext* pc=0;
|
CParserContext* pc=0;
|
||||||
@ -949,7 +954,19 @@ nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString
|
|||||||
//only make a new context if we dont have one, OR if we do, but has a different context key...
|
//only make a new context if we dont have one, OR if we do, but has a different context key...
|
||||||
|
|
||||||
nsScanner* theScanner=new nsScanner(mUnusedInput,mCharset,mCharsetSource);
|
nsScanner* theScanner=new nsScanner(mUnusedInput,mCharset,mCharsetSource);
|
||||||
pc=new CParserContext(theScanner,aKey, 0, aLastCall);
|
nsIDTD *theDTD=0;
|
||||||
|
eAutoDetectResult theStatus=eUnknownDetect;
|
||||||
|
|
||||||
|
if(mParserContext && (mParserContext->mSourceType==aContentType)) {
|
||||||
|
theDTD=mParserContext->mDTD;
|
||||||
|
theStatus=mParserContext->mAutoDetectStatus;
|
||||||
|
|
||||||
|
//added this to fix bug 32022.
|
||||||
|
}
|
||||||
|
|
||||||
|
pc=new CParserContext(theScanner,aKey, 0,theDTD,theStatus,aLastCall);
|
||||||
|
|
||||||
|
|
||||||
if(pc && theScanner) {
|
if(pc && theScanner) {
|
||||||
PushContext(*pc);
|
PushContext(*pc);
|
||||||
|
|
||||||
@ -962,21 +979,21 @@ nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString
|
|||||||
pc->mContextType=CParserContext::eCTString;
|
pc->mContextType=CParserContext::eCTString;
|
||||||
pc->mSourceType=aContentType;
|
pc->mSourceType=aContentType;
|
||||||
mUnusedInput.Truncate(0);
|
mUnusedInput.Truncate(0);
|
||||||
|
|
||||||
|
//printf("Parse(string) iterate: %i",PR_FALSE);
|
||||||
|
pc->mScanner->Append(aSourceBuffer);
|
||||||
|
result=ResumeParse(PR_FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NS_RELEASE(me);
|
NS_RELEASE(me);
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pc=mParserContext;
|
mParserContext->mScanner->Append(aSourceBuffer);
|
||||||
pc->mScanner->Append(mUnusedInput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pc->mScanner->Append(aSourceBuffer);
|
|
||||||
|
|
||||||
result=ResumeParse(PR_FALSE);
|
|
||||||
|
|
||||||
}//if
|
}//if
|
||||||
NS_RELEASE(me);
|
NS_RELEASE(me);
|
||||||
return result;
|
return result;
|
||||||
@ -1119,6 +1136,9 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag
|
|||||||
*/
|
*/
|
||||||
nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
||||||
|
|
||||||
|
//printf(" Resume %i, prev-context: %p\n",allowIteration,mParserContext->mPrevContext);
|
||||||
|
|
||||||
|
|
||||||
nsresult result=NS_OK;
|
nsresult result=NS_OK;
|
||||||
|
|
||||||
if(mParserContext->mParserEnabled && mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
if(mParserContext->mParserEnabled && mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||||
@ -1131,10 +1151,11 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
|||||||
if(mParserContext->mDTD) {
|
if(mParserContext->mDTD) {
|
||||||
|
|
||||||
mParserContext->mDTD->WillResumeParse();
|
mParserContext->mDTD->WillResumeParse();
|
||||||
PRBool theIterationIsOk=(allowIteration||(!mParserContext->mPrevContext));
|
PRBool theFirstTime=PR_TRUE;
|
||||||
|
PRBool theIterationIsOk=(allowIteration || (!mParserContext->mPrevContext));
|
||||||
while((result==NS_OK) && (theIterationIsOk)) {
|
|
||||||
|
|
||||||
|
while((result==NS_OK) && (theFirstTime || theIterationIsOk)) {
|
||||||
|
theFirstTime=PR_FALSE;
|
||||||
if(mUnusedInput.Length()>0) {
|
if(mUnusedInput.Length()>0) {
|
||||||
if(mParserContext->mScanner) {
|
if(mParserContext->mScanner) {
|
||||||
// -- Ref: Bug# 22485 --
|
// -- Ref: Bug# 22485 --
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "nsToken.h"
|
#include "nsToken.h"
|
||||||
|
|
||||||
MOZ_DECL_CTOR_COUNTER(CParserContext);
|
MOZ_DECL_CTOR_COUNTER(CParserContext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
|
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
|
||||||
* using it is the parser.
|
* using it is the parser.
|
||||||
@ -33,7 +34,12 @@ MOZ_DECL_CTOR_COUNTER(CParserContext);
|
|||||||
* @param aKey
|
* @param aKey
|
||||||
* @param aListener
|
* @param aListener
|
||||||
*/
|
*/
|
||||||
CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver* aListener,PRBool aCopyUnused) :
|
CParserContext::CParserContext(nsScanner* aScanner,
|
||||||
|
void *aKey,
|
||||||
|
nsIStreamObserver* aListener,
|
||||||
|
nsIDTD *aDTD,
|
||||||
|
eAutoDetectResult aStatus,
|
||||||
|
PRBool aCopyUnused) :
|
||||||
mSourceType()
|
mSourceType()
|
||||||
//,mTokenDeque(gTokenDeallocator)
|
//,mTokenDeque(gTokenDeallocator)
|
||||||
{
|
{
|
||||||
@ -45,9 +51,10 @@ CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver*
|
|||||||
mListener=aListener;
|
mListener=aListener;
|
||||||
NS_IF_ADDREF(mListener);
|
NS_IF_ADDREF(mListener);
|
||||||
mParseMode=eParseMode_unknown;
|
mParseMode=eParseMode_unknown;
|
||||||
mAutoDetectStatus=eUnknownDetect;
|
mAutoDetectStatus=aStatus;
|
||||||
mTransferBuffer=0;
|
mTransferBuffer=0;
|
||||||
mDTD=0;
|
mDTD=aDTD;
|
||||||
|
NS_IF_ADDREF(mDTD);
|
||||||
mTransferBufferSize=eTransferBufferSize;
|
mTransferBufferSize=eTransferBufferSize;
|
||||||
mParserEnabled=PR_TRUE;
|
mParserEnabled=PR_TRUE;
|
||||||
mStreamListenerState=eNone;
|
mStreamListenerState=eNone;
|
||||||
@ -56,6 +63,41 @@ CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver*
|
|||||||
mCopyUnused=aCopyUnused;
|
mCopyUnused=aCopyUnused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
|
||||||
|
* using it is the parser.
|
||||||
|
* @update gess7/23/98
|
||||||
|
* @param aScanner
|
||||||
|
* @param aKey
|
||||||
|
* @param aListener
|
||||||
|
*/
|
||||||
|
CParserContext::CParserContext(const CParserContext &aContext) :
|
||||||
|
mSourceType(aContext.mSourceType)
|
||||||
|
//,mTokenDeque(gTokenDeallocator)
|
||||||
|
{
|
||||||
|
MOZ_COUNT_CTOR(CParserContext);
|
||||||
|
|
||||||
|
mScanner=aContext.mScanner;
|
||||||
|
mKey=aContext.mKey;
|
||||||
|
mPrevContext=0;
|
||||||
|
mListener=aContext.mListener;
|
||||||
|
NS_IF_ADDREF(mListener);
|
||||||
|
|
||||||
|
mParseMode=aContext.mParseMode;
|
||||||
|
mAutoDetectStatus=aContext.mAutoDetectStatus;
|
||||||
|
mTransferBuffer=aContext.mTransferBuffer;
|
||||||
|
mDTD=aContext.mDTD;
|
||||||
|
NS_IF_ADDREF(mDTD);
|
||||||
|
|
||||||
|
mTransferBufferSize=eTransferBufferSize;
|
||||||
|
mParserEnabled=aContext.mParserEnabled;
|
||||||
|
mStreamListenerState=aContext.mStreamListenerState;
|
||||||
|
mMultipart=aContext.mMultipart;
|
||||||
|
mContextType=aContext.mContextType;
|
||||||
|
mCopyUnused;
|
||||||
|
mRefCount=2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor for parser context
|
* Destructor for parser context
|
||||||
@ -66,11 +108,14 @@ CParserContext::~CParserContext(){
|
|||||||
|
|
||||||
MOZ_COUNT_DTOR(CParserContext);
|
MOZ_COUNT_DTOR(CParserContext);
|
||||||
|
|
||||||
|
mRefCount--;
|
||||||
|
if(0==mRefCount) {
|
||||||
if(mScanner)
|
if(mScanner)
|
||||||
delete mScanner;
|
delete mScanner;
|
||||||
|
|
||||||
if(mTransferBuffer)
|
if(mTransferBuffer)
|
||||||
delete [] mTransferBuffer;
|
delete [] mTransferBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IF_RELEASE(mDTD);
|
NS_IF_RELEASE(mDTD);
|
||||||
|
|
||||||
|
@ -52,8 +52,12 @@ public:
|
|||||||
CParserContext( nsScanner* aScanner,
|
CParserContext( nsScanner* aScanner,
|
||||||
void* aKey=0,
|
void* aKey=0,
|
||||||
nsIStreamObserver* aListener=0,
|
nsIStreamObserver* aListener=0,
|
||||||
|
nsIDTD *aDTD=0,
|
||||||
|
eAutoDetectResult aStatus=eUnknownDetect,
|
||||||
PRBool aCopyUnused=PR_FALSE);
|
PRBool aCopyUnused=PR_FALSE);
|
||||||
|
|
||||||
|
CParserContext( const CParserContext& aContext);
|
||||||
|
|
||||||
|
|
||||||
~CParserContext();
|
~CParserContext();
|
||||||
|
|
||||||
@ -64,6 +68,7 @@ public:
|
|||||||
PRBool mMultipart;
|
PRBool mMultipart;
|
||||||
eContextType mContextType;
|
eContextType mContextType;
|
||||||
eAutoDetectResult mAutoDetectStatus;
|
eAutoDetectResult mAutoDetectStatus;
|
||||||
|
PRInt32 mRefCount;
|
||||||
|
|
||||||
nsString mSourceType;
|
nsString mSourceType;
|
||||||
|
|
||||||
|
@ -810,6 +810,9 @@ nsresult nsParser::EnableParser(PRBool aState){
|
|||||||
if(mParserContext) {
|
if(mParserContext) {
|
||||||
mParserContext->mParserEnabled=aState;
|
mParserContext->mParserEnabled=aState;
|
||||||
if(aState) {
|
if(aState) {
|
||||||
|
|
||||||
|
//printf(" Re-enable parser\n");
|
||||||
|
|
||||||
result=ResumeParse();
|
result=ResumeParse();
|
||||||
if(result!=NS_OK)
|
if(result!=NS_OK)
|
||||||
result=mInternalState;
|
result=mInternalState;
|
||||||
@ -926,7 +929,8 @@ nsresult nsParser::Parse(nsIInputStream& aStream,PRBool aVerifyEnabled, void* aK
|
|||||||
* @param aContentType tells us what type of content to expect in the given string
|
* @param aContentType 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 nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aVerifyEnabled,PRBool aLastCall,eParseMode aMode){
|
nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString&
|
||||||
|
aContentType,PRBool aVerifyEnabled,PRBool aLastCall,eParseMode 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!
|
||||||
@ -941,6 +945,7 @@ nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString
|
|||||||
// Maintain a reference to ourselves so we don't go away
|
// Maintain a reference to ourselves so we don't go away
|
||||||
// till we're completely done.
|
// till we're completely done.
|
||||||
NS_ADDREF(me);
|
NS_ADDREF(me);
|
||||||
|
|
||||||
if(aSourceBuffer.Length() || mUnusedInput.Length()) {
|
if(aSourceBuffer.Length() || mUnusedInput.Length()) {
|
||||||
mDTDVerification=aVerifyEnabled;
|
mDTDVerification=aVerifyEnabled;
|
||||||
CParserContext* pc=0;
|
CParserContext* pc=0;
|
||||||
@ -949,7 +954,19 @@ nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString
|
|||||||
//only make a new context if we dont have one, OR if we do, but has a different context key...
|
//only make a new context if we dont have one, OR if we do, but has a different context key...
|
||||||
|
|
||||||
nsScanner* theScanner=new nsScanner(mUnusedInput,mCharset,mCharsetSource);
|
nsScanner* theScanner=new nsScanner(mUnusedInput,mCharset,mCharsetSource);
|
||||||
pc=new CParserContext(theScanner,aKey, 0, aLastCall);
|
nsIDTD *theDTD=0;
|
||||||
|
eAutoDetectResult theStatus=eUnknownDetect;
|
||||||
|
|
||||||
|
if(mParserContext && (mParserContext->mSourceType==aContentType)) {
|
||||||
|
theDTD=mParserContext->mDTD;
|
||||||
|
theStatus=mParserContext->mAutoDetectStatus;
|
||||||
|
|
||||||
|
//added this to fix bug 32022.
|
||||||
|
}
|
||||||
|
|
||||||
|
pc=new CParserContext(theScanner,aKey, 0,theDTD,theStatus,aLastCall);
|
||||||
|
|
||||||
|
|
||||||
if(pc && theScanner) {
|
if(pc && theScanner) {
|
||||||
PushContext(*pc);
|
PushContext(*pc);
|
||||||
|
|
||||||
@ -962,21 +979,21 @@ nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString
|
|||||||
pc->mContextType=CParserContext::eCTString;
|
pc->mContextType=CParserContext::eCTString;
|
||||||
pc->mSourceType=aContentType;
|
pc->mSourceType=aContentType;
|
||||||
mUnusedInput.Truncate(0);
|
mUnusedInput.Truncate(0);
|
||||||
|
|
||||||
|
//printf("Parse(string) iterate: %i",PR_FALSE);
|
||||||
|
pc->mScanner->Append(aSourceBuffer);
|
||||||
|
result=ResumeParse(PR_FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NS_RELEASE(me);
|
NS_RELEASE(me);
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pc=mParserContext;
|
mParserContext->mScanner->Append(aSourceBuffer);
|
||||||
pc->mScanner->Append(mUnusedInput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pc->mScanner->Append(aSourceBuffer);
|
|
||||||
|
|
||||||
result=ResumeParse(PR_FALSE);
|
|
||||||
|
|
||||||
}//if
|
}//if
|
||||||
NS_RELEASE(me);
|
NS_RELEASE(me);
|
||||||
return result;
|
return result;
|
||||||
@ -1119,6 +1136,9 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag
|
|||||||
*/
|
*/
|
||||||
nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
||||||
|
|
||||||
|
//printf(" Resume %i, prev-context: %p\n",allowIteration,mParserContext->mPrevContext);
|
||||||
|
|
||||||
|
|
||||||
nsresult result=NS_OK;
|
nsresult result=NS_OK;
|
||||||
|
|
||||||
if(mParserContext->mParserEnabled && mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
if(mParserContext->mParserEnabled && mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||||
@ -1131,10 +1151,11 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
|||||||
if(mParserContext->mDTD) {
|
if(mParserContext->mDTD) {
|
||||||
|
|
||||||
mParserContext->mDTD->WillResumeParse();
|
mParserContext->mDTD->WillResumeParse();
|
||||||
PRBool theIterationIsOk=(allowIteration||(!mParserContext->mPrevContext));
|
PRBool theFirstTime=PR_TRUE;
|
||||||
|
PRBool theIterationIsOk=(allowIteration || (!mParserContext->mPrevContext));
|
||||||
while((result==NS_OK) && (theIterationIsOk)) {
|
|
||||||
|
|
||||||
|
while((result==NS_OK) && (theFirstTime || theIterationIsOk)) {
|
||||||
|
theFirstTime=PR_FALSE;
|
||||||
if(mUnusedInput.Length()>0) {
|
if(mUnusedInput.Length()>0) {
|
||||||
if(mParserContext->mScanner) {
|
if(mParserContext->mScanner) {
|
||||||
// -- Ref: Bug# 22485 --
|
// -- Ref: Bug# 22485 --
|
||||||
|
Loading…
Reference in New Issue
Block a user