| 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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 if (!layout_object || !layout_object->IsListBox()) | 731 if (!layout_object || !layout_object->IsListBox()) |
| 732 return WebInputEventResult::kNotHandled; | 732 return WebInputEventResult::kNotHandled; |
| 733 } | 733 } |
| 734 | 734 |
| 735 mouse_down_may_start_drag_ = false; | 735 mouse_down_may_start_drag_ = false; |
| 736 | 736 |
| 737 frame_->GetEventHandler().GetSelectionController().HandleMouseDraggedEvent( | 737 frame_->GetEventHandler().GetSelectionController().HandleMouseDraggedEvent( |
| 738 event, mouse_down_pos_, drag_start_pos_, mouse_press_node_.Get(), | 738 event, mouse_down_pos_, drag_start_pos_, mouse_press_node_.Get(), |
| 739 last_known_mouse_position_); | 739 last_known_mouse_position_); |
| 740 | 740 |
| 741 // The call into handleMouseDraggedEvent may have caused a re-layout, | 741 // The call into HandleMouseDraggedEvent may have caused a re-layout, |
| 742 // so get the LayoutObject again. | 742 // so get the LayoutObject again. |
| 743 layout_object = target_node->GetLayoutObject(); | 743 layout_object = target_node->GetLayoutObject(); |
| 744 | 744 |
| 745 if (layout_object && mouse_down_may_start_autoscroll_ && | 745 if (layout_object && mouse_down_may_start_autoscroll_ && |
| 746 !scroll_manager_->MiddleClickAutoscrollInProgress() && | 746 !scroll_manager_->MiddleClickAutoscrollInProgress() && |
| 747 !frame_->Selection().SelectedHTMLForClipboard().IsEmpty()) { | 747 !frame_->Selection().SelectedHTMLForClipboard().IsEmpty()) { |
| 748 if (AutoscrollController* controller = | 748 if (AutoscrollController* controller = |
| 749 scroll_manager_->GetAutoscrollController()) { | 749 scroll_manager_->GetAutoscrollController()) { |
| 750 controller->StartAutoscrollForSelection(layout_object); | 750 // Avoid updating the lifecycle unless it's possible to autoscroll. |
| 751 mouse_down_may_start_autoscroll_ = false; | 751 layout_object->GetFrameView()->UpdateAllLifecyclePhasesExceptPaint(); |
| 752 |
| 753 // The lifecycle update above may have invalidated the previous layout. |
| 754 layout_object = target_node->GetLayoutObject(); |
| 755 if (layout_object) { |
| 756 controller->StartAutoscrollForSelection(layout_object); |
| 757 mouse_down_may_start_autoscroll_ = false; |
| 758 } |
| 752 } | 759 } |
| 753 } | 760 } |
| 754 | 761 |
| 755 return WebInputEventResult::kHandledSystem; | 762 return WebInputEventResult::kHandledSystem; |
| 756 } | 763 } |
| 757 | 764 |
| 758 bool MouseEventManager::HandleDrag(const MouseEventWithHitTestResults& event, | 765 bool MouseEventManager::HandleDrag(const MouseEventWithHitTestResults& event, |
| 759 DragInitiator initiator) { | 766 DragInitiator initiator) { |
| 760 DCHECK(event.Event().GetType() == WebInputEvent::kMouseMove); | 767 DCHECK(event.Event().GetType() == WebInputEvent::kMouseMove); |
| 761 // Callers must protect the reference to FrameView, since this function may | 768 // Callers must protect the reference to FrameView, since this function may |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 | 1032 |
| 1026 void MouseEventManager::SetClickCount(int click_count) { | 1033 void MouseEventManager::SetClickCount(int click_count) { |
| 1027 click_count_ = click_count; | 1034 click_count_ = click_count; |
| 1028 } | 1035 } |
| 1029 | 1036 |
| 1030 bool MouseEventManager::MouseDownMayStartDrag() { | 1037 bool MouseEventManager::MouseDownMayStartDrag() { |
| 1031 return mouse_down_may_start_drag_; | 1038 return mouse_down_may_start_drag_; |
| 1032 } | 1039 } |
| 1033 | 1040 |
| 1034 } // namespace blink | 1041 } // namespace blink |
| OLD | NEW |