| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 919 |
| 918 return result; | 920 return result; |
| 919 } | 921 } |
| 920 | 922 |
| 921 void EventHandler::stopAutoscroll() | 923 void EventHandler::stopAutoscroll() |
| 922 { | 924 { |
| 923 if (AutoscrollController* controller = autoscrollController()) | 925 if (AutoscrollController* controller = autoscrollController()) |
| 924 controller->stopAutoscroll(); | 926 controller->stopAutoscroll(); |
| 925 } | 927 } |
| 926 | 928 |
| 927 bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari
ty, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint) | 929 ScrollResultOneDimensional EventHandler::scroll(ScrollDirection direction, Scrol
lGranularity granularity, Node* startNode, Node** stopNode, float delta, IntPoin
t absolutePoint) |
| 928 { | 930 { |
| 929 if (!delta) | 931 if (!delta) |
| 930 return false; | 932 return ScrollResultOneDimensional(false); |
| 931 | 933 |
| 932 Node* node = startNode; | 934 Node* node = startNode; |
| 933 | 935 |
| 934 if (!node) | 936 if (!node) |
| 935 node = m_frame->document()->focusedElement(); | 937 node = m_frame->document()->focusedElement(); |
| 936 | 938 |
| 937 if (!node) | 939 if (!node) |
| 938 node = m_mousePressNode.get(); | 940 node = m_mousePressNode.get(); |
| 939 | 941 |
| 940 if (!node || !node->layoutObject()) | 942 if (!node || !node->layoutObject()) |
| 941 return false; | 943 return ScrollResultOneDimensional(false, delta); |
| 942 | 944 |
| 943 LayoutBox* curBox = node->layoutObject()->enclosingBox(); | 945 LayoutBox* curBox = node->layoutObject()->enclosingBox(); |
| 944 while (curBox && !curBox->isLayoutView()) { | 946 while (curBox && !curBox->isLayoutView()) { |
| 945 ScrollDirection physicalDirection = toPhysicalDirection( | 947 ScrollDirection physicalDirection = toPhysicalDirection( |
| 946 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli
ppedBlocksWritingMode()); | 948 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli
ppedBlocksWritingMode()); |
| 947 | 949 |
| 948 // If we're at the stopNode, we should try to scroll it but we shouldn't
bubble past it | 950 // If we're at the stopNode, we should try to scroll it but we shouldn't
bubble past it |
| 949 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st
opNode; | 951 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st
opNode; |
| 950 bool didScroll = curBox->scroll(physicalDirection, granularity, delta); | 952 ScrollResultOneDimensional result = curBox->scroll(physicalDirection, gr
anularity, delta); |
| 951 | 953 |
| 952 if (didScroll && stopNode) | 954 if (result.didScroll && stopNode) |
| 953 *stopNode = curBox->node(); | 955 *stopNode = curBox->node(); |
| 954 | 956 |
| 955 if (didScroll || shouldStopBubbling) { | 957 if (result.didScroll || shouldStopBubbling) { |
| 956 setFrameWasScrolledByUser(); | 958 setFrameWasScrolledByUser(); |
| 957 return true; | 959 result.didScroll = true; |
| 960 return result; |
| 958 } | 961 } |
| 959 | 962 |
| 960 curBox = curBox->containingBlock(); | 963 curBox = curBox->containingBlock(); |
| 961 } | 964 } |
| 962 | 965 |
| 963 return false; | 966 return ScrollResultOneDimensional(false, delta); |
| 964 } | 967 } |
| 965 | 968 |
| 966 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt
ate) | 969 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt
ate) |
| 967 { | 970 { |
| 968 if (scrollState.fullyConsumed()) | 971 if (scrollState.fullyConsumed()) |
| 969 return; | 972 return; |
| 970 | 973 |
| 971 if (m_currentScrollChain.isEmpty()) | 974 if (m_currentScrollChain.isEmpty()) |
| 972 recomputeScrollChain(*m_frame, startNode, m_currentScrollChain); | 975 recomputeScrollChain(*m_frame, startNode, m_currentScrollChain); |
| 973 scrollState.setScrollChain(m_currentScrollChain); | 976 scrollState.setScrollChain(m_currentScrollChain); |
| 974 scrollState.distributeToScrollChainDescendant(); | 977 scrollState.distributeToScrollChainDescendant(); |
| 975 } | 978 } |
| 976 | 979 |
| 977 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g
ranularity, Node* startingNode) | 980 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g
ranularity, Node* startingNode) |
| 978 { | 981 { |
| 979 // The layout needs to be up to date to determine if we can scroll. We may b
e | 982 // The layout needs to be up to date to determine if we can scroll. We may b
e |
| 980 // here because of an onLoad event, in which case the final layout hasn't be
en performed yet. | 983 // here because of an onLoad event, in which case the final layout hasn't be
en performed yet. |
| 981 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 984 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 982 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 985 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 983 if (scroll(direction, granularity, startingNode)) | 986 if (scroll(direction, granularity, startingNode).didScroll) |
| 984 return true; | 987 return true; |
| 985 LocalFrame* frame = m_frame; | 988 LocalFrame* frame = m_frame; |
| 986 FrameView* view = frame->view(); | 989 FrameView* view = frame->view(); |
| 987 if (view && view->scroll(direction, granularity)) { | 990 if (view && view->scroll(direction, granularity).didScroll) { |
| 988 setFrameWasScrolledByUser(); | 991 setFrameWasScrolledByUser(); |
| 989 return true; | 992 return true; |
| 990 } | 993 } |
| 991 Frame* parentFrame = frame->tree().parent(); | 994 Frame* parentFrame = frame->tree().parent(); |
| 992 if (!parentFrame || !parentFrame->isLocalFrame()) | 995 if (!parentFrame || !parentFrame->isLocalFrame()) |
| 993 return false; | 996 return false; |
| 994 // FIXME: Broken for OOPI. | 997 // FIXME: Broken for OOPI. |
| 995 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g
ranularity, m_frame->deprecatedLocalOwner()); | 998 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g
ranularity, m_frame->deprecatedLocalOwner()); |
| 996 } | 999 } |
| 997 | 1000 |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2193 | 2196 |
| 2194 Node* stopNode = m_previousWheelScrolledNode.get(); | 2197 Node* stopNode = m_previousWheelScrolledNode.get(); |
| 2195 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve
nt); | 2198 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve
nt); |
| 2196 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation()); | 2199 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation()); |
| 2197 | 2200 |
| 2198 // Break up into two scrolls if we need to. Diagonal movement on | 2201 // Break up into two scrolls if we need to. Diagonal movement on |
| 2199 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b
oth deltaX and deltaY can be set). | 2202 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b
oth deltaX and deltaY can be set). |
| 2200 | 2203 |
| 2201 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 2204 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 2202 if (wheelEvent->railsMode() != Event::RailsModeVertical | 2205 if (wheelEvent->railsMode() != Event::RailsModeVertical |
| 2203 && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->de
ltaX(), absolutePosition)) | 2206 && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->de
ltaX(), absolutePosition).didScroll) |
| 2204 wheelEvent->setDefaultHandled(); | 2207 wheelEvent->setDefaultHandled(); |
| 2205 | 2208 |
| 2206 if (wheelEvent->railsMode() != Event::RailsModeHorizontal | 2209 if (wheelEvent->railsMode() != Event::RailsModeHorizontal |
| 2207 && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->del
taY(), absolutePosition)) | 2210 && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->del
taY(), absolutePosition).didScroll) |
| 2208 wheelEvent->setDefaultHandled(); | 2211 wheelEvent->setDefaultHandled(); |
| 2209 | 2212 |
| 2210 if (!m_latchedWheelEventNode) | 2213 if (!m_latchedWheelEventNode) |
| 2211 m_previousWheelScrolledNode = stopNode; | 2214 m_previousWheelScrolledNode = stopNode; |
| 2212 } | 2215 } |
| 2213 | 2216 |
| 2214 bool EventHandler::handleGestureShowPress() | 2217 bool EventHandler::handleGestureShowPress() |
| 2215 { | 2218 { |
| 2216 m_lastShowPressTimestamp = WTF::currentTime(); | 2219 m_lastShowPressTimestamp = WTF::currentTime(); |
| 2217 | 2220 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2698 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE
lement(); | 2701 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE
lement(); |
| 2699 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro
llSequence(); | 2702 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro
llSequence(); |
| 2700 scrolled = scrollState->deltaX() != gestureEvent.deltaX() | 2703 scrolled = scrollState->deltaX() != gestureEvent.deltaX() |
| 2701 || scrollState->deltaY() != gestureEvent.deltaY(); | 2704 || scrollState->deltaY() != gestureEvent.deltaY(); |
| 2702 } else { | 2705 } else { |
| 2703 if (gestureEvent.preventPropagation()) | 2706 if (gestureEvent.preventPropagation()) |
| 2704 stopNode = m_previousGestureScrolledNode.get(); | 2707 stopNode = m_previousGestureScrolledNode.get(); |
| 2705 | 2708 |
| 2706 // First try to scroll the closest scrollable LayoutBox ancestor of
|node|. | 2709 // First try to scroll the closest scrollable LayoutBox ancestor of
|node|. |
| 2707 ScrollGranularity granularity = ScrollByPrecisePixel; | 2710 ScrollGranularity granularity = ScrollByPrecisePixel; |
| 2708 bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopN
ode, delta.width()); | 2711 m_unusedDelta = FloatSize(); |
| 2712 ScrollResultOneDimensional result = scroll(ScrollLeft, granularity,
node, &stopNode, delta.width()); |
| 2713 bool horizontalScroll = result.didScroll; |
| 2709 if (!gestureEvent.preventPropagation()) | 2714 if (!gestureEvent.preventPropagation()) |
| 2710 stopNode = nullptr; | 2715 stopNode = nullptr; |
| 2711 bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode,
delta.height()); | 2716 result = scroll(ScrollUp, granularity, node, &stopNode, delta.height
()); |
| 2717 bool verticalScroll = result.didScroll; |
| 2712 scrolled = horizontalScroll || verticalScroll; | 2718 scrolled = horizontalScroll || verticalScroll; |
| 2713 | 2719 |
| 2714 if (gestureEvent.preventPropagation()) | 2720 if (gestureEvent.preventPropagation()) |
| 2715 m_previousGestureScrolledNode = stopNode; | 2721 m_previousGestureScrolledNode = stopNode; |
| 2722 |
| 2723 if (horizontalScroll) { |
| 2724 m_accumulatedRootOverscroll.setWidth(0); |
| 2725 m_unusedDelta.setWidth(0); |
| 2726 } |
| 2727 |
| 2728 if (verticalScroll) { |
| 2729 m_accumulatedRootOverscroll.setHeight(0); |
| 2730 m_unusedDelta.setHeight(0); |
| 2731 } |
| 2716 } | 2732 } |
| 2717 if (scrolled) { | 2733 if (scrolled) { |
| 2718 setFrameWasScrolledByUser(); | 2734 setFrameWasScrolledByUser(); |
| 2719 return true; | 2735 return true; |
| 2720 } | 2736 } |
| 2721 } | 2737 } |
| 2722 | 2738 |
| 2723 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | 2739 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
| 2724 return false; | 2740 return false; |
| 2725 | 2741 |
| 2726 // Try to scroll the frame view. | 2742 // Try to scroll the frame view. |
| 2727 if (m_frame->applyScrollDelta(delta, false)) { | 2743 ScrollResult resultScrollDelta = m_frame->applyScrollDelta(delta, false); |
| 2744 m_unusedDelta.setWidth(resultScrollDelta.unusedScrollDeltaX); |
| 2745 m_unusedDelta.setHeight(resultScrollDelta.unusedScrollDeltaY); |
| 2746 if (m_frame->isMainFrame() && m_unusedDelta != FloatSize()) { |
| 2747 m_accumulatedRootOverscroll += m_unusedDelta; |
| 2748 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEve
nt.position().y()); |
| 2749 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEvent.ve
locityY()); |
| 2750 m_frame->chromeClient().didOverscroll(m_unusedDelta, m_accumulatedRootOv
erscroll, position, velocity); |
| 2751 } |
| 2752 |
| 2753 if (resultScrollDelta.didScroll) { |
| 2728 setFrameWasScrolledByUser(); | 2754 setFrameWasScrolledByUser(); |
| 2729 return true; | 2755 return true; |
| 2730 } | 2756 } |
| 2731 | 2757 |
| 2732 return false; | 2758 return false; |
| 2733 } | 2759 } |
| 2734 | 2760 |
| 2735 void EventHandler::clearGestureScrollNodes() | 2761 void EventHandler::clearGestureScrollNodes() |
| 2736 { | 2762 { |
| 2737 m_scrollGestureHandlingNode = nullptr; | 2763 m_scrollGestureHandlingNode = nullptr; |
| 2738 m_previousGestureScrolledNode = nullptr; | 2764 m_previousGestureScrolledNode = nullptr; |
| 2739 m_deltaConsumedForScrollSequence = false; | 2765 m_deltaConsumedForScrollSequence = false; |
| 2740 m_currentScrollChain.clear(); | 2766 m_currentScrollChain.clear(); |
| 2767 m_accumulatedRootOverscroll = FloatSize(); |
| 2768 m_unusedDelta = FloatSize(); |
| 2741 } | 2769 } |
| 2742 | 2770 |
| 2743 bool EventHandler::isScrollbarHandlingGestures() const | 2771 bool EventHandler::isScrollbarHandlingGestures() const |
| 2744 { | 2772 { |
| 2745 return m_scrollbarHandlingScrollGesture.get(); | 2773 return m_scrollbarHandlingScrollGesture.get(); |
| 2746 } | 2774 } |
| 2747 | 2775 |
| 2748 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const | 2776 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const |
| 2749 { | 2777 { |
| 2750 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) | 2778 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3632 | 3660 |
| 3633 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) | 3661 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) |
| 3634 { | 3662 { |
| 3635 ASSERT(event->type() == EventTypeNames::keypress); | 3663 ASSERT(event->type() == EventTypeNames::keypress); |
| 3636 | 3664 |
| 3637 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 3665 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
| 3638 return; | 3666 return; |
| 3639 | 3667 |
| 3640 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward
: ScrollBlockDirectionForward; | 3668 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward
: ScrollBlockDirectionForward; |
| 3641 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 3669 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 3642 if (scroll(direction, ScrollByPage)) { | 3670 if (scroll(direction, ScrollByPage).didScroll) { |
| 3643 event->setDefaultHandled(); | 3671 event->setDefaultHandled(); |
| 3644 return; | 3672 return; |
| 3645 } | 3673 } |
| 3646 | 3674 |
| 3647 FrameView* view = m_frame->view(); | 3675 FrameView* view = m_frame->view(); |
| 3648 if (!view) | 3676 if (!view) |
| 3649 return; | 3677 return; |
| 3650 | 3678 |
| 3651 if (view->scroll(direction, ScrollByPage)) | 3679 if (view->scroll(direction, ScrollByPage).didScroll) |
| 3652 event->setDefaultHandled(); | 3680 event->setDefaultHandled(); |
| 3653 } | 3681 } |
| 3654 | 3682 |
| 3655 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) | 3683 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) |
| 3656 { | 3684 { |
| 3657 ASSERT(event->type() == EventTypeNames::keydown); | 3685 ASSERT(event->type() == EventTypeNames::keydown); |
| 3658 | 3686 |
| 3659 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 3687 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
| 3660 return; | 3688 return; |
| 3661 | 3689 |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4164 unsigned EventHandler::accessKeyModifiers() | 4192 unsigned EventHandler::accessKeyModifiers() |
| 4165 { | 4193 { |
| 4166 #if OS(MACOSX) | 4194 #if OS(MACOSX) |
| 4167 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4195 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4168 #else | 4196 #else |
| 4169 return PlatformEvent::AltKey; | 4197 return PlatformEvent::AltKey; |
| 4170 #endif | 4198 #endif |
| 4171 } | 4199 } |
| 4172 | 4200 |
| 4173 } // namespace blink | 4201 } // namespace blink |
| OLD | NEW |