Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: Source/core/frame/LocalFrame.cpp

Issue 988823003: Use scroll customization primitives for touch scrolling (behind REF). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address rbyers' nit. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/LocalFrame.h ('k') | Source/core/page/EventHandler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/LocalFrame.cpp
diff --git a/Source/core/frame/LocalFrame.cpp b/Source/core/frame/LocalFrame.cpp
index 653cc41004a6ad1bd539c7170932ee89d1b3927a..71d68ddad4e82ebdc13dfc2fbf6ff8e1931d4d11 100644
--- a/Source/core/frame/LocalFrame.cpp
+++ b/Source/core/frame/LocalFrame.cpp
@@ -728,6 +728,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;
+}
+
+// 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;
+
+ // If this is main frame, allow top controls to scroll first.
+ 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 = delta.height() > 0
+ || view()->scrollPosition().y() < view()->maximumScrollPosition().y();
+ }
+
+ FloatSize remainingDelta = delta;
+ if (giveToTopControls)
+ remainingDelta = host()->topControls().scrollBy(remainingDelta);
+
+ if (remainingDelta.isZero())
+ return true;
+
+ bool consumed = remainingDelta != delta;
+
+ if (scrollAreaOnBothAxes(remainingDelta, *view()))
+ return true;
+
+ // If this is the main frame and it didn't scroll, propagate up to the pinch viewport.
+ if (!isMainFrame())
+ return consumed;
+
+ if (scrollAreaOnBothAxes(remainingDelta, page()->frameHost().pinchViewport()))
+ return true;
+
+ return consumed;
+}
+
#if ENABLE(OILPAN)
void LocalFrame::registerPluginElement(HTMLPlugInElement* plugin)
{
« no previous file with comments | « Source/core/frame/LocalFrame.h ('k') | Source/core/page/EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698