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 a4a0fa685e3d705a74c016139af1788c30837816..a040bd5f33bbee669cde46506556fc83493bf788 100644 |
| --- a/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
| +++ b/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
| @@ -454,8 +454,6 @@ void PointerEventManager::dispatchTouchPointerEvents( |
| touchInfo.targetFrame = touchInfo.touchNode->document().frame(); |
| } |
| - WebInputEventResult result = WebInputEventResult::NotHandled; |
| - |
| // Do not send pointer events for stationary touches or null targetFrame |
| if (touchInfo.touchNode |
| && touchPoint.state() != PlatformTouchPoint::TouchStationary |
| @@ -474,15 +472,22 @@ void PointerEventManager::dispatchTouchPointerEvents( |
| touchInfo.touchNode ? |
| touchInfo.touchNode->document().domWindow() : nullptr); |
| - result = sendTouchPointerEvent(touchInfo.touchNode, pointerEvent); |
| - } |
| - // TODO(crbug.com/507408): Right now we add the touch point only if |
| - // its pointer event is NotHandled (e.g. preventDefault is called in |
| - // the pointer event listener). This behavior needs to change as it |
| - // may create some inconsistent touch event sequence. |
| - if (result == WebInputEventResult::NotHandled) { |
| - touchInfos.append(touchInfo); |
| + WebInputEventResult result = sendTouchPointerEvent(touchInfo.touchNode, pointerEvent); |
| + |
| + // If a pointerdown has been canceled, queue the unique id to allow |
| + // suppressing mouse events from gesture events. For mouse events |
| + // fired from GestureTap & GestureLongPress (which are triggered by |
| + // single touches only), it is enough to queue the ids only for |
| + // primary pointers. |
| + // TODO(mustaq): What about other cases (e.g. GestureTwoFingerTap)? |
| + if (result != WebInputEventResult::NotHandled |
| + && pointerEvent->type() == EventTypeNames::pointerdown |
| + && pointerEvent->isPrimary()) { |
| + m_touchIdsForCanceledPointerdowns.append(event.uniqueTouchEventId()); |
| + } |
| } |
| + |
| + touchInfos.append(touchInfo); |
| } |
| } |
| @@ -599,6 +604,7 @@ void PointerEventManager::clear() |
| m_touchEventManager.clear(); |
| m_inCanceledStateForPointerTypeTouch = false; |
| m_pointerEventFactory.clear(); |
| + m_touchIdsForCanceledPointerdowns.clear(); |
| m_nodeUnderPointer.clear(); |
| m_pointerCaptureTarget.clear(); |
| m_pendingPointerCaptureTarget.clear(); |
| @@ -773,6 +779,19 @@ bool PointerEventManager::isAnyTouchActive() const |
| return m_touchEventManager.isAnyTouchActive(); |
| } |
| +bool PointerEventManager::primaryPointerdownCanceled(uint32_t uniqueTouchEventId) |
| +{ |
| + while (!m_touchIdsForCanceledPointerdowns.isEmpty()) { |
|
dtapuska
2016/06/03 15:02:11
Can we add a comment that we never expect wrap aro
mustaq
2016/06/03 20:34:45
Done (but didn't mention you would be dead :-P).
|
| + uint32_t firstId = m_touchIdsForCanceledPointerdowns.first(); |
| + if (firstId > uniqueTouchEventId) |
| + return false; |
| + m_touchIdsForCanceledPointerdowns.takeFirst(); |
| + if (firstId == uniqueTouchEventId) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| DEFINE_TRACE(PointerEventManager) |
| { |
| visitor->trace(m_frame); |