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

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 1056983004: OverscrollGlow for mainThread-{BLINK CHANGES} (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tests !!! Created 5 years, 7 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 , m_selectionInitiationState(HaveNotStartedSelection) 226 , m_selectionInitiationState(HaveNotStartedSelection)
227 , m_hoverTimer(this, &EventHandler::hoverTimerFired) 227 , m_hoverTimer(this, &EventHandler::hoverTimerFired)
228 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) 228 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired)
229 , m_mouseDownMayStartAutoscroll(false) 229 , m_mouseDownMayStartAutoscroll(false)
230 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) 230 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d)
231 , m_svgPan(false) 231 , m_svgPan(false)
232 , m_resizeScrollableArea(nullptr) 232 , m_resizeScrollableArea(nullptr)
233 , m_eventHandlerWillResetCapturingMouseEventsNode(0) 233 , m_eventHandlerWillResetCapturingMouseEventsNode(0)
234 , m_clickCount(0) 234 , m_clickCount(0)
235 , m_shouldOnlyFireDragOverEvent(false) 235 , m_shouldOnlyFireDragOverEvent(false)
236 , m_unusedDelta(FloatSize())
237 , m_accumulatedRootOverscroll(FloatSize())
236 , m_mousePositionIsUnknown(true) 238 , m_mousePositionIsUnknown(true)
237 , m_mouseDownTimestamp(0) 239 , m_mouseDownTimestamp(0)
238 , m_widgetIsLatched(false) 240 , m_widgetIsLatched(false)
239 , m_touchPressed(false) 241 , m_touchPressed(false)
240 , m_scrollGestureHandlingNode(nullptr) 242 , m_scrollGestureHandlingNode(nullptr)
241 , m_lastGestureScrollOverWidget(false) 243 , m_lastGestureScrollOverWidget(false)
242 , m_maxMouseMovedDuration(0) 244 , m_maxMouseMovedDuration(0)
243 , m_longTapShouldInvokeContextMenu(false) 245 , m_longTapShouldInvokeContextMenu(false)
244 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) 246 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
245 , m_lastShowPressTimestamp(0) 247 , m_lastShowPressTimestamp(0)
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 921
920 return result; 922 return result;
921 } 923 }
922 924
923 void EventHandler::stopAutoscroll() 925 void EventHandler::stopAutoscroll()
924 { 926 {
925 if (AutoscrollController* controller = autoscrollController()) 927 if (AutoscrollController* controller = autoscrollController())
926 controller->stopAutoscroll(); 928 controller->stopAutoscroll();
927 } 929 }
928 930
929 bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari ty, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint) 931 ScrollResultOneDimensional EventHandler::scroll(ScrollDirection direction, Scrol lGranularity granularity, Node* startNode, Node** stopNode, float delta, IntPoin t absolutePoint)
930 { 932 {
931 if (!delta) 933 if (!delta)
932 return false; 934 return ScrollResultOneDimensional(false);
933 935
934 Node* node = startNode; 936 Node* node = startNode;
935 937
936 if (!node) 938 if (!node)
937 node = m_frame->document()->focusedElement(); 939 node = m_frame->document()->focusedElement();
938 940
939 if (!node) 941 if (!node)
940 node = m_mousePressNode.get(); 942 node = m_mousePressNode.get();
941 943
942 if (!node || !node->layoutObject()) 944 if (!node || !node->layoutObject())
943 return false; 945 return ScrollResultOneDimensional(false, delta);
944 946
945 bool rootLayerScrolls = m_frame->settings() && m_frame->settings()->rootLaye rScrolls(); 947 bool rootLayerScrolls = m_frame->settings() && m_frame->settings()->rootLaye rScrolls();
946 LayoutBox* curBox = node->layoutObject()->enclosingBox(); 948 LayoutBox* curBox = node->layoutObject()->enclosingBox();
949 ScrollResultOneDimensional result(false, delta);
947 while (curBox && (rootLayerScrolls || !curBox->isLayoutView())) { 950 while (curBox && (rootLayerScrolls || !curBox->isLayoutView())) {
948 ScrollDirection physicalDirection = toPhysicalDirection( 951 ScrollDirection physicalDirection = toPhysicalDirection(
949 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode()); 952 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode());
950 953
951 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it 954 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it
952 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode; 955 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode;
953 bool didScroll = curBox->scroll(physicalDirection, granularity, delta); 956 result = curBox->scroll(physicalDirection, granularity, delta);
954 957
955 if (didScroll && stopNode) 958 if (result.didScroll && stopNode)
956 *stopNode = curBox->node(); 959 *stopNode = curBox->node();
957 960
958 if (didScroll || shouldStopBubbling) { 961 if (result.didScroll || shouldStopBubbling) {
959 setFrameWasScrolledByUser(); 962 setFrameWasScrolledByUser();
960 return true; 963 return result;
majidvp 2015/05/07 16:35:30 This no longer guarantee that we return 'true' her
MuVen 2015/05/13 16:55:46 Done.
961 } 964 }
962 965
963 curBox = curBox->containingBlock(); 966 curBox = curBox->containingBlock();
964 } 967 }
965 968
966 return false; 969 return result;
967 } 970 }
968 971
969 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt ate) 972 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt ate)
970 { 973 {
971 if (scrollState.fullyConsumed()) 974 if (scrollState.fullyConsumed())
972 return; 975 return;
973 976
974 if (m_currentScrollChain.isEmpty()) 977 if (m_currentScrollChain.isEmpty())
975 recomputeScrollChain(*m_frame, startNode, m_currentScrollChain); 978 recomputeScrollChain(*m_frame, startNode, m_currentScrollChain);
976 scrollState.setScrollChain(m_currentScrollChain); 979 scrollState.setScrollChain(m_currentScrollChain);
977 scrollState.distributeToScrollChainDescendant(); 980 scrollState.distributeToScrollChainDescendant();
978 } 981 }
979 982
980 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) 983 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode)
981 { 984 {
982 // The layout needs to be up to date to determine if we can scroll. We may b e 985 // The layout needs to be up to date to determine if we can scroll. We may b e
983 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. 986 // here because of an onLoad event, in which case the final layout hasn't be en performed yet.
984 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 987 m_frame->document()->updateLayoutIgnorePendingStylesheets();
985 // FIXME: enable scroll customization in this case. See crbug.com/410974. 988 // FIXME: enable scroll customization in this case. See crbug.com/410974.
986 if (scroll(direction, granularity, startingNode)) 989 if (scroll(direction, granularity, startingNode).didScroll)
987 return true; 990 return true;
988 LocalFrame* frame = m_frame; 991 LocalFrame* frame = m_frame;
989 FrameView* view = frame->view(); 992 FrameView* view = frame->view();
990 if (view && view->scroll(direction, granularity)) 993 if (view && view->scroll(direction, granularity))
991 return true; 994 return true;
992 Frame* parentFrame = frame->tree().parent(); 995 Frame* parentFrame = frame->tree().parent();
993 if (!parentFrame || !parentFrame->isLocalFrame()) 996 if (!parentFrame || !parentFrame->isLocalFrame())
994 return false; 997 return false;
995 // FIXME: Broken for OOPI. 998 // FIXME: Broken for OOPI.
996 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner()); 999 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner());
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 2200
2198 Node* stopNode = m_previousWheelScrolledNode.get(); 2201 Node* stopNode = m_previousWheelScrolledNode.get();
2199 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); 2202 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt);
2200 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation()); 2203 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation());
2201 2204
2202 // Break up into two scrolls if we need to. Diagonal movement on 2205 // Break up into two scrolls if we need to. Diagonal movement on
2203 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set). 2206 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set).
2204 2207
2205 // FIXME: enable scroll customization in this case. See crbug.com/410974. 2208 // FIXME: enable scroll customization in this case. See crbug.com/410974.
2206 if (wheelEvent->railsMode() != Event::RailsModeVertical 2209 if (wheelEvent->railsMode() != Event::RailsModeVertical
2207 && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->de ltaX(), absolutePosition)) 2210 && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->de ltaX(), absolutePosition).didScroll)
2208 wheelEvent->setDefaultHandled(); 2211 wheelEvent->setDefaultHandled();
2209 2212
2210 if (wheelEvent->railsMode() != Event::RailsModeHorizontal 2213 if (wheelEvent->railsMode() != Event::RailsModeHorizontal
2211 && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->del taY(), absolutePosition)) 2214 && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->del taY(), absolutePosition).didScroll)
2212 wheelEvent->setDefaultHandled(); 2215 wheelEvent->setDefaultHandled();
2213 2216
2214 if (!m_latchedWheelEventNode) 2217 if (!m_latchedWheelEventNode)
2215 m_previousWheelScrolledNode = stopNode; 2218 m_previousWheelScrolledNode = stopNode;
2216 } 2219 }
2217 2220
2218 bool EventHandler::handleGestureShowPress() 2221 bool EventHandler::handleGestureShowPress()
2219 { 2222 {
2220 m_lastShowPressTimestamp = WTF::currentTime(); 2223 m_lastShowPressTimestamp = WTF::currentTime();
2221 2224
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); 2705 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement();
2703 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); 2706 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence();
2704 scrolled = scrollState->deltaX() != gestureEvent.deltaX() 2707 scrolled = scrollState->deltaX() != gestureEvent.deltaX()
2705 || scrollState->deltaY() != gestureEvent.deltaY(); 2708 || scrollState->deltaY() != gestureEvent.deltaY();
2706 } else { 2709 } else {
2707 if (gestureEvent.preventPropagation()) 2710 if (gestureEvent.preventPropagation())
2708 stopNode = m_previousGestureScrolledNode.get(); 2711 stopNode = m_previousGestureScrolledNode.get();
2709 2712
2710 // First try to scroll the closest scrollable LayoutBox ancestor of |node|. 2713 // First try to scroll the closest scrollable LayoutBox ancestor of |node|.
2711 ScrollGranularity granularity = ScrollByPrecisePixel; 2714 ScrollGranularity granularity = ScrollByPrecisePixel;
2712 bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopN ode, delta.width()); 2715 m_unusedDelta = FloatSize();
2716 ScrollResultOneDimensional result = scroll(ScrollLeft, granularity, node, &stopNode, delta.width());
2717 bool horizontalScroll = result.didScroll;
2718 if (m_frame->isMainFrame())
2719 m_unusedDelta.setWidth(result.unusedScrollDelta);
majidvp 2015/05/07 16:35:29 Compositor overscroll logic only collects overscro
MuVen 2015/05/13 16:55:46 Done.
2713 if (!gestureEvent.preventPropagation()) 2720 if (!gestureEvent.preventPropagation())
2714 stopNode = nullptr; 2721 stopNode = nullptr;
2715 bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode, delta.height()); 2722 result = scroll(ScrollUp, granularity, node, &stopNode, delta.height ());
2723 bool verticalScroll = result.didScroll;
2724 if (m_frame->isMainFrame())
2725 m_unusedDelta.setHeight(result.unusedScrollDelta);
2716 scrolled = horizontalScroll || verticalScroll; 2726 scrolled = horizontalScroll || verticalScroll;
2717 2727
2718 if (gestureEvent.preventPropagation()) 2728 if (gestureEvent.preventPropagation())
2719 m_previousGestureScrolledNode = stopNode; 2729 m_previousGestureScrolledNode = stopNode;
2730
2731 if (m_frame->isMainFrame())
majidvp 2015/05/07 16:35:30 mainframe check here is redundant. For non mainfra
MuVen 2015/05/13 16:55:46 Done.
2732 m_accumulatedRootOverscroll += m_unusedDelta;
2733
2734 if (m_frame->isMainFrame() && m_unusedDelta != FloatSize()) {
majidvp 2015/05/07 16:35:30 Again mainframe check is redundant.
MuVen 2015/05/13 16:55:46 Done.
2735 FloatPoint position = FloatPoint(gestureEvent.position().x(), ge stureEvent.position().y());
2736 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gesture Event.velocityY());
2737 m_frame->chromeClient().didOverscroll(m_unusedDelta, m_accumulat edRootOverscroll, position, velocity);
2738 }
2720 } 2739 }
2721 if (scrolled) { 2740 if (scrolled) {
2722 setFrameWasScrolledByUser(); 2741 setFrameWasScrolledByUser();
2723 return true; 2742 return true;
2724 } 2743 }
2725 } 2744 }
2726 2745
2727 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) 2746 if (RuntimeEnabledFeatures::scrollCustomizationEnabled())
2728 return false; 2747 return false;
2729 2748
2730 // Try to scroll the frame view. 2749 // Try to scroll the frame view.
2731 if (m_frame->applyScrollDelta(delta, false)) { 2750 if (m_frame->applyScrollDelta(delta, false)) {
2732 setFrameWasScrolledByUser(); 2751 setFrameWasScrolledByUser();
2733 return true; 2752 return true;
2734 } 2753 }
2735 2754
2736 return false; 2755 return false;
2737 } 2756 }
2738 2757
2739 void EventHandler::clearGestureScrollNodes() 2758 void EventHandler::clearGestureScrollNodes()
2740 { 2759 {
2741 m_scrollGestureHandlingNode = nullptr; 2760 m_scrollGestureHandlingNode = nullptr;
2742 m_previousGestureScrolledNode = nullptr; 2761 m_previousGestureScrolledNode = nullptr;
2743 m_deltaConsumedForScrollSequence = false; 2762 m_deltaConsumedForScrollSequence = false;
2744 m_currentScrollChain.clear(); 2763 m_currentScrollChain.clear();
2764 m_accumulatedRootOverscroll = FloatSize();
majidvp 2015/05/07 16:35:30 This clears accumulated root overscroll only at th
MuVen 2015/05/13 16:55:46 Done.
2745 } 2765 }
2746 2766
2747 bool EventHandler::isScrollbarHandlingGestures() const 2767 bool EventHandler::isScrollbarHandlingGestures() const
2748 { 2768 {
2749 return m_scrollbarHandlingScrollGesture.get(); 2769 return m_scrollbarHandlingScrollGesture.get();
2750 } 2770 }
2751 2771
2752 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event) const 2772 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event) const
2753 { 2773 {
2754 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) 2774 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled())
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
3618 3638
3619 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) 3639 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event)
3620 { 3640 {
3621 ASSERT(event->type() == EventTypeNames::keypress); 3641 ASSERT(event->type() == EventTypeNames::keypress);
3622 3642
3623 if (event->ctrlKey() || event->metaKey() || event->altKey()) 3643 if (event->ctrlKey() || event->metaKey() || event->altKey())
3624 return; 3644 return;
3625 3645
3626 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; 3646 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward;
3627 // FIXME: enable scroll customization in this case. See crbug.com/410974. 3647 // FIXME: enable scroll customization in this case. See crbug.com/410974.
3628 if (scroll(direction, ScrollByPage)) { 3648 if (scroll(direction, ScrollByPage).didScroll) {
3629 event->setDefaultHandled(); 3649 event->setDefaultHandled();
3630 return; 3650 return;
3631 } 3651 }
3632 3652
3633 FrameView* view = m_frame->view(); 3653 FrameView* view = m_frame->view();
3634 if (!view) 3654 if (!view)
3635 return; 3655 return;
3636 3656
3637 if (view->scroll(direction, ScrollByPage)) 3657 if (view->scroll(direction, ScrollByPage))
3638 event->setDefaultHandled(); 3658 event->setDefaultHandled();
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
4136 unsigned EventHandler::accessKeyModifiers() 4156 unsigned EventHandler::accessKeyModifiers()
4137 { 4157 {
4138 #if OS(MACOSX) 4158 #if OS(MACOSX)
4139 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4159 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4140 #else 4160 #else
4141 return PlatformEvent::AltKey; 4161 return PlatformEvent::AltKey;
4142 #endif 4162 #endif
4143 } 4163 }
4144 4164
4145 } // namespace blink 4165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698