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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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(const LocalFrame& frame, const Node& startNode, | |
| 200 WillBeHeapDeque<RefPtrWillBeMember<Element>>& scrollChain) | |
| 201 { | |
| 202 scrollChain.clear(); | |
| 203 bool rootLayerScrolls = frame.settings() && frame.settings()->rootLayerScrol ls(); | |
| 204 | |
| 205 ASSERT(startNode.layoutObject()); | |
| 206 LayoutBox* curBox = startNode.layoutObject()->enclosingBox(); | |
| 207 bool addedDocumentElement = false; | |
| 208 | |
| 209 while (curBox && (rootLayerScrolls || !curBox->isLayoutView())) { | |
|
Rick Byers
2015/03/11 02:22:18
I think this deserves a comment describing why we'
tdresser
2015/03/20 18:00:37
Done.
| |
| 210 Node* curNode = curBox->node(); | |
| 211 curBox = curBox->containingBlock(); | |
|
Rick Byers
2015/03/11 02:22:18
What if the first curBox is scrollable itself? It
tdresser
2015/03/20 18:00:37
We don't use curBox until the next iteration of th
Rick Byers
2015/03/26 21:22:49
Acknowledged.
| |
| 212 // FIXME: this should reject more elements. | |
| 213 if (!curNode || !curNode->isElementNode()) | |
| 214 continue; | |
| 215 scrollChain.prepend(toElement(curNode)); | |
| 216 if (curNode == frame.document()->documentElement()) | |
| 217 addedDocumentElement = true; | |
| 218 } | |
| 219 | |
| 220 if (!addedDocumentElement) | |
|
Rick Byers
2015/03/11 02:22:19
Do we want to do this even when rootLayerScrolls i
tdresser
2015/03/20 18:00:36
I've simplified the loop a bit. Actually determini
Rick Byers
2015/03/26 21:22:49
Acknowledged.
| |
| 221 scrollChain.prepend(frame.document()->documentElement()); | |
| 222 } | |
| 223 | |
| 198 EventHandler::EventHandler(LocalFrame* frame) | 224 EventHandler::EventHandler(LocalFrame* frame) |
| 199 : m_frame(frame) | 225 : m_frame(frame) |
| 200 , m_mousePressed(false) | 226 , m_mousePressed(false) |
| 201 , m_capturesDragging(false) | 227 , m_capturesDragging(false) |
| 202 , m_mouseDownMayStartSelect(false) | 228 , m_mouseDownMayStartSelect(false) |
| 203 , m_mouseDownMayStartDrag(false) | 229 , m_mouseDownMayStartDrag(false) |
| 204 , m_mouseDownWasSingleClickInSelection(false) | 230 , m_mouseDownWasSingleClickInSelection(false) |
| 205 , m_selectionInitiationState(HaveNotStartedSelection) | 231 , m_selectionInitiationState(HaveNotStartedSelection) |
| 206 , m_hoverTimer(this, &EventHandler::hoverTimerFired) | 232 , m_hoverTimer(this, &EventHandler::hoverTimerFired) |
| 207 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) | 233 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) |
| 208 , m_mouseDownMayStartAutoscroll(false) | 234 , m_mouseDownMayStartAutoscroll(false) |
| 209 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) | 235 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) |
| 210 , m_svgPan(false) | 236 , m_svgPan(false) |
| 211 , m_resizeScrollableArea(nullptr) | 237 , m_resizeScrollableArea(nullptr) |
| 212 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 238 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 213 , m_clickCount(0) | 239 , m_clickCount(0) |
| 214 , m_shouldOnlyFireDragOverEvent(false) | 240 , m_shouldOnlyFireDragOverEvent(false) |
| 215 , m_mousePositionIsUnknown(true) | 241 , m_mousePositionIsUnknown(true) |
| 216 , m_mouseDownTimestamp(0) | 242 , m_mouseDownTimestamp(0) |
| 217 , m_widgetIsLatched(false) | 243 , m_widgetIsLatched(false) |
| 218 , m_touchPressed(false) | 244 , m_touchPressed(false) |
| 219 , m_scrollGestureHandlingNode(nullptr) | 245 , m_scrollGestureHandlingNode(nullptr) |
| 220 , m_lastGestureScrollOverWidget(false) | 246 , m_lastGestureScrollOverWidget(false) |
| 221 , m_maxMouseMovedDuration(0) | 247 , m_maxMouseMovedDuration(0) |
| 222 , m_longTapShouldInvokeContextMenu(false) | 248 , m_longTapShouldInvokeContextMenu(false) |
| 223 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 249 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 224 , m_lastShowPressTimestamp(0) | 250 , m_lastShowPressTimestamp(0) |
| 251 , m_deltaConsumedForScrollSequence(false) | |
| 225 { | 252 { |
| 226 } | 253 } |
| 227 | 254 |
| 228 EventHandler::~EventHandler() | 255 EventHandler::~EventHandler() |
| 229 { | 256 { |
| 230 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); | 257 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); |
| 231 } | 258 } |
| 232 | 259 |
| 233 DEFINE_TRACE(EventHandler) | 260 DEFINE_TRACE(EventHandler) |
| 234 { | 261 { |
| 235 #if ENABLE(OILPAN) | 262 #if ENABLE(OILPAN) |
| 236 visitor->trace(m_mousePressNode); | 263 visitor->trace(m_mousePressNode); |
| 237 visitor->trace(m_capturingMouseEventsNode); | 264 visitor->trace(m_capturingMouseEventsNode); |
| 238 visitor->trace(m_nodeUnderMouse); | 265 visitor->trace(m_nodeUnderMouse); |
| 239 visitor->trace(m_lastNodeUnderMouse); | 266 visitor->trace(m_lastNodeUnderMouse); |
| 240 visitor->trace(m_lastMouseMoveEventSubframe); | 267 visitor->trace(m_lastMouseMoveEventSubframe); |
| 241 visitor->trace(m_lastScrollbarUnderMouse); | 268 visitor->trace(m_lastScrollbarUnderMouse); |
| 242 visitor->trace(m_clickNode); | 269 visitor->trace(m_clickNode); |
| 243 visitor->trace(m_dragTarget); | 270 visitor->trace(m_dragTarget); |
| 244 visitor->trace(m_frameSetBeingResized); | 271 visitor->trace(m_frameSetBeingResized); |
| 245 visitor->trace(m_latchedWheelEventNode); | 272 visitor->trace(m_latchedWheelEventNode); |
| 246 visitor->trace(m_previousWheelScrolledNode); | 273 visitor->trace(m_previousWheelScrolledNode); |
| 247 visitor->trace(m_scrollbarHandlingScrollGesture); | 274 visitor->trace(m_scrollbarHandlingScrollGesture); |
| 248 visitor->trace(m_targetForTouchID); | 275 visitor->trace(m_targetForTouchID); |
| 249 visitor->trace(m_touchSequenceDocument); | 276 visitor->trace(m_touchSequenceDocument); |
| 250 visitor->trace(m_scrollGestureHandlingNode); | 277 visitor->trace(m_scrollGestureHandlingNode); |
| 251 visitor->trace(m_previousGestureScrolledNode); | 278 visitor->trace(m_previousGestureScrolledNode); |
| 252 visitor->trace(m_lastDeferredTapElement); | 279 visitor->trace(m_lastDeferredTapElement); |
| 280 visitor->trace(m_currentScrollChain); | |
| 253 #endif | 281 #endif |
| 254 } | 282 } |
| 255 | 283 |
| 256 DragState& EventHandler::dragState() | 284 DragState& EventHandler::dragState() |
| 257 { | 285 { |
| 258 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<DragState>, state, (adoptPtrWillB eNoop(new DragState()))); | 286 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<DragState>, state, (adoptPtrWillB eNoop(new DragState()))); |
| 259 return *state; | 287 return *state; |
| 260 } | 288 } |
| 261 | 289 |
| 262 void EventHandler::clear() | 290 void EventHandler::clear() |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 937 setFrameWasScrolledByUser(); | 965 setFrameWasScrolledByUser(); |
| 938 return true; | 966 return true; |
| 939 } | 967 } |
| 940 | 968 |
| 941 curBox = curBox->containingBlock(); | 969 curBox = curBox->containingBlock(); |
| 942 } | 970 } |
| 943 | 971 |
| 944 return false; | 972 return false; |
| 945 } | 973 } |
| 946 | 974 |
| 975 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt ate) | |
| 976 { | |
| 977 if (scrollState.fullyConsumed()) | |
| 978 return; | |
| 979 | |
| 980 if (m_currentScrollChain.isEmpty()) | |
| 981 recomputeScrollChain(*m_frame, startNode, m_currentScrollChain); | |
| 982 scrollState.setScrollChain(m_currentScrollChain); | |
| 983 scrollState.distributeToScrollChainDescendant(); | |
| 984 } | |
| 985 | |
| 947 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) | 986 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) |
| 948 { | 987 { |
| 949 // The layout needs to be up to date to determine if we can scroll. We may b e | 988 // The layout needs to be up to date to determine if we can scroll. We may b e |
| 950 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. | 989 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. |
| 951 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 990 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 991 // FIXME: enable scroll customization in this case. | |
|
Rick Byers
2015/03/11 02:22:18
you might want to reference your scroll customizat
tdresser
2015/03/20 18:00:37
Done.
| |
| 952 if (scroll(direction, granularity, startingNode)) | 992 if (scroll(direction, granularity, startingNode)) |
| 953 return true; | 993 return true; |
| 954 LocalFrame* frame = m_frame; | 994 LocalFrame* frame = m_frame; |
| 955 FrameView* view = frame->view(); | 995 FrameView* view = frame->view(); |
| 956 if (view && view->scroll(direction, granularity)) | 996 if (view && view->scroll(direction, granularity)) |
| 957 return true; | 997 return true; |
| 958 Frame* parentFrame = frame->tree().parent(); | 998 Frame* parentFrame = frame->tree().parent(); |
| 959 if (!parentFrame || !parentFrame->isLocalFrame()) | 999 if (!parentFrame || !parentFrame->isLocalFrame()) |
| 960 return false; | 1000 return false; |
| 961 // FIXME: Broken for OOPI. | 1001 // FIXME: Broken for OOPI. |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2052 | 2092 |
| 2053 // When the wheelEvent do not scroll, we trigger zoom in/out instead. | 2093 // When the wheelEvent do not scroll, we trigger zoom in/out instead. |
| 2054 if (!wheelEvent->canScroll()) | 2094 if (!wheelEvent->canScroll()) |
| 2055 return; | 2095 return; |
| 2056 | 2096 |
| 2057 Node* stopNode = m_previousWheelScrolledNode.get(); | 2097 Node* stopNode = m_previousWheelScrolledNode.get(); |
| 2058 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); | 2098 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); |
| 2059 | 2099 |
| 2060 // Break up into two scrolls if we need to. Diagonal movement on | 2100 // Break up into two scrolls if we need to. Diagonal movement on |
| 2061 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set). | 2101 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set). |
| 2102 | |
| 2103 // FIXME: enable scroll customization in this case. | |
| 2062 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta X(), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2104 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta X(), roundedIntPoint(wheelEvent->absoluteLocation()))) |
| 2063 wheelEvent->setDefaultHandled(); | 2105 wheelEvent->setDefaultHandled(); |
| 2064 | 2106 |
| 2065 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY (), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2107 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY (), roundedIntPoint(wheelEvent->absoluteLocation()))) |
| 2066 wheelEvent->setDefaultHandled(); | 2108 wheelEvent->setDefaultHandled(); |
| 2067 | 2109 |
| 2068 if (!m_latchedWheelEventNode) | 2110 if (!m_latchedWheelEventNode) |
| 2069 m_previousWheelScrolledNode = stopNode; | 2111 m_previousWheelScrolledNode = stopNode; |
| 2070 } | 2112 } |
| 2071 | 2113 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2188 FrameView* view = m_frame->view(); | 2230 FrameView* view = m_frame->view(); |
| 2189 LayoutPoint viewPoint = view->windowToContents(gestureEvent.position()); | 2231 LayoutPoint viewPoint = view->windowToContents(gestureEvent.position()); |
| 2190 HitTestRequest request(HitTestRequest::ReadOnly); | 2232 HitTestRequest request(HitTestRequest::ReadOnly); |
| 2191 HitTestResult result(viewPoint); | 2233 HitTestResult result(viewPoint); |
| 2192 document->layoutView()->hitTest(request, result); | 2234 document->layoutView()->hitTest(request, result); |
| 2193 | 2235 |
| 2194 eventTarget = result.innerNode(); | 2236 eventTarget = result.innerNode(); |
| 2195 | 2237 |
| 2196 m_lastGestureScrollOverWidget = result.isOverWidget(); | 2238 m_lastGestureScrollOverWidget = result.isOverWidget(); |
| 2197 m_scrollGestureHandlingNode = eventTarget; | 2239 m_scrollGestureHandlingNode = eventTarget; |
| 2198 m_previousGestureScrolledNode = nullptr; | |
|
Rick Byers
2015/03/11 02:22:19
why remove this?
tdresser
2015/03/20 18:00:37
Looks wrong to me. Fixed.
| |
| 2199 | 2240 |
| 2200 if (!scrollbar) | 2241 if (!scrollbar) |
| 2201 scrollbar = result.scrollbar(); | 2242 scrollbar = result.scrollbar(); |
| 2202 } | 2243 } |
| 2203 | 2244 |
| 2204 if (scrollbar) { | 2245 if (scrollbar) { |
| 2205 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); | 2246 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); |
| 2206 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd | 2247 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd |
| 2207 || gestureEvent.type() == PlatformEvent::GestureFlingStart | 2248 || gestureEvent.type() == PlatformEvent::GestureFlingStart |
| 2208 || !eventSwallowed) { | 2249 || !eventSwallowed) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2441 Widget* widget = toLayoutPart(renderer)->widget(); | 2482 Widget* widget = toLayoutPart(renderer)->widget(); |
| 2442 | 2483 |
| 2443 if (!widget || !widget->isFrameView()) | 2484 if (!widget || !widget->isFrameView()) |
| 2444 return false; | 2485 return false; |
| 2445 | 2486 |
| 2446 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent); | 2487 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent); |
| 2447 } | 2488 } |
| 2448 | 2489 |
| 2449 bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve nt) { | 2490 bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve nt) { |
| 2450 RefPtrWillBeRawPtr<Node> node = m_scrollGestureHandlingNode; | 2491 RefPtrWillBeRawPtr<Node> node = m_scrollGestureHandlingNode; |
| 2492 | |
| 2493 if (node) { | |
| 2494 if (passScrollGestureEventToWidget(gestureEvent, node->layoutObject())) | |
| 2495 return false; | |
|
Rick Byers
2015/03/11 02:22:18
this doesn't make sense to me. If the subframe ha
tdresser
2015/03/20 18:00:37
This was correct before, but _extremely_ confusing
Rick Byers
2015/03/26 21:22:49
Thanks, makes sense.
| |
| 2496 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
| 2497 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( | |
| 2498 0, 0, 0, 0, 0, gestureEvent.inertial(), false, true, true); | |
|
Rick Byers
2015/03/11 02:22:18
Blink coding style says: "Prefer enums to bools on
tdresser
2015/03/20 18:00:37
Done.
| |
| 2499 customizedScroll(*node.get(), *scrollState); | |
| 2500 } | |
| 2501 } | |
| 2502 | |
| 2451 clearGestureScrollNodes(); | 2503 clearGestureScrollNodes(); |
| 2452 | 2504 m_currentScrollChain.clear(); |
| 2453 if (node) | |
| 2454 passScrollGestureEventToWidget(gestureEvent, node->layoutObject()); | |
| 2455 | |
| 2456 return false; | 2505 return false; |
| 2457 } | 2506 } |
| 2458 | 2507 |
| 2459 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent) | 2508 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent) |
| 2460 { | 2509 { |
| 2461 Document* document = m_frame->document(); | 2510 Document* document = m_frame->document(); |
| 2462 if (!document->layoutView()) | 2511 if (!document->layoutView()) |
| 2463 return false; | 2512 return false; |
| 2464 | 2513 |
| 2465 FrameView* view = m_frame->view(); | 2514 FrameView* view = m_frame->view(); |
| 2466 if (!view) | 2515 if (!view) |
| 2467 return false; | 2516 return false; |
| 2468 | 2517 |
| 2469 // If there's no renderer on the node, send the event to the nearest ancesto r with a renderer. | 2518 // If there's no renderer on the node, send the event to the nearest ancesto r with a renderer. |
| 2470 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s | 2519 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s |
| 2471 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->layoutOb ject()) | 2520 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->layoutOb ject()) |
| 2472 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode(); | 2521 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode(); |
| 2473 | 2522 |
| 2474 if (!m_scrollGestureHandlingNode) | 2523 if (!m_scrollGestureHandlingNode) { |
| 2475 return false; | 2524 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
| 2525 m_scrollGestureHandlingNode = m_frame->document()->documentElement() ; | |
| 2526 else | |
| 2527 return false; | |
| 2528 } | |
| 2529 ASSERT(m_scrollGestureHandlingNode); | |
| 2476 | 2530 |
| 2477 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->la youtObject()); | 2531 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->la youtObject()); |
| 2532 if (!RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
|
Rick Byers
2015/03/11 02:22:18
this would be slightly clearer to me as a if(enabl
tdresser
2015/03/20 18:00:37
Done.
Rick Byers
2015/03/26 21:22:49
nit: I meants put the true case first to avoid a d
tdresser
2015/03/27 15:28:52
Done.
| |
| 2533 if (m_frame->isMainFrame()) | |
| 2534 m_frame->host()->topControls().scrollBegin(); | |
| 2535 return true; | |
| 2536 } | |
| 2478 | 2537 |
| 2479 if (m_frame->isMainFrame()) | 2538 m_deltaConsumedForScrollSequence = false; |
| 2480 m_frame->host()->topControls().scrollBegin(); | 2539 m_currentScrollChain.clear(); |
| 2540 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( | |
| 2541 0, 0, 0, 0, 0, false, true, false, true); | |
|
Rick Byers
2015/03/11 02:22:18
ditto
tdresser
2015/03/20 18:00:37
Done.
| |
| 2542 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); | |
| 2481 | 2543 |
| 2482 return true; | 2544 return true; |
| 2483 } | 2545 } |
| 2484 | 2546 |
| 2485 static bool scrollAreaOnBothAxes(const FloatSize& delta, ScrollableArea& view) | |
| 2486 { | |
| 2487 bool scrolledHorizontal = view.scroll(ScrollLeft, ScrollByPrecisePixel, delt a.width()); | |
| 2488 bool scrolledVertical = view.scroll(ScrollUp, ScrollByPrecisePixel, delta.he ight()); | |
| 2489 return scrolledHorizontal || scrolledVertical; | |
| 2490 } | |
| 2491 | |
| 2492 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) | 2547 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) |
| 2493 { | 2548 { |
| 2494 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | 2549 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); |
| 2495 | 2550 |
| 2496 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); | 2551 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); |
| 2497 if (delta.isZero()) | 2552 if (delta.isZero()) |
| 2498 return false; | 2553 return false; |
| 2499 | 2554 |
| 2500 Node* node = m_scrollGestureHandlingNode.get(); | 2555 Node* node = m_scrollGestureHandlingNode.get(); |
| 2501 if (node) { | 2556 if (node) { |
| 2502 LayoutObject* renderer = node->layoutObject(); | 2557 LayoutObject* renderer = node->layoutObject(); |
| 2503 if (!renderer) | 2558 if (!renderer) |
| 2504 return false; | 2559 return false; |
| 2505 | 2560 |
| 2506 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 2561 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
| 2507 | 2562 |
| 2508 Node* stopNode = nullptr; | 2563 Node* stopNode = nullptr; |
| 2509 | 2564 |
| 2510 // Try to send the event to the correct view. | 2565 // Try to send the event to the correct view. |
| 2511 if (passScrollGestureEventToWidget(gestureEvent, renderer)) { | 2566 if (passScrollGestureEventToWidget(gestureEvent, renderer)) { |
| 2512 if (gestureEvent.preventPropagation()) | 2567 if (gestureEvent.preventPropagation()) |
| 2513 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; | 2568 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; |
| 2514 | 2569 m_deltaConsumedForScrollSequence = true; |
| 2515 return true; | 2570 return true; |
| 2516 } | 2571 } |
| 2517 | 2572 |
| 2573 bool scrolled = false; | |
| 2574 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
| 2575 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( | |
| 2576 gestureEvent.deltaX(), gestureEvent.deltaY(), | |
| 2577 0, gestureEvent.velocityX(), gestureEvent.velocityY(), | |
| 2578 gestureEvent.inertial(), false, false, true, | |
| 2579 !gestureEvent.preventPropagation(), m_deltaConsumedForScrollSequ ence); | |
| 2580 if (m_previousGestureScrolledNode) { | |
|
Rick Byers
2015/03/11 02:22:18
So does this field now represent just native scrol
tdresser
2015/03/20 18:00:37
Done.
| |
| 2581 ASSERT(m_previousGestureScrolledNode->isElementNode()); | |
| 2582 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get())); | |
| 2583 } | |
| 2584 customizedScroll(*node, *scrollState); | |
| 2585 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); | |
| 2586 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); | |
| 2518 | 2587 |
| 2519 if (gestureEvent.preventPropagation()) | 2588 scrolled = scrollState->deltaX() != gestureEvent.deltaX() |
| 2520 stopNode = m_previousGestureScrolledNode.get(); | 2589 || scrollState->deltaY() != gestureEvent.deltaY(); |
| 2590 } else { | |
| 2591 if (gestureEvent.preventPropagation()) | |
| 2592 stopNode = m_previousGestureScrolledNode.get(); | |
| 2521 | 2593 |
| 2522 // First try to scroll the closest scrollable LayoutBox ancestor of |nod e|. | 2594 // First try to scroll the closest scrollable LayoutBox ancestor of |node|. |
| 2523 ScrollGranularity granularity = ScrollByPixel; | 2595 ScrollGranularity granularity = ScrollByPixel; |
| 2524 bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopNode, delta.width()); | 2596 scrolled = scroll(ScrollLeft, granularity, node, &stopNode, delta.wi dth()) |
| 2525 bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode, del ta.height()); | 2597 | scroll(ScrollUp, granularity, node, &stopNode, delta.height()) ; |
|
Rick Byers
2015/03/11 02:22:19
This is a little subtle (I could imagine someone r
tdresser
2015/03/20 18:00:37
Done.
| |
| 2526 | 2598 |
| 2527 if (gestureEvent.preventPropagation()) | 2599 if (gestureEvent.preventPropagation()) |
| 2528 m_previousGestureScrolledNode = stopNode; | 2600 m_previousGestureScrolledNode = stopNode; |
| 2529 | 2601 } |
| 2530 if (horizontalScroll || verticalScroll) { | 2602 if (scrolled) { |
| 2531 setFrameWasScrolledByUser(); | 2603 setFrameWasScrolledByUser(); |
| 2532 return true; | 2604 return true; |
| 2533 } | 2605 } |
| 2534 } | 2606 } |
| 2535 | 2607 |
| 2536 // If this is main frame, allow top controls to scroll first and update | 2608 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
| 2537 // delta accordingly | 2609 return false; |
| 2538 bool consumed = false; | |
| 2539 if (m_frame->isMainFrame() && shouldTopControlsConsumeScroll(delta)) { | |
| 2540 FloatSize excessDelta = m_frame->host()->topControls().scrollBy(delta); | |
| 2541 consumed = excessDelta != delta; | |
| 2542 delta = excessDelta; | |
| 2543 | |
| 2544 if (delta.isZero()) | |
| 2545 return consumed; | |
| 2546 } | |
| 2547 | 2610 |
| 2548 // Try to scroll the frame view. | 2611 // Try to scroll the frame view. |
| 2549 FrameView* view = m_frame->view(); | 2612 if (m_frame->applyScrollDelta(delta, false)) { |
| 2550 if (!view) | |
| 2551 return consumed; | |
| 2552 | |
| 2553 if (scrollAreaOnBothAxes(delta, *view)) { | |
| 2554 setFrameWasScrolledByUser(); | 2613 setFrameWasScrolledByUser(); |
| 2555 return true; | 2614 return true; |
| 2556 } | 2615 } |
| 2557 | 2616 |
| 2558 // If this is the main frame and it didn't scroll, propagate up to the pinch viewport. | 2617 return false; |
| 2559 if (!m_frame->settings()->pinchVirtualViewportEnabled() || !m_frame->isMainF rame()) | |
| 2560 return consumed; | |
| 2561 | |
| 2562 if (scrollAreaOnBothAxes(delta, m_frame->host()->pinchViewport())) { | |
| 2563 setFrameWasScrolledByUser(); | |
| 2564 return true; | |
| 2565 } | |
| 2566 | |
| 2567 return consumed; | |
| 2568 } | 2618 } |
| 2569 | 2619 |
| 2570 void EventHandler::clearGestureScrollNodes() | 2620 void EventHandler::clearGestureScrollNodes() |
| 2571 { | 2621 { |
| 2572 m_scrollGestureHandlingNode = nullptr; | 2622 m_scrollGestureHandlingNode = nullptr; |
| 2573 m_previousGestureScrolledNode = nullptr; | 2623 m_previousGestureScrolledNode = nullptr; |
| 2574 } | 2624 } |
| 2575 | 2625 |
| 2576 bool EventHandler::isScrollbarHandlingGestures() const | 2626 bool EventHandler::isScrollbarHandlingGestures() const |
| 2577 { | 2627 { |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3387 } | 3437 } |
| 3388 | 3438 |
| 3389 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) | 3439 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) |
| 3390 { | 3440 { |
| 3391 ASSERT(event->type() == EventTypeNames::keypress); | 3441 ASSERT(event->type() == EventTypeNames::keypress); |
| 3392 | 3442 |
| 3393 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 3443 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
| 3394 return; | 3444 return; |
| 3395 | 3445 |
| 3396 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; | 3446 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; |
| 3447 // FIXME: enable scroll customization in this case. | |
| 3397 if (scroll(direction, ScrollByPage)) { | 3448 if (scroll(direction, ScrollByPage)) { |
| 3398 event->setDefaultHandled(); | 3449 event->setDefaultHandled(); |
| 3399 return; | 3450 return; |
| 3400 } | 3451 } |
| 3401 | 3452 |
| 3402 FrameView* view = m_frame->view(); | 3453 FrameView* view = m_frame->view(); |
| 3403 if (!view) | 3454 if (!view) |
| 3404 return; | 3455 return; |
| 3405 | 3456 |
| 3406 if (view->scroll(direction, ScrollByPage)) | 3457 if (view->scroll(direction, ScrollByPage)) |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3904 | 3955 |
| 3905 unsigned EventHandler::accessKeyModifiers() | 3956 unsigned EventHandler::accessKeyModifiers() |
| 3906 { | 3957 { |
| 3907 #if OS(MACOSX) | 3958 #if OS(MACOSX) |
| 3908 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3959 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3909 #else | 3960 #else |
| 3910 return PlatformEvent::AltKey; | 3961 return PlatformEvent::AltKey; |
| 3911 #endif | 3962 #endif |
| 3912 } | 3963 } |
| 3913 | 3964 |
| 3914 bool EventHandler::shouldTopControlsConsumeScroll(FloatSize scrollDelta) const | |
| 3915 { | |
| 3916 // Always consume if it's in the direction to show the top controls. | |
| 3917 if (scrollDelta.height() > 0) | |
| 3918 return true; | |
| 3919 | |
| 3920 // If it's in the direction to hide the top controls, only consume when the frame can also scroll. | |
| 3921 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo sition().y()) | |
| 3922 return true; | |
| 3923 | |
| 3924 return false; | |
| 3925 } | |
| 3926 | |
| 3927 | |
| 3928 } // namespace blink | 3965 } // namespace blink |
| OLD | NEW |