| Index: Source/bindings/dart/DartInjectedScriptHost.cpp
|
| diff --git a/Source/bindings/dart/custom/DartErrorEventCustom.cpp b/Source/bindings/dart/DartInjectedScriptHost.cpp
|
| similarity index 51%
|
| copy from Source/bindings/dart/custom/DartErrorEventCustom.cpp
|
| copy to Source/bindings/dart/DartInjectedScriptHost.cpp
|
| index 06a5c3a77c8e5d7e68d459ee9ac8f734cc3b4eba..a095836d6f2d9aab91683982628c871f29219e01 100644
|
| --- a/Source/bindings/dart/custom/DartErrorEventCustom.cpp
|
| +++ b/Source/bindings/dart/DartInjectedScriptHost.cpp
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2011, Google Inc.
|
| +// Copyright 2013, Google Inc.
|
| // All rights reserved.
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| @@ -28,37 +28,42 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| #include "config.h"
|
| -#include "DartErrorEvent.h"
|
| +#include "DartInjectedScriptHost.h"
|
|
|
| -#include "DartBlob.h"
|
| -#include "DartWindow.h"
|
| +#include "bindings/dart/DartController.h"
|
| +#include "bindings/dart/DartHandleProxy.h"
|
| +#include "bindings/dart/DartScriptState.h"
|
| #include "bindings/dart/V8Converter.h"
|
| -#include "bindings/v8/ScriptController.h"
|
| +#include "bindings/v8/V8HiddenPropertyName.h"
|
|
|
| namespace WebCore {
|
|
|
| -namespace DartErrorEventInternal {
|
| -
|
| -void errorGetter(Dart_NativeArguments args)
|
| +/**
|
| + * Returns true if the expression passed in my args was evaluated as Dart code.
|
| + */
|
| +v8::Handle<v8::Value> DartInjectedScriptHost::evaluateIfDartContext(v8::Handle<v8::Object> v8InjectedScriptHost, v8::Handle<v8::String> expression)
|
| {
|
| - // Tricky to implement because V8 appears to implement by setting a V8HiddenValue
|
| - /*
|
| - {
|
| - v8::Handle<v8::Value> error = info.Holder()->GetHiddenValue(V8HiddenPropertyName::error());
|
| + ASSERT(!v8::Context::GetCurrent().IsEmpty());
|
|
|
| - if (!error.IsEmpty()) {
|
| - v8SetReturnValue(info, error);
|
| - return;
|
| - }
|
| - ErrorEvent* receiver = DartDOMWrapper::receiver< ErrorEvent >(args);
|
| + ScriptState* currentScriptState = 0;
|
| + v8::Local<v8::Value> scriptStateWrapper = v8InjectedScriptHost->GetHiddenValue(V8HiddenPropertyName::scriptState());
|
| + if (!scriptStateWrapper.IsEmpty() && scriptStateWrapper->IsExternal())
|
| + currentScriptState = static_cast<ScriptState*>(v8::External::Cast(*scriptStateWrapper)->Value());
|
| + else
|
| + currentScriptState = ScriptState::current();
|
|
|
| - DartUtilities::setDartStringReturnValue(args, receiver->error());
|
| - return;
|
| - }
|
| - */
|
| - DART_UNIMPLEMENTED();
|
| -}
|
| + ScriptExecutionContext* scriptExecutionContext = currentScriptState->scriptExecutionContext();
|
| + ASSERT(scriptExecutionContext);
|
|
|
| -}
|
| + if (!currentScriptState->isJavaScript()) {
|
| + DartScriptState* dartScriptState = static_cast<DartScriptState*>(currentScriptState);
|
| + DartIsolateScope scope(dartScriptState->isolate());
|
| + DartApiScope apiScope;
|
|
|
| + Dart_Handle target = Dart_GetLibraryFromId(dartScriptState->libraryId());
|
| + return DartHandleProxy::evaluate(target, V8Converter::stringToDart(expression), Dart_Null());
|
| + }
|
| + return v8::Handle<v8::Value>();
|
| }
|
| +
|
| +} // namespace WebCore
|
|
|