diff options
Diffstat (limited to 'WebCore/bindings/v8/V8AbstractEventListener.cpp')
-rw-r--r-- | WebCore/bindings/v8/V8AbstractEventListener.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp index 07e944d..0c81846 100644 --- a/WebCore/bindings/v8/V8AbstractEventListener.cpp +++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp @@ -48,6 +48,12 @@ V8AbstractEventListener::V8AbstractEventListener(Frame* frame, bool isAttribute) if (!m_frame) return; + // We might be called directly from the parser. + v8::HandleScope handleScope; + + m_context.set(V8Proxy::context(m_frame)); + m_context.makeWeak(); + // Get the position in the source if any. if (m_isAttribute && m_frame->document()->tokenizer()) { m_lineNumber = m_frame->document()->tokenizer()->lineNumber(); @@ -55,7 +61,7 @@ V8AbstractEventListener::V8AbstractEventListener(Frame* frame, bool isAttribute) } } -void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> context, Event* event, v8::Handle<v8::Value> jsEvent, bool isWindowEvent) +void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> v8Context, Event* event, v8::Handle<v8::Value> jsEvent, bool isWindowEvent) { // We push the event being processed into the global object, so that it can be exposed by DOMWindow's bindings. v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event"); @@ -67,11 +73,11 @@ void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> context tryCatch.SetVerbose(true); // Save the old 'event' property so we can restore it later. - v8::Local<v8::Value> savedEvent = context->Global()->GetHiddenValue(eventSymbol); + v8::Local<v8::Value> savedEvent = v8Context->Global()->GetHiddenValue(eventSymbol); tryCatch.Reset(); // Make the event available in the global object, so DOMWindow can expose it. - context->Global()->SetHiddenValue(eventSymbol, jsEvent); + v8Context->Global()->SetHiddenValue(eventSymbol, jsEvent); tryCatch.Reset(); // Call the event handler. @@ -80,13 +86,13 @@ void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> context // Restore the old event. This must be done for all exit paths through this method. if (savedEvent.IsEmpty()) - context->Global()->SetHiddenValue(eventSymbol, v8::Undefined()); + v8Context->Global()->SetHiddenValue(eventSymbol, v8::Undefined()); else - context->Global()->SetHiddenValue(eventSymbol, savedEvent); + v8Context->Global()->SetHiddenValue(eventSymbol, savedEvent); tryCatch.Reset(); } - ASSERT(!V8Proxy::HandleOutOfMemory() || returnValue.IsEmpty()); + ASSERT(!V8Proxy::handleOutOfMemory() || returnValue.IsEmpty()); if (returnValue.IsEmpty()) return; @@ -113,20 +119,20 @@ void V8AbstractEventListener::handleEvent(Event* event, bool isWindowEvent) LOCK_V8; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame); - if (context.IsEmpty()) + v8::Handle<v8::Context> v8Context = m_context.get(); + if (v8Context.IsEmpty()) return; // m_frame can removed by the callback function, protect it until the callback function returns. RefPtr<Frame> protectFrame(m_frame); // Enter the V8 context in which to perform the event handling. - v8::Context::Scope scope(context); + v8::Context::Scope scope(v8Context); // Get the V8 wrapper for the event object. - v8::Handle<v8::Value> jsEvent = V8Proxy::EventToV8Object(event); + v8::Handle<v8::Value> jsEvent = V8DOMWrapper::convertEventToV8Object(event); - invokeEventHandler(context, event, jsEvent, isWindowEvent); + invokeEventHandler(v8Context, event, jsEvent, isWindowEvent); Document::updateStyleForAllDocuments(); } @@ -135,7 +141,7 @@ void V8AbstractEventListener::disposeListenerObject() { if (!m_listener.IsEmpty()) { #ifndef NDEBUG - V8Proxy::UnregisterGlobalHandle(this, m_listener); + V8GCController::unregisterGlobalHandle(this, m_listener); #endif m_listener.Dispose(); m_listener.Clear(); @@ -151,7 +157,7 @@ v8::Local<v8::Object> V8AbstractEventListener::getReceiverObject(Event* event, b return v8::Context::GetCurrent()->Global(); EventTarget* target = event->currentTarget(); - v8::Handle<v8::Value> value = V8Proxy::EventTargetToV8Object(target); + v8::Handle<v8::Value> value = V8DOMWrapper::convertEventTargetToV8Object(target); if (value.IsEmpty()) return v8::Local<v8::Object>(); return v8::Local<v8::Object>::New(v8::Handle<v8::Object>::Cast(value)); |