void GObjectEventListener::gobjectDestroyed() { ASSERT(m_coreTarget); // We must set m_coreTarget to null, because removeEventListener // may call the destructor as a side effect and we must be in the // proper state to prevent g_object_weak_unref. EventTarget* target = m_coreTarget; m_coreTarget = 0; target->removeEventListener(m_domEventName.data(), this, m_capture); }
void V8EventTarget::removeEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeEventListener", "EventTarget", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { setMinimumArityTypeError(exceptionState, 2, info.Length()); exceptionState.throwIfNeeded(); return; } EventTarget* impl = V8EventTarget::toImpl(info.Holder()); if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl, exceptionState)) { exceptionState.throwIfNeeded(); return; } V8StringResource<> type; RefPtrWillBeRawPtr<EventListener> listener; EventListenerOptionsOrBoolean options; { type = info[0]; if (!type.prepare()) return; listener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOnly); // TODO(dtapuska): This custom binding code can be eliminated once // EventListenerOptions runtime enabled feature is removed. // http://crbug.com/545163 if (UNLIKELY(info.Length() <= 2) || isUndefinedOrNull(info[2])) { removeEventListenerMethodPrologueCustom(info, impl); impl->removeEventListener(type, listener); removeEventListenerMethodEpilogueCustom(info, impl); return; } V8EventListenerOptionsOrBoolean::toImpl(info.GetIsolate(), info[2], options, UnionTypeConversionMode::NotNullable, exceptionState); if (exceptionState.throwIfNeeded()) return; } removeEventListenerMethodPrologueCustom(info, impl); impl->removeEventListener(type, listener, options); removeEventListenerMethodEpilogueCustom(info, impl); }
JSValue* jsEventTargetRemoveEventListener(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { Node* eventNode = 0; EventTarget* eventTarget = 0; if (!retrieveEventTargetAndCorrespondingNode(exec, thisValue, eventNode, eventTarget)) return throwError(exec, TypeError); Frame* frame = eventNode->document()->frame(); if (!frame) return jsUndefined(); if (JSEventListener* listener = toJSDOMWindow(frame)->findJSEventListener(args.at(exec, 1))) eventTarget->removeEventListener(args.at(exec, 0)->toString(exec), listener, args.at(exec, 2)->toBoolean(exec)); return jsUndefined(); }