From 620f913e6ea8693705856b08e08257743348ced9 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Wed, 1 Jun 2005 19:13:39 +0000 Subject: [PATCH] 295916 r=mrbkap sr=bz a=shaver - make parser handle calling Parse with an empty string and aLastCall=true correctly - call that from document.close() even in the non-HTML case git-svn-id: svn://10.0.0.236/trunk@173960 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/html/document/src/nsHTMLDocument.cpp | 3 +++ mozilla/parser/htmlparser/src/nsParser.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index e125a3a8c3e..3e0127f6002 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -2109,6 +2109,9 @@ nsHTMLDocument::Close() NS_GENERATE_PARSER_KEY(), mContentType, PR_FALSE, PR_TRUE); + } else { + rv = mParser->Parse(EmptyString(), NS_GENERATE_PARSER_KEY(), + mContentType, PR_FALSE, PR_TRUE); } --mWriteLevel; mIsWriting = 0; diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index 750ed637342..275b1e12c95 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -1696,10 +1696,12 @@ nsParser::Parse(const nsAString& aSourceBuffer, nsresult result=NS_OK; - if(aLastCall && aSourceBuffer.IsEmpty()) { + if(!aLastCall && aSourceBuffer.IsEmpty()) { // Nothing is being passed to the parser so return // immediately. mUnusedInput will get processed when // some data is actually passed in. + // But if this is the last call, make sure to finish up + // stuff correctly. return result; } @@ -1712,7 +1714,7 @@ nsParser::Parse(const nsAString& aSourceBuffer, // till we're completely done. nsCOMPtr kungFuDeathGrip(this); - if(!aSourceBuffer.IsEmpty() || !mUnusedInput.IsEmpty()) { + if(aLastCall || !aSourceBuffer.IsEmpty() || !mUnusedInput.IsEmpty()) { if (aVerifyEnabled) { mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION; @@ -1777,7 +1779,7 @@ nsParser::Parse(const nsAString& aSourceBuffer, pc->mDTDMode = aMode; } - mUnusedInput.Truncate(0); + mUnusedInput.Truncate(); //printf("Parse(string) iterate: %i",PR_FALSE); pc->mScanner->Append(aSourceBuffer);