OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/input/PointerEventManager.h" | 5 #include "core/input/PointerEventManager.h" |
6 | 6 |
7 #include "core/dom/ElementTraversal.h" | 7 #include "core/dom/ElementTraversal.h" |
8 #include "core/dom/shadow/FlatTreeTraversal.h" | 8 #include "core/dom/shadow/FlatTreeTraversal.h" |
9 #include "core/events/MouseEvent.h" | 9 #include "core/events/MouseEvent.h" |
10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 } | 447 } |
448 } else { | 448 } else { |
449 // Set the target of pointer event to the captured node as this | 449 // Set the target of pointer event to the captured node as this |
450 // pointer is captured otherwise it would have gone to the if block | 450 // pointer is captured otherwise it would have gone to the if block |
451 // and perform a hit-test. | 451 // and perform a hit-test. |
452 touchInfo.touchNode = m_pendingPointerCaptureTarget | 452 touchInfo.touchNode = m_pendingPointerCaptureTarget |
453 .get(pointerId)->toNode(); | 453 .get(pointerId)->toNode(); |
454 touchInfo.targetFrame = touchInfo.touchNode->document().frame(); | 454 touchInfo.targetFrame = touchInfo.touchNode->document().frame(); |
455 } | 455 } |
456 | 456 |
457 WebInputEventResult result = WebInputEventResult::NotHandled; | |
458 | |
459 // Do not send pointer events for stationary touches or null targetFrame | 457 // Do not send pointer events for stationary touches or null targetFrame |
460 if (touchInfo.touchNode | 458 if (touchInfo.touchNode |
461 && touchPoint.state() != PlatformTouchPoint::TouchStationary | 459 && touchPoint.state() != PlatformTouchPoint::TouchStationary |
462 && !m_inCanceledStateForPointerTypeTouch) { | 460 && !m_inCanceledStateForPointerTypeTouch) { |
463 FloatPoint pagePoint = touchInfo.targetFrame->view() | 461 FloatPoint pagePoint = touchInfo.targetFrame->view() |
464 ->rootFrameToContents(touchInfo.point.pos()); | 462 ->rootFrameToContents(touchInfo.point.pos()); |
465 float scaleFactor = 1.0f / touchInfo.targetFrame->pageZoomFactor(); | 463 float scaleFactor = 1.0f / touchInfo.targetFrame->pageZoomFactor(); |
466 FloatPoint scrollPosition = touchInfo.targetFrame->view()->scrollPos ition(); | 464 FloatPoint scrollPosition = touchInfo.targetFrame->view()->scrollPos ition(); |
467 FloatPoint framePoint = pagePoint.scaledBy(scaleFactor); | 465 FloatPoint framePoint = pagePoint.scaledBy(scaleFactor); |
468 framePoint.moveBy(scrollPosition.scaledBy(-scaleFactor)); | 466 framePoint.moveBy(scrollPosition.scaledBy(-scaleFactor)); |
469 PointerEvent* pointerEvent = m_pointerEventFactory.create( | 467 PointerEvent* pointerEvent = m_pointerEventFactory.create( |
470 pointerEventNameForTouchPointState(touchPoint.state()), | 468 pointerEventNameForTouchPointState(touchPoint.state()), |
471 touchPoint, event.getModifiers(), | 469 touchPoint, event.getModifiers(), |
472 touchPoint.radius().scaledBy(scaleFactor), | 470 touchPoint.radius().scaledBy(scaleFactor), |
473 framePoint, | 471 framePoint, |
474 touchInfo.touchNode ? | 472 touchInfo.touchNode ? |
475 touchInfo.touchNode->document().domWindow() : nullptr); | 473 touchInfo.touchNode->document().domWindow() : nullptr); |
476 | 474 |
477 result = sendTouchPointerEvent(touchInfo.touchNode, pointerEvent); | 475 WebInputEventResult result = sendTouchPointerEvent(touchInfo.touchNo de, pointerEvent); |
476 | |
477 // Queue the WebInputEventResult to allow suppressing mouse events | |
478 // from gesture events. Since mouse events are fired only from | |
479 // GestureTap and GestureLongPress events which are triggered by | |
480 // single touches only, it is enough to queue the | |
Rick Byers
2016/05/27 20:39:27
Not quite true - GestureTwoFingerTap behaves simil
mustaq
2016/05/30 15:14:26
I will update the comment to clarify it: TwoFinger
mustaq
2016/06/02 19:26:27
Clarified the comment. My last post seems wrong ab
| |
481 // WebInputEventResult for only primary pointerdowns. | |
482 if (pointerEvent->type() == EventTypeNames::pointerdown | |
483 && pointerEvent->isPrimary()) { | |
484 m_primaryPointerdownResults.append(result); | |
Rick Byers
2016/05/27 20:39:27
Unfortunately I don't think we can currently guara
dtapuska
2016/05/27 20:54:07
I'd prefer if the information went up the stack an
mustaq
2016/05/30 15:14:26
Local sync seems unavoidable. I had uniqueTouchIds
mustaq
2016/06/02 19:26:27
As we suspected, both of these cases can happen, s
| |
485 } | |
478 } | 486 } |
479 // TODO(crbug.com/507408): Right now we add the touch point only if | 487 |
480 // its pointer event is NotHandled (e.g. preventDefault is called in | 488 touchInfos.append(touchInfo); |
481 // the pointer event listener). This behavior needs to change as it | |
482 // may create some inconsistent touch event sequence. | |
483 if (result == WebInputEventResult::NotHandled) { | |
484 touchInfos.append(touchInfo); | |
485 } | |
486 } | 489 } |
487 } | 490 } |
488 | 491 |
489 WebInputEventResult PointerEventManager::sendTouchPointerEvent( | 492 WebInputEventResult PointerEventManager::sendTouchPointerEvent( |
490 EventTarget* target, PointerEvent* pointerEvent) | 493 EventTarget* target, PointerEvent* pointerEvent) |
491 { | 494 { |
492 if (m_inCanceledStateForPointerTypeTouch) | 495 if (m_inCanceledStateForPointerTypeTouch) |
493 return WebInputEventResult::NotHandled; | 496 return WebInputEventResult::NotHandled; |
494 | 497 |
495 processCaptureAndPositionOfPointerEvent(pointerEvent, target); | 498 processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 { | 595 { |
593 } | 596 } |
594 | 597 |
595 void PointerEventManager::clear() | 598 void PointerEventManager::clear() |
596 { | 599 { |
597 for (auto& entry : m_preventMouseEventForPointerType) | 600 for (auto& entry : m_preventMouseEventForPointerType) |
598 entry = false; | 601 entry = false; |
599 m_touchEventManager.clear(); | 602 m_touchEventManager.clear(); |
600 m_inCanceledStateForPointerTypeTouch = false; | 603 m_inCanceledStateForPointerTypeTouch = false; |
601 m_pointerEventFactory.clear(); | 604 m_pointerEventFactory.clear(); |
605 m_primaryPointerdownResults.clear(); | |
602 m_nodeUnderPointer.clear(); | 606 m_nodeUnderPointer.clear(); |
603 m_pointerCaptureTarget.clear(); | 607 m_pointerCaptureTarget.clear(); |
604 m_pendingPointerCaptureTarget.clear(); | 608 m_pendingPointerCaptureTarget.clear(); |
605 } | 609 } |
606 | 610 |
607 void PointerEventManager::processCaptureAndPositionOfPointerEvent( | 611 void PointerEventManager::processCaptureAndPositionOfPointerEvent( |
608 PointerEvent* pointerEvent, | 612 PointerEvent* pointerEvent, |
609 EventTarget* hitTestTarget, | 613 EventTarget* hitTestTarget, |
610 EventTarget* lastNodeUnderMouse, | 614 EventTarget* lastNodeUnderMouse, |
611 const PlatformMouseEvent& mouseEvent, | 615 const PlatformMouseEvent& mouseEvent, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
777 { | 781 { |
778 visitor->trace(m_frame); | 782 visitor->trace(m_frame); |
779 visitor->trace(m_nodeUnderPointer); | 783 visitor->trace(m_nodeUnderPointer); |
780 visitor->trace(m_pointerCaptureTarget); | 784 visitor->trace(m_pointerCaptureTarget); |
781 visitor->trace(m_pendingPointerCaptureTarget); | 785 visitor->trace(m_pendingPointerCaptureTarget); |
782 visitor->trace(m_touchEventManager); | 786 visitor->trace(m_touchEventManager); |
783 } | 787 } |
784 | 788 |
785 | 789 |
786 } // namespace blink | 790 } // namespace blink |
OLD | NEW |