diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
index ae3ffcc307c..c7b15b677a0 100644
--- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
@@ -2383,12 +2383,14 @@ HTMLContentSink::Init(nsIDocument* aDoc,
mCurrentContext->Begin(eHTMLTag_html, mRoot, 0, -1);
mContextStack.AppendElement(mCurrentContext);
+#ifdef NS_DEBUG
char* spec;
(void)aURL->GetSpec(&spec);
SINK_TRACE(SINK_TRACE_CALLS,
("HTMLContentSink::Init: this=%p url='%s'",
this, spec));
nsCRT::free(spec);
+#endif
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n"));
MOZ_TIMER_STOP(mWatch);
@@ -2443,11 +2445,19 @@ HTMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
// Reflow the last batch of content
- if (nsnull != mBody) {
+ if (mBody) {
SINK_TRACE(SINK_TRACE_REFLOW,
("HTMLContentSink::DidBuildModel: layout final content"));
mCurrentContext->FlushTags(PR_TRUE);
}
+ else if (!mLayoutStarted) {
+ // We never saw the body, and layout never got started. Force
+ // layout *now*, to get an initial reflow.
+ SINK_TRACE(SINK_TRACE_REFLOW,
+ ("HTMLContentSink::DidBuildModel: forcing reflow on empty document"));
+
+ StartLayout();
+ }
ScrollToRef();
diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp
index e26ab23fa42..94aef72a4ac 100644
--- a/mozilla/htmlparser/src/nsParser.cpp
+++ b/mozilla/htmlparser/src/nsParser.cpp
@@ -1414,7 +1414,7 @@ nsresult nsParser::DidBuildModel(nsresult anErrorCode) {
//One last thing...close any open containers.
nsresult result=anErrorCode;
- if(mParserEnabled && mParserContext && !mParserContext->mPrevContext) {
+ if(mParserContext && !mParserContext->mPrevContext) {
if(mParserContext->mDTD) {
result=mParserContext->mDTD->DidBuildModel(anErrorCode,PRBool(0==mParserContext->mPrevContext),this,mSink);
}
@@ -1491,11 +1491,10 @@ nsresult nsParser::Terminate(void){
// Hack - Hold a reference until we are completely done...
nsCOMPtr kungFuDeathGrip(this);
mInternalState=result;
- result=DidBuildModel(result);
- return result;
+ DidBuildModel(result);
}
}
- return mInternalState;
+ return result;
}
diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp
index e26ab23fa42..94aef72a4ac 100644
--- a/mozilla/parser/htmlparser/src/nsParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsParser.cpp
@@ -1414,7 +1414,7 @@ nsresult nsParser::DidBuildModel(nsresult anErrorCode) {
//One last thing...close any open containers.
nsresult result=anErrorCode;
- if(mParserEnabled && mParserContext && !mParserContext->mPrevContext) {
+ if(mParserContext && !mParserContext->mPrevContext) {
if(mParserContext->mDTD) {
result=mParserContext->mDTD->DidBuildModel(anErrorCode,PRBool(0==mParserContext->mPrevContext),this,mSink);
}
@@ -1491,11 +1491,10 @@ nsresult nsParser::Terminate(void){
// Hack - Hold a reference until we are completely done...
nsCOMPtr kungFuDeathGrip(this);
mInternalState=result;
- result=DidBuildModel(result);
- return result;
+ DidBuildModel(result);
}
}
- return mInternalState;
+ return result;
}