Chromium Code Reviews| 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 (it != pending_pointer_capture_target_.end()) ? it->value : nullptr; | 542 (it != pending_pointer_capture_target_.end()) ? it->value : nullptr; |
| 543 | 543 |
| 544 if (pointer_capture_target) | 544 if (pointer_capture_target) |
| 545 *pointer_capture_target = pointer_capture_target_temp; | 545 *pointer_capture_target = pointer_capture_target_temp; |
| 546 if (pending_pointer_capture_target) | 546 if (pending_pointer_capture_target) |
| 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 // TODO(727333): Replace the last two parameters by a single WebMouseEvent | |
|
mustaq
2017/05/29 18:37:44
Nit: Let's stick to the official style:
TODO(lanwe
lanwei
2017/05/30 17:11:36
Done.
| |
| 553 // pointer which defaults to null. | |
| 552 EventTarget* PointerEventManager::ProcessCaptureAndPositionOfPointerEvent( | 554 EventTarget* PointerEventManager::ProcessCaptureAndPositionOfPointerEvent( |
| 553 PointerEvent* pointer_event, | 555 PointerEvent* pointer_event, |
| 554 EventTarget* hit_test_target, | 556 EventTarget* hit_test_target, |
| 555 const String& canvas_region_id, | 557 const String& canvas_region_id, |
| 556 const WebMouseEvent& mouse_event, | 558 const WebMouseEvent& mouse_event, |
| 557 bool send_mouse_event) { | 559 bool send_mouse_event) { |
| 558 ProcessPendingPointerCapture(pointer_event); | 560 ProcessPendingPointerCapture(pointer_event); |
| 559 | 561 |
| 560 PointerCapturingMap::const_iterator it = | 562 PointerCapturingMap::const_iterator it = |
| 561 pointer_capture_target_.find(pointer_event->pointerId()); | 563 pointer_capture_target_.find(pointer_event->pointerId()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 SetNodeUnderPointer(pointer_event, pending_pointer_capture_target); | 603 SetNodeUnderPointer(pointer_event, pending_pointer_capture_target); |
| 602 DispatchPointerEvent(pending_pointer_capture_target, | 604 DispatchPointerEvent(pending_pointer_capture_target, |
| 603 pointer_event_factory_.CreatePointerCaptureEvent( | 605 pointer_event_factory_.CreatePointerCaptureEvent( |
| 604 pointer_event, EventTypeNames::gotpointercapture)); | 606 pointer_event, EventTypeNames::gotpointercapture)); |
| 605 pointer_capture_target_.Set(pointer_id, pending_pointer_capture_target); | 607 pointer_capture_target_.Set(pointer_id, pending_pointer_capture_target); |
| 606 } else { | 608 } else { |
| 607 pointer_capture_target_.erase(pointer_id); | 609 pointer_capture_target_.erase(pointer_id); |
| 608 } | 610 } |
| 609 } | 611 } |
| 610 | 612 |
| 613 void PointerEventManager::ProcessPendingPointerCaptureForPointerLock( | |
| 614 const WebMouseEvent& mouse_event) { | |
| 615 PointerEvent* pointer_event = pointer_event_factory_.Create( | |
| 616 EventTypeNames::mousemove, mouse_event, Vector<WebMouseEvent>(), | |
| 617 frame_->GetDocument()->domWindow()); | |
| 618 ProcessPendingPointerCapture(pointer_event); | |
| 619 } | |
| 620 | |
| 611 void PointerEventManager::RemoveTargetFromPointerCapturingMapping( | 621 void PointerEventManager::RemoveTargetFromPointerCapturingMapping( |
| 612 PointerCapturingMap& map, | 622 PointerCapturingMap& map, |
| 613 const EventTarget* target) { | 623 const EventTarget* target) { |
| 614 // We could have kept a reverse mapping to make this deletion possibly | 624 // 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 | 625 // 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 | 626 // the performance improvement considering there might not be a lot of |
| 617 // active pointer or pointer captures at the same time. | 627 // active pointer or pointer captures at the same time. |
| 618 PointerCapturingMap tmp = map; | 628 PointerCapturingMap tmp = map; |
| 619 for (PointerCapturingMap::iterator it = tmp.begin(); it != tmp.end(); ++it) { | 629 for (PointerCapturingMap::iterator it = tmp.begin(); it != tmp.end(); ++it) { |
| 620 if (it->value == target) | 630 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 | 670 // the capture. Note that this might be different from |
| 661 // |m_pointercaptureTarget|. |m_pointercaptureTarget| holds the element | 671 // |m_pointercaptureTarget|. |m_pointercaptureTarget| holds the element |
| 662 // that had the capture until now and has been receiving the pointerevents | 672 // that had the capture until now and has been receiving the pointerevents |
| 663 // but |m_pendingPointerCaptureTarget| indicated the element that gets the | 673 // 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 | 674 // 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. | 675 // capturing of a particular |pointerId|. See crbug.com/614481. |
| 666 if (pending_pointer_capture_target_.at(pointer_id) == target) | 676 if (pending_pointer_capture_target_.at(pointer_id) == target) |
| 667 ReleasePointerCapture(pointer_id); | 677 ReleasePointerCapture(pointer_id); |
| 668 } | 678 } |
| 669 | 679 |
| 680 void PointerEventManager::ReleaseMousePointerCapture() { | |
| 681 ReleasePointerCapture(PointerEventFactory::kMouseId); | |
| 682 } | |
| 683 | |
| 670 bool PointerEventManager::HasPointerCapture(int pointer_id, | 684 bool PointerEventManager::HasPointerCapture(int pointer_id, |
| 671 const EventTarget* target) const { | 685 const EventTarget* target) const { |
| 672 return pending_pointer_capture_target_.at(pointer_id) == target; | 686 return pending_pointer_capture_target_.at(pointer_id) == target; |
| 673 } | 687 } |
| 674 | 688 |
| 675 bool PointerEventManager::HasProcessedPointerCapture( | 689 bool PointerEventManager::HasProcessedPointerCapture( |
| 676 int pointer_id, | 690 int pointer_id, |
| 677 const EventTarget* target) const { | 691 const EventTarget* target) const { |
| 678 return pointer_capture_target_.at(pointer_id) == target; | 692 return pointer_capture_target_.at(pointer_id) == target; |
| 679 } | 693 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 if (first_id > unique_touch_event_id) | 732 if (first_id > unique_touch_event_id) |
| 719 return false; | 733 return false; |
| 720 touch_ids_for_canceled_pointerdowns_.TakeFirst(); | 734 touch_ids_for_canceled_pointerdowns_.TakeFirst(); |
| 721 if (first_id == unique_touch_event_id) | 735 if (first_id == unique_touch_event_id) |
| 722 return true; | 736 return true; |
| 723 } | 737 } |
| 724 return false; | 738 return false; |
| 725 } | 739 } |
| 726 | 740 |
| 727 } // namespace blink | 741 } // namespace blink |
| OLD | NEW |