当前位置: 首页>>代码示例>>C++>>正文


C++ EventTarget::addEventListener方法代码示例

本文整理汇总了C++中EventTarget::addEventListener方法的典型用法代码示例。如果您正苦于以下问题:C++ EventTarget::addEventListener方法的具体用法?C++ EventTarget::addEventListener怎么用?C++ EventTarget::addEventListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventTarget的用法示例。


在下文中一共展示了EventTarget::addEventListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exceptionState

void V8EventTarget::addEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "addEventListener", "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, ListenerFindOrCreate);
        // 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])) {
            addEventListenerMethodPrologueCustom(info, impl);
            impl->addEventListener(type, listener);
            addEventListenerMethodEpilogueCustom(info, impl);
            return;
        }
        V8EventListenerOptionsOrBoolean::toImpl(info.GetIsolate(), info[2], options, UnionTypeConversionMode::NotNullable, exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
    }
    addEventListenerMethodPrologueCustom(info, impl);
    impl->addEventListener(type, listener, options);
    addEventListenerMethodEpilogueCustom(info, impl);
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:38,代码来源:V8EventTargetCustom.cpp

示例2: type

  static v8::Handle<v8::Value> v8addEventListener(  const v8::Arguments& arguments ){
    if( arguments.Length() > 2 ){
      v8::Local<v8::External> external = v8::Local<v8::External>::Cast( arguments.This()->GetInternalField(0) );
      EventTarget* object = static_cast<EventTarget*>( external->Value() );
      
      v8::Local<v8::String> typeStr = v8::Local<v8::String>::Cast(arguments[0]);
      v8::String::AsciiValue type(typeStr);
      
      v8::Local<v8::Function> cb = v8::Local<v8::Function>::Cast(arguments[1]);
      v8::Persistent<v8::Function> handler = v8::Persistent<v8::Function>::New(cb);

      object->addEventListener( *type, handler, false );
    }
    return v8::Undefined();
  }
开发者ID:Moerphy,项目名称:roboto,代码行数:15,代码来源:eventtarget.cpp

示例3: jsEventTargetAddEventListener

JSValue* jsEventTargetAddEventListener(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 (RefPtr<JSEventListener> listener = toJSDOMWindow(frame)->findOrCreateJSEventListener(exec, args.at(exec, 1)))
        eventTarget->addEventListener(args.at(exec, 0)->toString(exec), listener.release(), args.at(exec, 2)->toBoolean(exec));

    return jsUndefined();
}
开发者ID:Czerrr,项目名称:ISeeBrowser,代码行数:16,代码来源:JSEventTargetBase.cpp


注:本文中的EventTarget::addEventListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。