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

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

Issue 28763006: Support $0, $1, ... $6, inspect, and other console api methods. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: ready for review Created 7 years, 2 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 | « Source/bindings/dart/DartHandleProxy.cpp ('k') | Source/bindings/dart/DartUtilities.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/dart/DartJsInterop.cpp
diff --git a/Source/bindings/dart/DartJsInterop.cpp b/Source/bindings/dart/DartJsInterop.cpp
index c5f76d18385d553683fdf052cc0672a095a71090..df1b167c19f48e78c935c1fdbf8839156b01ec05 100644
--- a/Source/bindings/dart/DartJsInterop.cpp
+++ b/Source/bindings/dart/DartJsInterop.cpp
@@ -231,6 +231,8 @@ v8::Local<v8::Value> JsInterop::fromDart(DartDOMData* domData, Dart_Handle handl
ASSERT(Dart_IsInstance(handle));
proxy = dartObjectTemplate()->InstanceTemplate()->NewInstance();
DartHandleProxy::writePointerToProxy(proxy, handle);
+ proxy->SetHiddenValue(v8::String::NewSymbol("dartProxy"), v8::Boolean::New(true));
+
return proxy;
}
@@ -265,7 +267,7 @@ Dart_Handle JsInterop::toDart(v8::Local<v8::Value> v8Handle)
// from Dart to JS as we have to wrap them with true JS Function objects.
// If this use case is important we can support it at the cost of hanging
// an extra expando off the JS function wrapping the Dart function.
- if (dartObjectTemplate()->HasInstance(v8Handle)) {
+ if (DartHandleProxy::isDartProxy(v8Handle)) {
DartScriptValue* scriptValue = DartHandleProxy::readPointerFromProxy(v8Handle);
ASSERT(scriptValue->isIsolateAlive());
return scriptValue->value();
@@ -338,6 +340,23 @@ void argsListToV8(DartDOMData* domData, Dart_Handle args, Vector<v8::Local<v8::V
}
}
+void argsListToV8DebuggerOnly(DartDOMData* domData, Dart_Handle args, Vector<v8::Local<v8::Value> >* v8Args, Dart_Handle& exception)
+{
+ if (Dart_IsNull(args))
+ return;
+
+ if (!Dart_IsList(args)) {
+ exception = Dart_NewStringFromCString("args not type list");
+ return;
+ }
+
+ intptr_t argsLength = 0;
+ Dart_ListLength(args, &argsLength);
+ for (intptr_t i = 0; i < argsLength; i++) {
+ v8Args->append(DartHandleProxy::create(Dart_ListGetAt(args, i)));
+ }
+}
+
static void jsObjectConstructorCallback(Dart_NativeArguments args)
{
Dart_Handle exception = 0;
@@ -693,6 +712,46 @@ fail:
ASSERT_NOT_REACHED();
}
+static void applyDebuggerOnlyCallback(Dart_NativeArguments args)
+{
+ Dart_Handle exception = 0;
+ {
+ JsInteropScopes scopes(args);
+ DartDOMData* domData = static_cast<DartDOMData*>(Dart_GetNativeIsolateData(args));
+ JsFunction* receiver = DartDOMWrapper::receiver<JsFunction>(args);
+
+ Vector<v8::Local<v8::Value> > v8Args;
+ argsListToV8DebuggerOnly(domData, Dart_GetNativeArgument(args, 1), &v8Args, exception);
+ if (exception)
+ goto fail;
+
+ v8::Local<v8::Value> thisArg;
+ Dart_Handle thisArgDart = Dart_GetNativeArgument(args, 2);
+ if (Dart_IsNull(thisArgDart)) {
+ // Use the global v8 object if no Dart thisArg was passed in.
+ thisArg = DartUtilities::currentV8Context()->Global();
+ } else {
+ thisArg = JsInterop::fromDart(domData, thisArgDart, exception);
+ if (exception)
+ goto fail;
+ if (!thisArg->IsObject()) {
+ exception = Dart_NewStringFromCString("thisArg is not an object");
+ goto fail;
+ }
+ }
+
+ v8::Local<v8::Value> ret = V8ScriptRunner::callFunction(receiver->localV8Function(), DartUtilities::scriptExecutionContext(), thisArg.As<v8::Object>(), v8Args.size(), v8Args.data());
+ if (scopes.handleJsException(&exception))
+ goto fail;
+ scopes.setReturnValue(ret);
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
static void toStringCallback(Dart_NativeArguments args)
{
Dart_Handle exception = 0;
@@ -899,6 +958,9 @@ Dart_NativeFunction JsInterop::resolver(Dart_Handle nameHandle, int argumentCoun
if (argumentCount == 3 && name == "JsFunction_apply")
return JsInteropInternal::applyCallback;
+ if (argumentCount == 3 && name == "JsFunction_applyDebuggerOnly")
+ return JsInteropInternal::applyDebuggerOnlyCallback;
+
if (argumentCount == 1 && name == "JsObject_fromBrowserObject")
return JsInteropInternal::fromBrowserObjectCallback;
« no previous file with comments | « Source/bindings/dart/DartHandleProxy.cpp ('k') | Source/bindings/dart/DartUtilities.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698