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

Unified Diff: third_party/WebKit/Source/core/dom/Modulator.cpp

Issue 2826313003: Worklet: Enable module script loading for main thread worklets (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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Modulator.cpp
diff --git a/third_party/WebKit/Source/core/dom/Modulator.cpp b/third_party/WebKit/Source/core/dom/Modulator.cpp
index 7d7f0ce0a7102fac9aef0a1ebf339216d18fdbc2..b17b720e4adf4413ae0a506dac906dde3b19f040 100644
--- a/third_party/WebKit/Source/core/dom/Modulator.cpp
+++ b/third_party/WebKit/Source/core/dom/Modulator.cpp
@@ -10,6 +10,7 @@
#include "core/dom/Document.h"
#include "core/dom/ModulatorImpl.h"
#include "core/frame/LocalFrame.h"
+#include "core/workers/MainThreadWorkletGlobalScope.h"
namespace blink {
@@ -27,11 +28,23 @@ Modulator* Modulator::From(ScriptState* script_state) {
Modulator* modulator =
static_cast<Modulator*>(per_context_data->GetData(kPerContextDataKey));
- if (!modulator) {
- if (Document* document = ToDocument(ExecutionContext::From(script_state))) {
- modulator = ModulatorImpl::Create(script_state, *document);
- Modulator::SetModulator(script_state, modulator);
- }
+ if (modulator)
+ return modulator;
+ ExecutionContext* execution_context = ExecutionContext::From(script_state);
+ if (execution_context->IsDocument()) {
+ Document* document = ToDocument(execution_context);
+ modulator =
+ ModulatorImpl::Create(script_state, *document, document->Fetcher());
+ Modulator::SetModulator(script_state, modulator);
+ } else if (execution_context->IsMainThreadWorkletGlobalScope()) {
+ MainThreadWorkletGlobalScope* global_scope =
+ ToMainThreadWorkletGlobalScope(execution_context);
+ modulator = ModulatorImpl::Create(
+ script_state, *global_scope,
+ global_scope->GetFrame()->GetDocument()->Fetcher());
+ Modulator::SetModulator(script_state, modulator);
+ } else {
+ NOTREACHED();
}
return modulator;
}

Powered by Google App Engine
This is Rietveld 408576698