Index: Source/core/page/EventHandler.cpp |
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp |
index 1cd7458bbc67b8dab90407b9c3189657103bf4e1..a36da6f1716c3155b63baf797335a0fec188c6b9 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) |
@@ -924,10 +926,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; |
@@ -938,7 +940,7 @@ bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari |
node = m_mousePressNode.get(); |
if (!node || !node->layoutObject()) |
- return false; |
+ return ScrollResultOneDimensional(false, delta); |
LayoutBox* curBox = node->layoutObject()->enclosingBox(); |
while (curBox && !curBox->isLayoutView()) { |
@@ -947,20 +949,21 @@ bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari |
// 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); |
+ ScrollResultOneDimensional 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; |
+ result.didScroll = true; |
+ return result; |
} |
curBox = curBox->containingBlock(); |
} |
- return false; |
+ return ScrollResultOneDimensional(false, delta); |
} |
void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollState) |
@@ -980,14 +983,14 @@ 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(); |
if (view) { |
ScrollDirectionPhysical physicalDirection = |
toPhysicalDirection(direction, view->isVerticalDocument(), view->isFlippedDocument()); |
- if (view->scrollableArea()->scroll(physicalDirection, granularity)) { |
+ if (view->scrollableArea()->scroll(physicalDirection, granularity).didScroll) { |
setFrameWasScrolledByUser(); |
return true; |
} |
@@ -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(ScrollRightIgnoringWritingMode, granularity, startNode, &stopNode, wheelEvent->deltaX(), absolutePosition)) |
+ && scroll(ScrollRightIgnoringWritingMode, granularity, startNode, &stopNode, wheelEvent->deltaX(), absolutePosition).didScroll) |
wheelEvent->setDefaultHandled(); |
if (wheelEvent->railsMode() != Event::RailsModeHorizontal |
- && scroll(ScrollDownIgnoringWritingMode, granularity, startNode, &stopNode, wheelEvent->deltaY(), absolutePosition)) |
+ && scroll(ScrollDownIgnoringWritingMode, granularity, startNode, &stopNode, wheelEvent->deltaY(), absolutePosition).didScroll) |
wheelEvent->setDefaultHandled(); |
if (!m_latchedWheelEventNode) |
@@ -2709,14 +2712,26 @@ bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture |
// First try to scroll the closest scrollable LayoutBox ancestor of |node|. |
ScrollGranularity granularity = ScrollByPrecisePixel; |
- bool horizontalScroll = scroll(ScrollLeftIgnoringWritingMode, granularity, node, &stopNode, delta.width()); |
+ m_unusedDelta = FloatSize(); |
+ ScrollResultOneDimensional result = scroll(ScrollLeftIgnoringWritingMode, granularity, node, &stopNode, delta.width()); |
+ bool horizontalScroll = result.didScroll; |
if (!gestureEvent.preventPropagation()) |
stopNode = nullptr; |
- bool verticalScroll = scroll(ScrollUpIgnoringWritingMode, granularity, node, &stopNode, delta.height()); |
+ result = scroll(ScrollUpIgnoringWritingMode, granularity, node, &stopNode, delta.height()); |
+ bool verticalScroll = result.didScroll; |
scrolled = horizontalScroll || verticalScroll; |
if (gestureEvent.preventPropagation()) |
m_previousGestureScrolledNode = stopNode; |
+ |
+ if (horizontalScroll) { |
+ m_accumulatedRootOverscroll.setWidth(0); |
+ m_unusedDelta.setWidth(0); |
+ } |
+ if (verticalScroll) { |
+ m_accumulatedRootOverscroll.setHeight(0); |
+ m_unusedDelta.setHeight(0); |
+ } |
} |
if (scrolled) { |
setFrameWasScrolledByUser(); |
@@ -2728,7 +2743,17 @@ bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture |
return false; |
// Try to scroll the frame view. |
- if (m_frame->applyScrollDelta(delta, false)) { |
+ ScrollResult resultScrollDelta = m_frame->applyScrollDelta(delta, false); |
majidvp
2015/05/29 19:14:19
s/resultScrollDelta/scrollResult/
majidvp
2015/05/29 19:14:19
I think you need to have the rest logic for oversc
MuVen
2015/06/01 13:29:26
Done.
|
+ m_unusedDelta.setWidth(resultScrollDelta.unusedScrollDeltaX); |
+ m_unusedDelta.setHeight(resultScrollDelta.unusedScrollDeltaY); |
+ if (m_frame->isMainFrame() && m_unusedDelta != FloatSize()) { |
+ m_accumulatedRootOverscroll += m_unusedDelta; |
+ 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 (resultScrollDelta.didScroll) { |
setFrameWasScrolledByUser(); |
return true; |
} |
@@ -2742,6 +2767,8 @@ void EventHandler::clearGestureScrollNodes() |
m_previousGestureScrolledNode = nullptr; |
m_deltaConsumedForScrollSequence = false; |
m_currentScrollChain.clear(); |
+ m_accumulatedRootOverscroll = FloatSize(); |
+ m_unusedDelta = FloatSize(); |
} |
bool EventHandler::isScrollbarHandlingGestures() const |
@@ -3644,7 +3671,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; |
} |
@@ -3656,7 +3683,7 @@ void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) |
ScrollDirectionPhysical physicalDirection = |
toPhysicalDirection(direction, view->isVerticalDocument(), view->isFlippedDocument()); |
- if (view->scrollableArea()->scroll(physicalDirection, ScrollByPage)) |
+ if (view->scrollableArea()->scroll(physicalDirection, ScrollByPage).didScroll) |
event->setDefaultHandled(); |
} |