diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index 4d37e4d0fc17..eebcfd763056 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -349,19 +349,21 @@ nsContentSink::ScriptAvailable(nsresult aResult, mParser->ScriptExecuting(); } - if (count == 0) { - return NS_OK; - } - // aElement will not be in mScriptElements if a + + + +
+Mozilla Bug 461555 + + + + + + + diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 6eb2532b6e22..443bcf06db80 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -185,6 +185,7 @@ public: NS_IMETHOD WillParse(void); NS_IMETHOD WillBuildModel(void); NS_IMETHOD DidBuildModel(void); + virtual PRBool ReadyToCallDidBuildModel(void); NS_IMETHOD WillInterrupt(void); NS_IMETHOD WillResume(void); NS_IMETHOD SetParser(nsIParser* aParser); @@ -1837,6 +1838,12 @@ HTMLContentSink::DidBuildModel(void) return NS_OK; } +PRBool +HTMLContentSink::ReadyToCallDidBuildModel() +{ + return ReadyToCallDidBuildModelImpl(); +} + NS_IMETHODIMP HTMLContentSink::SetParser(nsIParser* aParser) { diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index 2cfd643913c7..f3203a54cd41 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -383,6 +383,12 @@ nsXMLContentSink::DidBuildModel() return NS_OK; } +PRBool +nsXMLContentSink::ReadyToCallDidBuildModel() +{ + return ReadyToCallDidBuildModelImpl(); +} + NS_IMETHODIMP nsXMLContentSink::OnDocumentCreated(nsIDocument* aResultDocument) { diff --git a/content/xml/document/src/nsXMLContentSink.h b/content/xml/document/src/nsXMLContentSink.h index e12d478c3e5a..a3b77e9ad24a 100644 --- a/content/xml/document/src/nsXMLContentSink.h +++ b/content/xml/document/src/nsXMLContentSink.h @@ -93,6 +93,7 @@ public: NS_IMETHOD WillParse(void); NS_IMETHOD WillBuildModel(void); NS_IMETHOD DidBuildModel(void); + virtual PRBool ReadyToCallDidBuildModel(void); NS_IMETHOD WillInterrupt(void); NS_IMETHOD WillResume(void); NS_IMETHOD SetParser(nsIParser* aParser); diff --git a/parser/htmlparser/public/nsIContentSink.h b/parser/htmlparser/public/nsIContentSink.h index 55bed1f5c7ab..3cc8f6ea3d2e 100644 --- a/parser/htmlparser/public/nsIContentSink.h +++ b/parser/htmlparser/public/nsIContentSink.h @@ -56,8 +56,8 @@ class nsIParser; #define NS_ICONTENT_SINK_IID \ -{ 0x94ec4df1, 0x6885, 0x4b1f, \ - { 0x85, 0x10, 0xe3, 0x5f, 0x4f, 0x36, 0xea, 0xaa } } +{ 0xcfa3643b, 0xee60, 0x4bf0, \ + { 0xbc, 0x83, 0x49, 0x95, 0xdb, 0xbc, 0xda, 0x75 } } class nsIContentSink : public nsISupports { public: @@ -88,6 +88,12 @@ public: */ NS_IMETHOD DidBuildModel()=0; + /** + * Thie method gets caller right before DidBuildModel is called. + * If false + */ + virtual PRBool ReadyToCallDidBuildModel() { return PR_TRUE; }; + /** * This method gets called when the parser gets i/o blocked, * and wants to notify the sink that it may be a while before diff --git a/parser/htmlparser/src/nsParser.cpp b/parser/htmlparser/src/nsParser.cpp index abcb16f352ec..574b2c58f573 100644 --- a/parser/htmlparser/src/nsParser.cpp +++ b/parser/htmlparser/src/nsParser.cpp @@ -1525,7 +1525,12 @@ nsParser::DidBuildModel(nsresult anErrorCode) if (IsComplete()) { if (mParserContext && !mParserContext->mPrevContext) { - if (mParserContext->mDTD) { + // If mInternalState == NS_ERROR_HTMLPARSER_STOPPARSING then we got in + // here through Terminate() and so we always want to Call DidBuildModel + // on the DTD, even if the sink says 'no'. + if (mParserContext->mDTD && mSink && + (mInternalState == NS_ERROR_HTMLPARSER_STOPPARSING || + mSink->ReadyToCallDidBuildModel())) { result = mParserContext->mDTD->DidBuildModel(anErrorCode,PR_TRUE,this,mSink); }