Bug 717488 part 1. r=smaug.

This commit is contained in:
Henri Sivonen
2012-03-21 14:39:25 +02:00
parent 9e381e5240
commit 43610b6da3
5 changed files with 52 additions and 37 deletions

View File

@@ -117,6 +117,20 @@ nsHtml5TreeOpExecutor::WillParse()
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsHtml5TreeOpExecutor::WillBuildModel(nsDTDMode aDTDMode)
{
if (mDocShell && !GetDocument()->GetScriptGlobalObject()) {
// Not loading as data but script global object not ready
return MarkAsBroken(NS_ERROR_DOM_INVALID_STATE_ERR);
}
mDocument->AddObserver(this);
WillBuildModelImpl();
GetDocument()->BeginLoad();
return NS_OK;
}
// This is called when the tree construction has ended
NS_IMETHODIMP
nsHtml5TreeOpExecutor::DidBuildModel(bool aTerminated)
@@ -143,7 +157,9 @@ nsHtml5TreeOpExecutor::DidBuildModel(bool aTerminated)
GetParser()->DropStreamParser();
// This comes from nsXMLContentSink and nsHTMLContentSink
DidBuildModelImpl(aTerminated);
// If this parser has been marked as broken, treat the end of parse as
// forced termination.
DidBuildModelImpl(aTerminated || IsBroken());
if (!mLayoutStarted) {
// We never saw the body, and layout never got started. Force
@@ -274,12 +290,12 @@ nsHtml5TreeOpExecutor::UpdateChildCounts()
// No-op
}
void
nsHtml5TreeOpExecutor::MarkAsBroken()
nsresult
nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(!mRunsToCompletion, "Fragment parsers can't be broken!");
mBroken = true;
mBroken = aReason;
if (mStreamParser) {
mStreamParser->Terminate();
}
@@ -293,6 +309,7 @@ nsHtml5TreeOpExecutor::MarkAsBroken()
NS_WARNING("failed to dispatch executor flush event");
}
}
return aReason;
}
nsresult