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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 *pending_pointer_capture_target = pending_pointercapture_target_temp; | 547 *pending_pointer_capture_target = pending_pointercapture_target_temp; |
548 | 548 |
549 return pointer_capture_target_temp != pending_pointercapture_target_temp; | 549 return pointer_capture_target_temp != pending_pointercapture_target_temp; |
550 } | 550 } |
551 | 551 |
552 EventTarget* PointerEventManager::ProcessCaptureAndPositionOfPointerEvent( | 552 EventTarget* PointerEventManager::ProcessCaptureAndPositionOfPointerEvent( |
553 PointerEvent* pointer_event, | 553 PointerEvent* pointer_event, |
554 EventTarget* hit_test_target, | 554 EventTarget* hit_test_target, |
555 const String& canvas_region_id, | 555 const String& canvas_region_id, |
556 const WebMouseEvent& mouse_event, | 556 const WebMouseEvent& mouse_event, |
557 bool send_mouse_event) { | 557 bool send_mouse_event) { |
mustaq
2017/05/26 14:56:19
A clean-up request: the last two parameters should
| |
558 ProcessPendingPointerCapture(pointer_event); | 558 ProcessPendingPointerCapture(pointer_event); |
559 | 559 |
560 PointerCapturingMap::const_iterator it = | 560 PointerCapturingMap::const_iterator it = |
561 pointer_capture_target_.find(pointer_event->pointerId()); | 561 pointer_capture_target_.find(pointer_event->pointerId()); |
562 if (EventTarget* pointercapture_target = | 562 if (EventTarget* pointercapture_target = |
563 (it != pointer_capture_target_.end()) ? it->value : nullptr) | 563 (it != pointer_capture_target_.end()) ? it->value : nullptr) |
564 hit_test_target = pointercapture_target; | 564 hit_test_target = pointercapture_target; |
565 | 565 |
566 SetNodeUnderPointer(pointer_event, hit_test_target); | 566 SetNodeUnderPointer(pointer_event, hit_test_target); |
567 if (send_mouse_event) { | 567 if (send_mouse_event) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 SetNodeUnderPointer(pointer_event, pending_pointer_capture_target); | 601 SetNodeUnderPointer(pointer_event, pending_pointer_capture_target); |
602 DispatchPointerEvent(pending_pointer_capture_target, | 602 DispatchPointerEvent(pending_pointer_capture_target, |
603 pointer_event_factory_.CreatePointerCaptureEvent( | 603 pointer_event_factory_.CreatePointerCaptureEvent( |
604 pointer_event, EventTypeNames::gotpointercapture)); | 604 pointer_event, EventTypeNames::gotpointercapture)); |
605 pointer_capture_target_.Set(pointer_id, pending_pointer_capture_target); | 605 pointer_capture_target_.Set(pointer_id, pending_pointer_capture_target); |
606 } else { | 606 } else { |
607 pointer_capture_target_.erase(pointer_id); | 607 pointer_capture_target_.erase(pointer_id); |
608 } | 608 } |
609 } | 609 } |
610 | 610 |
611 void PointerEventManager::ProcessPendingPointerCapture( | |
mustaq
2017/05/26 14:56:19
The existing method with the same name is wrapped
lanwei
2017/05/29 18:30:07
Done.
| |
612 const WebMouseEvent& mouse_event, | |
613 const Vector<WebMouseEvent>& coalesced_events) { | |
614 PointerEvent* pointer_event = pointer_event_factory_.Create( | |
615 EventTypeNames::mousemove, mouse_event, coalesced_events, | |
616 frame_->GetDocument()->domWindow()); | |
617 ProcessPendingPointerCapture(pointer_event); | |
618 } | |
619 | |
611 void PointerEventManager::RemoveTargetFromPointerCapturingMapping( | 620 void PointerEventManager::RemoveTargetFromPointerCapturingMapping( |
612 PointerCapturingMap& map, | 621 PointerCapturingMap& map, |
613 const EventTarget* target) { | 622 const EventTarget* target) { |
614 // We could have kept a reverse mapping to make this deletion possibly | 623 // We could have kept a reverse mapping to make this deletion possibly |
615 // faster but it adds some code complication which might not be worth of | 624 // faster but it adds some code complication which might not be worth of |
616 // the performance improvement considering there might not be a lot of | 625 // the performance improvement considering there might not be a lot of |
617 // active pointer or pointer captures at the same time. | 626 // active pointer or pointer captures at the same time. |
618 PointerCapturingMap tmp = map; | 627 PointerCapturingMap tmp = map; |
619 for (PointerCapturingMap::iterator it = tmp.begin(); it != tmp.end(); ++it) { | 628 for (PointerCapturingMap::iterator it = tmp.begin(); it != tmp.end(); ++it) { |
620 if (it->value == target) | 629 if (it->value == target) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 // the capture. Note that this might be different from | 669 // the capture. Note that this might be different from |
661 // |m_pointercaptureTarget|. |m_pointercaptureTarget| holds the element | 670 // |m_pointercaptureTarget|. |m_pointercaptureTarget| holds the element |
662 // that had the capture until now and has been receiving the pointerevents | 671 // that had the capture until now and has been receiving the pointerevents |
663 // but |m_pendingPointerCaptureTarget| indicated the element that gets the | 672 // but |m_pendingPointerCaptureTarget| indicated the element that gets the |
664 // very next pointer event. They will be the same if there was no change in | 673 // very next pointer event. They will be the same if there was no change in |
665 // capturing of a particular |pointerId|. See crbug.com/614481. | 674 // capturing of a particular |pointerId|. See crbug.com/614481. |
666 if (pending_pointer_capture_target_.at(pointer_id) == target) | 675 if (pending_pointer_capture_target_.at(pointer_id) == target) |
667 ReleasePointerCapture(pointer_id); | 676 ReleasePointerCapture(pointer_id); |
668 } | 677 } |
669 | 678 |
679 void PointerEventManager::ReleaseMousePointerCapture() { | |
680 ReleasePointerCapture(PointerEventFactory::kMouseId); | |
681 } | |
682 | |
670 bool PointerEventManager::HasPointerCapture(int pointer_id, | 683 bool PointerEventManager::HasPointerCapture(int pointer_id, |
671 const EventTarget* target) const { | 684 const EventTarget* target) const { |
672 return pending_pointer_capture_target_.at(pointer_id) == target; | 685 return pending_pointer_capture_target_.at(pointer_id) == target; |
673 } | 686 } |
674 | 687 |
675 bool PointerEventManager::HasProcessedPointerCapture( | 688 bool PointerEventManager::HasProcessedPointerCapture( |
676 int pointer_id, | 689 int pointer_id, |
677 const EventTarget* target) const { | 690 const EventTarget* target) const { |
678 return pointer_capture_target_.at(pointer_id) == target; | 691 return pointer_capture_target_.at(pointer_id) == target; |
679 } | 692 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 if (first_id > unique_touch_event_id) | 731 if (first_id > unique_touch_event_id) |
719 return false; | 732 return false; |
720 touch_ids_for_canceled_pointerdowns_.TakeFirst(); | 733 touch_ids_for_canceled_pointerdowns_.TakeFirst(); |
721 if (first_id == unique_touch_event_id) | 734 if (first_id == unique_touch_event_id) |
722 return true; | 735 return true; |
723 } | 736 } |
724 return false; | 737 return false; |
725 } | 738 } |
726 | 739 |
727 } // namespace blink | 740 } // namespace blink |
OLD | NEW |