| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/dom/ModulatorImpl.h" | 5 #include "core/dom/ModulatorImpl.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/dom/ModuleMap.h" | 9 #include "core/dom/ModuleMap.h" |
| 10 #include "core/dom/ModuleScript.h" | 10 #include "core/dom/ModuleScript.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Step 2. When the internal module script graph fetching procedure | 70 // Step 2. When the internal module script graph fetching procedure |
| 71 // asynchronously completes with result, asynchronously complete this | 71 // asynchronously completes with result, asynchronously complete this |
| 72 // algorithm with result. | 72 // algorithm with result. |
| 73 // Note: We delegate to ModuleTreeLinker to notify ModuleTreeClient. | 73 // Note: We delegate to ModuleTreeLinker to notify ModuleTreeClient. |
| 74 } | 74 } |
| 75 | 75 |
| 76 void ModulatorImpl::FetchTreeInternal(const ModuleScriptFetchRequest& request, | 76 void ModulatorImpl::FetchTreeInternal(const ModuleScriptFetchRequest& request, |
| 77 const AncestorList& ancestor_list, | 77 const AncestorList& ancestor_list, |
| 78 ModuleGraphLevel level, | 78 ModuleGraphLevel level, |
| 79 ModuleTreeClient* client) { | 79 ModuleTreeClient* client) { |
| 80 // We ensure module-related code is not executed without the flag. |
| 81 // https://crbug.com/715376 |
| 82 CHECK(RuntimeEnabledFeatures::moduleScriptsEnabled()); |
| 83 |
| 80 tree_linker_registry_->Fetch(request, ancestor_list, level, this, client); | 84 tree_linker_registry_->Fetch(request, ancestor_list, level, this, client); |
| 81 } | 85 } |
| 82 | 86 |
| 83 void ModulatorImpl::FetchSingle(const ModuleScriptFetchRequest& request, | 87 void ModulatorImpl::FetchSingle(const ModuleScriptFetchRequest& request, |
| 84 ModuleGraphLevel level, | 88 ModuleGraphLevel level, |
| 85 SingleModuleClient* client) { | 89 SingleModuleClient* client) { |
| 90 // We ensure module-related code is not executed without the flag. |
| 91 // https://crbug.com/715376 |
| 92 CHECK(RuntimeEnabledFeatures::moduleScriptsEnabled()); |
| 93 |
| 86 map_->FetchSingleModuleScript(request, level, client); | 94 map_->FetchSingleModuleScript(request, level, client); |
| 87 } | 95 } |
| 88 | 96 |
| 89 void ModulatorImpl::FetchNewSingleModule( | 97 void ModulatorImpl::FetchNewSingleModule( |
| 90 const ModuleScriptFetchRequest& request, | 98 const ModuleScriptFetchRequest& request, |
| 91 ModuleGraphLevel level, | 99 ModuleGraphLevel level, |
| 92 ModuleScriptLoaderClient* client) { | 100 ModuleScriptLoaderClient* client) { |
| 101 // We ensure module-related code is not executed without the flag. |
| 102 // https://crbug.com/715376 |
| 103 CHECK(RuntimeEnabledFeatures::moduleScriptsEnabled()); |
| 104 |
| 93 loader_registry_->Fetch(request, level, this, fetcher_.Get(), client); | 105 loader_registry_->Fetch(request, level, this, fetcher_.Get(), client); |
| 94 } | 106 } |
| 95 | 107 |
| 96 ModuleScript* ModulatorImpl::GetFetchedModuleScript(const KURL& url) { | 108 ModuleScript* ModulatorImpl::GetFetchedModuleScript(const KURL& url) { |
| 97 return map_->GetFetchedModuleScript(url); | 109 return map_->GetFetchedModuleScript(url); |
| 98 } | 110 } |
| 99 | 111 |
| 100 ScriptModule ModulatorImpl::CompileModule( | 112 ScriptModule ModulatorImpl::CompileModule( |
| 101 const String& provided_source, | 113 const String& provided_source, |
| 102 const String& url_str, | 114 const String& url_str, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return script_module.ModuleRequests(script_state_.Get()); | 146 return script_module.ModuleRequests(script_state_.Get()); |
| 135 } | 147 } |
| 136 | 148 |
| 137 inline ExecutionContext* ModulatorImpl::GetExecutionContext() const { | 149 inline ExecutionContext* ModulatorImpl::GetExecutionContext() const { |
| 138 return ExecutionContext::From(script_state_.Get()); | 150 return ExecutionContext::From(script_state_.Get()); |
| 139 } | 151 } |
| 140 | 152 |
| 141 void ModulatorImpl::ExecuteModule(const ModuleScript* module_script) { | 153 void ModulatorImpl::ExecuteModule(const ModuleScript* module_script) { |
| 142 // https://html.spec.whatwg.org/#run-a-module-script | 154 // https://html.spec.whatwg.org/#run-a-module-script |
| 143 | 155 |
| 156 // We ensure module-related code is not executed without the flag. |
| 157 // https://crbug.com/715376 |
| 158 CHECK(RuntimeEnabledFeatures::moduleScriptsEnabled()); |
| 159 |
| 144 // 1. "Let settings be the settings object of s." | 160 // 1. "Let settings be the settings object of s." |
| 145 // The settings object is |this|. | 161 // The settings object is |this|. |
| 146 | 162 |
| 147 // 2. "Check if we can run script with settings. | 163 // 2. "Check if we can run script with settings. |
| 148 // If this returns "do not run" then abort these steps." | 164 // If this returns "do not run" then abort these steps." |
| 149 if (!GetExecutionContext()->CanExecuteScripts(kAboutToExecuteScript)) | 165 if (!GetExecutionContext()->CanExecuteScripts(kAboutToExecuteScript)) |
| 150 return; | 166 return; |
| 151 | 167 |
| 152 // 6. "Prepare to run script given settings." | 168 // 6. "Prepare to run script given settings." |
| 153 // This is placed here to also cover ScriptModule::ReportException(). | 169 // This is placed here to also cover ScriptModule::ReportException(). |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 visitor->Trace(loader_registry_); | 203 visitor->Trace(loader_registry_); |
| 188 visitor->Trace(tree_linker_registry_); | 204 visitor->Trace(tree_linker_registry_); |
| 189 visitor->Trace(script_module_resolver_); | 205 visitor->Trace(script_module_resolver_); |
| 190 } | 206 } |
| 191 | 207 |
| 192 DEFINE_TRACE_WRAPPERS(ModulatorImpl) { | 208 DEFINE_TRACE_WRAPPERS(ModulatorImpl) { |
| 193 visitor->TraceWrappers(map_); | 209 visitor->TraceWrappers(map_); |
| 194 } | 210 } |
| 195 | 211 |
| 196 } // namespace blink | 212 } // namespace blink |
| OLD | NEW |