Fix line numbers in html. b=111576, r=heikki, sr=jst, a=asa,chofmann
This commit is contained in:
@@ -1222,7 +1222,9 @@ nsresult nsParser::WillBuildModel(nsString& aFilename){
|
||||
}
|
||||
|
||||
if(PR_TRUE==FindSuitableDTD(*mParserContext,theBuffer)) {
|
||||
mParserContext->mDTD->WillBuildModel( *mParserContext,mSink);
|
||||
nsITokenizer* tokenizer;
|
||||
mParserContext->GetTokenizer(mParserContext->mDTD->GetType(), tokenizer);
|
||||
mParserContext->mDTD->WillBuildModel(*mParserContext, tokenizer, mSink);
|
||||
}//if
|
||||
}//if
|
||||
}
|
||||
@@ -1548,10 +1550,10 @@ nsresult nsParser::Parse(const nsAString& aSourceBuffer, void* aKey,
|
||||
return result;
|
||||
}
|
||||
|
||||
nsParser* me = this;
|
||||
|
||||
// Maintain a reference to ourselves so we don't go away
|
||||
// till we're completely done.
|
||||
NS_ADDREF(me);
|
||||
nsCOMPtr<nsIParser> kungFuDeathGrip(this);
|
||||
|
||||
if(aSourceBuffer.Length() || mUnusedInput.Length()) {
|
||||
|
||||
@@ -1567,57 +1569,55 @@ nsresult nsParser::Parse(const nsAString& aSourceBuffer, void* aKey,
|
||||
if((!mParserContext) || (mParserContext->mKey!=aKey)) {
|
||||
//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);
|
||||
nsIDTD *theDTD=0;
|
||||
eAutoDetectResult theStatus=eUnknownDetect;
|
||||
nsScanner* theScanner = new nsScanner(mUnusedInput,mCharset,mCharsetSource);
|
||||
NS_ENSURE_TRUE(theScanner, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsIDTD *theDTD = 0;
|
||||
eAutoDetectResult theStatus = eUnknownDetect;
|
||||
|
||||
if (mParserContext && mParserContext->mMimeType==aMimeType) {
|
||||
NS_ASSERTION(mParserContext->mDTD,"How come the DTD is null?"); // Ref. Bug 90379
|
||||
|
||||
if (mParserContext->mDTD) {
|
||||
mParserContext->mDTD->CreateNewInstance(&theDTD); // To fix 32263
|
||||
if (mParserContext) {
|
||||
// To fix bug 32263 we used create a new instance of the DTD!.
|
||||
// All we need is a new tokenizer which now gets created with
|
||||
// a parser context.
|
||||
theDTD = mParserContext->mDTD;
|
||||
theStatus=mParserContext->mAutoDetectStatus;
|
||||
//added this to fix bug 32022.
|
||||
}
|
||||
}
|
||||
|
||||
pc=new CParserContext(theScanner,aKey, mCommand,0,theDTD,theStatus,aLastCall);
|
||||
pc = new CParserContext(theScanner, aKey, mCommand, 0, theDTD, theStatus, aLastCall);
|
||||
NS_ENSURE_TRUE(pc, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if(pc && theScanner) {
|
||||
PushContext(*pc);
|
||||
|
||||
pc->mMultipart=!aLastCall; //by default
|
||||
if (pc->mPrevContext) {
|
||||
pc->mMultipart |= pc->mPrevContext->mMultipart; //if available
|
||||
}
|
||||
|
||||
// start fix bug 40143
|
||||
if(pc->mMultipart) {
|
||||
pc->mStreamListenerState=eOnDataAvail;
|
||||
if(pc->mScanner) pc->mScanner->SetIncremental(PR_TRUE);
|
||||
}
|
||||
else {
|
||||
pc->mStreamListenerState=eOnStop;
|
||||
if(pc->mScanner) pc->mScanner->SetIncremental(PR_FALSE);
|
||||
}
|
||||
// end fix for 40143
|
||||
|
||||
pc->mContextType=CParserContext::eCTString;
|
||||
pc->SetMimeType(aMimeType);
|
||||
pc->mDTDMode=aMode;
|
||||
mUnusedInput.Truncate(0);
|
||||
|
||||
//printf("Parse(string) iterate: %i",PR_FALSE);
|
||||
pc->mScanner->Append(aSourceBuffer);
|
||||
// Do not interrupt document.write() - bug 95487
|
||||
result = ResumeParse(PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
PushContext(*pc);
|
||||
|
||||
pc->mMultipart=!aLastCall; //by default
|
||||
if (pc->mPrevContext) {
|
||||
pc->mMultipart |= pc->mPrevContext->mMultipart; //if available
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(me);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_IF_RELEASE(theDTD);
|
||||
|
||||
// start fix bug 40143
|
||||
if(pc->mMultipart) {
|
||||
pc->mStreamListenerState=eOnDataAvail;
|
||||
if(pc->mScanner) pc->mScanner->SetIncremental(PR_TRUE);
|
||||
}
|
||||
else {
|
||||
pc->mStreamListenerState=eOnStop;
|
||||
if(pc->mScanner) pc->mScanner->SetIncremental(PR_FALSE);
|
||||
}
|
||||
// end fix for 40143
|
||||
|
||||
pc->mContextType=CParserContext::eCTString;
|
||||
pc->SetMimeType(aMimeType);
|
||||
pc->mDTDMode=aMode;
|
||||
mUnusedInput.Truncate(0);
|
||||
|
||||
//printf("Parse(string) iterate: %i",PR_FALSE);
|
||||
pc->mScanner->Append(aSourceBuffer);
|
||||
// Do not interrupt document.write() - bug 95487
|
||||
result = ResumeParse(PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
else {
|
||||
mParserContext->mScanner->Append(aSourceBuffer);
|
||||
@@ -1631,7 +1631,7 @@ nsresult nsParser::Parse(const nsAString& aSourceBuffer, void* aKey,
|
||||
}
|
||||
}
|
||||
}//if
|
||||
NS_RELEASE(me);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1841,33 +1841,33 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk, PRBo
|
||||
* @return error code -- 0 if ok, non-zero if error.
|
||||
*/
|
||||
nsresult nsParser::BuildModel() {
|
||||
|
||||
//nsDequeIterator e=mParserContext->mTokenDeque.End();
|
||||
CParserContext* theRootContext = mParserContext;
|
||||
nsITokenizer* theTokenizer = 0;
|
||||
|
||||
// if(!mParserContext->mCurrentPos)
|
||||
// mParserContext->mCurrentPos=new nsDequeIterator(mParserContext->mTokenDeque.Begin());
|
||||
nsresult result = NS_OK;
|
||||
if (mParserContext) {
|
||||
PRInt32 type = mParserContext->mDTD ? mParserContext->mDTD->GetType() : NS_IPARSER_FLAG_HTML;
|
||||
mParserContext->GetTokenizer(type, theTokenizer);
|
||||
}
|
||||
|
||||
if (theTokenizer) {
|
||||
|
||||
//Get the root DTD for use in model building...
|
||||
|
||||
CParserContext* theRootContext=mParserContext;
|
||||
nsITokenizer* theTokenizer=0;
|
||||
|
||||
nsresult result = (mParserContext->mDTD)? mParserContext->mDTD->GetTokenizer(theTokenizer):NS_OK;
|
||||
if(theTokenizer){
|
||||
|
||||
while(theRootContext->mPrevContext) {
|
||||
theRootContext=theRootContext->mPrevContext;
|
||||
while (theRootContext->mPrevContext) {
|
||||
theRootContext = theRootContext->mPrevContext;
|
||||
}
|
||||
|
||||
nsIDTD* theRootDTD=theRootContext->mDTD;
|
||||
if(theRootDTD) {
|
||||
nsIDTD* theRootDTD = theRootContext->mDTD;
|
||||
if (theRootDTD) {
|
||||
MOZ_TIMER_START(mDTDTime);
|
||||
result=theRootDTD->BuildModel(this,theTokenizer,mTokenObserver,mSink);
|
||||
|
||||
result = theRootDTD->BuildModel(this, theTokenizer, mTokenObserver, mSink);
|
||||
|
||||
MOZ_TIMER_STOP(mDTDTime);
|
||||
}
|
||||
}
|
||||
else{
|
||||
mInternalState=result=NS_ERROR_HTMLPARSER_BADTOKENIZER;
|
||||
mInternalState = result = NS_ERROR_HTMLPARSER_BADTOKENIZER;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1879,12 +1879,14 @@ nsresult nsParser::BuildModel() {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsITokenizer* nsParser::GetTokenizer(void) {
|
||||
nsITokenizer* theTokenizer=0;
|
||||
if(mParserContext && mParserContext->mDTD) {
|
||||
mParserContext->mDTD->GetTokenizer(theTokenizer);
|
||||
nsresult nsParser::GetTokenizer(nsITokenizer*& aTokenizer) {
|
||||
nsresult result = NS_OK;
|
||||
aTokenizer = nsnull;
|
||||
if(mParserContext) {
|
||||
PRInt32 type = mParserContext->mDTD ? mParserContext->mDTD->GetType() : NS_IPARSER_FLAG_HTML;
|
||||
result = mParserContext->GetTokenizer(type, aTokenizer);
|
||||
}
|
||||
return theTokenizer;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@@ -2446,7 +2448,12 @@ nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext,
|
||||
*/
|
||||
PRBool nsParser::WillTokenize(PRBool aIsFinalChunk){
|
||||
nsITokenizer* theTokenizer=0;
|
||||
nsresult result = (mParserContext->mDTD)? mParserContext->mDTD->GetTokenizer(theTokenizer):NS_OK;
|
||||
nsresult result = NS_OK;
|
||||
if (mParserContext) {
|
||||
PRInt32 type = mParserContext->mDTD ? mParserContext->mDTD->GetType() : NS_IPARSER_FLAG_HTML;
|
||||
mParserContext->GetTokenizer(type, theTokenizer);
|
||||
}
|
||||
|
||||
if (theTokenizer) {
|
||||
result = theTokenizer->WillTokenize(aIsFinalChunk,&mTokenAllocator);
|
||||
}
|
||||
@@ -2466,16 +2473,23 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){
|
||||
|
||||
nsITokenizer* theTokenizer = 0;
|
||||
|
||||
nsresult result =
|
||||
(mParserContext && mParserContext->mDTD)? mParserContext->mDTD->GetTokenizer(theTokenizer) : NS_OK;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (theTokenizer){
|
||||
if (mParserContext) {
|
||||
PRInt32 type = mParserContext->mDTD ? mParserContext->mDTD->GetType() : NS_IPARSER_FLAG_HTML;
|
||||
mParserContext->GetTokenizer(type, theTokenizer);
|
||||
}
|
||||
|
||||
if (theTokenizer) {
|
||||
if (mFlags & NS_PARSER_FLAG_FLUSH_TOKENS) {
|
||||
// For some reason tokens didn't get flushed ( probably
|
||||
// the parser got blocked before all the tokens in the
|
||||
// stack got handled ). Flush 'em now. Ref. bug 104856
|
||||
if (theTokenizer->GetCount() == 0) {
|
||||
mFlags &= ~NS_PARSER_FLAG_FLUSH_TOKENS; // reset since the tokens have been flushed.
|
||||
// Resume tokenization for the rest of the document
|
||||
// since all the tokens in the tokenizer got flushed.
|
||||
result = Tokenize(aIsFinalChunk);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -2534,7 +2548,11 @@ PRBool nsParser::DidTokenize(PRBool aIsFinalChunk){
|
||||
PRBool result=PR_TRUE;
|
||||
|
||||
nsITokenizer* theTokenizer=0;
|
||||
nsresult rv = (mParserContext->mDTD)? mParserContext->mDTD->GetTokenizer(theTokenizer):NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
if (mParserContext) {
|
||||
PRInt32 type = mParserContext->mDTD ? mParserContext->mDTD->GetType() : NS_IPARSER_FLAG_HTML;
|
||||
mParserContext->GetTokenizer(type, theTokenizer);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && theTokenizer) {
|
||||
result = theTokenizer->DidTokenize(aIsFinalChunk);
|
||||
@@ -2556,7 +2574,9 @@ void nsParser::DebugDumpSource(nsOutputStream& aStream) {
|
||||
PRInt32 theIndex=-1;
|
||||
|
||||
nsITokenizer* theTokenizer=0;
|
||||
if(NS_SUCCEEDED(mParserContext->mDTD->GetTokenizer(theTokenizer))){
|
||||
PRInt32 type = mParserContext && mParserContext->mDTD ?
|
||||
mParserContext->mDTD->GetType() : NS_IPARSER_FLAG_HTML;
|
||||
if(NS_SUCCEEDED(mParserContext->GetTokenizer(type, theTokenizer))){
|
||||
CToken* theToken;
|
||||
while(nsnull != (theToken=theTokenizer->GetTokenAt(++theIndex))) {
|
||||
// theToken->DebugDumpToken(out);
|
||||
|
||||
Reference in New Issue
Block a user