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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ScriptState::Scope scope(script_state_.Get()); | 133 ScriptState::Scope scope(script_state_.Get()); |
134 return ScriptModule::Compile(script_state_->GetIsolate(), script_source, | 134 return ScriptModule::Compile(script_state_->GetIsolate(), script_source, |
135 url_str, access_control_status); | 135 url_str, access_control_status); |
136 } | 136 } |
137 | 137 |
138 ScriptValue ModulatorImpl::InstantiateModule(ScriptModule script_module) { | 138 ScriptValue ModulatorImpl::InstantiateModule(ScriptModule script_module) { |
139 ScriptState::Scope scope(script_state_.Get()); | 139 ScriptState::Scope scope(script_state_.Get()); |
140 return script_module.Instantiate(script_state_.Get()); | 140 return script_module.Instantiate(script_state_.Get()); |
141 } | 141 } |
142 | 142 |
| 143 ScriptValue ModulatorImpl::GetInstantiationError( |
| 144 const ModuleScript* module_script) { |
| 145 ScriptState::Scope scope(script_state_.Get()); |
| 146 return ScriptValue(script_state_.Get(), |
| 147 module_script->CreateInstantiationErrorInternal( |
| 148 script_state_->GetIsolate())); |
| 149 } |
| 150 |
143 Vector<String> ModulatorImpl::ModuleRequestsFromScriptModule( | 151 Vector<String> ModulatorImpl::ModuleRequestsFromScriptModule( |
144 ScriptModule script_module) { | 152 ScriptModule script_module) { |
145 ScriptState::Scope scope(script_state_.Get()); | 153 ScriptState::Scope scope(script_state_.Get()); |
146 return script_module.ModuleRequests(script_state_.Get()); | 154 return script_module.ModuleRequests(script_state_.Get()); |
147 } | 155 } |
148 | 156 |
149 inline ExecutionContext* ModulatorImpl::GetExecutionContext() const { | 157 inline ExecutionContext* ModulatorImpl::GetExecutionContext() const { |
150 return ExecutionContext::From(script_state_.Get()); | 158 return ExecutionContext::From(script_state_.Get()); |
151 } | 159 } |
152 | 160 |
(...skipping 16 matching lines...) Expand all Loading... |
169 // This is placed here to also cover ScriptModule::ReportException(). | 177 // This is placed here to also cover ScriptModule::ReportException(). |
170 ScriptState::Scope scope(script_state_.Get()); | 178 ScriptState::Scope scope(script_state_.Get()); |
171 | 179 |
172 // 3. "If s's instantiation state is "errored", then report the exception | 180 // 3. "If s's instantiation state is "errored", then report the exception |
173 // given by s's instantiation error for s and abort these steps." | 181 // given by s's instantiation error for s and abort these steps." |
174 ModuleInstantiationState instantiationState = | 182 ModuleInstantiationState instantiationState = |
175 module_script->InstantiationState(); | 183 module_script->InstantiationState(); |
176 if (instantiationState == ModuleInstantiationState::kErrored) { | 184 if (instantiationState == ModuleInstantiationState::kErrored) { |
177 v8::Isolate* isolate = script_state_->GetIsolate(); | 185 v8::Isolate* isolate = script_state_->GetIsolate(); |
178 ScriptModule::ReportException( | 186 ScriptModule::ReportException( |
179 script_state_.Get(), module_script->CreateInstantiationError(isolate), | 187 script_state_.Get(), |
| 188 module_script->CreateInstantiationErrorInternal(isolate), |
180 module_script->BaseURL().GetString()); | 189 module_script->BaseURL().GetString()); |
181 return; | 190 return; |
182 } | 191 } |
183 | 192 |
184 // 4. "Assert: s's instantiation state is "instantiated" (and thus its | 193 // 4. "Assert: s's instantiation state is "instantiated" (and thus its |
185 // module record is not null)." | 194 // module record is not null)." |
186 CHECK_EQ(instantiationState, ModuleInstantiationState::kInstantiated); | 195 CHECK_EQ(instantiationState, ModuleInstantiationState::kInstantiated); |
187 | 196 |
188 // 5. "Let record be s's module record." | 197 // 5. "Let record be s's module record." |
189 const ScriptModule& record = module_script->Record(); | 198 const ScriptModule& record = module_script->Record(); |
(...skipping 13 matching lines...) Expand all Loading... |
203 visitor->Trace(loader_registry_); | 212 visitor->Trace(loader_registry_); |
204 visitor->Trace(tree_linker_registry_); | 213 visitor->Trace(tree_linker_registry_); |
205 visitor->Trace(script_module_resolver_); | 214 visitor->Trace(script_module_resolver_); |
206 } | 215 } |
207 | 216 |
208 DEFINE_TRACE_WRAPPERS(ModulatorImpl) { | 217 DEFINE_TRACE_WRAPPERS(ModulatorImpl) { |
209 visitor->TraceWrappers(map_); | 218 visitor->TraceWrappers(map_); |
210 } | 219 } |
211 | 220 |
212 } // namespace blink | 221 } // namespace blink |
OLD | NEW |