From 730197985365889de9baacc68f73f9a29e3e400a Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Tue, 23 Nov 1999 03:07:09 +0000 Subject: [PATCH] fixed bug 18312; it's not PDT+, but it's something Phil has been *really* anxious to fix. r=nisheeth git-svn-id: svn://10.0.0.236/trunk@54243 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/CNavDTD.cpp | 10 ++++++---- mozilla/htmlparser/src/nsParser.cpp | 21 ++++++++++++++++++++- mozilla/parser/htmlparser/src/CNavDTD.cpp | 10 ++++++---- mozilla/parser/htmlparser/src/nsParser.cpp | 21 ++++++++++++++++++++- 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 28d5c56a586..7b3ab94e2d8 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -1062,11 +1062,13 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode if(mParser) { - CObserverService& theService=mParser->GetObserverService(); - CParserContext* pc=mParser->PeekContext(); - void* theDocID=(pc)? pc->mKey:0; + CObserverService* theService=mParser->GetObserverService(); + if(theService) { + CParserContext* pc=mParser->PeekContext(); + void* theDocID=(pc)? pc->mKey:0; - result=theService.Notify(aTag,aNode,(PRUint32)theDocID,kHTMLTextContentType,mParser); + result=theService->Notify(aTag,aNode,(PRUint32)theDocID,kHTMLTextContentType,mParser); + } } MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::WillHandleStartTag(), this=%p\n", this)); diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index 3681e73d0a0..9f02e7ba47a 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -206,7 +206,8 @@ nsParser::nsParser(nsITokenObserver* anObserver) : mCommand(""), mUnusedInput("" mDTDVerification=PR_FALSE; mCharsetSource=kCharsetUninitialized; mInternalState=NS_OK; - + mObserversEnabled=PR_TRUE; + MOZ_TIMER_DEBUGLOG(("Reset: Parse Time: nsParser::nsParser(), this=%p\n", this)); MOZ_TIMER_RESET(mParseTime); MOZ_TIMER_RESET(mDTDTime); @@ -923,7 +924,10 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag if(theBuffer.Length()){ //now it's time to try to build the model from this fragment + + mObserversEnabled=PR_FALSE; //disable observers for fragments result=Parse(theBuffer,(void*)&theBuffer,aContentType,PR_FALSE,PR_TRUE); + mObserversEnabled=PR_TRUE; //now reenable. } return result; @@ -1499,3 +1503,18 @@ nsParser::GetDTD(nsIDTD** aDTD) return NS_OK; } + + +/** + * Get the observer service + * + * @update rickg 11/22/99 + * @return ptr to server or NULL + */ +CObserverService* nsParser::GetObserverService(void) { + //XXX Hack! this should be XPCOM based! + if(mObserversEnabled) + return &mObserverService; + return 0; +} + diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index 28d5c56a586..7b3ab94e2d8 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -1062,11 +1062,13 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode if(mParser) { - CObserverService& theService=mParser->GetObserverService(); - CParserContext* pc=mParser->PeekContext(); - void* theDocID=(pc)? pc->mKey:0; + CObserverService* theService=mParser->GetObserverService(); + if(theService) { + CParserContext* pc=mParser->PeekContext(); + void* theDocID=(pc)? pc->mKey:0; - result=theService.Notify(aTag,aNode,(PRUint32)theDocID,kHTMLTextContentType,mParser); + result=theService->Notify(aTag,aNode,(PRUint32)theDocID,kHTMLTextContentType,mParser); + } } MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::WillHandleStartTag(), this=%p\n", this)); diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index 3681e73d0a0..9f02e7ba47a 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -206,7 +206,8 @@ nsParser::nsParser(nsITokenObserver* anObserver) : mCommand(""), mUnusedInput("" mDTDVerification=PR_FALSE; mCharsetSource=kCharsetUninitialized; mInternalState=NS_OK; - + mObserversEnabled=PR_TRUE; + MOZ_TIMER_DEBUGLOG(("Reset: Parse Time: nsParser::nsParser(), this=%p\n", this)); MOZ_TIMER_RESET(mParseTime); MOZ_TIMER_RESET(mDTDTime); @@ -923,7 +924,10 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag if(theBuffer.Length()){ //now it's time to try to build the model from this fragment + + mObserversEnabled=PR_FALSE; //disable observers for fragments result=Parse(theBuffer,(void*)&theBuffer,aContentType,PR_FALSE,PR_TRUE); + mObserversEnabled=PR_TRUE; //now reenable. } return result; @@ -1499,3 +1503,18 @@ nsParser::GetDTD(nsIDTD** aDTD) return NS_OK; } + + +/** + * Get the observer service + * + * @update rickg 11/22/99 + * @return ptr to server or NULL + */ +CObserverService* nsParser::GetObserverService(void) { + //XXX Hack! this should be XPCOM based! + if(mObserversEnabled) + return &mObserverService; + return 0; +} +