Bug 765620 - When parsing from stream without executing scripts, avoid script execution-related tree ops. r=smaug
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user