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

Unified Diff: third_party/WebKit/Source/core/page/scrolling/OverscrollController.h

Issue 1915783002: Move overscroll logic out of EventHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make m_visualViewport a WeakMember Created 4 years, 8 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
Index: third_party/WebKit/Source/core/page/scrolling/OverscrollController.h
diff --git a/third_party/WebKit/Source/core/page/scrolling/OverscrollController.h b/third_party/WebKit/Source/core/page/scrolling/OverscrollController.h
new file mode 100644
index 0000000000000000000000000000000000000000..d1c5531e811b57f6f0ce771ea28c1b185fd457ef
--- /dev/null
+++ b/third_party/WebKit/Source/core/page/scrolling/OverscrollController.h
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OverscrollController_h
+#define OverscrollController_h
+
+#include "platform/geometry/FloatSize.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class ChromeClient;
+class FloatPoint;
+struct ScrollResult;
+class VisualViewport;
+
+// Handles overscroll logic that occurs when the user scolls past the end of the
+// document's scroll extents. Currently, this applies only to document scrolling
+// and only on the root frame. We "accumulate" overscroll deltas from separate
+// scroll events if the user continuously scrolls past the extent but reset it
+// as soon as a gesture ends.
+class OverscrollController : public GarbageCollected<OverscrollController> {
+public:
+ static OverscrollController* create(
+ VisualViewport& visualViewport,
+ ChromeClient& chromeClient) {
+ return new OverscrollController(visualViewport, chromeClient);
+ }
+
+ void resetAccumulated(bool resetX, bool resetY);
+
+ // Reports unused scroll as overscroll to the content layer. The position
+ // argument is the most recent location of the gesture, the finger position
+ // for touch scrolling and the cursor position for wheel. Velocity is used
+ // in the case of a fling gesture where we want the overscroll to feel like
+ // it has momentum.
+ void handleOverscroll(
+ const ScrollResult&,
+ const FloatPoint& positionInRootFrame,
+ const FloatSize& velocityInRootFrame);
+
+ DECLARE_TRACE();
+
+private:
+ OverscrollController(VisualViewport&, ChromeClient&);
+
+ WeakMember<VisualViewport> m_visualViewport;
bokan 2016/04/25 13:44:21 This should really be `const VisualViewport` but W
bokan 2016/04/26 01:08:41 Oilpan team fixed so I made this const again.
+ ChromeClient& m_chromeClient;
+
+ FloatSize m_accumulatedRootOverscroll;
+};
+
+} // namespace blink
+
+#endif // OverscrollController_h

Powered by Google App Engine
This is Rietveld 408576698