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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 } | 648 } |
649 | 649 |
650 void PointerEventManager::releasePointerCapture(int pointerId) { | 650 void PointerEventManager::releasePointerCapture(int pointerId) { |
651 m_pendingPointerCaptureTarget.remove(pointerId); | 651 m_pendingPointerCaptureTarget.remove(pointerId); |
652 } | 652 } |
653 | 653 |
654 bool PointerEventManager::isActive(const int pointerId) const { | 654 bool PointerEventManager::isActive(const int pointerId) const { |
655 return m_pointerEventFactory.isActive(pointerId); | 655 return m_pointerEventFactory.isActive(pointerId); |
656 } | 656 } |
657 | 657 |
| 658 // This function checks the type of the pointer event to be touch as touch |
| 659 // pointer events are the only ones that are directly dispatched from the main |
| 660 // page managers to their target (event if target is in an iframe) and only |
| 661 // those managers will keep track of these pointer events. |
| 662 bool PointerEventManager::isTouchPointerIdActiveOnFrame( |
| 663 int pointerId, |
| 664 LocalFrame* frame) const { |
| 665 if (m_pointerEventFactory.getPointerType(pointerId) != |
| 666 WebPointerProperties::PointerType::Touch) |
| 667 return false; |
| 668 Node* lastNodeReceivingEvent = |
| 669 m_nodeUnderPointer.contains(pointerId) |
| 670 ? m_nodeUnderPointer.get(pointerId).target->toNode() |
| 671 : nullptr; |
| 672 return lastNodeReceivingEvent && |
| 673 lastNodeReceivingEvent->document().frame() == frame; |
| 674 } |
| 675 |
658 bool PointerEventManager::isAnyTouchActive() const { | 676 bool PointerEventManager::isAnyTouchActive() const { |
659 return m_touchEventManager->isAnyTouchActive(); | 677 return m_touchEventManager->isAnyTouchActive(); |
660 } | 678 } |
661 | 679 |
662 bool PointerEventManager::primaryPointerdownCanceled( | 680 bool PointerEventManager::primaryPointerdownCanceled( |
663 uint32_t uniqueTouchEventId) { | 681 uint32_t uniqueTouchEventId) { |
664 // It's safe to assume that uniqueTouchEventIds won't wrap back to 0 from | 682 // It's safe to assume that uniqueTouchEventIds won't wrap back to 0 from |
665 // 2^32-1 (>4.2 billion): even with a generous 100 unique ids per touch | 683 // 2^32-1 (>4.2 billion): even with a generous 100 unique ids per touch |
666 // sequence & one sequence per 10 second, it takes 13+ years to wrap back. | 684 // sequence & one sequence per 10 second, it takes 13+ years to wrap back. |
667 while (!m_touchIdsForCanceledPointerdowns.isEmpty()) { | 685 while (!m_touchIdsForCanceledPointerdowns.isEmpty()) { |
668 uint32_t firstId = m_touchIdsForCanceledPointerdowns.first(); | 686 uint32_t firstId = m_touchIdsForCanceledPointerdowns.first(); |
669 if (firstId > uniqueTouchEventId) | 687 if (firstId > uniqueTouchEventId) |
670 return false; | 688 return false; |
671 m_touchIdsForCanceledPointerdowns.takeFirst(); | 689 m_touchIdsForCanceledPointerdowns.takeFirst(); |
672 if (firstId == uniqueTouchEventId) | 690 if (firstId == uniqueTouchEventId) |
673 return true; | 691 return true; |
674 } | 692 } |
675 return false; | 693 return false; |
676 } | 694 } |
677 | 695 |
678 EventTarget* PointerEventManager::getMouseCapturingNode() { | 696 EventTarget* PointerEventManager::getMouseCapturingNode() { |
679 return getCapturingNode(PointerEventFactory::s_mouseId); | 697 return getCapturingNode(PointerEventFactory::s_mouseId); |
680 } | 698 } |
681 | 699 |
682 } // namespace blink | 700 } // namespace blink |
OLD | NEW |