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

Side by Side Diff: third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp

Issue 2781713003: Enable module scripts in ScriptLoader (Closed)
Patch Set: Rebase Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
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/loader/modulescript/ModuleTreeLinker.h" 5 #include "core/loader/modulescript/ModuleTreeLinker.h"
6 6
7 #include "bindings/core/v8/ScriptModule.h" 7 #include "bindings/core/v8/ScriptModule.h"
8 #include "core/dom/AncestorList.h" 8 #include "core/dom/AncestorList.h"
9 #include "core/dom/ModuleScript.h" 9 #include "core/dom/ModuleScript.h"
10 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" 10 #include "core/loader/modulescript/ModuleScriptFetchRequest.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (state != ModuleInstantiationState::kUninstantiated) { 310 if (state != ModuleInstantiationState::kUninstantiated) {
311 AdvanceState(State::kFinished); 311 AdvanceState(State::kFinished);
312 return; 312 return;
313 } 313 }
314 314
315 // Step 5. Let record be result's module record. 315 // Step 5. Let record be result's module record.
316 ScriptModule record = module_script_->Record(); 316 ScriptModule record = module_script_->Record();
317 317
318 // Step 6. Let instantiationStatus be record.ModuleDeclarationInstantiation(). 318 // Step 6. Let instantiationStatus be record.ModuleDeclarationInstantiation().
319 ScriptValue error = modulator_->InstantiateModule(record); 319 ScriptValue error = modulator_->InstantiateModule(record);
320 /*
320 if (!error.IsEmpty()) { 321 if (!error.IsEmpty()) {
321 module_script_->SetInstantiationError(error.GetIsolate(), error.V8Value()); 322 module_script_->SetInstantiationError(error.GetIsolate(), error.V8Value());
322 } else { 323 } else {
323 module_script_->SetInstantiationSuccess(); 324 module_script_->SetInstantiationSuccess();
324 } 325 }
325 ModuleInstantiationState instantiation_status = 326 ModuleInstantiationState instantiation_status =
326 module_script_->InstantiationState(); 327 module_script_->InstantiationState();
328 */
327 329
328 // Step 7. For each module script script in result's uninstantiated inclusive 330 // Step 7. For each module script script in result's uninstantiated inclusive
329 // descendant module scripts, perform the following steps: 331 // descendant module scripts, perform the following steps:
330 HeapHashSet<Member<ModuleScript>> uninstantiated_set = 332 HeapHashSet<Member<ModuleScript>> uninstantiated_set =
331 UninstantiatedInclusiveDescendants(); 333 UninstantiatedInclusiveDescendants();
332 for (const auto& descendant : uninstantiated_set) { 334 for (const auto& descendant : uninstantiated_set) {
333 if (instantiation_status == ModuleInstantiationState::kErrored) { 335 if (!error.IsEmpty()) {
334 // Step 7.1. If instantiationStatus is an abrupt completion, then set 336 // Step 7.1. If instantiationStatus is an abrupt completion, then set
335 // script's 337 // script's
336 // instantiation state to "errored", its instantiation error to 338 // instantiation state to "errored", its instantiation error to
337 // instantiationStatus.[[Value]], and its module record to null. 339 // instantiationStatus.[[Value]], and its module record to null.
338 DCHECK(!error.IsEmpty()); 340 DCHECK(!error.IsEmpty());
339 descendant->SetInstantiationError(error.GetIsolate(), error.V8Value()); 341 descendant->SetInstantiationError(error.GetIsolate(), error.V8Value());
340 descendant->ClearRecord(); 342 descendant->ClearRecord();
341 } else { 343 } else {
342 // Step 7.2. Otherwise, set script's instantiation state to 344 // Step 7.2. Otherwise, set script's instantiation state to
343 // "instantiated". 345 // "instantiated".
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 HeapHashSet<Member<ModuleScript>> uninstantiated_set; 422 HeapHashSet<Member<ModuleScript>> uninstantiated_set;
421 for (const auto& script : inclusive_descendants) { 423 for (const auto& script : inclusive_descendants) {
422 if (script->InstantiationState() == 424 if (script->InstantiationState() ==
423 ModuleInstantiationState::kUninstantiated) 425 ModuleInstantiationState::kUninstantiated)
424 uninstantiated_set.insert(script); 426 uninstantiated_set.insert(script);
425 } 427 }
426 return uninstantiated_set; 428 return uninstantiated_set;
427 } 429 }
428 430
429 } // namespace blink 431 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698