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/DocumentUserGestureToken.h" | 7 #include "core/dom/DocumentUserGestureToken.h" |
8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.h" |
9 #include "core/dom/shadow/FlatTreeTraversal.h" | 9 #include "core/dom/shadow/FlatTreeTraversal.h" |
10 #include "core/events/MouseEvent.h" | 10 #include "core/events/MouseEvent.h" |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 SetNodeUnderPointer(pointer_event, pending_pointer_capture_target); | 600 SetNodeUnderPointer(pointer_event, pending_pointer_capture_target); |
601 DispatchPointerEvent(pending_pointer_capture_target, | 601 DispatchPointerEvent(pending_pointer_capture_target, |
602 pointer_event_factory_.CreatePointerCaptureEvent( | 602 pointer_event_factory_.CreatePointerCaptureEvent( |
603 pointer_event, EventTypeNames::gotpointercapture)); | 603 pointer_event, EventTypeNames::gotpointercapture)); |
604 pointer_capture_target_.Set(pointer_id, pending_pointer_capture_target); | 604 pointer_capture_target_.Set(pointer_id, pending_pointer_capture_target); |
605 } else { | 605 } else { |
606 pointer_capture_target_.erase(pointer_id); | 606 pointer_capture_target_.erase(pointer_id); |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
| 610 void PointerEventManager::DispatchLostPointerCaptureEvent( |
| 611 const WebMouseEvent& mouse_event, |
| 612 const Vector<WebMouseEvent>& coalesced_events) { |
| 613 PointerEvent* pointer_event = pointer_event_factory_.Create( |
| 614 EventTypeNames::mousemove, mouse_event, coalesced_events, |
| 615 frame_->GetDocument()->domWindow()); |
| 616 if (EventTarget* capturing_target = |
| 617 GetCapturingNode(pointer_event->pointerId())) { |
| 618 if (capturing_target->ToNode() && |
| 619 !capturing_target->ToNode()->isConnected()) { |
| 620 capturing_target = capturing_target->ToNode()->ownerDocument(); |
| 621 } |
| 622 DispatchPointerEvent( |
| 623 capturing_target, |
| 624 pointer_event_factory_.CreatePointerCaptureEvent( |
| 625 pointer_event, EventTypeNames::lostpointercapture)); |
| 626 } |
| 627 } |
| 628 |
610 void PointerEventManager::RemoveTargetFromPointerCapturingMapping( | 629 void PointerEventManager::RemoveTargetFromPointerCapturingMapping( |
611 PointerCapturingMap& map, | 630 PointerCapturingMap& map, |
612 const EventTarget* target) { | 631 const EventTarget* target) { |
613 // We could have kept a reverse mapping to make this deletion possibly | 632 // We could have kept a reverse mapping to make this deletion possibly |
614 // faster but it adds some code complication which might not be worth of | 633 // faster but it adds some code complication which might not be worth of |
615 // the performance improvement considering there might not be a lot of | 634 // the performance improvement considering there might not be a lot of |
616 // active pointer or pointer captures at the same time. | 635 // active pointer or pointer captures at the same time. |
617 PointerCapturingMap tmp = map; | 636 PointerCapturingMap tmp = map; |
618 for (PointerCapturingMap::iterator it = tmp.begin(); it != tmp.end(); ++it) { | 637 for (PointerCapturingMap::iterator it = tmp.begin(); it != tmp.end(); ++it) { |
619 if (it->value == target) | 638 if (it->value == target) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 // the capture. Note that this might be different from | 678 // the capture. Note that this might be different from |
660 // |m_pointercaptureTarget|. |m_pointercaptureTarget| holds the element | 679 // |m_pointercaptureTarget|. |m_pointercaptureTarget| holds the element |
661 // that had the capture until now and has been receiving the pointerevents | 680 // that had the capture until now and has been receiving the pointerevents |
662 // but |m_pendingPointerCaptureTarget| indicated the element that gets the | 681 // but |m_pendingPointerCaptureTarget| indicated the element that gets the |
663 // very next pointer event. They will be the same if there was no change in | 682 // very next pointer event. They will be the same if there was no change in |
664 // capturing of a particular |pointerId|. See crbug.com/614481. | 683 // capturing of a particular |pointerId|. See crbug.com/614481. |
665 if (pending_pointer_capture_target_.at(pointer_id) == target) | 684 if (pending_pointer_capture_target_.at(pointer_id) == target) |
666 ReleasePointerCapture(pointer_id); | 685 ReleasePointerCapture(pointer_id); |
667 } | 686 } |
668 | 687 |
| 688 void PointerEventManager::ReleaseMousePointerCapture() { |
| 689 ReleasePointerCapture(PointerEventFactory::kMouseId); |
| 690 } |
| 691 |
669 bool PointerEventManager::HasPointerCapture(int pointer_id, | 692 bool PointerEventManager::HasPointerCapture(int pointer_id, |
670 const EventTarget* target) const { | 693 const EventTarget* target) const { |
671 return pending_pointer_capture_target_.at(pointer_id) == target; | 694 return pending_pointer_capture_target_.at(pointer_id) == target; |
672 } | 695 } |
673 | 696 |
674 bool PointerEventManager::HasProcessedPointerCapture( | 697 bool PointerEventManager::HasProcessedPointerCapture( |
675 int pointer_id, | 698 int pointer_id, |
676 const EventTarget* target) const { | 699 const EventTarget* target) const { |
677 return pointer_capture_target_.at(pointer_id) == target; | 700 return pointer_capture_target_.at(pointer_id) == target; |
678 } | 701 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 if (first_id > unique_touch_event_id) | 740 if (first_id > unique_touch_event_id) |
718 return false; | 741 return false; |
719 touch_ids_for_canceled_pointerdowns_.TakeFirst(); | 742 touch_ids_for_canceled_pointerdowns_.TakeFirst(); |
720 if (first_id == unique_touch_event_id) | 743 if (first_id == unique_touch_event_id) |
721 return true; | 744 return true; |
722 } | 745 } |
723 return false; | 746 return false; |
724 } | 747 } |
725 | 748 |
726 } // namespace blink | 749 } // namespace blink |
OLD | NEW |