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

Unified Diff: Source/bindings/core/dart/DartJsInterop.cpp

Issue 1724593002: Fix broken code passing typed data from Dart to V8. Attempted to match patterns in SerializeScriptV… (Closed) Base URL: https://chromium.googlesource.com/dart/dartium/blink.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | Source/bindings/core/dart/V8Converter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/dart/DartJsInterop.cpp
diff --git a/Source/bindings/core/dart/DartJsInterop.cpp b/Source/bindings/core/dart/DartJsInterop.cpp
index 7478ca2de1cd0dc5a91e9dcd9d961770ac810e33..afad3c232955c9af17329ebfc5a7bdb7c6cd1d9d 100644
--- a/Source/bindings/core/dart/DartJsInterop.cpp
+++ b/Source/bindings/core/dart/DartJsInterop.cpp
@@ -337,6 +337,7 @@ PassRefPtr<JsObject> JsObject::create(v8::Local<v8::Object> v8Handle)
v8::Local<v8::Value> JsInterop::fromDart(DartDOMData* domData, Dart_Handle handle, Dart_Handle& exception)
{
+ v8::Isolate* v8Isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::Value> value = V8Converter::toV8IfPrimitive(domData, handle, exception);
if (!value.IsEmpty() || exception)
return value;
@@ -359,7 +360,13 @@ v8::Local<v8::Value> JsInterop::fromDart(DartDOMData* domData, Dart_Handle handl
DartHandleProxy::writePointerToProxy(functionProxy, handle);
// The raw functionProxy doesn't behave enough like a true JS function
// so we wrap it in a true JS function.
- return domData->jsInteropData()->wrapDartFunction()->Call(functionProxy, 0, 0);
+ v8::Local<v8::Function> object = domData->jsInteropData()->wrapDartFunction()->Call(functionProxy, 0, 0).As<v8::Function>();
+
+ v8::Local<v8::String> existingDartWrapperKey = domData->jsInteropData()->existingDartWrapperHiddenField(v8Isolate);
+ v8::Local<v8::Object> containerForDartHandle = dartObjectTemplate()->InstanceTemplate()->NewInstance();
+ DartHandleProxy::writePointerToProxy(containerForDartHandle, handle);
+ object->SetHiddenValue(existingDartWrapperKey, containerForDartHandle);
+ return object;
}
v8::Local<v8::Object> proxy;
@@ -377,7 +384,6 @@ v8::Local<v8::Value> JsInterop::fromDart(DartDOMData* domData, Dart_Handle handl
proxy = dartObjectTemplate()->InstanceTemplate()->NewInstance();
}
DartHandleProxy::writePointerToProxy(proxy, handle);
- v8::Isolate* v8Isolate = v8::Isolate::GetCurrent();
proxy->SetHiddenValue(v8::String::NewFromUtf8(v8Isolate, "dartProxy"), v8::Boolean::New(v8Isolate, true));
return proxy;
@@ -466,9 +472,6 @@ Dart_Handle JsObject::toDart(v8::Local<v8::Object> object, bool sometimesUseHtml
DartDOMData* domData = DartDOMData::current();
DartJsInteropData* interopData = domData->jsInteropData();
v8::Local<v8::String> existingDartWrapperKey = interopData->existingDartWrapperHiddenField(v8Isolate);
-
- // TODO(alanknight): This will fail for multiple isolates referencing the same JS object.
- // We probably need to use a different property name for different isolates.
v8::Local<v8::Value> hiddenValue = object->GetHiddenValue(existingDartWrapperKey);
if (*hiddenValue && hiddenValue->IsObject()) {
« no previous file with comments | « no previous file | Source/bindings/core/dart/V8Converter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698