本文整理汇总了C++中ContainerNode::defaultEventHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerNode::defaultEventHandler方法的具体用法?C++ ContainerNode::defaultEventHandler怎么用?C++ ContainerNode::defaultEventHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerNode
的用法示例。
在下文中一共展示了ContainerNode::defaultEventHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dispatchGenericEvent
//.........这里部分代码省略.........
// Set up a pointer to indicate whether to dispatch window events.
// We don't dispatch load events to the window. That quirk was originally
// added because Mozilla doesn't propagate load events to the window object.
Document* documentForWindowEvents = 0;
if (event->type() != eventNames().loadEvent) {
EventTargetNode* topLevelContainer = ancestors.isEmpty() ? this : ancestors.last().get();
if (topLevelContainer->isDocumentNode())
documentForWindowEvents = static_cast<Document*>(topLevelContainer);
}
// Give the target node a chance to do some work before DOM event handlers get a crack.
void* data = preDispatchEventHandler(event.get());
if (event->propagationStopped())
goto doneDispatching;
// Trigger capturing event handlers, starting at the top and working our way down.
event->setEventPhase(Event::CAPTURING_PHASE);
if (documentForWindowEvents) {
event->setCurrentTarget(documentForWindowEvents);
documentForWindowEvents->handleWindowEvent(event.get(), true);
if (event->propagationStopped())
goto doneDispatching;
}
for (size_t i = ancestors.size(); i; --i) {
ContainerNode* ancestor = ancestors[i - 1].get();
event->setCurrentTarget(eventTargetRespectingSVGTargetRules(ancestor));
ancestor->handleLocalEvents(event.get(), true);
if (event->propagationStopped())
goto doneDispatching;
}
event->setEventPhase(Event::AT_TARGET);
// We do want capturing event listeners to be invoked here, even though
// that violates some versions of the DOM specification; Mozilla does it.
event->setCurrentTarget(eventTargetRespectingSVGTargetRules(this));
handleLocalEvents(event.get(), true);
if (event->propagationStopped())
goto doneDispatching;
handleLocalEvents(event.get(), false);
if (event->propagationStopped())
goto doneDispatching;
if (event->bubbles() && !event->cancelBubble()) {
// Trigger bubbling event handlers, starting at the bottom and working our way up.
event->setEventPhase(Event::BUBBLING_PHASE);
size_t size = ancestors.size();
for (size_t i = 0; i < size; ++i) {
ContainerNode* ancestor = ancestors[i].get();
event->setCurrentTarget(eventTargetRespectingSVGTargetRules(ancestor));
ancestor->handleLocalEvents(event.get(), false);
if (event->propagationStopped() || event->cancelBubble())
goto doneDispatching;
}
if (documentForWindowEvents) {
event->setCurrentTarget(documentForWindowEvents);
documentForWindowEvents->handleWindowEvent(event.get(), false);
if (event->propagationStopped() || event->cancelBubble())
goto doneDispatching;
}
}
doneDispatching:
event->setCurrentTarget(0);
event->setEventPhase(0);
// Pass the data from the preDispatchEventHandler to the postDispatchEventHandler.
postDispatchEventHandler(event.get(), data);
// Call default event handlers. While the DOM does have a concept of preventing
// default handling, the detail of which handlers are called is an internal
// implementation detail and not part of the DOM.
if (!event->defaultPrevented() && !event->defaultHandled()) {
// Non-bubbling events call only one default event handler, the one for the target.
defaultEventHandler(event.get());
ASSERT(!event->defaultPrevented());
if (event->defaultHandled())
goto doneWithDefault;
// For bubbling events, call default event handlers on the same targets in the
// same order as the bubbling phase.
if (event->bubbles()) {
size_t size = ancestors.size();
for (size_t i = 0; i < size; ++i) {
ContainerNode* ancestor = ancestors[i].get();
ancestor->defaultEventHandler(event.get());
ASSERT(!event->defaultPrevented());
if (event->defaultHandled())
goto doneWithDefault;
}
}
}
doneWithDefault:
Document::updateDocumentsRendering();
return !event->defaultPrevented();
}