| 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/MouseEventManager.h" | 5 #include "core/input/MouseEventManager.h" |
| 6 | 6 |
| 7 #include "core/clipboard/DataObject.h" | 7 #include "core/clipboard/DataObject.h" |
| 8 #include "core/clipboard/DataTransfer.h" | 8 #include "core/clipboard/DataTransfer.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/ElementTraversal.h" | 10 #include "core/dom/ElementTraversal.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Clear(); | 84 Clear(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void MouseEventManager::Clear() { | 87 void MouseEventManager::Clear() { |
| 88 node_under_mouse_ = nullptr; | 88 node_under_mouse_ = nullptr; |
| 89 mouse_press_node_ = nullptr; | 89 mouse_press_node_ = nullptr; |
| 90 mouse_down_may_start_autoscroll_ = false; | 90 mouse_down_may_start_autoscroll_ = false; |
| 91 mouse_down_may_start_drag_ = false; | 91 mouse_down_may_start_drag_ = false; |
| 92 captures_dragging_ = false; | 92 captures_dragging_ = false; |
| 93 is_mouse_position_unknown_ = true; | 93 is_mouse_position_unknown_ = true; |
| 94 last_known_mouse_position_ = IntPoint(); | 94 last_known_mouse_position_ = FloatPoint(); |
| 95 last_known_mouse_global_position_ = IntPoint(); | 95 last_known_mouse_global_position_ = FloatPoint(); |
| 96 mouse_pressed_ = false; | 96 mouse_pressed_ = false; |
| 97 click_count_ = 0; | 97 click_count_ = 0; |
| 98 click_element_ = nullptr; | 98 click_element_ = nullptr; |
| 99 mouse_down_element_ = nullptr; | 99 mouse_down_element_ = nullptr; |
| 100 mouse_down_pos_ = IntPoint(); | 100 mouse_down_pos_ = IntPoint(); |
| 101 mouse_down_timestamp_ = TimeTicks(); | 101 mouse_down_timestamp_ = TimeTicks(); |
| 102 mouse_down_ = WebMouseEvent(); | 102 mouse_down_ = WebMouseEvent(); |
| 103 svg_pan_ = false; | 103 svg_pan_ = false; |
| 104 drag_start_pos_ = LayoutPoint(); | 104 drag_start_pos_ = LayoutPoint(); |
| 105 fake_mouse_move_event_timer_.Stop(); | 105 fake_mouse_move_event_timer_.Stop(); |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 560 |
| 561 frame_->GetEventHandler().GetSelectionController().SetMouseDownMayStartSelect( | 561 frame_->GetEventHandler().GetSelectionController().SetMouseDownMayStartSelect( |
| 562 false); | 562 false); |
| 563 } | 563 } |
| 564 | 564 |
| 565 bool MouseEventManager::IsMousePositionUnknown() { | 565 bool MouseEventManager::IsMousePositionUnknown() { |
| 566 return is_mouse_position_unknown_; | 566 return is_mouse_position_unknown_; |
| 567 } | 567 } |
| 568 | 568 |
| 569 IntPoint MouseEventManager::LastKnownMousePosition() { | 569 IntPoint MouseEventManager::LastKnownMousePosition() { |
| 570 return last_known_mouse_position_; | 570 return FlooredIntPoint(last_known_mouse_position_); |
| 571 } |
| 572 |
| 573 FloatPoint MouseEventManager::LastKnownMousePositionGlobal() { |
| 574 return last_known_mouse_global_position_; |
| 571 } | 575 } |
| 572 | 576 |
| 573 void MouseEventManager::SetLastKnownMousePosition(const WebMouseEvent& event) { | 577 void MouseEventManager::SetLastKnownMousePosition(const WebMouseEvent& event) { |
| 574 is_mouse_position_unknown_ = false; | 578 is_mouse_position_unknown_ = false; |
| 575 last_known_mouse_position_ = FlooredIntPoint(event.PositionInRootFrame()); | 579 last_known_mouse_position_ = event.PositionInRootFrame(); |
| 576 last_known_mouse_global_position_ = | 580 last_known_mouse_global_position_ = event.PositionInScreen(); |
| 577 IntPoint(event.PositionInScreen().x, event.PositionInScreen().y); | |
| 578 } | 581 } |
| 579 | 582 |
| 580 void MouseEventManager::DispatchFakeMouseMoveEventSoon() { | 583 void MouseEventManager::DispatchFakeMouseMoveEventSoon() { |
| 581 if (mouse_pressed_) | 584 if (mouse_pressed_) |
| 582 return; | 585 return; |
| 583 | 586 |
| 584 if (is_mouse_position_unknown_) | 587 if (is_mouse_position_unknown_) |
| 585 return; | 588 return; |
| 586 | 589 |
| 587 // Reschedule the timer, to prevent dispatching mouse move events | 590 // Reschedule the timer, to prevent dispatching mouse move events |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 (mouse_press_node_ && mouse_press_node_->GetLayoutBox() && | 664 (mouse_press_node_ && mouse_press_node_->GetLayoutBox() && |
| 662 mouse_press_node_->GetLayoutBox()->CanBeProgramaticallyScrolled()); | 665 mouse_press_node_->GetLayoutBox()->CanBeProgramaticallyScrolled()); |
| 663 | 666 |
| 664 return swallow_event ? WebInputEventResult::kHandledSystem | 667 return swallow_event ? WebInputEventResult::kHandledSystem |
| 665 : WebInputEventResult::kNotHandled; | 668 : WebInputEventResult::kNotHandled; |
| 666 } | 669 } |
| 667 | 670 |
| 668 WebInputEventResult MouseEventManager::HandleMouseReleaseEvent( | 671 WebInputEventResult MouseEventManager::HandleMouseReleaseEvent( |
| 669 const MouseEventWithHitTestResults& event) { | 672 const MouseEventWithHitTestResults& event) { |
| 670 AutoscrollController* controller = scroll_manager_->GetAutoscrollController(); | 673 AutoscrollController* controller = scroll_manager_->GetAutoscrollController(); |
| 671 if (controller && controller->AutoscrollInProgress()) | 674 if (controller && controller->SelectionAutoscrollInProgress()) |
| 672 scroll_manager_->StopAutoscroll(); | 675 scroll_manager_->StopAutoscroll(); |
| 673 | 676 |
| 674 return frame_->GetEventHandler() | 677 return frame_->GetEventHandler() |
| 675 .GetSelectionController() | 678 .GetSelectionController() |
| 676 .HandleMouseReleaseEvent(event, drag_start_pos_) | 679 .HandleMouseReleaseEvent(event, drag_start_pos_) |
| 677 ? WebInputEventResult::kHandledSystem | 680 ? WebInputEventResult::kHandledSystem |
| 678 : WebInputEventResult::kNotHandled; | 681 : WebInputEventResult::kNotHandled; |
| 679 } | 682 } |
| 680 | 683 |
| 681 void MouseEventManager::UpdateSelectionForMouseDrag() { | 684 void MouseEventManager::UpdateSelectionForMouseDrag() { |
| 682 frame_->GetEventHandler() | 685 frame_->GetEventHandler() |
| 683 .GetSelectionController() | 686 .GetSelectionController() |
| 684 .UpdateSelectionForMouseDrag(mouse_press_node_, drag_start_pos_, | 687 .UpdateSelectionForMouseDrag(mouse_press_node_, drag_start_pos_, |
| 685 last_known_mouse_position_); | 688 FlooredIntPoint(last_known_mouse_position_)); |
| 686 } | 689 } |
| 687 | 690 |
| 688 bool MouseEventManager::HandleDragDropIfPossible( | 691 bool MouseEventManager::HandleDragDropIfPossible( |
| 689 const GestureEventWithHitTestResults& targeted_event) { | 692 const GestureEventWithHitTestResults& targeted_event) { |
| 690 if (frame_->GetSettings() && | 693 if (frame_->GetSettings() && |
| 691 frame_->GetSettings()->GetTouchDragDropEnabled() && frame_->View()) { | 694 frame_->GetSettings()->GetTouchDragDropEnabled() && frame_->View()) { |
| 692 const WebGestureEvent& gesture_event = targeted_event.Event(); | 695 const WebGestureEvent& gesture_event = targeted_event.Event(); |
| 693 unsigned modifiers = gesture_event.GetModifiers(); | 696 unsigned modifiers = gesture_event.GetModifiers(); |
| 694 | 697 |
| 695 // TODO(mustaq): Suppressing long-tap MouseEvents could break | 698 // TODO(mustaq): Suppressing long-tap MouseEvents could break |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 | 777 |
| 775 layout_object = parent->GetLayoutObject(); | 778 layout_object = parent->GetLayoutObject(); |
| 776 if (!layout_object || !layout_object->IsListBox()) | 779 if (!layout_object || !layout_object->IsListBox()) |
| 777 return WebInputEventResult::kNotHandled; | 780 return WebInputEventResult::kNotHandled; |
| 778 } | 781 } |
| 779 | 782 |
| 780 mouse_down_may_start_drag_ = false; | 783 mouse_down_may_start_drag_ = false; |
| 781 | 784 |
| 782 frame_->GetEventHandler().GetSelectionController().HandleMouseDraggedEvent( | 785 frame_->GetEventHandler().GetSelectionController().HandleMouseDraggedEvent( |
| 783 event, mouse_down_pos_, drag_start_pos_, mouse_press_node_.Get(), | 786 event, mouse_down_pos_, drag_start_pos_, mouse_press_node_.Get(), |
| 784 last_known_mouse_position_); | 787 FlooredIntPoint(last_known_mouse_position_)); |
| 785 | 788 |
| 786 // The call into HandleMouseDraggedEvent may have caused a re-layout, | 789 // The call into HandleMouseDraggedEvent may have caused a re-layout, |
| 787 // so get the LayoutObject again. | 790 // so get the LayoutObject again. |
| 788 layout_object = target_node->GetLayoutObject(); | 791 layout_object = target_node->GetLayoutObject(); |
| 789 | 792 |
| 790 if (layout_object && mouse_down_may_start_autoscroll_ && | 793 if (layout_object && mouse_down_may_start_autoscroll_ && |
| 791 !scroll_manager_->MiddleClickAutoscrollInProgress() && | 794 !scroll_manager_->MiddleClickAutoscrollInProgress() && |
| 792 !frame_->Selection().SelectedHTMLForClipboard().IsEmpty()) { | 795 !frame_->Selection().SelectedHTMLForClipboard().IsEmpty()) { |
| 793 if (AutoscrollController* controller = | 796 if (AutoscrollController* controller = |
| 794 scroll_manager_->GetAutoscrollController()) { | 797 scroll_manager_->GetAutoscrollController()) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 | 1090 |
| 1088 void MouseEventManager::SetClickCount(int click_count) { | 1091 void MouseEventManager::SetClickCount(int click_count) { |
| 1089 click_count_ = click_count; | 1092 click_count_ = click_count; |
| 1090 } | 1093 } |
| 1091 | 1094 |
| 1092 bool MouseEventManager::MouseDownMayStartDrag() { | 1095 bool MouseEventManager::MouseDownMayStartDrag() { |
| 1093 return mouse_down_may_start_drag_; | 1096 return mouse_down_may_start_drag_; |
| 1094 } | 1097 } |
| 1095 | 1098 |
| 1096 } // namespace blink | 1099 } // namespace blink |
| OLD | NEW |