Bug 765620 - When parsing from stream without executing scripts, avoid script execution-related tree ops. r=smaug

This commit is contained in:
Henri Sivonen
2012-06-20 10:05:39 +03:00
parent b89242d733
commit 67be401de2
11 changed files with 40 additions and 32 deletions

View File

@@ -60,7 +60,7 @@ nsHtml5StringParser::ParseFragment(const nsAString& aSourceBuffer,
}
#endif
mExecutor->EnableFragmentMode(aPreventScriptExecution);
mTreeBuilder->SetPreventScriptExecution(aPreventScriptExecution);
Tokenize(aSourceBuffer, doc, true);
return NS_OK;
@@ -81,7 +81,7 @@ nsHtml5StringParser::ParseDocument(const nsAString& aSourceBuffer,
nsnull,
false);
mExecutor->PreventScriptExecution();
mTreeBuilder->SetPreventScriptExecution(true);
Tokenize(aSourceBuffer, aTargetDoc, aScriptingEnabledForNoscriptParsing);
return NS_OK;
@@ -113,8 +113,10 @@ nsHtml5StringParser::Tokenize(const nsAString& aSourceBuffer,
if (buffer.hasMore()) {
lastWasCR = mTokenizer->tokenizeBuffer(&buffer);
if (mTreeBuilder->HasScript()) {
// Flush on each script, because the execution prevention code
// can handle at most one script per flush.
// If we come here, we are in createContextualFragment() or in the
// upcoming document.parse(). It's unclear if it's really necessary
// to flush here, but let's do so for consistency with other flushes
// to avoid different code paths on the executor side.
mTreeBuilder->Flush(); // Move ops to the executor
mExecutor->FlushDocumentWrite(); // run the ops
}