Commit db092e5e authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Merge ScriptLoader::ExecuteScript() into ExecuteScriptBlock()

To make it clearer that ExecuteScriptBlock() is the single entry
point of script execution by removing the similarly-named
ExecuteScript(), which is now only called from ExecuteScriptBlock().

No behavior changes.

Bug: 686281
Change-Id: I0e2bcdcf05cc9c3141398a3a465fa6fb268b0913
Reviewed-on: https://chromium-review.googlesource.com/564301Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491492}
parent 1b85da5f
...@@ -795,29 +795,9 @@ PendingScript* ScriptLoader::CreatePendingScript() { ...@@ -795,29 +795,9 @@ PendingScript* ScriptLoader::CreatePendingScript() {
return nullptr; return nullptr;
} }
ScriptLoader::ExecuteScriptResult ScriptLoader::ExecuteScript( // Steps 3--7 of https://html.spec.whatwg.org/#execute-the-script-block
const Script* script) {
double script_exec_start_time = MonotonicallyIncreasingTime();
ExecuteScriptResult result = DoExecuteScript(script);
// NOTE: we do not check m_willBeParserExecuted here, since
// m_willBeParserExecuted is false for inline scripts, and we want to
// include inline script execution time as part of parser blocked script
// execution time.
if (async_exec_type_ == ScriptRunner::kNone)
DocumentParserTiming::From(element_->GetDocument())
.RecordParserBlockedOnScriptExecutionDuration(
MonotonicallyIncreasingTime() - script_exec_start_time,
WasCreatedDuringDocumentWrite());
return result;
}
// https://html.spec.whatwg.org/#execute-the-script-block
// with additional support for HTML imports. // with additional support for HTML imports.
// Note that Steps 2 and 8 must be handled by the caller of doExecuteScript(), // Steps 2 and 8 are handled in ExecuteScriptBlock().
// i.e. load/error events are dispatched by the caller.
// Steps 3--7 are implemented here in doExecuteScript().
// TODO(hiroshige): Move event dispatching code to doExecuteScript().
ScriptLoader::ExecuteScriptResult ScriptLoader::DoExecuteScript( ScriptLoader::ExecuteScriptResult ScriptLoader::DoExecuteScript(
const Script* script) { const Script* script) {
DCHECK(already_started_); DCHECK(already_started_);
...@@ -941,8 +921,23 @@ bool ScriptLoader::ExecuteScriptBlock(PendingScript* pending_script, ...@@ -941,8 +921,23 @@ bool ScriptLoader::ExecuteScriptBlock(PendingScript* pending_script,
if (was_canceled) if (was_canceled)
return false; return false;
// Steps 3--7 are in ExecuteScript(). double script_exec_start_time = MonotonicallyIncreasingTime();
switch (ExecuteScript(script)) {
// Steps 3--7 are in DoExecuteScript().
ExecuteScriptResult result = DoExecuteScript(script);
// NOTE: we do not check m_willBeParserExecuted here, since
// m_willBeParserExecuted is false for inline scripts, and we want to
// include inline script execution time as part of parser blocked script
// execution time.
if (async_exec_type_ == ScriptRunner::kNone) {
DocumentParserTiming::From(element_->GetDocument())
.RecordParserBlockedOnScriptExecutionDuration(
MonotonicallyIncreasingTime() - script_exec_start_time,
WasCreatedDuringDocumentWrite());
}
switch (result) {
case ExecuteScriptResult::kShouldFireLoadEvent: case ExecuteScriptResult::kShouldFireLoadEvent:
// 8. "If the script is from an external file, then fire an event named // 8. "If the script is from an external file, then fire an event named
// load at the script element." // load at the script element."
......
...@@ -180,7 +180,6 @@ class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, ...@@ -180,7 +180,6 @@ class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>,
kShouldFireLoadEvent, kShouldFireLoadEvent,
kShouldFireNone kShouldFireNone
}; };
WARN_UNUSED_RESULT ExecuteScriptResult ExecuteScript(const Script*);
ExecuteScriptResult DoExecuteScript(const Script*); ExecuteScriptResult DoExecuteScript(const Script*);
void DispatchLoadEvent(); void DispatchLoadEvent();
void DispatchErrorEvent(); void DispatchErrorEvent();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment