| Index: third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp b/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp
|
| index c64fc776dbe07fb27ad0f93be52256628ba34dfc..5e16341e64f60ca82d3213149526f7498185727f 100644
|
| --- a/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp
|
| +++ b/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp
|
| @@ -34,6 +34,7 @@
|
| #include "bindings/core/v8/V8DOMStringList.h"
|
| #include "bindings/core/v8/V8File.h"
|
| #include "bindings/core/v8/V8Uint8Array.h"
|
| +#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
|
| #include "bindings/modules/v8/ToV8ForModules.h"
|
| #include "bindings/modules/v8/V8IDBCursor.h"
|
| #include "bindings/modules/v8/V8IDBCursorWithValue.h"
|
| @@ -41,13 +42,16 @@
|
| #include "bindings/modules/v8/V8IDBIndex.h"
|
| #include "bindings/modules/v8/V8IDBKeyRange.h"
|
| #include "bindings/modules/v8/V8IDBObjectStore.h"
|
| +#include "bindings/modules/v8/V8WorkletGlobalScope.h"
|
| #include "core/dom/DOMArrayBuffer.h"
|
| #include "core/dom/DOMArrayBufferView.h"
|
| +#include "core/dom/ExecutionContext.h"
|
| #include "modules/indexeddb/IDBKey.h"
|
| #include "modules/indexeddb/IDBKeyPath.h"
|
| #include "modules/indexeddb/IDBKeyRange.h"
|
| #include "modules/indexeddb/IDBTracing.h"
|
| #include "modules/indexeddb/IDBValue.h"
|
| +#include "modules/worklet/WorkletGlobalScope.h"
|
| #include "platform/RuntimeEnabledFeatures.h"
|
| #include "platform/SharedBuffer.h"
|
| #include "wtf/MathExtras.h"
|
| @@ -159,6 +163,23 @@ v8::Local<v8::Value> toV8(const IDBAny* impl, v8::Local<v8::Object> creationCont
|
| return v8::Undefined(isolate);
|
| }
|
|
|
| +v8::Local<v8::Value> toV8(WorkletGlobalScope* impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
|
| +{
|
| + // Notice that we explicitly ignore creationContext because the
|
| + // WorkletGlobalScope has its own creationContext.
|
| +
|
| + if (UNLIKELY(!impl))
|
| + return v8::Null(isolate);
|
| +
|
| + WorkerOrWorkletScriptController* script = impl->script();
|
| + if (!script)
|
| + return v8::Null(isolate);
|
| +
|
| + v8::Local<v8::Object> global = script->context()->Global();
|
| + ASSERT(!global.IsEmpty());
|
| + return global;
|
| +}
|
| +
|
| static const size_t maximumDepth = 2000;
|
|
|
| static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, v8::Local<v8::Value> value, Vector<v8::Local<v8::Array>>& stack, ExceptionState& exceptionState, bool allowExperimentalTypes = false)
|
| @@ -516,4 +537,27 @@ void assertPrimaryKeyValidOrInjectable(ScriptState* scriptState, const IDBValue*
|
| }
|
| #endif
|
|
|
| +ExecutionContext* toExecutionContextForModules(v8::Local<v8::Context> context)
|
| +{
|
| + if (context.IsEmpty())
|
| + return nullptr;
|
| + v8::Local<v8::Object> global = context->Global();
|
| + v8::Local<v8::Object> workletWrapper = V8WorkletGlobalScope::findInstanceInPrototypeChain(global, context->GetIsolate());
|
| + if (!workletWrapper.IsEmpty())
|
| + return V8WorkletGlobalScope::toImpl(workletWrapper);
|
| + // FIXME: Is this line of code reachable?
|
| + return nullptr;
|
| +}
|
| +
|
| +v8::Local<v8::Context> toV8ContextForModules(ExecutionContext* context)
|
| +{
|
| + if (context->isWorkletGlobalScope()) {
|
| + if (WorkerOrWorkletScriptController* script = toWorkletGlobalScope(context)->script()) {
|
| + if (script->scriptState()->contextIsValid())
|
| + return script->scriptState()->context();
|
| + }
|
| + }
|
| + return v8::Local<v8::Context>();
|
| +}
|
| +
|
| } // namespace blink
|
|
|