Index: Source/core/frame/LocalFrame.cpp |
diff --git a/Source/core/frame/LocalFrame.cpp b/Source/core/frame/LocalFrame.cpp |
index 28169539cf8a328a7f762123976014824720c0af..48c35439e68842bb8e8140f3d83f0e306127f3ff 100644 |
--- a/Source/core/frame/LocalFrame.cpp |
+++ b/Source/core/frame/LocalFrame.cpp |
@@ -765,6 +765,55 @@ void LocalFrame::removeSpellingMarkersUnderWords(const Vector<String>& words) |
spellChecker().removeSpellingMarkersUnderWords(words); |
} |
+static bool scrollAreaOnBothAxes(const FloatSize& delta, ScrollableArea& view) |
+{ |
+ bool scrolledHorizontal = view.scroll(ScrollLeft, ScrollByPrecisePixel, delta.width()); |
+ bool scrolledVertical = view.scroll(ScrollUp, ScrollByPrecisePixel, delta.height()); |
+ return scrolledHorizontal || scrolledVertical; |
Rick Byers
2015/03/11 02:22:18
again, don't you need to handle these two cases se
tdresser
2015/03/20 18:00:36
This doesn't change any behavior, see
https://cod
Rick Byers
2015/03/26 21:22:49
Ok, SGTM - thanks.
|
+} |
+ |
+// Returns true if a scroll occurred. |
+bool LocalFrame::applyScrollDelta(const FloatSize& delta, bool isScrollBegin) |
+{ |
+ if (isScrollBegin) |
+ host()->topControls().scrollBegin(); |
+ |
+ if (!view() || delta.isZero()) |
+ return false; |
+ |
+ FloatSize remainingDelta = delta; |
+ |
+ // If this is main frame, allow top controls to scroll first and update |
+ // |remainingDelta| accordingly |
+ bool giveToTopControls = false; |
+ if (isMainFrame()) { |
+ // Always give the delta to the top controls if the scroll is in |
+ // the direction to show the top controls. If it's in the |
+ // direction to hide the top controls, only give the delta to the |
+ // top controls when the frame can scroll. |
+ giveToTopControls = remainingDelta.height() > 0 |
+ || view()->scrollPosition().y() < view()->maximumScrollPosition().y(); |
+ } |
+ |
+ if (giveToTopControls) |
+ remainingDelta = host()->topControls().scrollBy(remainingDelta); |
+ |
+ if (remainingDelta.isZero()) |
+ return true; |
+ |
+ if (scrollAreaOnBothAxes(remainingDelta, *view())) |
+ return true; |
+ |
+ // If this is the main frame and it didn't scroll, propagate up to the pinch viewport. |
+ if (!settings()->pinchVirtualViewportEnabled() || !isMainFrame()) |
+ return false; |
+ |
+ if (scrollAreaOnBothAxes(remainingDelta, page()->frameHost().pinchViewport())) |
+ return true; |
+ |
+ return false; |
+} |
+ |
#if ENABLE(OILPAN) |
void LocalFrame::registerPluginElement(HTMLPlugInElement* plugin) |
{ |