本文整理汇总了C++中EventPath::size方法的典型用法代码示例。如果您正苦于以下问题:C++ EventPath::size方法的具体用法?C++ EventPath::size怎么用?C++ EventPath::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventPath
的用法示例。
在下文中一共展示了EventPath::size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adjustedFocusedElement
Element* TreeScope::adjustedFocusedElement() const {
Document& document = rootNode().document();
Element* element = document.focusedElement();
if (!element && document.page())
element = document.page()->focusController().focusedFrameOwnerElement(
*document.frame());
if (!element)
return nullptr;
if (rootNode().isInV1ShadowTree()) {
if (Element* retargeted = retarget(*element)) {
return (this == &retargeted->treeScope()) ? retargeted : nullptr;
}
return nullptr;
}
EventPath* eventPath = new EventPath(*element);
for (size_t i = 0; i < eventPath->size(); ++i) {
if (eventPath->at(i).node() == rootNode()) {
// eventPath->at(i).target() is one of the followings:
// - InsertionPoint
// - shadow host
// - Document::focusedElement()
// So, it's safe to do toElement().
return toElement(eventPath->at(i).target()->toNode());
}
}
return nullptr;
}
示例2: if
PassRefPtr<StaticNodeList> TreeScopeEventContext::ensureEventPath(EventPath& path)
{
if (m_eventPath)
return m_eventPath;
Vector<RefPtr<Node> > nodes;
nodes.reserveInitialCapacity(path.size());
for (size_t i = 0; i < path.size(); ++i) {
TreeScope& treeScope = path[i].treeScopeEventContext().treeScope();
if (treeScope.rootNode().isShadowRoot())
nodes.append(path[i].node());
else if (path[i].treeScopeEventContext().isInclusiveAncestorOf(*this))
nodes.append(path[i].node());
}
m_eventPath = StaticNodeList::adopt(nodes);
return m_eventPath;
}
示例3: dispatchEventInDOM
static void dispatchEventInDOM(Event& event, const EventPath& path, WindowEventContext& windowEventContext)
{
// Trigger capturing event handlers, starting at the top and working our way down.
event.setEventPhase(Event::CAPTURING_PHASE);
// We don't dispatch load events to the window. This quirk was originally
// added because Mozilla doesn't propagate load events to the window object.
bool shouldFireEventAtWindow = event.type() != eventNames().loadEvent;
if (shouldFireEventAtWindow && windowEventContext.handleLocalEvents(event) && event.propagationStopped())
return;
for (size_t i = path.size() - 1; i > 0; --i) {
const EventContext& eventContext = path.contextAt(i);
if (eventContext.currentTargetSameAsTarget())
continue;
eventContext.handleLocalEvents(event);
if (event.propagationStopped())
return;
}
event.setEventPhase(Event::AT_TARGET);
path.contextAt(0).handleLocalEvents(event);
if (event.propagationStopped())
return;
// Trigger bubbling event handlers, starting at the bottom and working our way up.
size_t size = path.size();
for (size_t i = 1; i < size; ++i) {
const EventContext& eventContext = path.contextAt(i);
if (eventContext.currentTargetSameAsTarget())
event.setEventPhase(Event::AT_TARGET);
else if (event.bubbles() && !event.cancelBubble())
event.setEventPhase(Event::BUBBLING_PHASE);
else
continue;
eventContext.handleLocalEvents(event);
if (event.propagationStopped())
return;
}
if (event.bubbles() && !event.cancelBubble()) {
event.setEventPhase(Event::BUBBLING_PHASE);
if (shouldFireEventAtWindow)
windowEventContext.handleLocalEvents(event);
}
}
示例4: adjustTouchList
void EventRetargeter::adjustTouchList(const Node* node, const TouchList* touchList, const EventPath& eventPath, EventPathTouchLists& eventPathTouchLists)
{
if (!touchList)
return;
size_t eventPathSize = eventPath.size();
ASSERT(eventPathTouchLists.size() == eventPathSize);
for (size_t i = 0; i < touchList->length(); ++i) {
const Touch& touch = *touchList->item(i);
AdjustedNodes adjustedNodes;
calculateAdjustedNodes(node, touch.target()->toNode(), DoesNotStopAtBoundary, const_cast<EventPath&>(eventPath), adjustedNodes);
ASSERT(adjustedNodes.size() == eventPathSize);
for (size_t j = 0; j < eventPathSize; ++j)
eventPathTouchLists[j]->append(touch.cloneWithNewTarget(adjustedNodes[j].get()));
}
}
示例5: callDefaultEventHandlersInTheBubblingOrder
static void callDefaultEventHandlersInTheBubblingOrder(Event& event, const EventPath& path)
{
// Non-bubbling events call only one default event handler, the one for the target.
path.contextAt(0).node()->defaultEventHandler(&event);
ASSERT(!event.defaultPrevented());
if (event.defaultHandled() || !event.bubbles())
return;
size_t size = path.size();
for (size_t i = 1; i < size; ++i) {
path.contextAt(i).node()->defaultEventHandler(&event);
ASSERT(!event.defaultPrevented());
if (event.defaultHandled())
return;
}
}
示例6: adjustForRelatedTarget
void EventRetargeter::adjustForRelatedTarget(const Node* node, EventTarget* relatedTarget, EventPath& eventPath)
{
if (!node)
return;
if (!relatedTarget)
return;
Node* relatedNode = relatedTarget->toNode();
if (!relatedNode)
return;
AdjustedNodes adjustedNodes;
calculateAdjustedNodes(node, relatedNode, StopAtBoundaryIfNeeded, eventPath, adjustedNodes);
ASSERT(adjustedNodes.size() <= eventPath.size());
for (size_t i = 0; i < adjustedNodes.size(); ++i) {
ASSERT(eventPath[i]->isMouseOrFocusEventContext());
MouseOrFocusEventContext* mouseOrFocusEventContext = static_cast<MouseOrFocusEventContext*>(eventPath[i].get());
mouseOrFocusEventContext->setRelatedTarget(adjustedNodes[i]);
}
}
示例7: adjustForTouchEvent
void EventRetargeter::adjustForTouchEvent(Node* node, const TouchEvent& touchEvent, EventPath& eventPath)
{
size_t eventPathSize = eventPath.size();
EventPathTouchLists eventPathTouches(eventPathSize);
EventPathTouchLists eventPathTargetTouches(eventPathSize);
EventPathTouchLists eventPathChangedTouches(eventPathSize);
for (size_t i = 0; i < eventPathSize; ++i) {
ASSERT(eventPath[i]->isTouchEventContext());
TouchEventContext* touchEventContext = toTouchEventContext(eventPath[i].get());
eventPathTouches[i] = touchEventContext->touches();
eventPathTargetTouches[i] = touchEventContext->targetTouches();
eventPathChangedTouches[i] = touchEventContext->changedTouches();
}
adjustTouchList(node, touchEvent.touches(), eventPath, eventPathTouches);
adjustTouchList(node, touchEvent.targetTouches(), eventPath, eventPathTargetTouches);
adjustTouchList(node, touchEvent.changedTouches(), eventPath, eventPathChangedTouches);
}
示例8: calculateAdjustedNodes
void EventRetargeter::calculateAdjustedNodes(const Node* node, const Node* relatedNode, EventWithRelatedTargetDispatchBehavior eventWithRelatedTargetDispatchBehavior, EventPath& eventPath, AdjustedTargets& adjustedTargets)
{
RelatedTargetMap relatedNodeMap;
buildRelatedNodeMap(relatedNode, relatedNodeMap);
// Synthetic mouse events can have a relatedTarget which is identical to the target.
bool targetIsIdenticalToToRelatedTarget = (node == relatedNode);
TreeScope* lastTreeScope = 0;
EventTarget* adjustedTarget = 0;
for (size_t i = 0; i < eventPath.size(); ++i) {
TreeScope* scope = &eventPath[i].node()->treeScope();
if (scope == lastTreeScope) {
// Re-use the previous adjustedRelatedTarget if treeScope does not change. Just for the performance optimization.
adjustedTargets.append(adjustedTarget);
} else {
adjustedTarget = findRelatedNode(scope, relatedNodeMap);
adjustedTargets.append(adjustedTarget);
}
lastTreeScope = scope;
if (eventWithRelatedTargetDispatchBehavior == DoesNotStopAtBoundary)
continue;
if (targetIsIdenticalToToRelatedTarget) {
if (node->treeScope().rootNode() == eventPath[i].node()) {
eventPath.shrink(i + 1);
break;
}
} else if (eventPath[i].target() == adjustedTarget) {
// Event dispatching should be stopped here.
eventPath.shrink(i);
adjustedTargets.shrink(adjustedTargets.size() - 1);
break;
}
}
}