Bug 1333333 - Label runnables in the HTML parser (again). r=billm.

MozReview-Commit-ID: 1Z89LSr46dN
This commit is contained in:
Henri Sivonen
2017-06-27 10:38:30 -07:00
parent 15be754192
commit c3862d6f4b
8 changed files with 384 additions and 518 deletions

View File

@@ -239,10 +239,14 @@ nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason)
// We are under memory pressure, but let's hope the following allocation
// works out so that we get to terminate and clean up the parser from
// a safer point.
if (mParser) { // can mParser ever be null here?
MOZ_ALWAYS_SUCCEEDS(
NS_DispatchToMainThread(NewRunnableMethod("nsHtml5Parser::Terminate",
GetParser(), &nsHtml5Parser::Terminate)));
if (mParser && mDocument) { // can mParser ever be null here?
nsCOMPtr<nsIRunnable> terminator =
NewRunnableMethod("nsHtml5Parser::Terminate", GetParser(), &nsHtml5Parser::Terminate);
if (NS_FAILED(mDocument->Dispatch("nsHtml5Parser::Terminate",
TaskCategory::Network,
terminator.forget()))) {
NS_WARNING("failed to dispatch executor flush event");
}
}
return aReason;
}
@@ -266,9 +270,9 @@ void
nsHtml5TreeOpExecutor::ContinueInterruptedParsingAsync()
{
if (!mDocument || !mDocument->IsInBackgroundWindow()) {
nsCOMPtr<nsIRunnable> flusher = new nsHtml5ExecutorReflusher(this);
nsCOMPtr<nsIRunnable> flusher = new nsHtml5ExecutorReflusher(this);
if (NS_FAILED(mDocument->Dispatch("nsHtml5ExecutorReflusher",
TaskCategory::Other,
TaskCategory::Network,
flusher.forget()))) {
NS_WARNING("failed to dispatch executor flush event");
}