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 3fe3d505ceb762ad2aa1113063f61d54fca70961..243fc24d3377fcfb341fc49f11eea49deb7b4ba2 100644 |
| --- a/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
| +++ b/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
| @@ -37,7 +37,7 @@ const AtomicString& pointerEventNameForTouchPointState(PlatformTouchPoint::Touch |
| case PlatformTouchPoint::TouchStationary: |
| // Fall through to default |
| default: |
| - ASSERT_NOT_REACHED(); |
| + NOTREACHED(); |
| return emptyAtom; |
| } |
| } |
| @@ -211,15 +211,6 @@ void PointerEventManager::sendBoundaryEvents( |
| if (exitedTarget == enteredTarget) |
| return; |
| - if (EventTarget* capturingTarget = getCapturingNode(pointerEvent->pointerId())) { |
| - if (capturingTarget == exitedTarget) |
| - enteredTarget = nullptr; |
| - else if (capturingTarget == enteredTarget) |
| - exitedTarget = nullptr; |
| - else |
| - return; |
| - } |
| - |
| // Dispatch pointerout/mouseout events |
| if (isInDocument(exitedTarget)) { |
| if (!sendMouseEvent) { |
| @@ -321,8 +312,7 @@ void PointerEventManager::sendBoundaryEvents( |
| void PointerEventManager::setNodeUnderPointer( |
| PointerEvent* pointerEvent, |
| - EventTarget* target, |
| - bool sendEvent) |
| + EventTarget* target) |
| { |
| if (m_nodeUnderPointer.contains(pointerEvent->pointerId())) { |
| EventTargetAttributes node = m_nodeUnderPointer.get( |
| @@ -334,13 +324,11 @@ void PointerEventManager::setNodeUnderPointer( |
| m_nodeUnderPointer.set(pointerEvent->pointerId(), |
| EventTargetAttributes(target, false)); |
| } |
| - if (sendEvent) |
| - sendBoundaryEvents(node.target, target, pointerEvent); |
| + sendBoundaryEvents(node.target, target, pointerEvent); |
| } else if (target) { |
| m_nodeUnderPointer.add(pointerEvent->pointerId(), |
| EventTargetAttributes(target, false)); |
| - if (sendEvent) |
| - sendBoundaryEvents(nullptr, target, pointerEvent); |
| + sendBoundaryEvents(nullptr, target, pointerEvent); |
| } |
| } |
| @@ -358,7 +346,7 @@ void PointerEventManager::blockTouchPointers() |
| = m_pointerEventFactory.createPointerCancelEvent( |
| pointerId, WebPointerProperties::PointerType::Touch); |
| - ASSERT(m_nodeUnderPointer.contains(pointerId)); |
| + DCHECK(m_nodeUnderPointer.contains(pointerId)); |
| EventTarget* target = m_nodeUnderPointer.get(pointerId).target; |
| processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
| @@ -547,11 +535,11 @@ WebInputEventResult PointerEventManager::sendMousePointerEvent( |
| mouseEvent.pointerProperties().pointerType)] = false; |
| } |
| - processCaptureAndPositionOfPointerEvent(pointerEvent, target, |
| + EventTarget* pointerEventTarget = processCaptureAndPositionOfPointerEvent(pointerEvent, target, |
| lastNodeUnderMouse, mouseEvent, true, true); |
| EventTarget* effectiveTarget = |
| - getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()); |
| + getEffectiveTargetForPointerEvent(pointerEventTarget, pointerEvent->pointerId()); |
| WebInputEventResult result = |
| dispatchPointerEvent(effectiveTarget, pointerEvent); |
| @@ -620,46 +608,47 @@ bool PointerEventManager::getPointerCaptureState(int pointerId, |
| EventTarget** pointerCaptureTarget, |
| EventTarget** pendingPointerCaptureTarget) |
| { |
| - PointerCapturingMap::iterator it; |
| + PointerCapturingMap::const_iterator it; |
| it = m_pointerCaptureTarget.find(pointerId); |
| - EventTarget* pointercaptureTargetTemp = (it != m_pointerCaptureTarget.end()) ? it->value : nullptr; |
| + EventTarget* pointerCaptureTargetTemp = (it != m_pointerCaptureTarget.end()) ? it->value : nullptr; |
| it = m_pendingPointerCaptureTarget.find(pointerId); |
| EventTarget* pendingPointercaptureTargetTemp = (it != m_pendingPointerCaptureTarget.end()) ? it->value : nullptr; |
| if (pointerCaptureTarget) |
| - *pointerCaptureTarget = pointercaptureTargetTemp; |
| + *pointerCaptureTarget = pointerCaptureTargetTemp; |
| if (pendingPointerCaptureTarget) |
| *pendingPointerCaptureTarget = pendingPointercaptureTargetTemp; |
| - return pointercaptureTargetTemp != pendingPointercaptureTargetTemp; |
| + return pointerCaptureTargetTemp != pendingPointercaptureTargetTemp; |
| } |
| -void PointerEventManager::processCaptureAndPositionOfPointerEvent( |
| +EventTarget* PointerEventManager::processCaptureAndPositionOfPointerEvent( |
| PointerEvent* pointerEvent, |
| EventTarget* hitTestTarget, |
| EventTarget* lastNodeUnderMouse, |
| const PlatformMouseEvent& mouseEvent, |
| bool sendMouseEvent, bool setPointerPosition) |
| { |
| - bool isCaptureChanged = false; |
| - |
| if (setPointerPosition) { |
| - isCaptureChanged = processPendingPointerCapture(pointerEvent, |
| - hitTestTarget, mouseEvent, sendMouseEvent); |
| - // If there was a change in capturing processPendingPointerCapture has |
| - // already taken care of transition events. So we don't need to send the |
| - // transition events here. |
| - setNodeUnderPointer(pointerEvent, hitTestTarget, !isCaptureChanged); |
| + processPendingPointerCapture(pointerEvent->pointerId()); |
| + |
| + PointerCapturingMap::const_iterator it = m_pointerCaptureTarget.find(pointerEvent->pointerId()); |
| + EventTarget* pointercaptureTarget = (it != m_pointerCaptureTarget.end()) ? it->value : nullptr; |
|
dtapuska
2016/07/22 15:57:39
collapse this into the if;
like if(EventTarget* p
Navid Zolghadr
2016/07/22 16:39:24
Done.
|
| + if (pointercaptureTarget) |
| + hitTestTarget = pointercaptureTarget; |
| + |
| + setNodeUnderPointer(pointerEvent, hitTestTarget); |
| } |
| - if (sendMouseEvent && !isCaptureChanged) { |
| + if (sendMouseEvent) { |
| // lastNodeUnderMouse is needed here because it is still stored in EventHandler. |
| sendBoundaryEvents(lastNodeUnderMouse, hitTestTarget, |
| pointerEvent, mouseEvent, true); |
| } |
| + return hitTestTarget; |
| } |
| -void PointerEventManager::immediatelyProcessPendingPointerCapture(int pointerId) |
| +void PointerEventManager::processPendingPointerCapture(int pointerId) |
| { |
| EventTarget* pointerCaptureTarget; |
| EventTarget* pendingPointerCaptureTarget; |
| @@ -694,79 +683,6 @@ void PointerEventManager::immediatelyProcessPendingPointerCapture(int pointerId) |
| m_pointerCaptureTarget.remove(pointerId); |
| } |
| -// TODO(crbug.com/629921): This function should be merged with |immediatelyProcessPendingPointerCapture| |
| -// when we stop hit-testing while a pointer is captured. |
| -bool PointerEventManager::processPendingPointerCapture( |
| - PointerEvent* pointerEvent, |
| - EventTarget* hitTestTarget, |
| - const PlatformMouseEvent& mouseEvent, bool sendMouseEvent) |
| -{ |
| - int pointerId = pointerEvent->pointerId(); |
| - EventTarget* pointerCaptureTarget; |
| - EventTarget* pendingPointerCaptureTarget; |
| - const bool isCaptureChanged = getPointerCaptureState(pointerId, |
| - &pointerCaptureTarget, &pendingPointerCaptureTarget); |
| - const EventTargetAttributes &nodeUnderPointerAtt = |
| - m_nodeUnderPointer.contains(pointerId) |
| - ? m_nodeUnderPointer.get(pointerId) : EventTargetAttributes(); |
| - |
| - if (isCaptureChanged) { |
| - if ((hitTestTarget != nodeUnderPointerAtt.target |
| - || (pendingPointerCaptureTarget |
| - && pendingPointerCaptureTarget != nodeUnderPointerAtt.target)) |
| - && nodeUnderPointerAtt.hasRecievedOverEvent) { |
| - if (sendMouseEvent) { |
| - // Send pointer event transitions as the line after this if |
| - // block sends the mouse events |
| - sendBoundaryEvents(nodeUnderPointerAtt.target, nullptr, |
| - pointerEvent); |
| - } |
| - sendBoundaryEvents(nodeUnderPointerAtt.target, nullptr, |
| - pointerEvent, mouseEvent, sendMouseEvent); |
| - } |
| - if (pointerCaptureTarget) { |
| - // Re-target lostpointercapture to the document when the element is |
| - // no longer participating in the tree. |
| - EventTarget* target = pointerCaptureTarget; |
| - if (target->toNode() |
| - && !target->toNode()->isConnected()) { |
| - target = target->toNode()->ownerDocument(); |
| - } |
| - dispatchPointerEvent(target, |
| - m_pointerEventFactory.createPointerCaptureEvent( |
| - pointerId, EventTypeNames::lostpointercapture)); |
| - } |
| - } |
| - |
| - // Set pointerCaptureTarget from pendingPointerCaptureTarget. This does |
| - // affect the behavior of sendBoundaryEvents function. So the |
| - // ordering of the surrounding blocks of code for sending transition events |
| - // are important. |
| - if (pendingPointerCaptureTarget) |
| - m_pointerCaptureTarget.set(pointerId, pendingPointerCaptureTarget); |
| - else |
| - m_pointerCaptureTarget.remove(pointerId); |
| - |
| - if (isCaptureChanged) { |
| - dispatchPointerEvent(pendingPointerCaptureTarget, |
| - m_pointerEventFactory.createPointerCaptureEvent( |
| - pointerId, EventTypeNames::gotpointercapture)); |
| - if ((pendingPointerCaptureTarget == hitTestTarget |
| - || !pendingPointerCaptureTarget) |
| - && (nodeUnderPointerAtt.target != hitTestTarget |
| - || !nodeUnderPointerAtt.hasRecievedOverEvent)) { |
| - if (sendMouseEvent) { |
| - // Send pointer event transitions as the line after this if |
| - // block sends the mouse events |
| - sendBoundaryEvents(nullptr, hitTestTarget, pointerEvent); |
| - } |
| - sendBoundaryEvents(nullptr, hitTestTarget, pointerEvent, |
| - mouseEvent, sendMouseEvent); |
| - } |
| - } |
| - return isCaptureChanged; |
| -} |
| - |
| void PointerEventManager::removeTargetFromPointerCapturingMapping( |
| PointerCapturingMap& map, const EventTarget* target) |
| { |
| @@ -781,7 +697,7 @@ void PointerEventManager::removeTargetFromPointerCapturingMapping( |
| } |
| } |
| -EventTarget* PointerEventManager::getCapturingNode(int pointerId) |
| +EventTarget* PointerEventManager::getCapturingNode(int pointerId) const |
| { |
| if (m_pointerCaptureTarget.contains(pointerId)) |
| return m_pointerCaptureTarget.get(pointerId); |
| @@ -874,6 +790,11 @@ bool PointerEventManager::primaryPointerdownCanceled(uint32_t uniqueTouchEventId |
| return false; |
| } |
| +EventTarget* PointerEventManager::getMouseCapturingNode() const |
| +{ |
| + return getCapturingNode(1); |
|
dtapuska
2016/07/22 15:57:39
This is an odd little constant. Can we name it for
mustaq
2016/07/22 16:01:01
May be reuse the constant from PE factory?
Navid Zolghadr
2016/07/22 16:39:24
:) yeah. I was trying to avoid making that constan
|
| +} |
| + |
| DEFINE_TRACE(PointerEventManager) |
| { |
| visitor->trace(m_frame); |