Chromium Code Reviews| Index: Source/core/page/EventHandler.cpp |
| diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp |
| index dd3c5aee907340e0eb1b561e52fb6f57dfe5547c..e8977f1439602f965f3dda18832102d72d456ef4 100644 |
| --- a/Source/core/page/EventHandler.cpp |
| +++ b/Source/core/page/EventHandler.cpp |
| @@ -233,6 +233,8 @@ EventHandler::EventHandler(LocalFrame* frame) |
| , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| , m_clickCount(0) |
| , m_shouldOnlyFireDragOverEvent(false) |
| + , m_unusedDelta(FloatSize()) |
| + , m_accumulatedRootOverscroll(FloatSize()) |
| , m_mousePositionIsUnknown(true) |
| , m_mouseDownTimestamp(0) |
| , m_widgetIsLatched(false) |
| @@ -926,10 +928,10 @@ void EventHandler::stopAutoscroll() |
| controller->stopAutoscroll(); |
| } |
| -bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granularity, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint) |
| +ScrollResultOneDimensional EventHandler::scroll(ScrollDirection direction, ScrollGranularity granularity, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint) |
| { |
| if (!delta) |
| - return false; |
| + return ScrollResultOneDimensional(false); |
| Node* node = startNode; |
| @@ -940,30 +942,31 @@ bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari |
| node = m_mousePressNode.get(); |
| if (!node || !node->layoutObject()) |
| - return false; |
| + return ScrollResultOneDimensional(false, delta); |
| bool rootLayerScrolls = m_frame->settings() && m_frame->settings()->rootLayerScrolls(); |
| LayoutBox* curBox = node->layoutObject()->enclosingBox(); |
| + ScrollResultOneDimensional result(false, delta); |
| while (curBox && (rootLayerScrolls || !curBox->isLayoutView())) { |
| ScrollDirection physicalDirection = toPhysicalDirection( |
| direction, curBox->isHorizontalWritingMode(), curBox->style()->isFlippedBlocksWritingMode()); |
| // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it |
| bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *stopNode; |
| - bool didScroll = curBox->scroll(physicalDirection, granularity, delta); |
| + result = curBox->scroll(physicalDirection, granularity, delta); |
| - if (didScroll && stopNode) |
| + if (result.didScroll && stopNode) |
| *stopNode = curBox->node(); |
| - if (didScroll || shouldStopBubbling) { |
| + if (result.didScroll || shouldStopBubbling) { |
| setFrameWasScrolledByUser(); |
| - return true; |
| + return result; |
|
majidvp
2015/05/07 16:35:30
This no longer guarantee that we return 'true' her
MuVen
2015/05/13 16:55:46
Done.
|
| } |
| curBox = curBox->containingBlock(); |
| } |
| - return false; |
| + return result; |
| } |
| void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollState) |
| @@ -983,7 +986,7 @@ bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g |
| // here because of an onLoad event, in which case the final layout hasn't been performed yet. |
| m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| - if (scroll(direction, granularity, startingNode)) |
| + if (scroll(direction, granularity, startingNode).didScroll) |
| return true; |
| LocalFrame* frame = m_frame; |
| FrameView* view = frame->view(); |
| @@ -2204,11 +2207,11 @@ void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv |
| // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| if (wheelEvent->railsMode() != Event::RailsModeVertical |
| - && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->deltaX(), absolutePosition)) |
| + && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->deltaX(), absolutePosition).didScroll) |
| wheelEvent->setDefaultHandled(); |
| if (wheelEvent->railsMode() != Event::RailsModeHorizontal |
| - && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY(), absolutePosition)) |
| + && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY(), absolutePosition).didScroll) |
| wheelEvent->setDefaultHandled(); |
| if (!m_latchedWheelEventNode) |
| @@ -2709,14 +2712,30 @@ bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture |
| // First try to scroll the closest scrollable LayoutBox ancestor of |node|. |
| ScrollGranularity granularity = ScrollByPrecisePixel; |
| - bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopNode, delta.width()); |
| + m_unusedDelta = FloatSize(); |
| + ScrollResultOneDimensional result = scroll(ScrollLeft, granularity, node, &stopNode, delta.width()); |
| + bool horizontalScroll = result.didScroll; |
| + if (m_frame->isMainFrame()) |
| + m_unusedDelta.setWidth(result.unusedScrollDelta); |
|
majidvp
2015/05/07 16:35:29
Compositor overscroll logic only collects overscro
MuVen
2015/05/13 16:55:46
Done.
|
| if (!gestureEvent.preventPropagation()) |
| stopNode = nullptr; |
| - bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode, delta.height()); |
| + result = scroll(ScrollUp, granularity, node, &stopNode, delta.height()); |
| + bool verticalScroll = result.didScroll; |
| + if (m_frame->isMainFrame()) |
| + m_unusedDelta.setHeight(result.unusedScrollDelta); |
| scrolled = horizontalScroll || verticalScroll; |
| if (gestureEvent.preventPropagation()) |
| m_previousGestureScrolledNode = stopNode; |
| + |
| + if (m_frame->isMainFrame()) |
|
majidvp
2015/05/07 16:35:30
mainframe check here is redundant. For non mainfra
MuVen
2015/05/13 16:55:46
Done.
|
| + m_accumulatedRootOverscroll += m_unusedDelta; |
| + |
| + if (m_frame->isMainFrame() && m_unusedDelta != FloatSize()) { |
|
majidvp
2015/05/07 16:35:30
Again mainframe check is redundant.
MuVen
2015/05/13 16:55:46
Done.
|
| + FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEvent.position().y()); |
| + FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEvent.velocityY()); |
| + m_frame->chromeClient().didOverscroll(m_unusedDelta, m_accumulatedRootOverscroll, position, velocity); |
| + } |
| } |
| if (scrolled) { |
| setFrameWasScrolledByUser(); |
| @@ -2742,6 +2761,7 @@ void EventHandler::clearGestureScrollNodes() |
| m_previousGestureScrolledNode = nullptr; |
| m_deltaConsumedForScrollSequence = false; |
| m_currentScrollChain.clear(); |
| + m_accumulatedRootOverscroll = FloatSize(); |
|
majidvp
2015/05/07 16:35:30
This clears accumulated root overscroll only at th
MuVen
2015/05/13 16:55:46
Done.
|
| } |
| bool EventHandler::isScrollbarHandlingGestures() const |
| @@ -3625,7 +3645,7 @@ void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) |
| ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; |
| // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| - if (scroll(direction, ScrollByPage)) { |
| + if (scroll(direction, ScrollByPage).didScroll) { |
| event->setDefaultHandled(); |
| return; |
| } |