Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 , m_selectionInitiationState(HaveNotStartedSelection) | 225 , m_selectionInitiationState(HaveNotStartedSelection) |
| 226 , m_hoverTimer(this, &EventHandler::hoverTimerFired) | 226 , m_hoverTimer(this, &EventHandler::hoverTimerFired) |
| 227 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) | 227 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) |
| 228 , m_mouseDownMayStartAutoscroll(false) | 228 , m_mouseDownMayStartAutoscroll(false) |
| 229 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) | 229 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) |
| 230 , m_svgPan(false) | 230 , m_svgPan(false) |
| 231 , m_resizeScrollableArea(nullptr) | 231 , m_resizeScrollableArea(nullptr) |
| 232 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 232 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 233 , m_clickCount(0) | 233 , m_clickCount(0) |
| 234 , m_shouldOnlyFireDragOverEvent(false) | 234 , m_shouldOnlyFireDragOverEvent(false) |
| 235 , m_accumulatedRootOverscroll(FloatSize()) | |
| 235 , m_mousePositionIsUnknown(true) | 236 , m_mousePositionIsUnknown(true) |
| 236 , m_mouseDownTimestamp(0) | 237 , m_mouseDownTimestamp(0) |
| 237 , m_widgetIsLatched(false) | 238 , m_widgetIsLatched(false) |
| 238 , m_touchPressed(false) | 239 , m_touchPressed(false) |
| 239 , m_scrollGestureHandlingNode(nullptr) | 240 , m_scrollGestureHandlingNode(nullptr) |
| 240 , m_lastGestureScrollOverWidget(false) | 241 , m_lastGestureScrollOverWidget(false) |
| 241 , m_maxMouseMovedDuration(0) | 242 , m_maxMouseMovedDuration(0) |
| 242 , m_longTapShouldInvokeContextMenu(false) | 243 , m_longTapShouldInvokeContextMenu(false) |
| 243 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 244 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 244 , m_lastShowPressTimestamp(0) | 245 , m_lastShowPressTimestamp(0) |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 | 917 |
| 917 return result; | 918 return result; |
| 918 } | 919 } |
| 919 | 920 |
| 920 void EventHandler::stopAutoscroll() | 921 void EventHandler::stopAutoscroll() |
| 921 { | 922 { |
| 922 if (AutoscrollController* controller = autoscrollController()) | 923 if (AutoscrollController* controller = autoscrollController()) |
| 923 controller->stopAutoscroll(); | 924 controller->stopAutoscroll(); |
| 924 } | 925 } |
| 925 | 926 |
| 926 bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari ty, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint) | 927 ScrollResultOneDimensional EventHandler::scroll(ScrollDirection direction, Scrol lGranularity granularity, Node* startNode, Node** stopNode, float delta, IntPoin t absolutePoint) |
| 927 { | 928 { |
| 928 if (!delta) | 929 if (!delta) |
| 929 return false; | 930 return ScrollResultOneDimensional(false); |
| 930 | 931 |
| 931 Node* node = startNode; | 932 Node* node = startNode; |
| 932 | 933 |
| 933 if (!node) | 934 if (!node) |
| 934 node = m_frame->document()->focusedElement(); | 935 node = m_frame->document()->focusedElement(); |
| 935 | 936 |
| 936 if (!node) | 937 if (!node) |
| 937 node = m_mousePressNode.get(); | 938 node = m_mousePressNode.get(); |
| 938 | 939 |
| 939 if (!node || !node->layoutObject()) | 940 if (!node || !node->layoutObject()) |
| 940 return false; | 941 return ScrollResultOneDimensional(false, delta); |
| 941 | 942 |
| 942 LayoutBox* curBox = node->layoutObject()->enclosingBox(); | 943 LayoutBox* curBox = node->layoutObject()->enclosingBox(); |
| 943 while (curBox && !curBox->isLayoutView()) { | 944 while (curBox && !curBox->isLayoutView()) { |
| 944 ScrollDirectionPhysical physicalDirection = toPhysicalDirection( | 945 ScrollDirectionPhysical physicalDirection = toPhysicalDirection( |
| 945 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode()); | 946 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode()); |
| 946 | 947 |
| 947 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it | 948 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it |
| 948 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode; | 949 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode; |
| 949 bool didScroll = curBox->scroll(physicalDirection, granularity, delta); | 950 ScrollResultOneDimensional result = curBox->scroll(physicalDirection, gr anularity, delta); |
| 950 | 951 |
| 951 if (didScroll && stopNode) | 952 if (result.didScroll && stopNode) |
| 952 *stopNode = curBox->node(); | 953 *stopNode = curBox->node(); |
| 953 | 954 |
| 954 if (didScroll || shouldStopBubbling) { | 955 if (result.didScroll || shouldStopBubbling) { |
| 955 setFrameWasScrolledByUser(); | 956 setFrameWasScrolledByUser(); |
| 956 return true; | 957 result.didScroll = true; |
| 958 return result; | |
| 957 } | 959 } |
| 958 | 960 |
| 959 curBox = curBox->containingBlock(); | 961 curBox = curBox->containingBlock(); |
| 960 } | 962 } |
| 961 | 963 |
| 962 return false; | 964 return ScrollResultOneDimensional(false, delta); |
| 963 } | 965 } |
| 964 | 966 |
| 965 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt ate) | 967 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt ate) |
| 966 { | 968 { |
| 967 if (scrollState.fullyConsumed()) | 969 if (scrollState.fullyConsumed()) |
| 968 return; | 970 return; |
| 969 | 971 |
| 970 if (m_currentScrollChain.isEmpty()) | 972 if (m_currentScrollChain.isEmpty()) |
| 971 recomputeScrollChain(*m_frame, startNode, m_currentScrollChain); | 973 recomputeScrollChain(*m_frame, startNode, m_currentScrollChain); |
| 972 scrollState.setScrollChain(m_currentScrollChain); | 974 scrollState.setScrollChain(m_currentScrollChain); |
| 973 scrollState.distributeToScrollChainDescendant(); | 975 scrollState.distributeToScrollChainDescendant(); |
| 974 } | 976 } |
| 975 | 977 |
| 976 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) | 978 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) |
| 977 { | 979 { |
| 978 // The layout needs to be up to date to determine if we can scroll. We may b e | 980 // The layout needs to be up to date to determine if we can scroll. We may b e |
| 979 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. | 981 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. |
| 980 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 982 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 981 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 983 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 982 if (scroll(direction, granularity, startingNode)) | 984 if (scroll(direction, granularity, startingNode).didScroll) |
| 983 return true; | 985 return true; |
| 984 LocalFrame* frame = m_frame; | 986 LocalFrame* frame = m_frame; |
| 985 FrameView* view = frame->view(); | 987 FrameView* view = frame->view(); |
| 986 if (view) { | 988 if (view) { |
| 987 ScrollDirectionPhysical physicalDirection = | 989 ScrollDirectionPhysical physicalDirection = |
| 988 toPhysicalDirection(direction, view->isVerticalDocument(), view->isF lippedDocument()); | 990 toPhysicalDirection(direction, view->isVerticalDocument(), view->isF lippedDocument()); |
| 989 if (view->scrollableArea()->userScroll(physicalDirection, granularity)) { | 991 if (view->scrollableArea()->userScroll(physicalDirection, granularity).d idScroll) { |
| 990 setFrameWasScrolledByUser(); | 992 setFrameWasScrolledByUser(); |
| 991 return true; | 993 return true; |
| 992 } | 994 } |
| 993 } | 995 } |
| 994 | 996 |
| 995 Frame* parentFrame = frame->tree().parent(); | 997 Frame* parentFrame = frame->tree().parent(); |
| 996 if (!parentFrame || !parentFrame->isLocalFrame()) | 998 if (!parentFrame || !parentFrame->isLocalFrame()) |
| 997 return false; | 999 return false; |
| 998 // FIXME: Broken for OOPI. | 1000 // FIXME: Broken for OOPI. |
| 999 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner()); | 1001 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner()); |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2170 if (node && !node->dispatchWheelEvent(event)) | 2172 if (node && !node->dispatchWheelEvent(event)) |
| 2171 RETURN_WHEEL_EVENT_HANDLED(); | 2173 RETURN_WHEEL_EVENT_HANDLED(); |
| 2172 } | 2174 } |
| 2173 | 2175 |
| 2174 // We do another check on the frame view because the event handler can run | 2176 // We do another check on the frame view because the event handler can run |
| 2175 // JS which results in the frame getting destroyed. | 2177 // JS which results in the frame getting destroyed. |
| 2176 view = m_frame->view(); | 2178 view = m_frame->view(); |
| 2177 if (!view) | 2179 if (!view) |
| 2178 return false; | 2180 return false; |
| 2179 | 2181 |
| 2180 if (view->scrollableArea()->handleWheel(event).didScroll) | 2182 if (view->scrollableArea()->handleWheel(event).didScroll()) |
| 2181 RETURN_WHEEL_EVENT_HANDLED(); | 2183 RETURN_WHEEL_EVENT_HANDLED(); |
| 2182 | 2184 |
| 2183 return false; | 2185 return false; |
| 2184 #undef RETURN_WHEEL_EVENT_HANDLED | 2186 #undef RETURN_WHEEL_EVENT_HANDLED |
| 2185 } | 2187 } |
| 2186 | 2188 |
| 2187 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) | 2189 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) |
| 2188 { | 2190 { |
| 2189 if (!startNode || !wheelEvent) | 2191 if (!startNode || !wheelEvent) |
| 2190 return; | 2192 return; |
| 2191 | 2193 |
| 2192 // When the wheelEvent do not scroll, we trigger zoom in/out instead. | 2194 // When the wheelEvent do not scroll, we trigger zoom in/out instead. |
| 2193 if (!wheelEvent->canScroll()) | 2195 if (!wheelEvent->canScroll()) |
| 2194 return; | 2196 return; |
| 2195 | 2197 |
| 2196 Node* stopNode = m_previousWheelScrolledNode.get(); | 2198 Node* stopNode = m_previousWheelScrolledNode.get(); |
| 2197 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); | 2199 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); |
| 2198 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation()); | 2200 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation()); |
| 2199 | 2201 |
| 2200 // Break up into two scrolls if we need to. Diagonal movement on | 2202 // Break up into two scrolls if we need to. Diagonal movement on |
| 2201 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set). | 2203 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set). |
| 2202 | 2204 |
| 2203 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 2205 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 2204 if (wheelEvent->railsMode() != Event::RailsModeVertical | 2206 if (wheelEvent->railsMode() != Event::RailsModeVertical |
| 2205 && scroll(ScrollRightIgnoringWritingMode, granularity, startNode, &stopN ode, wheelEvent->deltaX(), absolutePosition)) | 2207 && scroll(ScrollRightIgnoringWritingMode, granularity, startNode, &stopN ode, wheelEvent->deltaX(), absolutePosition).didScroll) |
| 2206 wheelEvent->setDefaultHandled(); | 2208 wheelEvent->setDefaultHandled(); |
| 2207 | 2209 |
| 2208 if (wheelEvent->railsMode() != Event::RailsModeHorizontal | 2210 if (wheelEvent->railsMode() != Event::RailsModeHorizontal |
| 2209 && scroll(ScrollDownIgnoringWritingMode, granularity, startNode, &stopNo de, wheelEvent->deltaY(), absolutePosition)) | 2211 && scroll(ScrollDownIgnoringWritingMode, granularity, startNode, &stopNo de, wheelEvent->deltaY(), absolutePosition).didScroll) |
| 2210 wheelEvent->setDefaultHandled(); | 2212 wheelEvent->setDefaultHandled(); |
| 2211 | 2213 |
| 2212 if (!m_latchedWheelEventNode) | 2214 if (!m_latchedWheelEventNode) |
| 2213 m_previousWheelScrolledNode = stopNode; | 2215 m_previousWheelScrolledNode = stopNode; |
| 2214 } | 2216 } |
| 2215 | 2217 |
| 2216 bool EventHandler::handleGestureShowPress() | 2218 bool EventHandler::handleGestureShowPress() |
| 2217 { | 2219 { |
| 2218 m_lastShowPressTimestamp = WTF::currentTime(); | 2220 m_lastShowPressTimestamp = WTF::currentTime(); |
| 2219 | 2221 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2600 if (node) { | 2602 if (node) { |
| 2601 passScrollGestureEventToWidget(gestureEvent, node->layoutObject()); | 2603 passScrollGestureEventToWidget(gestureEvent, node->layoutObject()); |
| 2602 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | 2604 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { |
| 2603 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( | 2605 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( |
| 2604 0, 0, 0, 0, 0, gestureEvent.inertial(), /* isBeginning */ | 2606 0, 0, 0, 0, 0, gestureEvent.inertial(), /* isBeginning */ |
| 2605 false, /* isEnding */ true, /* fromUserInput */ true); | 2607 false, /* isEnding */ true, /* fromUserInput */ true); |
| 2606 customizedScroll(*node.get(), *scrollState); | 2608 customizedScroll(*node.get(), *scrollState); |
| 2607 } | 2609 } |
| 2608 } | 2610 } |
| 2609 | 2611 |
| 2610 clearGestureScrollNodes(); | 2612 clearGestureScrollState(); |
| 2611 return false; | 2613 return false; |
| 2612 } | 2614 } |
| 2613 | 2615 |
| 2614 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent) | 2616 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent) |
| 2615 { | 2617 { |
| 2616 Document* document = m_frame->document(); | 2618 Document* document = m_frame->document(); |
| 2617 if (!document->layoutView()) | 2619 if (!document->layoutView()) |
| 2618 return false; | 2620 return false; |
| 2619 | 2621 |
| 2620 FrameView* view = m_frame->view(); | 2622 FrameView* view = m_frame->view(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2641 0, 0, 0, 0, 0, /* inInertialPhase */ false, /* isBeginning */ | 2643 0, 0, 0, 0, 0, /* inInertialPhase */ false, /* isBeginning */ |
| 2642 true, /* isEnding */ false, /* fromUserInput */ true); | 2644 true, /* isEnding */ false, /* fromUserInput */ true); |
| 2643 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); | 2645 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); |
| 2644 } else { | 2646 } else { |
| 2645 if (m_frame->isMainFrame()) | 2647 if (m_frame->isMainFrame()) |
| 2646 m_frame->host()->topControls().scrollBegin(); | 2648 m_frame->host()->topControls().scrollBegin(); |
| 2647 } | 2649 } |
| 2648 return true; | 2650 return true; |
| 2649 } | 2651 } |
| 2650 | 2652 |
| 2653 void EventHandler::resetOverscroll(bool didScrollX, bool didScrollY, FloatSize& unusedDelta) | |
|
bokan
2015/06/04 12:05:42
I don't think you need to reset unusedDelta. The f
MuVen
2015/06/04 14:01:19
Done.
| |
| 2654 { | |
| 2655 if (didScrollX) { | |
| 2656 m_accumulatedRootOverscroll.setWidth(0); | |
| 2657 unusedDelta.setWidth(0); | |
| 2658 } | |
| 2659 if (didScrollY) { | |
| 2660 m_accumulatedRootOverscroll.setHeight(0); | |
| 2661 unusedDelta.setHeight(0); | |
| 2662 } | |
| 2663 } | |
| 2664 | |
| 2651 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) | 2665 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) |
| 2652 { | 2666 { |
| 2653 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | 2667 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); |
| 2654 | 2668 |
| 2655 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); | 2669 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); |
| 2656 if (delta.isZero()) | 2670 if (delta.isZero()) |
| 2657 return false; | 2671 return false; |
| 2658 | 2672 |
| 2659 Node* node = m_scrollGestureHandlingNode.get(); | 2673 Node* node = m_scrollGestureHandlingNode.get(); |
| 2674 FloatSize unusedDelta; | |
| 2660 if (node) { | 2675 if (node) { |
| 2661 LayoutObject* layoutObject = node->layoutObject(); | 2676 LayoutObject* layoutObject = node->layoutObject(); |
| 2662 if (!layoutObject) | 2677 if (!layoutObject) |
| 2663 return false; | 2678 return false; |
| 2664 | 2679 |
| 2665 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 2680 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 2666 | 2681 |
| 2667 Node* stopNode = nullptr; | 2682 Node* stopNode = nullptr; |
| 2668 | 2683 |
| 2669 // Try to send the event to the correct view. | 2684 // Try to send the event to the correct view. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 2700 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); | 2715 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); |
| 2701 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); | 2716 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); |
| 2702 scrolled = scrollState->deltaX() != gestureEvent.deltaX() | 2717 scrolled = scrollState->deltaX() != gestureEvent.deltaX() |
| 2703 || scrollState->deltaY() != gestureEvent.deltaY(); | 2718 || scrollState->deltaY() != gestureEvent.deltaY(); |
| 2704 } else { | 2719 } else { |
| 2705 if (gestureEvent.preventPropagation()) | 2720 if (gestureEvent.preventPropagation()) |
| 2706 stopNode = m_previousGestureScrolledNode.get(); | 2721 stopNode = m_previousGestureScrolledNode.get(); |
| 2707 | 2722 |
| 2708 // First try to scroll the closest scrollable LayoutBox ancestor of |node|. | 2723 // First try to scroll the closest scrollable LayoutBox ancestor of |node|. |
| 2709 ScrollGranularity granularity = ScrollByPrecisePixel; | 2724 ScrollGranularity granularity = ScrollByPrecisePixel; |
| 2710 bool horizontalScroll = scroll(ScrollLeftIgnoringWritingMode, granul arity, node, &stopNode, delta.width()); | 2725 ScrollResultOneDimensional result = scroll(ScrollLeftIgnoringWriting Mode, granularity, node, &stopNode, delta.width()); |
| 2726 bool horizontalScroll = result.didScroll; | |
| 2711 if (!gestureEvent.preventPropagation()) | 2727 if (!gestureEvent.preventPropagation()) |
| 2712 stopNode = nullptr; | 2728 stopNode = nullptr; |
| 2713 bool verticalScroll = scroll(ScrollUpIgnoringWritingMode, granularit y, node, &stopNode, delta.height()); | 2729 result = scroll(ScrollUpIgnoringWritingMode, granularity, node, &sto pNode, delta.height()); |
| 2730 bool verticalScroll = result.didScroll; | |
| 2714 scrolled = horizontalScroll || verticalScroll; | 2731 scrolled = horizontalScroll || verticalScroll; |
| 2715 | 2732 |
| 2716 if (gestureEvent.preventPropagation()) | 2733 if (gestureEvent.preventPropagation()) |
| 2717 m_previousGestureScrolledNode = stopNode; | 2734 m_previousGestureScrolledNode = stopNode; |
| 2735 | |
| 2736 resetOverscroll(horizontalScroll, verticalScroll, unusedDelta); | |
| 2718 } | 2737 } |
| 2719 if (scrolled) { | 2738 if (scrolled) { |
| 2720 setFrameWasScrolledByUser(); | 2739 setFrameWasScrolledByUser(); |
| 2721 return true; | 2740 return true; |
| 2722 } | 2741 } |
| 2723 } | 2742 } |
| 2724 | 2743 |
| 2725 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | 2744 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
| 2726 return false; | 2745 return false; |
| 2727 | 2746 |
| 2728 // Try to scroll the frame view. | 2747 // Try to scroll the frame view. |
| 2729 if (m_frame->applyScrollDelta(delta, false)) { | 2748 ScrollResult scrollResult = m_frame->applyScrollDelta(delta, false); |
| 2749 if (m_frame->isMainFrame() && m_frame->view() && m_frame->view()->scrollable Area()) { | |
| 2750 ScrollableArea* scrollablearea = m_frame->view()->scrollableArea(); | |
| 2751 // Set unusedDelta if axes is scrollable, else set 0 to ensure overflow is not reported on non-scrollable axes. | |
| 2752 unusedDelta.setWidth(scrollablearea->scrollSize(HorizontalScrollbar) ? s crollResult.unusedScrollDeltaX : 0); | |
| 2753 unusedDelta.setHeight(scrollablearea->scrollSize(VerticalScrollbar) ? sc rollResult.unusedScrollDeltaY : 0); | |
| 2754 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY, unused Delta); | |
| 2755 if (unusedDelta != FloatSize()) { | |
| 2756 m_accumulatedRootOverscroll += unusedDelta; | |
| 2757 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestur eEvent.position().y()); | |
| 2758 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEven t.velocityY()); | |
| 2759 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRoot Overscroll, position, velocity); | |
| 2760 } | |
| 2761 } | |
| 2762 if (scrollResult.didScroll()) { | |
| 2730 setFrameWasScrolledByUser(); | 2763 setFrameWasScrolledByUser(); |
| 2731 return true; | 2764 return true; |
| 2732 } | 2765 } |
| 2733 | 2766 |
| 2734 return false; | 2767 return false; |
| 2735 } | 2768 } |
| 2736 | 2769 |
| 2737 void EventHandler::clearGestureScrollNodes() | 2770 void EventHandler::clearGestureScrollState() |
| 2738 { | 2771 { |
| 2739 m_scrollGestureHandlingNode = nullptr; | 2772 m_scrollGestureHandlingNode = nullptr; |
| 2740 m_previousGestureScrolledNode = nullptr; | 2773 m_previousGestureScrolledNode = nullptr; |
| 2741 m_deltaConsumedForScrollSequence = false; | 2774 m_deltaConsumedForScrollSequence = false; |
| 2742 m_currentScrollChain.clear(); | 2775 m_currentScrollChain.clear(); |
| 2776 m_accumulatedRootOverscroll = FloatSize(); | |
| 2743 } | 2777 } |
| 2744 | 2778 |
| 2745 bool EventHandler::isScrollbarHandlingGestures() const | 2779 bool EventHandler::isScrollbarHandlingGestures() const |
| 2746 { | 2780 { |
| 2747 return m_scrollbarHandlingScrollGesture.get(); | 2781 return m_scrollbarHandlingScrollGesture.get(); |
| 2748 } | 2782 } |
| 2749 | 2783 |
| 2750 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event) const | 2784 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event) const |
| 2751 { | 2785 { |
| 2752 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) | 2786 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3635 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) | 3669 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) |
| 3636 { | 3670 { |
| 3637 ASSERT(event->type() == EventTypeNames::keypress); | 3671 ASSERT(event->type() == EventTypeNames::keypress); |
| 3638 | 3672 |
| 3639 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 3673 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
| 3640 return; | 3674 return; |
| 3641 | 3675 |
| 3642 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; | 3676 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; |
| 3643 | 3677 |
| 3644 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 3678 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 3645 if (scroll(direction, ScrollByPage)) { | 3679 if (scroll(direction, ScrollByPage).didScroll) { |
| 3646 event->setDefaultHandled(); | 3680 event->setDefaultHandled(); |
| 3647 return; | 3681 return; |
| 3648 } | 3682 } |
| 3649 | 3683 |
| 3650 FrameView* view = m_frame->view(); | 3684 FrameView* view = m_frame->view(); |
| 3651 if (!view) | 3685 if (!view) |
| 3652 return; | 3686 return; |
| 3653 | 3687 |
| 3654 ScrollDirectionPhysical physicalDirection = | 3688 ScrollDirectionPhysical physicalDirection = |
| 3655 toPhysicalDirection(direction, view->isVerticalDocument(), view->isFlipp edDocument()); | 3689 toPhysicalDirection(direction, view->isVerticalDocument(), view->isFlipp edDocument()); |
| 3656 | 3690 |
| 3657 if (view->scrollableArea()->userScroll(physicalDirection, ScrollByPage)) | 3691 if (view->scrollableArea()->userScroll(physicalDirection, ScrollByPage).didS croll) |
| 3658 event->setDefaultHandled(); | 3692 event->setDefaultHandled(); |
| 3659 } | 3693 } |
| 3660 | 3694 |
| 3661 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) | 3695 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) |
| 3662 { | 3696 { |
| 3663 ASSERT(event->type() == EventTypeNames::keydown); | 3697 ASSERT(event->type() == EventTypeNames::keydown); |
| 3664 | 3698 |
| 3665 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 3699 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
| 3666 return; | 3700 return; |
| 3667 | 3701 |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4170 unsigned EventHandler::accessKeyModifiers() | 4204 unsigned EventHandler::accessKeyModifiers() |
| 4171 { | 4205 { |
| 4172 #if OS(MACOSX) | 4206 #if OS(MACOSX) |
| 4173 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4207 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4174 #else | 4208 #else |
| 4175 return PlatformEvent::AltKey; | 4209 return PlatformEvent::AltKey; |
| 4176 #endif | 4210 #endif |
| 4177 } | 4211 } |
| 4178 | 4212 |
| 4179 } // namespace blink | 4213 } // namespace blink |
| OLD | NEW |