Chromium Code Reviews

Side by Side Diff: third_party/WebKit/Source/core/input/MouseEventManager.cpp

Issue 2844593002: Protect against lifecycle updates that delete a layout object for autoscroll (Closed)
Patch Set: none Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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...)
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 layout_object->GetFrameView()->UpdateAllLifecyclePhasesExceptPaint();
751 mouse_down_may_start_autoscroll_ = false; 751
752 // The lifecycle update above may have invalidated the previous layout.
753 if (LayoutObject* next_layout_object = target_node->GetLayoutObject()) {
754 controller->StartAutoscrollForSelection(next_layout_object);
755 mouse_down_may_start_autoscroll_ = false;
756 }
752 } 757 }
753 } 758 }
754 759
755 return WebInputEventResult::kHandledSystem; 760 return WebInputEventResult::kHandledSystem;
756 } 761 }
757 762
758 bool MouseEventManager::HandleDrag(const MouseEventWithHitTestResults& event, 763 bool MouseEventManager::HandleDrag(const MouseEventWithHitTestResults& event,
759 DragInitiator initiator) { 764 DragInitiator initiator) {
760 DCHECK(event.Event().GetType() == WebInputEvent::kMouseMove); 765 DCHECK(event.Event().GetType() == WebInputEvent::kMouseMove);
761 // Callers must protect the reference to FrameView, since this function may 766 // Callers must protect the reference to FrameView, since this function may
(...skipping 263 matching lines...)
1025 1030
1026 void MouseEventManager::SetClickCount(int click_count) { 1031 void MouseEventManager::SetClickCount(int click_count) {
1027 click_count_ = click_count; 1032 click_count_ = click_count;
1028 } 1033 }
1029 1034
1030 bool MouseEventManager::MouseDownMayStartDrag() { 1035 bool MouseEventManager::MouseDownMayStartDrag() {
1031 return mouse_down_may_start_drag_; 1036 return mouse_down_may_start_drag_;
1032 } 1037 }
1033 1038
1034 } // namespace blink 1039 } // namespace blink
OLDNEW

Powered by Google App Engine