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

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

Issue 2289213002: Implement Middle Click Autoscroll on all platforms not just Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' of https://chromium.googlesource.com/chromium/src into panscroll Created 4 years, 3 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 reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (!parent) 374 if (!parent)
375 return WebInputEventResult::NotHandled; 375 return WebInputEventResult::NotHandled;
376 376
377 layoutObject = parent->layoutObject(); 377 layoutObject = parent->layoutObject();
378 if (!layoutObject || !layoutObject->isListBox()) 378 if (!layoutObject || !layoutObject->isListBox())
379 return WebInputEventResult::NotHandled; 379 return WebInputEventResult::NotHandled;
380 } 380 }
381 381
382 m_mouseDownMayStartDrag = false; 382 m_mouseDownMayStartDrag = false;
383 383
384 if (m_mouseDownMayStartAutoscroll && !m_scrollManager->panScrollInProgress() ) { 384 if (m_mouseDownMayStartAutoscroll && !m_scrollManager->middleClickAutoscroll InProgress()) {
385 if (AutoscrollController* controller = m_scrollManager->autoscrollContro ller()) { 385 if (AutoscrollController* controller = m_scrollManager->autoscrollContro ller()) {
386 controller->startAutoscrollForSelection(layoutObject); 386 controller->startAutoscrollForSelection(layoutObject);
387 m_mouseDownMayStartAutoscroll = false; 387 m_mouseDownMayStartAutoscroll = false;
388 } 388 }
389 } 389 }
390 390
391 selectionController().handleMouseDraggedEvent(event, m_mouseDownPos, m_dragS tartPos, m_mousePressNode.get(), m_lastKnownMousePosition); 391 selectionController().handleMouseDraggedEvent(event, m_mouseDownPos, m_dragS tartPos, m_mousePressNode.get(), m_lastKnownMousePosition);
392 return WebInputEventResult::HandledSystem; 392 return WebInputEventResult::HandledSystem;
393 } 393 }
394 394
395 void EventHandler::updateSelectionForMouseDrag() 395 void EventHandler::updateSelectionForMouseDrag()
396 { 396 {
397 selectionController().updateSelectionForMouseDrag(m_mousePressNode.get(), m_ dragStartPos, m_lastKnownMousePosition); 397 selectionController().updateSelectionForMouseDrag(m_mousePressNode.get(), m_ dragStartPos, m_lastKnownMousePosition);
398 } 398 }
399 399
400 // TODO(nzolghadr): Refactor the mouse related functions to MouseEventManager. 400 // TODO(nzolghadr): Refactor the mouse related functions to MouseEventManager.
401 WebInputEventResult EventHandler::handleMouseReleaseEvent(const MouseEventWithHi tTestResults& event) 401 WebInputEventResult EventHandler::handleMouseReleaseEvent(const MouseEventWithHi tTestResults& event)
402 { 402 {
403 AutoscrollController* controller = m_scrollManager->autoscrollController(); 403 AutoscrollController* controller = m_scrollManager->autoscrollController();
404 if (controller && controller->autoscrollInProgress()) 404 if (controller && controller->autoscrollInProgress())
405 m_scrollManager->stopAutoscroll(); 405 m_scrollManager->stopAutoscroll();
406 406
407 return selectionController().handleMouseReleaseEvent(event, m_dragStartPos) ? WebInputEventResult::HandledSystem : WebInputEventResult::NotHandled; 407 return selectionController().handleMouseReleaseEvent(event, m_dragStartPos) ? WebInputEventResult::HandledSystem : WebInputEventResult::NotHandled;
408 } 408 }
409 409
410 #if OS(WIN) 410 void EventHandler::startMiddleClickAutoscroll(LayoutObject* layoutObject)
411
412 void EventHandler::startPanScrolling(LayoutObject* layoutObject)
413 { 411 {
412 DCHECK(RuntimeEnabledFeatures::middleClickAutoscrollEnabled());
414 if (!layoutObject->isBox()) 413 if (!layoutObject->isBox())
415 return; 414 return;
416 AutoscrollController* controller = m_scrollManager->autoscrollController(); 415 AutoscrollController* controller = m_scrollManager->autoscrollController();
417 if (!controller) 416 if (!controller)
418 return; 417 return;
419 controller->startPanScrolling(toLayoutBox(layoutObject), lastKnownMousePosit ion()); 418 controller->startMiddleClickAutoscroll(toLayoutBox(layoutObject), lastKnownM ousePosition());
420 invalidateClick(); 419 invalidateClick();
421 } 420 }
422 421
423 #endif // OS(WIN)
424
425 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding) 422 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding)
426 { 423 {
427 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); 424 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint");
428 425
429 ASSERT((hitType & HitTestRequest::ListBased) || padding.isEmpty()); 426 ASSERT((hitType & HitTestRequest::ListBased) || padding.isEmpty());
430 427
431 // We always send hitTestResultAtPoint to the main frame if we have one, 428 // We always send hitTestResultAtPoint to the main frame if we have one,
432 // otherwise we might hit areas that are obscured by higher frames. 429 // otherwise we might hit areas that are obscured by higher frames.
433 if (m_frame->page()) { 430 if (m_frame->page()) {
434 LocalFrame* mainFrame = m_frame->localFrameRoot(); 431 LocalFrame* mainFrame = m_frame->localFrameRoot();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 562 }
566 563
567 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) 564 OptionalCursor EventHandler::selectCursor(const HitTestResult& result)
568 { 565 {
569 if (m_scrollManager->inResizeMode()) 566 if (m_scrollManager->inResizeMode())
570 return NoCursorChange; 567 return NoCursorChange;
571 568
572 Page* page = m_frame->page(); 569 Page* page = m_frame->page();
573 if (!page) 570 if (!page)
574 return NoCursorChange; 571 return NoCursorChange;
575 if (m_scrollManager->panScrollInProgress()) 572 if (m_scrollManager->middleClickAutoscrollInProgress())
576 return NoCursorChange; 573 return NoCursorChange;
577 574
578 Node* node = result.innerPossiblyPseudoNode(); 575 Node* node = result.innerPossiblyPseudoNode();
579 if (!node) 576 if (!node)
580 return selectAutoCursor(result, node, iBeamCursor()); 577 return selectAutoCursor(result, node, iBeamCursor());
581 578
582 LayoutObject* layoutObject = node->layoutObject(); 579 LayoutObject* layoutObject = node->layoutObject();
583 const ComputedStyle* style = layoutObject ? layoutObject->style() : nullptr; 580 const ComputedStyle* style = layoutObject ? layoutObject->style() : nullptr;
584 581
585 if (layoutObject) { 582 if (layoutObject) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 // has been handled. See crbug.com/269917 792 // has been handled. See crbug.com/269917
796 m_capturesDragging = subframe->eventHandler().capturesDragging(); 793 m_capturesDragging = subframe->eventHandler().capturesDragging();
797 if (m_mousePressed && m_capturesDragging) { 794 if (m_mousePressed && m_capturesDragging) {
798 m_capturingMouseEventsNode = mev.innerNode(); 795 m_capturingMouseEventsNode = mev.innerNode();
799 m_eventHandlerWillResetCapturingMouseEventsNode = true; 796 m_eventHandlerWillResetCapturingMouseEventsNode = true;
800 } 797 }
801 invalidateClick(); 798 invalidateClick();
802 return result; 799 return result;
803 } 800 }
804 801
805 #if OS(WIN) 802 if (RuntimeEnabledFeatures::middleClickAutoscrollEnabled()) {
806 // We store whether pan scrolling is in progress before calling stopAutoscro ll() 803 // We store whether middle click autoscroll is in progress before callin g stopAutoscroll()
807 // because it will set m_autoscrollType to NoAutoscroll on return. 804 // because it will set m_autoscrollType to NoAutoscroll on return.
808 bool isPanScrollInProgress = m_scrollManager->panScrollInProgress(); 805 bool isMiddleClickAutoscrollInProgress = m_scrollManager->middleClickAut oscrollInProgress();
809 m_scrollManager->stopAutoscroll(); 806 m_scrollManager->stopAutoscroll();
810 if (isPanScrollInProgress) { 807 if (isMiddleClickAutoscrollInProgress) {
811 // We invalidate the click when exiting pan scrolling so that we don't i nadvertently navigate 808 // We invalidate the click when exiting middle click auto scroll so that we don't inadvertently navigate
812 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>. 809 // away from the current page (e.g. the click was on a hyperlink). S ee <rdar://problem/6095023>.
813 invalidateClick(); 810 invalidateClick();
814 return WebInputEventResult::HandledSuppressed; 811 return WebInputEventResult::HandledSuppressed;
812 }
815 } 813 }
816 #endif
817 814
818 m_clickCount = mouseEvent.clickCount(); 815 m_clickCount = mouseEvent.clickCount();
819 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me v.innerNode()) : mev.innerNode(); 816 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me v.innerNode()) : mev.innerNode();
820 817
821 if (!mouseEvent.fromTouch()) 818 if (!mouseEvent.fromTouch())
822 m_frame->selection().setCaretBlinkingSuspended(true); 819 m_frame->selection().setCaretBlinkingSuspended(true);
823 820
824 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event()); 821 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event());
825 822
826 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) { 823 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 if (!mouseEvent.fromTouch()) 1074 if (!mouseEvent.fromTouch())
1078 m_frame->selection().setCaretBlinkingSuspended(false); 1075 m_frame->selection().setCaretBlinkingSuspended(false);
1079 1076
1080 std::unique_ptr<UserGestureIndicator> gestureIndicator; 1077 std::unique_ptr<UserGestureIndicator> gestureIndicator;
1081 1078
1082 if (m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToke n) 1079 if (m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToke n)
1083 gestureIndicator = wrapUnique(new UserGestureIndicator(m_frame->localFra meRoot()->eventHandler().m_lastMouseDownUserGestureToken.release())); 1080 gestureIndicator = wrapUnique(new UserGestureIndicator(m_frame->localFra meRoot()->eventHandler().m_lastMouseDownUserGestureToken.release()));
1084 else 1081 else
1085 gestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProcess ingUserGesture)); 1082 gestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProcess ingUserGesture));
1086 1083
1087 #if OS(WIN) 1084 if (RuntimeEnabledFeatures::middleClickAutoscrollEnabled()) {
1088 if (Page* page = m_frame->page()) 1085 if (Page* page = m_frame->page())
1089 page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame, mouseEvent); 1086 page->autoscrollController().handleMouseReleaseForMiddleClickAutoscr oll(m_frame, mouseEvent);
1090 #endif 1087 }
1091 1088
1092 m_mousePressed = false; 1089 m_mousePressed = false;
1093 setLastKnownMousePosition(mouseEvent); 1090 setLastKnownMousePosition(mouseEvent);
1094 1091
1095 if (m_svgPan) { 1092 if (m_svgPan) {
1096 m_svgPan = false; 1093 m_svgPan = false;
1097 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition)); 1094 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition));
1098 return WebInputEventResult::HandledSuppressed; 1095 return WebInputEventResult::HandledSuppressed;
1099 } 1096 }
1100 1097
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 2558
2562 FrameHost* EventHandler::frameHost() const 2559 FrameHost* EventHandler::frameHost() const
2563 { 2560 {
2564 if (!m_frame->page()) 2561 if (!m_frame->page())
2565 return nullptr; 2562 return nullptr;
2566 2563
2567 return &m_frame->page()->frameHost(); 2564 return &m_frame->page()->frameHost();
2568 } 2565 }
2569 2566
2570 } // namespace blink 2567 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | third_party/WebKit/Source/core/input/KeyboardEventManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698