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

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

Issue 2536553002: Simplify: remove PendingScript::releaseElementAndClear (Closed)
Patch Set: git cl try 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
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 07cb059cc5930396fb017ad97bd02bf2314095af..1f130d3c38f7273a9aabf4c24320ba78c7f7d9b2 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
@@ -169,13 +169,11 @@ void HTMLScriptRunner::detach() {
if (!m_document)
return;
- m_parserBlockingScript->stopWatchingForLoad();
- m_parserBlockingScript->releaseElementAndClear();
+ m_parserBlockingScript->dispose();
while (!m_scriptsToExecuteAfterParsing.isEmpty()) {
PendingScript* pendingScript = m_scriptsToExecuteAfterParsing.takeFirst();
- pendingScript->stopWatchingForLoad();
- pendingScript->releaseElementAndClear();
+ pendingScript->dispose();
}
m_document = nullptr;
// m_reentryPermit is not cleared here, because the script runner
@@ -210,6 +208,8 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(
// Stop watching loads before executeScript to prevent recursion if the script
// reloads itself.
+ // TODO(kouhei): Consider merging this w/ pendingScript->dispose() after the
+ // if block.
pendingScript->stopWatchingForLoad();
if (!isExecutingScript()) {
@@ -227,7 +227,9 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(
double scriptParserBlockingTime =
pendingScript->parserBlockingLoadStartTime();
// Clear the pending script before possible re-entrancy from executeScript()
- Element* element = pendingScript->releaseElementAndClear();
+ Element* element = pendingScript->element();
+ pendingScript->dispose();
+
if (ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element)) {
HTMLParserReentryPermit::ScriptNestingLevelIncrementer
nestingLevelIncrementer =
@@ -261,14 +263,12 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(
void HTMLScriptRunner::stopWatchingResourceForLoad(Resource* resource) {
if (m_parserBlockingScript->resource() == resource) {
- m_parserBlockingScript->stopWatchingForLoad();
- m_parserBlockingScript->releaseElementAndClear();
+ m_parserBlockingScript->dispose();
return;
}
for (auto& script : m_scriptsToExecuteAfterParsing) {
if (script->resource() == resource) {
- script->stopWatchingForLoad();
- script->releaseElementAndClear();
+ script->dispose();
return;
}
}
@@ -515,7 +515,7 @@ void HTMLScriptRunner::runScript(Element* script,
m_parserBlockingScript->setStartingPosition(scriptStartPosition);
} else {
DCHECK_GT(m_reentryPermit->scriptNestingLevel(), 1u);
- m_parserBlockingScript->releaseElementAndClear();
+ m_parserBlockingScript->dispose();
yhirano 2016/11/29 01:29:00 Can you tell me why we can call stopWatchingLoad h
kouhei (in TOK) 2016/11/29 01:52:57 This is when we execute inline scripts. We shouldn
ScriptSourceCode sourceCode(script->textContent(),
documentURLForScriptExecution(m_document),
scriptStartPosition);

Powered by Google App Engine
This is Rietveld 408576698