diff options
Diffstat (limited to 'WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp')
-rw-r--r-- | WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp b/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp index f4ea62a..bc7bb6c 100644 --- a/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp @@ -31,14 +31,15 @@ #include "config.h" #include "V8CustomVoidCallback.h" -#include "Frame.h" +#include "ScriptExecutionContext.h" #include "V8Binding.h" +#include "V8Proxy.h" namespace WebCore { -V8CustomVoidCallback::V8CustomVoidCallback(v8::Local<v8::Object> callback, Frame* frame) +V8CustomVoidCallback::V8CustomVoidCallback(v8::Local<v8::Object> callback, ScriptExecutionContext *context) : m_callback(v8::Persistent<v8::Object>::New(callback)) - , m_frame(frame) + , m_scriptExecutionContext(context) { } @@ -51,20 +52,17 @@ void V8CustomVoidCallback::handleEvent() { v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); - if (context.IsEmpty()) + v8::Handle<v8::Context> v8Context = toV8Context(m_scriptExecutionContext.get(), WorldContextHandle(UseCurrentWorld)); + if (v8Context.IsEmpty()) return; - v8::Context::Scope scope(context); - - // Protect the frame until the callback returns. - RefPtr<Frame> protector(m_frame); + v8::Context::Scope scope(v8Context); bool callbackReturnValue = false; - invokeCallback(m_callback, 0, 0, callbackReturnValue); + invokeCallback(m_callback, 0, 0, callbackReturnValue, m_scriptExecutionContext.get()); } -bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue) +bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext) { v8::TryCatch exceptionCatcher; @@ -83,15 +81,12 @@ bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8 v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global(); - V8Proxy* proxy = V8Proxy::retrieve(); - ASSERT(proxy); - - v8::Handle<v8::Value> result = proxy->callFunction(callbackFunction, thisObject, argc, argv); + v8::Handle<v8::Value> result = callbackFunction->Call(thisObject, argc, argv); callbackReturnValue = !result.IsEmpty() && result->BooleanValue(); if (exceptionCatcher.HasCaught()) { v8::Local<v8::Message> message = exceptionCatcher.Message(); - proxy->frame()->document()->reportException(toWebCoreString(message->Get()), message->GetLineNumber(), toWebCoreString(message->GetScriptResourceName())); + scriptExecutionContext->reportException(toWebCoreString(message->Get()), message->GetLineNumber(), toWebCoreString(message->GetScriptResourceName())); return true; } |