void V8AbstractEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
{
    // EventListener could be disconnected from the frame.
    if (disconnected())
        return;

    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtr<V8AbstractEventListener> protect(this);

    v8::HandleScope handleScope;

    if (!m_context)
        return;

    // Create a new local handle since the persistent handle stored in
    // m_context may be disposed before we're done.
    v8::Handle<v8::Context> v8Context = v8::Local<v8::Context>::New(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(v8Context);

    // Get the V8 wrapper for the event object.
    v8::Handle<v8::Value> jsEvent = V8DOMWrapper::convertEventToV8Object(event);

    invokeEventHandler(v8Context, event, jsEvent);

    Document::updateStyleForAllDocuments();
}
void V8WorkerContextEventListener::handleEvent(ScriptExecutionContext* context, Event* event)
{
    if (!context)
        return;

    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtr<V8AbstractEventListener> protect(this);

    v8::HandleScope handleScope;

    ASSERT(context->isWorkerContext());
    WorkerScriptController* script = static_cast<WorkerContext*>(context)->script();
    if (!script)
        return;

    v8::Handle<v8::Context> v8Context = script->context();
    if (v8Context.IsEmpty())
        return;

    // Enter the V8 context in which to perform the event handling.
    v8::Context::Scope scope(v8Context);

    // Get the V8 wrapper for the event object.
    v8::Handle<v8::Value> jsEvent = toV8(event);

    invokeEventHandler(context, event, jsEvent);
}
void V8WorkerGlobalScopeEventListener::handleEvent(ExecutionContext* context, Event* event)
{
    if (!context)
        return;

    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtr<V8AbstractEventListener> protect(this);

    v8::Isolate* isolate = toIsolate(context);
    v8::HandleScope handleScope(isolate);

    WorkerScriptController* script = toWorkerGlobalScope(context)->script();
    if (!script)
        return;

    v8::Handle<v8::Context> v8Context = script->context();
    if (v8Context.IsEmpty())
        return;

    // Enter the V8 context in which to perform the event handling.
    v8::Context::Scope scope(v8Context);

    // Get the V8 wrapper for the event object.
    v8::Handle<v8::Value> jsEvent = toV8(event, v8::Handle<v8::Object>(), isolate);

    invokeEventHandler(context, event, v8::Local<v8::Value>::New(isolate, jsEvent));
}
Esempio n. 4
0
void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event* event)
{
    // Don't reenter V8 if execution was terminated in this instance of V8.
    if (context->isJSExecutionForbidden())
        return;

    ASSERT(event);

    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtr<V8AbstractEventListener> protect(this);

    v8::HandleScope handleScope;

    v8::Local<v8::Context> v8Context = toV8Context(context, worldContext());
    if (v8Context.IsEmpty())
        return;

    // Enter the V8 context in which to perform the event handling.
    v8::Context::Scope scope(v8Context);

    // Get the V8 wrapper for the event object.
    v8::Handle<v8::Value> jsEvent = toV8(event);
    ASSERT(!jsEvent.IsEmpty());

    invokeEventHandler(context, event, jsEvent);
}
void V8AbstractEventListener::handleEvent(ScriptState* scriptState,
        Event* event) {
    ScriptState::Scope scope(scriptState);

    // Get the V8 wrapper for the event object.
    v8::Local<v8::Value> jsEvent =
        toV8(event, scriptState->context()->Global(), isolate());
    if (jsEvent.IsEmpty())
        return;
    invokeEventHandler(scriptState, event,
                       v8::Local<v8::Value>::New(isolate(), jsEvent));
}
void V8AbstractEventListener::handleEvent(ScriptState* scriptState, Event* event)
{
    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtrWillBeRawPtr<V8AbstractEventListener> protect(this);

    ScriptState::Scope scope(scriptState);

    // Get the V8 wrapper for the event object.
    v8::Local<v8::Value> jsEvent = toV8(event, scriptState->context()->Global(), isolate());
    if (jsEvent.IsEmpty())
        return;
    invokeEventHandler(scriptState, event, v8::Local<v8::Value>::New(isolate(), jsEvent));
}
void V8WorkerGlobalScopeEventListener::handleEvent(ScriptState* scriptState,
                                                   Event* event) {
  WorkerOrWorkletScriptController* script =
      toWorkerGlobalScope(scriptState->getExecutionContext())
          ->scriptController();
  if (!script)
    return;

  ScriptState::Scope scope(scriptState);

  // Get the V8 wrapper for the event object.
  v8::Local<v8::Value> jsEvent =
      toV8(event, scriptState->context()->Global(), isolate());
  if (jsEvent.IsEmpty())
    return;

  invokeEventHandler(scriptState, event,
                     v8::Local<v8::Value>::New(isolate(), jsEvent));
}
void V8WorkerGlobalScopeEventListener::handleEvent(ExecutionContext*, Event* event)
{
    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtr<V8AbstractEventListener> protect(this);

    WorkerScriptController* script = toWorkerGlobalScope(scriptState()->executionContext())->script();
    if (!script)
        return;

    if (scriptState()->contextIsValid())
        return;
    ScriptState::Scope scope(scriptState());

    // Get the V8 wrapper for the event object.
    v8::Handle<v8::Value> jsEvent = toV8(event, scriptState()->context()->Global(), isolate());

    invokeEventHandler(event, v8::Local<v8::Value>::New(isolate(), jsEvent));
}
void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event* event)
{
    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtr<V8AbstractEventListener> protect(this);

    v8::HandleScope handleScope;

    v8::Local<v8::Context> v8Context = toV8Context(context, worldContext());
    if (v8Context.IsEmpty())
        return;

    // Enter the V8 context in which to perform the event handling.
    v8::Context::Scope scope(v8Context);

    // Get the V8 wrapper for the event object.
    v8::Handle<v8::Value> jsEvent = V8DOMWrapper::convertEventToV8Object(event);

    invokeEventHandler(context, event, jsEvent);

    Document::updateStyleForAllDocuments();
}
void V8AbstractEventListener::handleEvent(ExecutionContext*, Event* event)
{
    // Don't reenter V8 if execution was terminated in this instance of V8.
    if (scriptState()->executionContext()->isJSExecutionForbidden())
        return;

    ASSERT(event);

    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtr<V8AbstractEventListener> protect(this);

    if (scriptState()->contextIsEmpty())
        return;
    ScriptState::Scope scope(scriptState());

    // Get the V8 wrapper for the event object.
    v8::Handle<v8::Value> jsEvent = toV8(event, scriptState()->context()->Global(), isolate());
    if (jsEvent.IsEmpty())
        return;
    invokeEventHandler(event, v8::Local<v8::Value>::New(isolate(), jsEvent));
}
void V8WorkerContextEventListener::handleEvent(ScriptExecutionContext*, Event* event)
{
    // Is the EventListener disconnected?
    if (disconnected())
        return;

    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.
    // See issue 889829.
    RefPtr<V8AbstractEventListener> protect(this);

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> context = m_proxy->context();
    if (context.IsEmpty())
        return;

    // Enter the V8 context in which to perform the event handling.
    v8::Context::Scope scope(context);

    // Get the V8 wrapper for the event object.
    v8::Handle<v8::Value> jsEvent = WorkerContextExecutionProxy::convertEventToV8Object(event);

    invokeEventHandler(context, event, jsEvent);
}