Chromium Code Reviews| Index: third_party/WebKit/Source/core/input/PointerEventManager.cpp |
| diff --git a/third_party/WebKit/Source/core/input/PointerEventManager.cpp b/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
| index 0e764b369cac07d3ee685f6307973e691634fc47..d76e7af78f6ce4b7678dca15848746d11d4cd51f 100644 |
| --- a/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
| +++ b/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
| @@ -10,6 +10,9 @@ |
| #include "core/frame/FrameView.h" |
| #include "core/html/HTMLCanvasElement.h" |
| #include "core/input/EventHandler.h" |
| +#include "core/input/TouchActionUtil.h" |
| +#include "core/page/ChromeClient.h" |
| +#include "core/page/Page.h" |
| #include "platform/PlatformTouchEvent.h" |
| namespace blink { |
| @@ -397,11 +400,6 @@ WebInputEventResult PointerEventManager::handleTouchEvents( |
| unblockTouchPointers(); |
| HeapVector<TouchEventManager::TouchInfo> touchInfos; |
| - // TODO(crbug.com/606822): This will be moved after pointer events so |
| - // pointer event operations will get the first shot to fill up this array. |
| - if (!m_touchEventManager.generateTouchInfosAfterHittest(event, touchInfos)) |
| - return WebInputEventResult::NotHandled; |
| - |
| dispatchTouchPointerEvents(event, touchInfos); |
| return m_touchEventManager.handleTouchEvent(event, touchInfos); |
| @@ -411,32 +409,71 @@ void PointerEventManager::dispatchTouchPointerEvents( |
| const PlatformTouchEvent& event, |
| HeapVector<TouchEventManager::TouchInfo>& touchInfos) |
| { |
| - if (!RuntimeEnabledFeatures::pointerEventEnabled()) |
| - return; |
| + // Iterate through the touch points, sending PointerEvents to the targets as required. |
| + for (const auto& touchPoint : event.touchPoints()) { |
| + TouchEventManager::TouchInfo touchInfo; |
| + touchInfo.point = touchPoint; |
| + |
| + int pointerId = m_pointerEventFactory.getPointerEventId( |
| + touchPoint.pointerProperties()); |
| + // Do the hit test either when the touch first starts or when the touch |
| + // is not captured. |m_pendingPointerCaptureTarget| indicates the target |
| + // that will be capturing this event. |m_pointerCaptureTarget| may not |
| + // have this target yet since the processing of that will be done right |
| + // before firing the event. |
| + if (touchInfo.point.state() == PlatformTouchPoint::TouchPressed |
| + || !m_pendingPointerCaptureTarget.contains(pointerId)) { |
| + HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent | HitTestRequest::ReadOnly | HitTestRequest::Active; |
| + LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFrameToContents(touchInfo.point.pos())); |
| + HitTestResult hitTestTesult = m_frame->eventHandler().hitTestResultAtPoint(pagePoint, hitType); |
| + Node* node = hitTestTesult.innerNode(); |
| + if (node) { |
| + touchInfo.targetFrame = node->document().frame(); |
| + if (isHTMLCanvasElement(node)) { |
| + std::pair<Element*, String> regionInfo = toHTMLCanvasElement(node)->getControlAndIdIfHitRegionExists(hitTestTesult.pointInInnerNodeFrame()); |
| + if (regionInfo.first) |
| + node = regionInfo.first; |
| + touchInfo.region = regionInfo.second; |
| + } |
| + // Touch events should not go to text nodes. |
|
Rick Byers
2016/05/17 14:20:01
update comment, probably even file a bug to track
Navid Zolghadr
2016/05/17 16:40:44
I don't know to be honest with you. This is the be
|
| + if (node->isTextNode()) |
| + node = FlatTreeTraversal::parent(*node); |
| + touchInfo.touchNode = node; |
| - if (m_inCanceledStateForPointerTypeTouch) |
| - return; |
| + } |
| + } else { |
| + // Set the target of pointer event to the captured node as this |
| + // pointer is captured otherwise it would have gone to the if block |
| + // and perform a hit-test. |
| + touchInfo.touchNode = m_pendingPointerCaptureTarget |
| + .get(pointerId)->toNode(); |
| + touchInfo.targetFrame = touchInfo.touchNode->document().frame(); |
| + } |
| - // Iterate through the touch points, sending PointerEvents to the targets as required. |
| - for (auto& touchInfo: touchInfos) { |
| - const PlatformTouchPoint &touchPoint = touchInfo.point; |
| WebInputEventResult result = WebInputEventResult::NotHandled; |
| - // Do not send pointer events for stationary touches. |
| - if (touchPoint.state() != PlatformTouchPoint::TouchStationary) { |
| + |
| + // Do not send pointer events for stationary touches or null targetFrame |
| + if (touchInfo.touchNode |
| + && touchPoint.state() != PlatformTouchPoint::TouchStationary |
| + && !m_inCanceledStateForPointerTypeTouch) { |
| + FloatPoint pagePoint = touchInfo.targetFrame->view() |
| + ->rootFrameToContents(touchInfo.point.pos()); |
| float scaleFactor = 1.0f / touchInfo.targetFrame->pageZoomFactor(); |
| FloatPoint scrollPosition = touchInfo.targetFrame->view()->scrollPosition(); |
| - FloatPoint framePoint = touchInfo.contentPoint; |
| + FloatPoint framePoint = pagePoint.scaledBy(scaleFactor); |
| framePoint.moveBy(scrollPosition.scaledBy(-scaleFactor)); |
| PointerEvent* pointerEvent = m_pointerEventFactory.create( |
| pointerEventNameForTouchPointState(touchPoint.state()), |
| touchPoint, event.getModifiers(), |
| - touchInfo.adjustedRadius, |
| + touchPoint.radius().scaledBy(scaleFactor), |
| framePoint); |
| // Consume the touch point if its pointer event is anything but NotHandled |
| // (e.g. preventDefault is called in the listener for the pointer event). |
| result = sendTouchPointerEvent(touchInfo.touchNode, pointerEvent); |
| - touchInfo.consumed = result != WebInputEventResult::NotHandled; |
| + } |
| + if (result == WebInputEventResult::NotHandled) { |
| + touchInfos.append(touchInfo); |
|
Rick Byers
2016/05/17 14:20:01
So the touchinfos are now just the data needed for
mustaq
2016/05/17 14:40:14
We already have a p1 bug for this: crbug.com/60758
Navid Zolghadr
2016/05/17 16:40:44
Yup. I haven't changed the behavior here and just
|
| } |
| } |
| } |