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