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

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

Issue 2540653002: Revert of Script blocking resources tracking should be only done by Document::isScriptExecutionReady (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8fc126133bdaa508cac8d037ad42b5ac7997b00b..07cb059cc5930396fb017ad97bd02bf2314095af 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
@@ -154,7 +154,8 @@
: m_reentryPermit(reentryPermit),
m_document(document),
m_host(host),
- m_parserBlockingScript(PendingScript::create(nullptr, nullptr)) {
+ m_parserBlockingScript(PendingScript::create(nullptr, nullptr)),
+ m_hasScriptsWaitingForResources(false) {
ASSERT(m_host);
ThreadState::current()->registerPreFinalizer(this);
}
@@ -182,17 +183,18 @@
// detached.
}
-bool HTMLScriptRunner::isPendingScriptReady() {
- if (!m_document->isScriptExecutionReady())
+bool HTMLScriptRunner::isPendingScriptReady(const PendingScript* script) {
+ m_hasScriptsWaitingForResources = !m_document->isScriptExecutionReady();
+ if (m_hasScriptsWaitingForResources)
return false;
- return m_parserBlockingScript->isReady();
+ return script->isReady();
}
void HTMLScriptRunner::executeParsingBlockingScript() {
- DCHECK(m_document);
- DCHECK(!isExecutingScript());
- DCHECK(m_document->isScriptExecutionReady());
- DCHECK(isPendingScriptReady());
+ ASSERT(m_document);
+ ASSERT(!isExecutingScript());
+ ASSERT(m_document->isScriptExecutionReady());
+ ASSERT(isPendingScriptReady(m_parserBlockingScript.get()));
InsertionPointRecord insertionPointRecord(m_host->inputStream());
executePendingScriptAndDispatchEvent(m_parserBlockingScript.get(),
@@ -213,9 +215,10 @@
if (!isExecutingScript()) {
Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate());
if (pendingScriptType == ScriptStreamer::ParsingBlocking) {
+ m_hasScriptsWaitingForResources = !m_document->isScriptExecutionReady();
// The parser cannot be unblocked as a microtask requested another
// resource
- if (!m_document->isScriptExecutionReady())
+ if (m_hasScriptsWaitingForResources)
return;
}
}
@@ -370,7 +373,8 @@
}
void HTMLScriptRunner::executeParsingBlockingScripts() {
- while (hasParserBlockingScript() && isPendingScriptReady())
+ while (hasParserBlockingScript() &&
+ isPendingScriptReady(m_parserBlockingScript.get()))
executeParsingBlockingScript();
}
@@ -386,6 +390,9 @@
void HTMLScriptRunner::executeScriptsWaitingForResources() {
TRACE_EVENT0("blink", "HTMLScriptRunner::executeScriptsWaitingForResources");
ASSERT(m_document);
+ // Callers should check hasScriptsWaitingForResources() before calling
+ // to prevent parser or script re-entry during </style> parsing.
+ ASSERT(hasScriptsWaitingForResources());
ASSERT(!isExecutingScript());
ASSERT(m_document->isScriptExecutionReady());
executeParsingBlockingScripts();
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698