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


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

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


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

示例1: dispatchEvents

void ScriptedAnimationController::dispatchEvents(const AtomicString& eventInterfaceFilter)
{
    WillBeHeapVector<RefPtrWillBeMember<Event> > events;
    if (eventInterfaceFilter.isEmpty()) {
        events.swap(m_eventQueue);
        m_perFrameEvents.clear();
    } else {
        WillBeHeapVector<RefPtrWillBeMember<Event> > remaining;
        for (auto& event : m_eventQueue) {
            if (event && event->interfaceName() == eventInterfaceFilter) {
                m_perFrameEvents.remove(eventTargetKey(event.get()));
                events.append(event.release());
            } else {
                remaining.append(event.release());
            }
        }
        remaining.swap(m_eventQueue);
    }


    for (size_t i = 0; i < events.size(); ++i) {
        EventTarget* eventTarget = events[i]->target();
        // FIXME: we should figure out how to make dispatchEvent properly virtual to avoid
        // special casting window.
        // FIXME: We should not fire events for nodes that are no longer in the tree.
        if (LocalDOMWindow* window = eventTarget->toDOMWindow())
            window->dispatchEvent(events[i], nullptr);
        else
            eventTarget->dispatchEvent(events[i]);

        InspectorInstrumentation::didRemoveEvent(eventTarget, events[i].get());
    }
}
开发者ID:eth-srl,项目名称:BlinkER,代码行数:33,代码来源:ScriptedAnimationController.cpp

示例2: dispatchErrorEvent

bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, CachedScript* cachedScript)
{
    EventTarget* target = errorEventTarget();
    if (!target)
        return false;

#if PLATFORM(IOS)
    if (target == target->toDOMWindow() && isDocument()) {
        Settings* settings = static_cast<Document*>(this)->settings();
        if (settings && !settings->shouldDispatchJavaScriptWindowOnErrorEvents())
            return false;
    }
#endif

    String message = errorMessage;
    int line = lineNumber;
    int column = columnNumber;
    String sourceName = sourceURL;
    sanitizeScriptError(message, line, column, sourceName, cachedScript);

    ASSERT(!m_inDispatchErrorEvent);
    m_inDispatchErrorEvent = true;
    RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line, column);
    target->dispatchEvent(errorEvent);
    m_inDispatchErrorEvent = false;
    return errorEvent->defaultPrevented();
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:27,代码来源:ScriptExecutionContext.cpp

示例3: revoke

    void revoke()
    {
        ExecutionContext* executionContext = m_scriptState->executionContext();
        if (!executionContext)
            return;

        ScriptState::Scope scope(m_scriptState);
        v8::Local<v8::Value> value = m_promise.newLocal(m_scriptState->isolate());
        v8::Local<v8::Value> reason = m_exception.newLocal(m_scriptState->isolate());
        // Either collected or https://crbug.com/450330
        if (value.IsEmpty() || !value->IsPromise())
            return;

        EventTarget* target = executionContext->errorEventTarget();
        if (RuntimeEnabledFeatures::promiseRejectionEventEnabled() && target && !executionContext->shouldSanitizeScriptError(m_resourceName, m_corsStatus)) {
            PromiseRejectionEventInit init;
            init.setPromise(ScriptPromise(m_scriptState, value));
            init.setReason(ScriptValue(m_scriptState, reason));
            RefPtrWillBeRawPtr<PromiseRejectionEvent> event = PromiseRejectionEvent::create(m_scriptState, EventTypeNames::rejectionhandled, init);
            target->dispatchEvent(event);
        }

        if (m_shouldLogToConsole) {
            RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSource, RevokedErrorMessageLevel, "Handler added to rejected promise");
            consoleMessage->setRelatedMessageId(m_consoleMessageId);
            executionContext->addConsoleMessage(consoleMessage.release());
        }
    }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例4: dispatchErrorEvent

bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL)
{
    EventTarget* target = errorEventTarget();
    if (!target)
        return false;

    String message;
    int line;
    String sourceName;
    KURL targetUrl = completeURL(sourceURL);
    if (securityOrigin()->canRequest(targetUrl)) {
        message = errorMessage;
        line = lineNumber;
        sourceName = sourceURL;
    } else {
        message = "Script error.";
        sourceName = String();
        line = 0;
    }

    ASSERT(!m_inDispatchErrorEvent);
    m_inDispatchErrorEvent = true;
    RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line);
    target->dispatchEvent(errorEvent);
    m_inDispatchErrorEvent = false;
    return errorEvent->defaultPrevented();
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例5: NodeRemovedFromDocument

void NodeRemovedFromDocument(Node* node)
{
	NodeList* childNodes = node->get_childNodes();

	unsigned int length = childNodes->get_length();

	for (unsigned int i = 0; i < length; ++i)
	{
		Node* child = childNodes->item(i);

		NodeRemovedFromDocument(child);
	}

	Document* ownerDocument = node->get_ownerDocument();

	DocumentEvent* ownerDocumentEvent = dynamic_cast<DocumentEvent*>(ownerDocument);
	ASSERT(ownerDocumentEvent != nullptr);

	MutationEvent* event = dynamic_cast<MutationEvent*>(ownerDocumentEvent->createEvent(S("MutationEvent")));

	event->initMutationEvent(S("DOMNodeRemovedFromDocument"), false, false, NULL/*relatedNode*/, nullptr, nullptr, nullptr, CHANGE_UNKNOWN);

	EventTarget* target = dynamic_cast<EventTarget*>(node);

	target->dispatchEvent(event);
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例6: revoke

  void revoke() {
    ExecutionContext* executionContext = m_scriptState->getExecutionContext();
    if (!executionContext)
      return;

    ScriptState::Scope scope(m_scriptState);
    v8::Local<v8::Value> value = m_promise.newLocal(m_scriptState->isolate());
    v8::Local<v8::Value> reason =
        m_exception.newLocal(m_scriptState->isolate());
    // Either collected or https://crbug.com/450330
    if (value.IsEmpty() || !value->IsPromise())
      return;

    EventTarget* target = executionContext->errorEventTarget();
    if (target &&
        !executionContext->shouldSanitizeScriptError(m_resourceName,
                                                     m_corsStatus)) {
      PromiseRejectionEventInit init;
      init.setPromise(ScriptPromise(m_scriptState, value));
      init.setReason(ScriptValue(m_scriptState, reason));
      PromiseRejectionEvent* event = PromiseRejectionEvent::create(
          m_scriptState, EventTypeNames::rejectionhandled, init);
      target->dispatchEvent(event);
    }

    if (m_shouldLogToConsole && m_promiseRejectionId) {
      V8PerIsolateData* data = V8PerIsolateData::from(m_scriptState->isolate());
      if (data->threadDebugger())
        data->threadDebugger()->promiseRejectionRevoked(
            m_scriptState->context(), m_promiseRejectionId);
    }
  }
开发者ID:ollie314,项目名称:chromium,代码行数:32,代码来源:RejectedPromises.cpp

示例7: dispatchEvent

void DOMWindowEventQueue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
{
    EventTarget* eventTarget = event->target();
    if (eventTarget->toDOMWindow())
        eventTarget->toDOMWindow()->dispatchEvent(event, nullptr);
    else
        eventTarget->dispatchEvent(event);
}
开发者ID:ewilligers,项目名称:blink,代码行数:8,代码来源:DOMWindowEventQueue.cpp

示例8: dispatchEvent

void EventQueue::dispatchEvent(PassRefPtr<Event> event)
{
    EventTarget* eventTarget = event->target();
    if (eventTarget->toDOMWindow())
        eventTarget->toDOMWindow()->dispatchEvent(event, 0);
    else
        eventTarget->dispatchEvent(event);
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:8,代码来源:EventQueue.cpp

示例9: dispatchEvent

void DOMWindowEventQueue::dispatchEvent(Event* event) {
  EventTarget* eventTarget = event->target();
  InspectorInstrumentation::AsyncTask asyncTask(
      eventTarget->getExecutionContext(), event);
  if (LocalDOMWindow* window = eventTarget->toLocalDOMWindow())
    window->dispatchEvent(event, nullptr);
  else
    eventTarget->dispatchEvent(event);
}
开发者ID:mirror,项目名称:chromium,代码行数:9,代码来源:DOMWindowEventQueue.cpp

示例10: jsEventTargetDispatchEvent

JSValue* jsEventTargetDispatchEvent(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    Node* eventNode = 0;
    EventTarget* eventTarget = 0;
    if (!retrieveEventTargetAndCorrespondingNode(exec, thisValue, eventNode, eventTarget))
        return throwError(exec, TypeError);

    DOMExceptionTranslator exception(exec);
    return jsBoolean(eventTarget->dispatchEvent(toEvent(args.at(exec, 0)), exception));
}
开发者ID:Czerrr,项目名称:ISeeBrowser,代码行数:10,代码来源:JSEventTargetBase.cpp

示例11: report

    void report()
    {
        if (!m_scriptState->contextIsValid())
            return;
        // If execution termination has been triggered, quietly bail out.
        if (v8::V8::IsExecutionTerminating(m_scriptState->isolate()))
            return;
        ExecutionContext* executionContext = m_scriptState->executionContext();
        if (!executionContext)
            return;

        ScriptState::Scope scope(m_scriptState);
        v8::Local<v8::Value> value = m_promise.newLocal(m_scriptState->isolate());
        v8::Local<v8::Value> reason = m_exception.newLocal(m_scriptState->isolate());
        // Either collected or https://crbug.com/450330
        if (value.IsEmpty() || !value->IsPromise())
            return;
        ASSERT(!hasHandler());

        EventTarget* target = executionContext->errorEventTarget();
        if (RuntimeEnabledFeatures::promiseRejectionEventEnabled() && target && !executionContext->shouldSanitizeScriptError(m_resourceName, m_corsStatus)) {
            PromiseRejectionEventInit init;
            init.setPromise(ScriptPromise(m_scriptState, value));
            init.setReason(ScriptValue(m_scriptState, reason));
            init.setCancelable(true);
            RefPtrWillBeRawPtr<PromiseRejectionEvent> event = PromiseRejectionEvent::create(m_scriptState, EventTypeNames::unhandledrejection, init);
            // Log to console if event was not preventDefault()'ed.
            m_shouldLogToConsole = target->dispatchEvent(event);
        }

        if (m_shouldLogToConsole) {
            const String errorMessage = "Uncaught (in promise)";
            Vector<ScriptValue> args;
            args.append(ScriptValue(m_scriptState, v8String(m_scriptState->isolate(), errorMessage)));
            args.append(ScriptValue(m_scriptState, reason));
            RefPtrWillBeRawPtr<ScriptArguments> arguments = ScriptArguments::create(m_scriptState, args);

            String embedderErrorMessage = m_errorMessage;
            if (embedderErrorMessage.isEmpty())
                embedderErrorMessage = errorMessage;
            else if (embedderErrorMessage.startsWith("Uncaught "))
                embedderErrorMessage.insert(" (in promise)", 8);

            RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, embedderErrorMessage, m_resourceName, m_lineNumber, m_columnNumber);
            consoleMessage->setScriptArguments(arguments);
            consoleMessage->setCallStack(m_callStack);
            consoleMessage->setScriptId(m_scriptId);
            m_consoleMessageId = consoleMessage->assignMessageId();
            executionContext->addConsoleMessage(consoleMessage.release());
        }

        m_callStack.clear();
    }
开发者ID:,项目名称:,代码行数:53,代码来源:

示例12: timerFired

void GenericEventQueue::timerFired(Timer<GenericEventQueue>*)
{
    ASSERT(!m_timer.isActive());
    ASSERT(!m_pendingEvents.isEmpty());

    Vector<RefPtr<Event> > pendingEvents;
    m_pendingEvents.swap(pendingEvents);

    RefPtr<EventTarget> protect(m_owner);
    for (unsigned i = 0; i < pendingEvents.size(); ++i) {
        EventTarget* target = pendingEvents[i]->target() ? pendingEvents[i]->target() : m_owner;
        target->dispatchEvent(pendingEvents[i].release());
    }
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:14,代码来源:GenericEventQueue.cpp

示例13: dispatchErrorEventInternal

bool ExecutionContext::dispatchErrorEventInternal(
    ErrorEvent* errorEvent,
    AccessControlStatus corsStatus) {
  EventTarget* target = errorEventTarget();
  if (!target)
    return false;

  if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus))
    errorEvent = ErrorEvent::createSanitizedError(errorEvent->world());

  DCHECK(!m_inDispatchErrorEvent);
  m_inDispatchErrorEvent = true;
  target->dispatchEvent(errorEvent);
  m_inDispatchErrorEvent = false;
  return errorEvent->defaultPrevented();
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例14:

 static v8::Handle<v8::Value> v8dispatchEvent(  const v8::Arguments& arguments ){
   if( arguments.Length() > 0 ){
     v8::Local<v8::External> external = v8::Local<v8::External>::Cast( arguments.This()->GetInternalField(0) );
     EventTarget* object = static_cast<EventTarget*>( external->Value() );
     
     
     v8::Handle<v8::Object> ev =  v8::Handle<v8::Object>::Cast(arguments[0]);
     external = v8::Local<v8::External>::Cast( ev->GetInternalField(0) );
     Event* event = static_cast<Event*>( external->Value() );
     
     
     object->dispatchEvent(event, ev);
   }
   // TODO return value
   return v8::Undefined();
 }
开发者ID:Moerphy,项目名称:roboto,代码行数:16,代码来源:eventtarget.cpp

示例15: dispatchErrorEvent

bool ExecutionContext::dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent> event, AccessControlStatus corsStatus)
{
    EventTarget* target = errorEventTarget();
    if (!target)
        return false;

    RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event;
    if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus))
        errorEvent = ErrorEvent::createSanitizedError(errorEvent->world());

    ASSERT(!m_inDispatchErrorEvent);
    m_inDispatchErrorEvent = true;
    target->dispatchEvent(errorEvent);
    m_inDispatchErrorEvent = false;
    return errorEvent->defaultPrevented();
}
开发者ID:kingysu,项目名称:blink-crosswalk,代码行数:16,代码来源:ExecutionContext.cpp


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