diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 872dae53d63..2193e0bfac4 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -966,6 +966,19 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, return rv; } +void +nsHTMLDocument::StopDocumentLoad() +{ + // If we're writing (i.e., there's been a document.open call), then + // nsDocument::StopDocumentLoad will do the wrong thing and simply terminate + // our parser. + if (mWriteState != eNotWriting) { + Close(); + } else { + nsDocument::StopDocumentLoad(); + } +} + // static void nsHTMLDocument::DocumentWriteTerminationFunc(nsISupports *aRef) @@ -2191,6 +2204,12 @@ nsHTMLDocument::Close() nsresult rv = NS_OK; if (mParser && mWriteState == eDocumentOpened) { + mPendingScripts.RemoveElement(GenerateParserKey()); + + mWriteState = mPendingScripts.Count() == 0 + ? eDocumentClosed + : ePendingClose; + ++mWriteLevel; if (mContentType.EqualsLiteral("text/html")) { rv = mParser->Parse(NS_LITERAL_STRING(""), @@ -2202,12 +2221,6 @@ nsHTMLDocument::Close() } --mWriteLevel; - mPendingScripts.RemoveElement(GenerateParserKey()); - - mWriteState = mPendingScripts.Count() == 0 - ? eDocumentClosed - : ePendingClose; - // XXX Make sure that all the document.written content is // reflowed. We should remove this call once we change // nsHTMLDocument::OpenCommon() so that it completely destroys the diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 81d991bd45a..5b24ae5ed59 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -98,6 +98,7 @@ public: nsIStreamListener **aDocListener, PRBool aReset = PR_TRUE, nsIContentSink* aSink = nsnull); + virtual void StopDocumentLoad(); virtual void EndLoad();