| 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(FloatPoint()) |
| 237 , m_accumulatedRootOverScroll(FloatPoint()) |
| 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 Loading... |
| 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); |
| 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); |
| 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; |
| 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()); |
| 997 } | 1000 } |
| 998 | 1001 |
| 1002 FloatPoint EventHandler::unusedDelta() const |
| 1003 { |
| 1004 return m_unusedDelta; |
| 1005 } |
| 1006 |
| 1007 FloatPoint EventHandler::accumulatedRootOverScroll() const |
| 1008 { |
| 1009 return m_accumulatedRootOverScroll; |
| 1010 } |
| 1011 |
| 999 IntPoint EventHandler::lastKnownMousePosition() const | 1012 IntPoint EventHandler::lastKnownMousePosition() const |
| 1000 { | 1013 { |
| 1001 return m_lastKnownMousePosition; | 1014 return m_lastKnownMousePosition; |
| 1002 } | 1015 } |
| 1003 | 1016 |
| 1004 static LocalFrame* subframeForTargetNode(Node* node) | 1017 static LocalFrame* subframeForTargetNode(Node* node) |
| 1005 { | 1018 { |
| 1006 if (!node) | 1019 if (!node) |
| 1007 return nullptr; | 1020 return nullptr; |
| 1008 | 1021 |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2197 | 2210 |
| 2198 Node* stopNode = m_previousWheelScrolledNode.get(); | 2211 Node* stopNode = m_previousWheelScrolledNode.get(); |
| 2199 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve
nt); | 2212 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve
nt); |
| 2200 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation()); | 2213 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation()); |
| 2201 | 2214 |
| 2202 // Break up into two scrolls if we need to. Diagonal movement on | 2215 // 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). | 2216 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b
oth deltaX and deltaY can be set). |
| 2204 | 2217 |
| 2205 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 2218 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 2206 if (wheelEvent->railsMode() != Event::RailsModeVertical | 2219 if (wheelEvent->railsMode() != Event::RailsModeVertical |
| 2207 && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->de
ltaX(), absolutePosition)) | 2220 && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->de
ltaX(), absolutePosition).didScroll) |
| 2208 wheelEvent->setDefaultHandled(); | 2221 wheelEvent->setDefaultHandled(); |
| 2209 | 2222 |
| 2210 if (wheelEvent->railsMode() != Event::RailsModeHorizontal | 2223 if (wheelEvent->railsMode() != Event::RailsModeHorizontal |
| 2211 && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->del
taY(), absolutePosition)) | 2224 && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->del
taY(), absolutePosition).didScroll) |
| 2212 wheelEvent->setDefaultHandled(); | 2225 wheelEvent->setDefaultHandled(); |
| 2213 | 2226 |
| 2214 if (!m_latchedWheelEventNode) | 2227 if (!m_latchedWheelEventNode) |
| 2215 m_previousWheelScrolledNode = stopNode; | 2228 m_previousWheelScrolledNode = stopNode; |
| 2216 } | 2229 } |
| 2217 | 2230 |
| 2218 bool EventHandler::handleGestureShowPress() | 2231 bool EventHandler::handleGestureShowPress() |
| 2219 { | 2232 { |
| 2220 m_lastShowPressTimestamp = WTF::currentTime(); | 2233 m_lastShowPressTimestamp = WTF::currentTime(); |
| 2221 | 2234 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2702 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE
lement(); | 2715 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE
lement(); |
| 2703 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro
llSequence(); | 2716 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro
llSequence(); |
| 2704 scrolled = scrollState->deltaX() != gestureEvent.deltaX() | 2717 scrolled = scrollState->deltaX() != gestureEvent.deltaX() |
| 2705 || scrollState->deltaY() != gestureEvent.deltaY(); | 2718 || scrollState->deltaY() != gestureEvent.deltaY(); |
| 2706 } else { | 2719 } else { |
| 2707 if (gestureEvent.preventPropagation()) | 2720 if (gestureEvent.preventPropagation()) |
| 2708 stopNode = m_previousGestureScrolledNode.get(); | 2721 stopNode = m_previousGestureScrolledNode.get(); |
| 2709 | 2722 |
| 2710 // First try to scroll the closest scrollable LayoutBox ancestor of
|node|. | 2723 // First try to scroll the closest scrollable LayoutBox ancestor of
|node|. |
| 2711 ScrollGranularity granularity = ScrollByPrecisePixel; | 2724 ScrollGranularity granularity = ScrollByPrecisePixel; |
| 2712 bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopN
ode, delta.width()); | 2725 m_unusedDelta = FloatPoint(); |
| 2726 ScrollResultOneDimensional result = scroll(ScrollLeft, granularity,
node, &stopNode, delta.width()); |
| 2727 bool horizontalScroll = result.didScroll; |
| 2728 if (m_frame->isMainFrame()) |
| 2729 m_unusedDelta.setX(result.unusedScrollDelta); |
| 2713 if (!gestureEvent.preventPropagation()) | 2730 if (!gestureEvent.preventPropagation()) |
| 2714 stopNode = nullptr; | 2731 stopNode = nullptr; |
| 2715 bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode,
delta.height()); | 2732 result = scroll(ScrollUp, granularity, node, &stopNode, delta.height
()); |
| 2733 bool verticalScroll = result.didScroll; |
| 2734 if (m_frame->isMainFrame()) |
| 2735 m_unusedDelta.setY(result.unusedScrollDelta); |
| 2716 scrolled = horizontalScroll || verticalScroll; | 2736 scrolled = horizontalScroll || verticalScroll; |
| 2717 | 2737 |
| 2718 if (gestureEvent.preventPropagation()) | 2738 if (gestureEvent.preventPropagation()) |
| 2719 m_previousGestureScrolledNode = stopNode; | 2739 m_previousGestureScrolledNode = stopNode; |
| 2740 |
| 2741 if (m_frame->isMainFrame()) |
| 2742 m_accumulatedRootOverScroll += m_unusedDelta; |
| 2720 } | 2743 } |
| 2721 if (scrolled) { | 2744 if (scrolled) { |
| 2722 setFrameWasScrolledByUser(); | 2745 setFrameWasScrolledByUser(); |
| 2723 return true; | 2746 return true; |
| 2724 } | 2747 } |
| 2725 } | 2748 } |
| 2726 | 2749 |
| 2727 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | 2750 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
| 2728 return false; | 2751 return false; |
| 2729 | 2752 |
| 2730 // Try to scroll the frame view. | 2753 // Try to scroll the frame view. |
| 2731 if (m_frame->applyScrollDelta(delta, false)) { | 2754 if (m_frame->applyScrollDelta(delta, false)) { |
| 2732 setFrameWasScrolledByUser(); | 2755 setFrameWasScrolledByUser(); |
| 2733 return true; | 2756 return true; |
| 2734 } | 2757 } |
| 2735 | 2758 |
| 2736 return false; | 2759 return false; |
| 2737 } | 2760 } |
| 2738 | 2761 |
| 2739 void EventHandler::clearGestureScrollNodes() | 2762 void EventHandler::clearGestureScrollNodes() |
| 2740 { | 2763 { |
| 2741 m_scrollGestureHandlingNode = nullptr; | 2764 m_scrollGestureHandlingNode = nullptr; |
| 2742 m_previousGestureScrolledNode = nullptr; | 2765 m_previousGestureScrolledNode = nullptr; |
| 2743 m_deltaConsumedForScrollSequence = false; | 2766 m_deltaConsumedForScrollSequence = false; |
| 2744 m_currentScrollChain.clear(); | 2767 m_currentScrollChain.clear(); |
| 2768 m_accumulatedRootOverScroll = FloatPoint(); |
| 2745 } | 2769 } |
| 2746 | 2770 |
| 2747 bool EventHandler::isScrollbarHandlingGestures() const | 2771 bool EventHandler::isScrollbarHandlingGestures() const |
| 2748 { | 2772 { |
| 2749 return m_scrollbarHandlingScrollGesture.get(); | 2773 return m_scrollbarHandlingScrollGesture.get(); |
| 2750 } | 2774 } |
| 2751 | 2775 |
| 2752 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const | 2776 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const |
| 2753 { | 2777 { |
| 2754 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) | 2778 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3618 | 3642 |
| 3619 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) | 3643 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) |
| 3620 { | 3644 { |
| 3621 ASSERT(event->type() == EventTypeNames::keypress); | 3645 ASSERT(event->type() == EventTypeNames::keypress); |
| 3622 | 3646 |
| 3623 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 3647 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
| 3624 return; | 3648 return; |
| 3625 | 3649 |
| 3626 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward
: ScrollBlockDirectionForward; | 3650 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward
: ScrollBlockDirectionForward; |
| 3627 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 3651 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 3628 if (scroll(direction, ScrollByPage)) { | 3652 if (scroll(direction, ScrollByPage).didScroll) { |
| 3629 event->setDefaultHandled(); | 3653 event->setDefaultHandled(); |
| 3630 return; | 3654 return; |
| 3631 } | 3655 } |
| 3632 | 3656 |
| 3633 FrameView* view = m_frame->view(); | 3657 FrameView* view = m_frame->view(); |
| 3634 if (!view) | 3658 if (!view) |
| 3635 return; | 3659 return; |
| 3636 | 3660 |
| 3637 if (view->scroll(direction, ScrollByPage)) | 3661 if (view->scroll(direction, ScrollByPage)) |
| 3638 event->setDefaultHandled(); | 3662 event->setDefaultHandled(); |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4136 unsigned EventHandler::accessKeyModifiers() | 4160 unsigned EventHandler::accessKeyModifiers() |
| 4137 { | 4161 { |
| 4138 #if OS(MACOSX) | 4162 #if OS(MACOSX) |
| 4139 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4163 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4140 #else | 4164 #else |
| 4141 return PlatformEvent::AltKey; | 4165 return PlatformEvent::AltKey; |
| 4142 #endif | 4166 #endif |
| 4143 } | 4167 } |
| 4144 | 4168 |
| 4145 } // namespace blink | 4169 } // namespace blink |
| OLD | NEW |