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

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

Issue 850443002: Scroll Customization Prototype (Not for review, WIP) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase / cleanup / minor bug fixes Created 5 years, 9 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
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/core/page/scrolling/ScrollState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "core/page/Chrome.h" 73 #include "core/page/Chrome.h"
74 #include "core/page/ChromeClient.h" 74 #include "core/page/ChromeClient.h"
75 #include "core/page/DragController.h" 75 #include "core/page/DragController.h"
76 #include "core/page/DragState.h" 76 #include "core/page/DragState.h"
77 #include "core/page/EditorClient.h" 77 #include "core/page/EditorClient.h"
78 #include "core/page/FocusController.h" 78 #include "core/page/FocusController.h"
79 #include "core/page/FrameTree.h" 79 #include "core/page/FrameTree.h"
80 #include "core/page/Page.h" 80 #include "core/page/Page.h"
81 #include "core/page/SpatialNavigation.h" 81 #include "core/page/SpatialNavigation.h"
82 #include "core/page/TouchAdjustment.h" 82 #include "core/page/TouchAdjustment.h"
83 #include "core/page/scrolling/ScrollState.h"
83 #include "core/svg/SVGDocumentExtensions.h" 84 #include "core/svg/SVGDocumentExtensions.h"
84 #include "platform/PlatformGestureEvent.h" 85 #include "platform/PlatformGestureEvent.h"
85 #include "platform/PlatformKeyboardEvent.h" 86 #include "platform/PlatformKeyboardEvent.h"
86 #include "platform/PlatformTouchEvent.h" 87 #include "platform/PlatformTouchEvent.h"
87 #include "platform/PlatformWheelEvent.h" 88 #include "platform/PlatformWheelEvent.h"
88 #include "platform/RuntimeEnabledFeatures.h" 89 #include "platform/RuntimeEnabledFeatures.h"
89 #include "platform/TraceEvent.h" 90 #include "platform/TraceEvent.h"
90 #include "platform/WindowsKeyboardCodes.h" 91 #include "platform/WindowsKeyboardCodes.h"
91 #include "platform/geometry/FloatPoint.h" 92 #include "platform/geometry/FloatPoint.h"
92 #include "platform/graphics/Image.h" 93 #include "platform/graphics/Image.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid get and thus the 189 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid get and thus the
189 // event target node can't still be the shadow node. 190 // event target node can't still be the shadow node.
190 static inline bool shouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) 191 static inline bool shouldRefetchEventTarget(const MouseEventWithHitTestResults& mev)
191 { 192 {
192 Node* targetNode = mev.innerNode(); 193 Node* targetNode = mev.innerNode();
193 if (!targetNode || !targetNode->parentNode()) 194 if (!targetNode || !targetNode->parentNode())
194 return true; 195 return true;
195 return targetNode->isShadowRoot() && isHTMLInputElement(*toShadowRoot(target Node)->host()); 196 return targetNode->isShadowRoot() && isHTMLInputElement(*toShadowRoot(target Node)->host());
196 } 197 }
197 198
199 void recomputeScrollChain(LocalFrame* const frame, Node* scrollGestureHandlingNo de, WillBeHeapVector<RefPtrWillBeMember<Element>>& scrollChain)
200 {
201 ASSERT(frame);
202 ASSERT(scrollGestureHandlingNode);
203 scrollChain.clear();
204 bool rootLayerScrolls = frame->settings() && frame->settings()->rootLayerScr olls();
205 LayoutBox* curBox = scrollGestureHandlingNode->renderer()->enclosingBox();
206
207 bool includesDocument = false;
208 while (curBox && (rootLayerScrolls || !curBox->isLayoutView())) {
209 Node* curNode = curBox->node();
210 curBox = curBox->containingBlock();
211
212 includesDocument = includesDocument || curNode == frame->document()->doc umentElement();
213
214 // FIXME: this should reject more elements.
215 if (!curNode || !curNode->isElementNode())
216 continue;
217 ASSERT(curNode->isElementNode());
218 scrollChain.prepend(toElement(curNode));
219 }
220
221 if (!includesDocument)
222 scrollChain.prepend(frame->document()->documentElement());
223 }
224
198 EventHandler::EventHandler(LocalFrame* frame) 225 EventHandler::EventHandler(LocalFrame* frame)
199 : m_frame(frame) 226 : m_frame(frame)
200 , m_mousePressed(false) 227 , m_mousePressed(false)
201 , m_capturesDragging(false) 228 , m_capturesDragging(false)
202 , m_mouseDownMayStartSelect(false) 229 , m_mouseDownMayStartSelect(false)
203 , m_mouseDownMayStartDrag(false) 230 , m_mouseDownMayStartDrag(false)
204 , m_mouseDownWasSingleClickInSelection(false) 231 , m_mouseDownWasSingleClickInSelection(false)
205 , m_selectionInitiationState(HaveNotStartedSelection) 232 , m_selectionInitiationState(HaveNotStartedSelection)
206 , m_hoverTimer(this, &EventHandler::hoverTimerFired) 233 , m_hoverTimer(this, &EventHandler::hoverTimerFired)
207 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) 234 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired)
208 , m_mouseDownMayStartAutoscroll(false) 235 , m_mouseDownMayStartAutoscroll(false)
209 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) 236 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d)
210 , m_svgPan(false) 237 , m_svgPan(false)
211 , m_resizeScrollableArea(nullptr) 238 , m_resizeScrollableArea(nullptr)
212 , m_eventHandlerWillResetCapturingMouseEventsNode(0) 239 , m_eventHandlerWillResetCapturingMouseEventsNode(0)
213 , m_clickCount(0) 240 , m_clickCount(0)
214 , m_shouldOnlyFireDragOverEvent(false) 241 , m_shouldOnlyFireDragOverEvent(false)
215 , m_mousePositionIsUnknown(true) 242 , m_mousePositionIsUnknown(true)
216 , m_mouseDownTimestamp(0) 243 , m_mouseDownTimestamp(0)
217 , m_widgetIsLatched(false) 244 , m_widgetIsLatched(false)
218 , m_touchPressed(false) 245 , m_touchPressed(false)
219 , m_scrollGestureHandlingNode(nullptr) 246 , m_scrollGestureHandlingNode(nullptr)
220 , m_lastGestureScrollOverWidget(false) 247 , m_lastGestureScrollOverWidget(false)
221 , m_maxMouseMovedDuration(0) 248 , m_maxMouseMovedDuration(0)
222 , m_longTapShouldInvokeContextMenu(false) 249 , m_longTapShouldInvokeContextMenu(false)
223 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) 250 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
224 , m_lastShowPressTimestamp(0) 251 , m_lastShowPressTimestamp(0)
252 , m_scrollLockedToElement(false)
225 { 253 {
226 } 254 }
227 255
228 EventHandler::~EventHandler() 256 EventHandler::~EventHandler()
229 { 257 {
230 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); 258 ASSERT(!m_fakeMouseMoveEventTimer.isActive());
231 } 259 }
232 260
233 DEFINE_TRACE(EventHandler) 261 DEFINE_TRACE(EventHandler)
234 { 262 {
235 #if ENABLE(OILPAN) 263 #if ENABLE(OILPAN)
236 visitor->trace(m_mousePressNode); 264 visitor->trace(m_mousePressNode);
237 visitor->trace(m_capturingMouseEventsNode); 265 visitor->trace(m_capturingMouseEventsNode);
238 visitor->trace(m_nodeUnderMouse); 266 visitor->trace(m_nodeUnderMouse);
239 visitor->trace(m_lastNodeUnderMouse); 267 visitor->trace(m_lastNodeUnderMouse);
240 visitor->trace(m_lastMouseMoveEventSubframe); 268 visitor->trace(m_lastMouseMoveEventSubframe);
241 visitor->trace(m_lastScrollbarUnderMouse); 269 visitor->trace(m_lastScrollbarUnderMouse);
242 visitor->trace(m_clickNode); 270 visitor->trace(m_clickNode);
243 visitor->trace(m_dragTarget); 271 visitor->trace(m_dragTarget);
244 visitor->trace(m_frameSetBeingResized); 272 visitor->trace(m_frameSetBeingResized);
245 visitor->trace(m_latchedWheelEventNode); 273 visitor->trace(m_latchedWheelEventNode);
246 visitor->trace(m_previousWheelScrolledNode); 274 visitor->trace(m_previousWheelScrolledNode);
247 visitor->trace(m_scrollbarHandlingScrollGesture); 275 visitor->trace(m_scrollbarHandlingScrollGesture);
248 visitor->trace(m_targetForTouchID); 276 visitor->trace(m_targetForTouchID);
249 visitor->trace(m_touchSequenceDocument); 277 visitor->trace(m_touchSequenceDocument);
250 visitor->trace(m_scrollGestureHandlingNode); 278 visitor->trace(m_scrollGestureHandlingNode);
251 visitor->trace(m_previousGestureScrolledNode); 279 visitor->trace(m_previousGestureScrolledNode);
252 visitor->trace(m_lastDeferredTapElement); 280 visitor->trace(m_lastDeferredTapElement);
281 visitor->trace(m_currentNativeScrollingElement);
282 visitor->trace(m_currentScrollChain);
253 #endif 283 #endif
254 } 284 }
255 285
256 DragState& EventHandler::dragState() 286 DragState& EventHandler::dragState()
257 { 287 {
258 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<DragState>, state, (adoptPtrWillB eNoop(new DragState()))); 288 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<DragState>, state, (adoptPtrWillB eNoop(new DragState())));
259 return *state; 289 return *state;
260 } 290 }
261 291
262 void EventHandler::clear() 292 void EventHandler::clear()
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 setFrameWasScrolledByUser(); 966 setFrameWasScrolledByUser();
937 return true; 967 return true;
938 } 968 }
939 969
940 curBox = curBox->containingBlock(); 970 curBox = curBox->containingBlock();
941 } 971 }
942 972
943 return false; 973 return false;
944 } 974 }
945 975
976 // FIXME: handle flipped direction (toPhysicalDirection) and granularity.
977 bool EventHandler::customizedScroll(ScrollState* scrollState, Node* startNode)
978 {
979 Node* node = startNode;
980
981 if (!node)
982 node = m_frame->document()->focusedElement();
983
984 if (!node)
985 node = m_mousePressNode.get();
986
987 if (!node || !node->renderer())
988 return false;
989
990 if (!m_currentScrollChain.size() && m_scrollGestureHandlingNode.get())
991 recomputeScrollChain(m_frame, m_scrollGestureHandlingNode.get(), m_curre ntScrollChain);
992 scrollState->setScrollChain(m_currentScrollChain);
993
994 double deltaX = scrollState->deltaX();
995 double deltaY = scrollState->deltaY();
996 scrollState->distributeToScrollChainDescendant();
997 bool didScroll = deltaX != scrollState->deltaX() || deltaY != scrollState->d eltaY();
998
999 if (didScroll) {
1000 if (scrollState->fromUserInput())
1001 setFrameWasScrolledByUser();
1002 return true;
1003 }
1004
1005 return false;
1006 }
1007
946 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) 1008 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode)
947 { 1009 {
948 // The layout needs to be up to date to determine if we can scroll. We may b e 1010 // The layout needs to be up to date to determine if we can scroll. We may b e
949 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. 1011 // here because of an onLoad event, in which case the final layout hasn't be en performed yet.
950 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 1012 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1013 // FIXME: enable scroll customization in this case.
951 if (scroll(direction, granularity, startingNode)) 1014 if (scroll(direction, granularity, startingNode))
952 return true; 1015 return true;
953 LocalFrame* frame = m_frame; 1016 LocalFrame* frame = m_frame;
954 FrameView* view = frame->view(); 1017 FrameView* view = frame->view();
955 if (view && view->scroll(direction, granularity)) 1018 if (view && view->scroll(direction, granularity))
956 return true; 1019 return true;
957 Frame* parentFrame = frame->tree().parent(); 1020 Frame* parentFrame = frame->tree().parent();
958 if (!parentFrame || !parentFrame->isLocalFrame()) 1021 if (!parentFrame || !parentFrame->isLocalFrame())
959 return false; 1022 return false;
960 // FIXME: Broken for OOPI. 1023 // FIXME: Broken for OOPI.
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 2118
2056 // When the wheelEvent do not scroll, we trigger zoom in/out instead. 2119 // When the wheelEvent do not scroll, we trigger zoom in/out instead.
2057 if (!wheelEvent->canScroll()) 2120 if (!wheelEvent->canScroll())
2058 return; 2121 return;
2059 2122
2060 Node* stopNode = m_previousWheelScrolledNode.get(); 2123 Node* stopNode = m_previousWheelScrolledNode.get();
2061 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); 2124 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt);
2062 2125
2063 // Break up into two scrolls if we need to. Diagonal movement on 2126 // Break up into two scrolls if we need to. Diagonal movement on
2064 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set). 2127 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set).
2128
2129 // FIXME: enable scroll customization in this case.
2065 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta X(), roundedIntPoint(wheelEvent->absoluteLocation()))) 2130 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta X(), roundedIntPoint(wheelEvent->absoluteLocation())))
2066 wheelEvent->setDefaultHandled(); 2131 wheelEvent->setDefaultHandled();
2067 2132
2068 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY (), roundedIntPoint(wheelEvent->absoluteLocation()))) 2133 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY (), roundedIntPoint(wheelEvent->absoluteLocation())))
2069 wheelEvent->setDefaultHandled(); 2134 wheelEvent->setDefaultHandled();
2070 2135
2071 if (!m_latchedWheelEventNode) 2136 if (!m_latchedWheelEventNode)
2072 m_previousWheelScrolledNode = stopNode; 2137 m_previousWheelScrolledNode = stopNode;
2073 } 2138 }
2074 2139
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 if (!widget || !widget->isFrameView()) 2512 if (!widget || !widget->isFrameView())
2448 return false; 2513 return false;
2449 2514
2450 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent); 2515 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent);
2451 } 2516 }
2452 2517
2453 bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve nt) { 2518 bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve nt) {
2454 RefPtrWillBeRawPtr<Node> node = m_scrollGestureHandlingNode; 2519 RefPtrWillBeRawPtr<Node> node = m_scrollGestureHandlingNode;
2455 clearGestureScrollNodes(); 2520 clearGestureScrollNodes();
2456 2521
2457 if (node) 2522 if (node) {
2458 passScrollGestureEventToWidget(gestureEvent, node->renderer()); 2523 if (passScrollGestureEventToWidget(gestureEvent, node->renderer()))
2524 return false;
2525 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) {
2526 ScrollState* scrollState = ScrollState::create(gestureEvent.deltaX() , gestureEvent.deltaY(),
2527 0, gestureEvent.velocityX(), gestureEvent.velocityY(), gestureEv ent.inertial(), true, true);
2528 customizedScroll(scrollState, node.get());
2529 }
2530 }
2459 2531
2532 m_currentNativeScrollingElement = nullptr;
2533 m_scrollLockedToElement = false;
2534 m_currentScrollChain.clear();
2460 return false; 2535 return false;
2461 } 2536 }
2462 2537
2463 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent) 2538 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent)
2464 { 2539 {
2465 Document* document = m_frame->document(); 2540 Document* document = m_frame->document();
2466 if (!document->layoutView()) 2541 if (!document->layoutView())
2467 return false; 2542 return false;
2468 2543
2469 FrameView* view = m_frame->view(); 2544 FrameView* view = m_frame->view();
2470 if (!view) 2545 if (!view)
2471 return false; 2546 return false;
2472 2547
2473 // If there's no renderer on the node, send the event to the nearest ancesto r with a renderer. 2548 // If there's no renderer on the node, send the event to the nearest ancesto r with a renderer.
2474 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s 2549 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s
2475 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->renderer ()) 2550 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->renderer ())
2476 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode(); 2551 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode();
2477 2552
2478 if (!m_scrollGestureHandlingNode) 2553 if (!m_scrollGestureHandlingNode) {
2479 return false; 2554 if (RuntimeEnabledFeatures::scrollCustomizationEnabled())
2555 m_scrollGestureHandlingNode = m_frame->document()->documentElement() ;
2556 else
2557 return false;
2558 }
2480 2559
2481 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->re nderer()); 2560 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->re nderer());
2482 2561
2483 if (m_frame->isMainFrame()) 2562 if (m_frame->isMainFrame())
2484 m_frame->host()->topControls().scrollBegin(); 2563 m_frame->host()->topControls().scrollBegin();
2485 2564
2565 if (!RuntimeEnabledFeatures::scrollCustomizationEnabled())
2566 return true;
2567
2568 m_currentNativeScrollingElement = nullptr;
2569 m_scrollLockedToElement = false;
2570
2571 recomputeScrollChain(m_frame, m_scrollGestureHandlingNode.get(), m_currentSc rollChain);
2486 return true; 2572 return true;
2487 } 2573 }
2488 2574
2489 static bool scrollAreaOnBothAxes(const FloatSize& delta, ScrollableArea& view)
2490 {
2491 bool scrolledHorizontal = view.scroll(ScrollLeft, ScrollByPrecisePixel, delt a.width());
2492 bool scrolledVertical = view.scroll(ScrollUp, ScrollByPrecisePixel, delta.he ight());
2493 return scrolledHorizontal || scrolledVertical;
2494 }
2495
2496 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) 2575 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event)
2497 { 2576 {
2498 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); 2577 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate);
2499 2578
2500 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); 2579 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY());
2501 if (delta.isZero()) 2580 if (delta.isZero())
2502 return false; 2581 return false;
2503 2582
2504 Node* node = m_scrollGestureHandlingNode.get(); 2583 Node* node = m_scrollGestureHandlingNode.get();
2505 if (node) { 2584 if (node) {
2506 LayoutObject* renderer = node->renderer(); 2585 LayoutObject* renderer = node->renderer();
2507 if (!renderer) 2586 if (!renderer)
2508 return false; 2587 return false;
2509 2588
2510 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); 2589 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
2511 2590
2512 Node* stopNode = nullptr; 2591 Node* stopNode = nullptr;
2513 2592
2514 // Try to send the event to the correct view. 2593 // Try to send the event to the correct view.
2515 if (passScrollGestureEventToWidget(gestureEvent, renderer)) { 2594 if (passScrollGestureEventToWidget(gestureEvent, renderer)) {
2516 if (gestureEvent.preventPropagation()) 2595 if (gestureEvent.preventPropagation())
2517 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; 2596 m_previousGestureScrolledNode = m_scrollGestureHandlingNode;
2518 2597 m_scrollLockedToElement = true;
2519 return true; 2598 return true;
2520 } 2599 }
2521 2600
2522
2523 if (gestureEvent.preventPropagation()) 2601 if (gestureEvent.preventPropagation())
2524 stopNode = m_previousGestureScrolledNode.get(); 2602 stopNode = m_previousGestureScrolledNode.get();
2525 2603
2526 // First try to scroll the closest scrollable LayoutBox ancestor of |nod e|. 2604 bool scrolled = false;
2527 ScrollGranularity granularity = ScrollByPixel; 2605 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) {
2528 bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopNode, delta.width()); 2606 ScrollState* scrollState = ScrollState::create(gestureEvent.deltaX() , gestureEvent.deltaY(),
2529 bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode, del ta.height()); 2607 0, gestureEvent.velocityX(), gestureEvent.velocityY(), gestureEv ent.inertial(), false, true,
2608 !gestureEvent.preventPropagation());
2609 scrollState->setCurrentNativeScrollingElement(m_currentNativeScrolli ngElement.get());
2610 scrollState->setScrollLockedToElement(m_scrollLockedToElement);
2611 scrolled = customizedScroll(scrollState, node);
2612 m_currentNativeScrollingElement = scrollState->currentNativeScrollin gElement();
2613 m_scrollLockedToElement = scrollState->scrollLockedToElement();
2614 } else {
2615 // First try to scroll the closest scrollable LayoutBox ancestor of |node|.
2616 ScrollGranularity granularity = ScrollByPixel;
2617 scrolled = scroll(ScrollLeft, granularity, node, &stopNode, delta.wi dth())
2618 | scroll(ScrollUp, granularity, node, &stopNode, delta.height()) ;
2619 }
2530 2620
2531 if (gestureEvent.preventPropagation()) 2621 if (gestureEvent.preventPropagation())
2532 m_previousGestureScrolledNode = stopNode; 2622 m_previousGestureScrolledNode = stopNode;
2533 2623
2534 if (horizontalScroll || verticalScroll) { 2624 if (scrolled) {
2535 setFrameWasScrolledByUser(); 2625 setFrameWasScrolledByUser();
2536 return true; 2626 return true;
2537 } 2627 }
2538 } 2628 }
2539 2629
2630
2631 if (RuntimeEnabledFeatures::scrollCustomizationEnabled())
2632 return false;
2633
2540 // If this is main frame, allow top controls to scroll first and update 2634 // If this is main frame, allow top controls to scroll first and update
2541 // delta accordingly 2635 // delta accordingly
2542 bool consumed = false; 2636 bool consumed = false;
2543 if (m_frame->isMainFrame() && shouldTopControlsConsumeScroll(delta)) { 2637 if (m_frame->isMainFrame() && shouldTopControlsConsumeScroll(delta)) {
2544 FloatSize excessDelta = m_frame->host()->topControls().scrollBy(delta); 2638 FloatSize excessDelta = m_frame->host()->topControls().scrollBy(delta);
2545 consumed = excessDelta != delta; 2639 consumed = excessDelta != delta;
2546 delta = excessDelta; 2640 delta = excessDelta;
2547 2641
2548 if (delta.isZero()) 2642 if (delta.isZero())
2549 return consumed; 2643 return consumed;
2550 } 2644 }
2551 2645
2552 // Try to scroll the frame view. 2646 // Try to scroll the frame view.
2553 FrameView* view = m_frame->view(); 2647 FrameView* view = m_frame->view();
2554 if (!view) 2648 if (!view)
2555 return consumed; 2649 return consumed;
2556 2650
2557 if (scrollAreaOnBothAxes(delta, *view)) { 2651 if (m_frame->scrollByDelta(delta)) {
2558 setFrameWasScrolledByUser(); 2652 setFrameWasScrolledByUser();
2559 return true; 2653 return true;
2560 } 2654 }
2561
2562 // If this is the main frame and it didn't scroll, propagate up to the pinch viewport.
2563 if (!m_frame->settings()->pinchVirtualViewportEnabled() || !m_frame->isMainF rame())
2564 return consumed;
2565
2566 if (scrollAreaOnBothAxes(delta, m_frame->host()->pinchViewport())) {
2567 setFrameWasScrolledByUser();
2568 return true;
2569 }
2570 2655
2571 return consumed; 2656 return consumed;
2572 } 2657 }
2573 2658
2574 void EventHandler::clearGestureScrollNodes() 2659 void EventHandler::clearGestureScrollNodes()
2575 { 2660 {
2576 m_scrollGestureHandlingNode = nullptr; 2661 m_scrollGestureHandlingNode = nullptr;
2577 m_previousGestureScrolledNode = nullptr; 2662 m_previousGestureScrolledNode = nullptr;
2578 } 2663 }
2579 2664
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
3397 } 3482 }
3398 3483
3399 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) 3484 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event)
3400 { 3485 {
3401 ASSERT(event->type() == EventTypeNames::keypress); 3486 ASSERT(event->type() == EventTypeNames::keypress);
3402 3487
3403 if (event->ctrlKey() || event->metaKey() || event->altKey()) 3488 if (event->ctrlKey() || event->metaKey() || event->altKey())
3404 return; 3489 return;
3405 3490
3406 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; 3491 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward;
3492 // FIXME: enable scroll customization in this case.
3407 if (scroll(direction, ScrollByPage)) { 3493 if (scroll(direction, ScrollByPage)) {
3408 event->setDefaultHandled(); 3494 event->setDefaultHandled();
3409 return; 3495 return;
3410 } 3496 }
3411 3497
3412 FrameView* view = m_frame->view(); 3498 FrameView* view = m_frame->view();
3413 if (!view) 3499 if (!view)
3414 return; 3500 return;
3415 3501
3416 if (view->scroll(direction, ScrollByPage)) 3502 if (view->scroll(direction, ScrollByPage))
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 4015
3930 // If it's in the direction to hide the top controls, only consume when the frame can also scroll. 4016 // If it's in the direction to hide the top controls, only consume when the frame can also scroll.
3931 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo sition().y()) 4017 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo sition().y())
3932 return true; 4018 return true;
3933 4019
3934 return false; 4020 return false;
3935 } 4021 }
3936 4022
3937 4023
3938 } // namespace blink 4024 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/core/page/scrolling/ScrollState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698