Bug 655682 - Perform discretionary flushes in the HTML parser even if the current node is foster-parenting. r=bzbarsky.

This commit is contained in:
Henri Sivonen
2011-05-19 11:42:01 +03:00
parent 0f23ec019c
commit d1d75c9d82
3 changed files with 20 additions and 29 deletions

View File

@@ -1159,13 +1159,11 @@ nsHtml5StreamParser::ContinueAfterScripts(nsHtml5Tokenizer* aTokenizer,
mSpeculations.RemoveElementAt(0);
if (mSpeculations.IsEmpty()) {
// yes, it was still the only speculation. Now stop speculating
if (mTreeBuilder->IsDiscretionaryFlushSafe()) {
// However, before telling the executor to read from stage, flush
// any pending ops straight to the executor, because otherwise
// they remain unflushed until we get more data from the network.
mTreeBuilder->SetOpSink(mExecutor);
mTreeBuilder->Flush();
}
// However, before telling the executor to read from stage, flush
// any pending ops straight to the executor, because otherwise
// they remain unflushed until we get more data from the network.
mTreeBuilder->SetOpSink(mExecutor);
mTreeBuilder->Flush(PR_TRUE);
mTreeBuilder->SetOpSink(mExecutor->GetStage());
mExecutor->StartReadingFromStage();
mSpeculating = PR_FALSE;
@@ -1268,15 +1266,9 @@ nsHtml5StreamParser::TimerFlush()
// we aren't speculating and we don't know when new data is
// going to arrive. Send data to the main thread.
// However, don't do if the current element on the stack is a
// foster-parenting element and there's pending text, because flushing in
// that case would make the tree shape dependent on where the flush points
// fall.
if (mTreeBuilder->IsDiscretionaryFlushSafe()) {
if (mTreeBuilder->Flush()) {
if (NS_FAILED(NS_DispatchToMainThread(mExecutorFlusher))) {
NS_WARNING("failed to dispatch executor flush event");
}
if (mTreeBuilder->Flush(PR_TRUE)) {
if (NS_FAILED(NS_DispatchToMainThread(mExecutorFlusher))) {
NS_WARNING("failed to dispatch executor flush event");
}
}
}