Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

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

Issue 2918053002: Move middle-click autoscroll to synthetic fling. (Closed)
Patch Set: Clean up Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 246 }
247 247
248 void EventHandler::StartMiddleClickAutoscroll(LayoutObject* layout_object) { 248 void EventHandler::StartMiddleClickAutoscroll(LayoutObject* layout_object) {
249 DCHECK(RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()); 249 DCHECK(RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled());
250 if (!layout_object->IsBox()) 250 if (!layout_object->IsBox())
251 return; 251 return;
252 AutoscrollController* controller = scroll_manager_->GetAutoscrollController(); 252 AutoscrollController* controller = scroll_manager_->GetAutoscrollController();
253 if (!controller) 253 if (!controller)
254 return; 254 return;
255 controller->StartMiddleClickAutoscroll( 255 controller->StartMiddleClickAutoscroll(
256 ToLayoutBox(layout_object), 256 layout_object->GetFrame(), mouse_event_manager_->LastKnownMousePosition(),
257 mouse_event_manager_->LastKnownMousePosition()); 257 mouse_event_manager_->LastKnownMousePositionGlobal());
258 mouse_event_manager_->InvalidateClick(); 258 mouse_event_manager_->InvalidateClick();
259 } 259 }
260 260
261 HitTestResult EventHandler::HitTestResultAtPoint( 261 HitTestResult EventHandler::HitTestResultAtPoint(
262 const LayoutPoint& point, 262 const LayoutPoint& point,
263 HitTestRequest::HitTestRequestType hit_type, 263 HitTestRequest::HitTestRequestType hit_type,
264 const LayoutSize& padding) { 264 const LayoutSize& padding) {
265 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); 265 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint");
266 266
267 DCHECK((hit_type & HitTestRequest::kListBased) || padding.IsEmpty()); 267 DCHECK((hit_type & HitTestRequest::kListBased) || padding.IsEmpty());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 302
303 frame_->ContentLayoutItem().HitTest(result); 303 frame_->ContentLayoutItem().HitTest(result);
304 if (!request.ReadOnly()) 304 if (!request.ReadOnly())
305 frame_->GetDocument()->UpdateHoverActiveState(request, 305 frame_->GetDocument()->UpdateHoverActiveState(request,
306 result.InnerElement()); 306 result.InnerElement());
307 307
308 return result; 308 return result;
309 } 309 }
310 310
311 void EventHandler::StopAutoscroll() { 311 void EventHandler::StopAutoscroll() {
312 scroll_manager_->StopMiddleClickAutoscroll();
312 scroll_manager_->StopAutoscroll(); 313 scroll_manager_->StopAutoscroll();
313 } 314 }
314 315
315 // TODO(bokan): This should be merged with logicalScroll assuming 316 // TODO(bokan): This should be merged with logicalScroll assuming
316 // defaultSpaceEventHandler's chaining scroll can be done crossing frames. 317 // defaultSpaceEventHandler's chaining scroll can be done crossing frames.
317 bool EventHandler::BubblingScroll(ScrollDirection direction, 318 bool EventHandler::BubblingScroll(ScrollDirection direction,
318 ScrollGranularity granularity, 319 ScrollGranularity granularity,
319 Node* starting_node) { 320 Node* starting_node) {
320 return scroll_manager_->BubblingScroll( 321 return scroll_manager_->BubblingScroll(
321 direction, granularity, starting_node, 322 direction, granularity, starting_node,
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 .GetEventHandler() 644 .GetEventHandler()
644 .last_mouse_down_user_gesture_token_ = 645 .last_mouse_down_user_gesture_token_ =
645 UserGestureIndicator::CurrentToken(); 646 UserGestureIndicator::CurrentToken();
646 647
647 if (RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()) { 648 if (RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()) {
648 // We store whether middle click autoscroll is in progress before calling 649 // We store whether middle click autoscroll is in progress before calling
649 // stopAutoscroll() because it will set m_autoscrollType to NoAutoscroll on 650 // stopAutoscroll() because it will set m_autoscrollType to NoAutoscroll on
650 // return. 651 // return.
651 bool is_middle_click_autoscroll_in_progress = 652 bool is_middle_click_autoscroll_in_progress =
652 scroll_manager_->MiddleClickAutoscrollInProgress(); 653 scroll_manager_->MiddleClickAutoscrollInProgress();
653 scroll_manager_->StopAutoscroll(); 654 scroll_manager_->StopMiddleClickAutoscroll();
654 if (is_middle_click_autoscroll_in_progress) { 655 if (is_middle_click_autoscroll_in_progress) {
655 // We invalidate the click when exiting middle click auto scroll so that 656 // We invalidate the click when exiting middle click auto scroll so that
656 // we don't inadvertently navigate away from the current page (e.g. the 657 // we don't inadvertently navigate away from the current page (e.g. the
657 // click was on a hyperlink). See <rdar://problem/6095023>. 658 // click was on a hyperlink). See <rdar://problem/6095023>.
658 mouse_event_manager_->InvalidateClick(); 659 mouse_event_manager_->InvalidateClick();
659 return WebInputEventResult::kHandledSuppressed; 660 return WebInputEventResult::kHandledSuppressed;
660 } 661 }
661 } 662 }
662 663
663 mouse_event_manager_->SetClickCount(mouse_event.click_count); 664 mouse_event_manager_->SetClickCount(mouse_event.click_count);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 DCHECK(frame_->View()); 799 DCHECK(frame_->View());
799 800
800 mouse_event_manager_->SetLastKnownMousePosition(mouse_event); 801 mouse_event_manager_->SetLastKnownMousePosition(mouse_event);
801 802
802 hover_timer_.Stop(); 803 hover_timer_.Stop();
803 cursor_update_timer_.Stop(); 804 cursor_update_timer_.Stop();
804 805
805 mouse_event_manager_->CancelFakeMouseMoveEvent(); 806 mouse_event_manager_->CancelFakeMouseMoveEvent();
806 mouse_event_manager_->HandleSvgPanIfNeeded(false); 807 mouse_event_manager_->HandleSvgPanIfNeeded(false);
807 808
809 if (RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()) {
810 if (Page* page = frame_->GetPage()) {
811 if (mouse_event.GetType() == WebInputEvent::kMouseLeave &&
812 mouse_event.button != WebPointerProperties::Button::kMiddle) {
bokan 2017/06/15 17:40:12 Does this mean that if the cursor leaves the windo
aelias_OOO_until_Jul13 2017/06/15 22:19:54 Yes, that's the preexisting behavior.
813 page->GetAutoscrollController().StopMiddleClickAutoscroll(frame_);
814 } else {
815 page->GetAutoscrollController().HandleMouseMoveForMiddleClickAutoscroll(
816 frame_, mouse_event_manager_->LastKnownMousePositionGlobal(),
817 mouse_event.button == WebPointerProperties::Button::kMiddle);
818 }
819 }
820 }
821
808 if (frame_set_being_resized_) { 822 if (frame_set_being_resized_) {
809 return UpdatePointerTargetAndDispatchEvents( 823 return UpdatePointerTargetAndDispatchEvents(
810 EventTypeNames::mousemove, frame_set_being_resized_.Get(), String(), 824 EventTypeNames::mousemove, frame_set_being_resized_.Get(), String(),
811 mouse_event, coalesced_events); 825 mouse_event, coalesced_events);
812 } 826 }
813 827
814 // Send events right to a scrollbar if the mouse is pressed. 828 // Send events right to a scrollbar if the mouse is pressed.
815 if (last_scrollbar_under_mouse_ && mouse_event_manager_->MousePressed()) { 829 if (last_scrollbar_under_mouse_ && mouse_event_manager_->MousePressed()) {
816 last_scrollbar_under_mouse_->MouseMoved(mouse_event); 830 last_scrollbar_under_mouse_->MouseMoved(mouse_event);
817 return WebInputEventResult::kHandledSystem; 831 return WebInputEventResult::kHandledSystem;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 // For 4th/5th button in the mouse since Chrome does not yet send 943 // For 4th/5th button in the mouse since Chrome does not yet send
930 // button value to Blink but in some cases it does send the event. 944 // button value to Blink but in some cases it does send the event.
931 // This check is needed to suppress such an event (crbug.com/574959) 945 // This check is needed to suppress such an event (crbug.com/574959)
932 if (mouse_event.button == WebPointerProperties::Button::kNoButton) 946 if (mouse_event.button == WebPointerProperties::Button::kNoButton)
933 return WebInputEventResult::kHandledSuppressed; 947 return WebInputEventResult::kHandledSuppressed;
934 948
935 if (!mouse_event.FromTouch()) 949 if (!mouse_event.FromTouch())
936 frame_->Selection().SetCaretBlinkingSuspended(false); 950 frame_->Selection().SetCaretBlinkingSuspended(false);
937 951
938 if (RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()) { 952 if (RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()) {
939 if (Page* page = frame_->GetPage()) 953 if (Page* page = frame_->GetPage()) {
940 page->GetAutoscrollController() 954 page->GetAutoscrollController()
941 .HandleMouseReleaseForMiddleClickAutoscroll(frame_, mouse_event); 955 .HandleMouseReleaseForMiddleClickAutoscroll(
956 frame_,
957 mouse_event.button == WebPointerProperties::Button::kMiddle);
958 }
942 } 959 }
943 960
944 mouse_event_manager_->SetMousePressed(false); 961 mouse_event_manager_->SetMousePressed(false);
945 mouse_event_manager_->SetLastKnownMousePosition(mouse_event); 962 mouse_event_manager_->SetLastKnownMousePosition(mouse_event);
946 mouse_event_manager_->HandleSvgPanIfNeeded(true); 963 mouse_event_manager_->HandleSvgPanIfNeeded(true);
947 964
948 if (frame_set_being_resized_) { 965 if (frame_set_being_resized_) {
949 return mouse_event_manager_->SetMousePositionAndDispatchMouseEvent( 966 return mouse_event_manager_->SetMousePositionAndDispatchMouseEvent(
950 UpdateMouseEventTargetNode(frame_set_being_resized_.Get()), String(), 967 UpdateMouseEventTargetNode(frame_set_being_resized_.Get()), String(),
951 EventTypeNames::mouseup, mouse_event); 968 EventTypeNames::mouseup, mouse_event);
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 MouseEventWithHitTestResults& mev, 2165 MouseEventWithHitTestResults& mev,
2149 LocalFrame* subframe) { 2166 LocalFrame* subframe) {
2150 WebInputEventResult result = 2167 WebInputEventResult result =
2151 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); 2168 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event());
2152 if (result != WebInputEventResult::kNotHandled) 2169 if (result != WebInputEventResult::kNotHandled)
2153 return result; 2170 return result;
2154 return WebInputEventResult::kHandledSystem; 2171 return WebInputEventResult::kHandledSystem;
2155 } 2172 }
2156 2173
2157 } // namespace blink 2174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698