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"
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(CParserContext);
|
||||
|
||||
/**
|
||||
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
|
||||
* using it is the parser.
|
||||
@ -33,7 +34,12 @@ MOZ_DECL_CTOR_COUNTER(CParserContext);
|
||||
* @param aKey
|
||||
* @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()
|
||||
//,mTokenDeque(gTokenDeallocator)
|
||||
{
|
||||
@ -45,9 +51,10 @@ CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver*
|
||||
mListener=aListener;
|
||||
NS_IF_ADDREF(mListener);
|
||||
mParseMode=eParseMode_unknown;
|
||||
mAutoDetectStatus=eUnknownDetect;
|
||||
mAutoDetectStatus=aStatus;
|
||||
mTransferBuffer=0;
|
||||
mDTD=0;
|
||||
mDTD=aDTD;
|
||||
NS_IF_ADDREF(mDTD);
|
||||
mTransferBufferSize=eTransferBufferSize;
|
||||
mParserEnabled=PR_TRUE;
|
||||
mStreamListenerState=eNone;
|
||||
@ -56,6 +63,41 @@ CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver*
|
||||
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
|
||||
@ -66,11 +108,14 @@ CParserContext::~CParserContext(){
|
||||
|
||||
MOZ_COUNT_DTOR(CParserContext);
|
||||
|
||||
mRefCount--;
|
||||
if(0==mRefCount) {
|
||||
if(mScanner)
|
||||
delete mScanner;
|
||||
|
||||
if(mTransferBuffer)
|
||||
delete [] mTransferBuffer;
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mDTD);
|
||||
|
||||
|
@ -52,8 +52,12 @@ public:
|
||||
CParserContext( nsScanner* aScanner,
|
||||
void* aKey=0,
|
||||
nsIStreamObserver* aListener=0,
|
||||
nsIDTD *aDTD=0,
|
||||
eAutoDetectResult aStatus=eUnknownDetect,
|
||||
PRBool aCopyUnused=PR_FALSE);
|
||||
|
||||
CParserContext( const CParserContext& aContext);
|
||||
|
||||
|
||||
~CParserContext();
|
||||
|
||||
@ -64,6 +68,7 @@ public:
|
||||
PRBool mMultipart;
|
||||
eContextType mContextType;
|
||||
eAutoDetectResult mAutoDetectStatus;
|
||||
PRInt32 mRefCount;
|
||||
|
||||
nsString mSourceType;
|
||||
|
||||
|
@ -810,6 +810,9 @@ nsresult nsParser::EnableParser(PRBool aState){
|
||||
if(mParserContext) {
|
||||
mParserContext->mParserEnabled=aState;
|
||||
if(aState) {
|
||||
|
||||
//printf(" Re-enable parser\n");
|
||||
|
||||
result=ResumeParse();
|
||||
if(result!=NS_OK)
|
||||
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
|
||||
* @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
|
||||
// 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
|
||||
// till we're completely done.
|
||||
NS_ADDREF(me);
|
||||
|
||||
if(aSourceBuffer.Length() || mUnusedInput.Length()) {
|
||||
mDTDVerification=aVerifyEnabled;
|
||||
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...
|
||||
|
||||
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) {
|
||||
PushContext(*pc);
|
||||
|
||||
@ -962,21 +979,21 @@ nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString
|
||||
pc->mContextType=CParserContext::eCTString;
|
||||
pc->mSourceType=aContentType;
|
||||
mUnusedInput.Truncate(0);
|
||||
|
||||
//printf("Parse(string) iterate: %i",PR_FALSE);
|
||||
pc->mScanner->Append(aSourceBuffer);
|
||||
result=ResumeParse(PR_FALSE);
|
||||
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(me);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
pc=mParserContext;
|
||||
pc->mScanner->Append(mUnusedInput);
|
||||
mParserContext->mScanner->Append(aSourceBuffer);
|
||||
}
|
||||
|
||||
pc->mScanner->Append(aSourceBuffer);
|
||||
|
||||
result=ResumeParse(PR_FALSE);
|
||||
|
||||
}//if
|
||||
NS_RELEASE(me);
|
||||
return result;
|
||||
@ -1119,6 +1136,9 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag
|
||||
*/
|
||||
nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
||||
|
||||
//printf(" Resume %i, prev-context: %p\n",allowIteration,mParserContext->mPrevContext);
|
||||
|
||||
|
||||
nsresult result=NS_OK;
|
||||
|
||||
if(mParserContext->mParserEnabled && mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||
@ -1131,10 +1151,11 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
||||
if(mParserContext->mDTD) {
|
||||
|
||||
mParserContext->mDTD->WillResumeParse();
|
||||
PRBool theIterationIsOk=(allowIteration||(!mParserContext->mPrevContext));
|
||||
|
||||
while((result==NS_OK) && (theIterationIsOk)) {
|
||||
PRBool theFirstTime=PR_TRUE;
|
||||
PRBool theIterationIsOk=(allowIteration || (!mParserContext->mPrevContext));
|
||||
|
||||
while((result==NS_OK) && (theFirstTime || theIterationIsOk)) {
|
||||
theFirstTime=PR_FALSE;
|
||||
if(mUnusedInput.Length()>0) {
|
||||
if(mParserContext->mScanner) {
|
||||
// -- Ref: Bug# 22485 --
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsToken.h"
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(CParserContext);
|
||||
|
||||
/**
|
||||
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
|
||||
* using it is the parser.
|
||||
@ -33,7 +34,12 @@ MOZ_DECL_CTOR_COUNTER(CParserContext);
|
||||
* @param aKey
|
||||
* @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()
|
||||
//,mTokenDeque(gTokenDeallocator)
|
||||
{
|
||||
@ -45,9 +51,10 @@ CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver*
|
||||
mListener=aListener;
|
||||
NS_IF_ADDREF(mListener);
|
||||
mParseMode=eParseMode_unknown;
|
||||
mAutoDetectStatus=eUnknownDetect;
|
||||
mAutoDetectStatus=aStatus;
|
||||
mTransferBuffer=0;
|
||||
mDTD=0;
|
||||
mDTD=aDTD;
|
||||
NS_IF_ADDREF(mDTD);
|
||||
mTransferBufferSize=eTransferBufferSize;
|
||||
mParserEnabled=PR_TRUE;
|
||||
mStreamListenerState=eNone;
|
||||
@ -56,6 +63,41 @@ CParserContext::CParserContext(nsScanner* aScanner,void* aKey,nsIStreamObserver*
|
||||
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
|
||||
@ -66,11 +108,14 @@ CParserContext::~CParserContext(){
|
||||
|
||||
MOZ_COUNT_DTOR(CParserContext);
|
||||
|
||||
mRefCount--;
|
||||
if(0==mRefCount) {
|
||||
if(mScanner)
|
||||
delete mScanner;
|
||||
|
||||
if(mTransferBuffer)
|
||||
delete [] mTransferBuffer;
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mDTD);
|
||||
|
||||
|
@ -52,8 +52,12 @@ public:
|
||||
CParserContext( nsScanner* aScanner,
|
||||
void* aKey=0,
|
||||
nsIStreamObserver* aListener=0,
|
||||
nsIDTD *aDTD=0,
|
||||
eAutoDetectResult aStatus=eUnknownDetect,
|
||||
PRBool aCopyUnused=PR_FALSE);
|
||||
|
||||
CParserContext( const CParserContext& aContext);
|
||||
|
||||
|
||||
~CParserContext();
|
||||
|
||||
@ -64,6 +68,7 @@ public:
|
||||
PRBool mMultipart;
|
||||
eContextType mContextType;
|
||||
eAutoDetectResult mAutoDetectStatus;
|
||||
PRInt32 mRefCount;
|
||||
|
||||
nsString mSourceType;
|
||||
|
||||
|
@ -810,6 +810,9 @@ nsresult nsParser::EnableParser(PRBool aState){
|
||||
if(mParserContext) {
|
||||
mParserContext->mParserEnabled=aState;
|
||||
if(aState) {
|
||||
|
||||
//printf(" Re-enable parser\n");
|
||||
|
||||
result=ResumeParse();
|
||||
if(result!=NS_OK)
|
||||
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
|
||||
* @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
|
||||
// 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
|
||||
// till we're completely done.
|
||||
NS_ADDREF(me);
|
||||
|
||||
if(aSourceBuffer.Length() || mUnusedInput.Length()) {
|
||||
mDTDVerification=aVerifyEnabled;
|
||||
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...
|
||||
|
||||
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) {
|
||||
PushContext(*pc);
|
||||
|
||||
@ -962,21 +979,21 @@ nsresult nsParser::Parse(const nsString& aSourceBuffer,void* aKey,const nsString
|
||||
pc->mContextType=CParserContext::eCTString;
|
||||
pc->mSourceType=aContentType;
|
||||
mUnusedInput.Truncate(0);
|
||||
|
||||
//printf("Parse(string) iterate: %i",PR_FALSE);
|
||||
pc->mScanner->Append(aSourceBuffer);
|
||||
result=ResumeParse(PR_FALSE);
|
||||
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(me);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
pc=mParserContext;
|
||||
pc->mScanner->Append(mUnusedInput);
|
||||
mParserContext->mScanner->Append(aSourceBuffer);
|
||||
}
|
||||
|
||||
pc->mScanner->Append(aSourceBuffer);
|
||||
|
||||
result=ResumeParse(PR_FALSE);
|
||||
|
||||
}//if
|
||||
NS_RELEASE(me);
|
||||
return result;
|
||||
@ -1119,6 +1136,9 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag
|
||||
*/
|
||||
nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
||||
|
||||
//printf(" Resume %i, prev-context: %p\n",allowIteration,mParserContext->mPrevContext);
|
||||
|
||||
|
||||
nsresult result=NS_OK;
|
||||
|
||||
if(mParserContext->mParserEnabled && mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||
@ -1131,10 +1151,11 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
|
||||
if(mParserContext->mDTD) {
|
||||
|
||||
mParserContext->mDTD->WillResumeParse();
|
||||
PRBool theIterationIsOk=(allowIteration||(!mParserContext->mPrevContext));
|
||||
|
||||
while((result==NS_OK) && (theIterationIsOk)) {
|
||||
PRBool theFirstTime=PR_TRUE;
|
||||
PRBool theIterationIsOk=(allowIteration || (!mParserContext->mPrevContext));
|
||||
|
||||
while((result==NS_OK) && (theFirstTime || theIterationIsOk)) {
|
||||
theFirstTime=PR_FALSE;
|
||||
if(mUnusedInput.Length()>0) {
|
||||
if(mParserContext->mScanner) {
|
||||
// -- Ref: Bug# 22485 --
|
||||
|
Loading…
Reference in New Issue
Block a user