void TouchEventManager::updateTargetAndRegionMapsForTouchStarts( HeapVector<TouchInfo>& touchInfos) { for (auto& touchInfo : touchInfos) { // Touch events implicitly capture to the touched node, and don't change // active/hover states themselves (Gesture events do). So we only need // to hit-test on touchstart and when the target could be different than // the corresponding pointer event target. if (touchInfo.point.state() == PlatformTouchPoint::TouchPressed) { HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent | HitTestRequest::ReadOnly | HitTestRequest::Active; LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFrameToContents(touchInfo.point.pos())); HitTestResult result; if (!m_touchSequenceDocument) { result = m_frame->eventHandler().hitTestResultAtPoint(pagePoint, hitType); } else if (m_touchSequenceDocument->frame()) { LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocument->frame()->view()->rootFrameToContents(touchInfo.point.pos())); result = EventHandler::hitTestResultInFrame(m_touchSequenceDocument->frame(), framePoint, hitType); } else { continue; } Node* node = result.innerNode(); if (!node) continue; if (isHTMLCanvasElement(node)) { std::pair<Element*, String> regionInfo = toHTMLCanvasElement(node)->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame()); if (regionInfo.first) node = regionInfo.first; touchInfo.region = regionInfo.second; } // Touch events should not go to text nodes. if (node->isTextNode()) node = FlatTreeTraversal::parent(*node); touchInfo.touchNode = node; if (!m_touchSequenceDocument) { // Keep track of which document should receive all touch events // in the active sequence. This must be a single document to // ensure we don't leak Nodes between documents. m_touchSequenceDocument = &(touchInfo.touchNode->document()); ASSERT(m_touchSequenceDocument->frame()->view()); } // Ideally we'd ASSERT(!m_targetForTouchID.contains(point.id()) // since we shouldn't get a touchstart for a touch that's already // down. However EventSender allows this to be violated and there's // some tests that take advantage of it. There may also be edge // cases in the browser where this happens. // See http://crbug.com/345372. m_targetForTouchID.set(touchInfo.point.id(), touchInfo.touchNode); m_regionForTouchID.set(touchInfo.point.id(), touchInfo.region); TouchAction effectiveTouchAction = TouchActionUtil::computeEffectiveTouchAction( *touchInfo.touchNode); if (effectiveTouchAction != TouchActionAuto) m_frame->page()->chromeClient().setTouchAction(effectiveTouchAction); } } }