Index: Source/core/page/EventHandler.cpp |
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp |
index f5667d003a275407cf9304ebd526e82dc658e6d1..5dfe1d6e1504e37912e8f51b63bebfad83c29875 100644 |
--- a/Source/core/page/EventHandler.cpp |
+++ b/Source/core/page/EventHandler.cpp |
@@ -299,6 +299,8 @@ void EventHandler::clear() |
m_dragTarget = nullptr; |
m_shouldOnlyFireDragOverEvent = false; |
m_mousePositionIsUnknown = true; |
+ m_unusedDelta = IntPoint(); |
+ m_accumulatedRootOverscroll = IntPoint(); |
m_lastKnownMousePosition = IntPoint(); |
m_lastKnownMouseGlobalPosition = IntPoint(); |
m_lastMouseDownUserGestureToken.clear(); |
@@ -926,7 +928,7 @@ void EventHandler::stopAutoscroll() |
controller->stopAutoscroll(); |
} |
-bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granularity, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint) |
+bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granularity, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint, int* unusedDelta) |
{ |
if (!delta) |
return false; |
@@ -951,6 +953,11 @@ 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); |
+ IntPoint cbUnusedDelta = curBox->unUsedDelta(); |
+ if (direction == ScrollUp) |
+ *unusedDelta = cbUnusedDelta.y(); |
+ else if (direction == ScrollLeft) |
+ *unusedDelta = cbUnusedDelta.x(); |
majidvp
2015/04/23 18:25:08
Overscroll should happen only if the document's ma
MuVen
2015/04/27 12:53:46
if (m_frame->isMainFrame()) condition will accumul
|
if (didScroll && stopNode) |
*stopNode = curBox->node(); |
@@ -996,6 +1003,21 @@ bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g |
return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, granularity, m_frame->deprecatedLocalOwner()); |
} |
+IntPoint EventHandler::unusedDelta() const |
+{ |
+ return m_unusedDelta; |
+} |
+ |
+IntPoint EventHandler::accumaltedRootOverScroll() const |
+{ |
+ return m_accumulatedRootOverscroll; |
+} |
+ |
+void EventHandler::resetOverScrollParams() |
+{ |
+ m_unusedDelta = m_accumulatedRootOverscroll = IntPoint(); |
majidvp
2015/04/23 18:25:08
Scroll deltas should use |FloatSize| and not |IntP
MuVen
2015/04/27 12:53:46
Done.
|
+} |
+ |
IntPoint EventHandler::lastKnownMousePosition() const |
{ |
return m_lastKnownMousePosition; |
@@ -2366,7 +2388,6 @@ bool EventHandler::handleGestureScrollEvent(const PlatformGestureEvent& gestureE |
if (eventSwallowed) |
return true; |
} |
- |
switch (gestureEvent.type()) { |
case PlatformEvent::GestureScrollBegin: |
return handleGestureScrollBegin(gestureEvent); |
@@ -2611,6 +2632,7 @@ bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve |
} |
clearGestureScrollNodes(); |
+ resetOverScrollParams(); |
return false; |
} |
@@ -2636,7 +2658,6 @@ bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE |
return false; |
} |
ASSERT(m_scrollGestureHandlingNode); |
- |
passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->layoutObject()); |
if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { |
m_currentScrollChain.clear(); |
@@ -2648,6 +2669,8 @@ bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE |
if (m_frame->isMainFrame()) |
m_frame->host()->topControls().scrollBegin(); |
} |
+ |
+ resetOverScrollParams(); |
return true; |
} |
@@ -2709,13 +2732,17 @@ bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture |
stopNode = m_previousGestureScrolledNode.get(); |
// First try to scroll the closest scrollable LayoutBox ancestor of |node|. |
+ int uDelta; |
+ m_unusedDelta = IntPoint(); |
ScrollGranularity granularity = ScrollByPrecisePixel; |
- bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopNode, delta.width()); |
+ bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopNode, delta.width(), IntPoint(), &uDelta); |
+ m_unusedDelta.setX(uDelta); |
if (!gestureEvent.preventPropagation()) |
stopNode = nullptr; |
- bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode, delta.height()); |
+ bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode, delta.height(), IntPoint(), &uDelta); |
+ m_unusedDelta.setY(uDelta); |
scrolled = horizontalScroll || verticalScroll; |
- |
+ m_accumulatedRootOverscroll = m_accumulatedRootOverscroll + m_unusedDelta; |
if (gestureEvent.preventPropagation()) |
m_previousGestureScrolledNode = stopNode; |
} |