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

Unified Diff: third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp

Issue 1535943005: Initial implementation of bindings and basic classes for worklets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 12 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/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..0c8b8fbbeeecc1c4a071b2b90b95f981726f826c 100644
--- a/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp
+++ b/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp
@@ -25,6 +25,7 @@
#include "bindings/modules/v8/V8BindingForModules.h"
+#include "bindings/core/v8/IsolatedScriptController.h"
#include "bindings/core/v8/SerializedScriptValue.h"
#include "bindings/core/v8/SerializedScriptValueFactory.h"
#include "bindings/core/v8/V8ArrayBuffer.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);
+
+ IsolatedScriptController* 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 0;
haraken 2016/01/05 06:08:06 nullptr
ikilpatrick 2016/01/07 22:47:35 Done.
+ 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 0;
haraken 2016/01/05 06:08:06 nullptr
ikilpatrick 2016/01/07 22:47:35 Done.
+}
+
+v8::Local<v8::Context> toV8ContextForModules(ExecutionContext* context)
+{
+ if (context->isWorkletGlobalScope()) {
+ if (IsolatedScriptController* script = toWorkletGlobalScope(context)->script()) {
+ if (script->scriptState()->contextIsValid())
+ return script->scriptState()->context();
+ }
+ }
+ return v8::Local<v8::Context>();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698