void EventPath::setRelatedTarget(Node& origin, EventTarget& relatedTarget) { Node* relatedNode = relatedTarget.toNode(); if (!relatedNode) return; EventRelatedNodeResolver resolver(*relatedNode); bool originIsRelatedTarget = &origin == relatedNode; Node& rootNodeInOriginTreeScope = origin.treeScope().rootNode(); size_t eventPathSize = m_path.size(); size_t i = 0; while (i < eventPathSize) { Node* contextNode = m_path[i]->node(); Node* currentRelatedNode = resolver.moveToParentOrShadowHost(*contextNode); if (!originIsRelatedTarget && m_path[i]->target() == currentRelatedNode) break; toMouseOrFocusEventContext(*m_path[i]).setRelatedTarget(currentRelatedNode); i++; if (originIsRelatedTarget && &rootNodeInOriginTreeScope == contextNode) break; } m_path.shrink(i); }
void EventPath::setRelatedTarget(EventTarget& relatedTarget) { Node* relatedNode = relatedTarget.toNode(); if (!relatedNode) return; EventRelatedNodeResolver resolver(*relatedNode); size_t eventPathSize = m_path.size(); for (size_t i = 0; i < eventPathSize; i++) toMouseOrFocusEventContext(*m_path[i]).setRelatedTarget(resolver.moveToParentOrShadowHost(*m_path[i]->node())); }