Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp

Issue 2200613002: The HTML parser synchronously creates custom elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Eliminate redundant TODOs. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
index d386b09772fd3a37dede8b2a6a2ab7cb38240e48..05c63f6a5e263a17e414899171190371b90a2073 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
@@ -133,11 +133,11 @@ static KURL documentURLForScriptExecution(Document* document)
using namespace HTMLNames;
-HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* host)
- : m_document(document)
+HTMLScriptRunner::HTMLScriptRunner(HTMLParserReentryPermit* reentryPermit, Document* document, HTMLScriptRunnerHost* host)
+ : m_reentryPermit(reentryPermit)
+ , m_document(document)
, m_host(host)
, m_parserBlockingScript(PendingScript::create(nullptr, nullptr))
- , m_scriptNestingLevel(0)
, m_hasScriptsWaitingForResources(false)
{
ASSERT(m_host);
@@ -164,6 +164,9 @@ void HTMLScriptRunner::detach()
pendingScript->releaseElementAndClear();
}
m_document = nullptr;
+ // m_reentryPermit is not cleared here, because the script runner
+ // may continue to run pending scripts after the parser has
+ // detached.
}
bool HTMLScriptRunner::isPendingScriptReady(const PendingScript* script)
@@ -208,7 +211,7 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript* pendi
// Clear the pending script before possible re-entrancy from executeScript()
Element* element = pendingScript->releaseElementAndClear();
if (ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element)) {
- NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
+ HTMLParserReentryPermit::ScriptNestingLevelIncrementer nestingLevelIncrementer = m_reentryPermit->incrementScriptNestingLevel();
IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrementer(m_document);
if (errorOccurred) {
TRACE_EVENT_WITH_FLOW1("blink", "HTMLScriptRunner ExecuteScriptFailed", element, TRACE_EVENT_FLAG_FLOW_IN,
@@ -419,7 +422,7 @@ void HTMLScriptRunner::runScript(Element* script, const TextPosition& scriptStar
Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate());
InsertionPointRecord insertionPointRecord(m_host->inputStream());
- NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
+ HTMLParserReentryPermit::ScriptNestingLevelIncrementer nestingLevelIncrementer = m_reentryPermit->incrementScriptNestingLevel();
scriptLoader->prepareScript(scriptStartPosition);
@@ -429,11 +432,11 @@ void HTMLScriptRunner::runScript(Element* script, const TextPosition& scriptStar
if (scriptLoader->willExecuteWhenDocumentFinishedParsing()) {
requestDeferredScript(script);
} else if (scriptLoader->readyToBeParserExecuted()) {
- if (m_scriptNestingLevel == 1) {
+ if (m_reentryPermit->scriptNestingLevel() == 1u) {
m_parserBlockingScript->setElement(script);
m_parserBlockingScript->setStartingPosition(scriptStartPosition);
} else {
- ASSERT(m_scriptNestingLevel > 1);
+ DCHECK_GT(m_reentryPermit->scriptNestingLevel(), 1u);
m_parserBlockingScript->releaseElementAndClear();
ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), scriptStartPosition);
doExecuteScript(script, sourceCode, scriptStartPosition);

Powered by Google App Engine
This is Rietveld 408576698