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

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

Issue 2273163002: Cleanup and refactor RootScrollerController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed class comment Created 4 years, 4 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/ViewportScrollCallback.h
diff --git a/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h b/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h
index a27c0d48426b34865f77519f929ee03407f63a24..bd974df88c3d685d26cb0586bff82d52a20ed970 100644
--- a/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h
+++ b/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h
@@ -11,34 +11,58 @@
namespace blink {
+class FloatSize;
class ScrollableArea;
class ScrollState;
+class TopControls;
+class OverscrollController;
+class RootFrameViewport;
-// ViewportScrollCallback is an interface that's used by the
-// RootScrollerController to apply scrolls to the designated rootScroller
-// element. It is a ScrollStateCallback, meaning that it's applied during the
-// applyScroll step of ScrollCustomization and child classes must implement
-// handleEvent in order to actually do the scrolling as well as any possible
-// associated actions.
+// ViewportScrollCallback is a ScrollStateCallback, meaning that it's applied
+// during the applyScroll step of ScrollCustomization. It implements viewport
+// actions like moving top controls and showing overscroll glow as well as
+// scrolling the Element.
//
// ScrollCustomization generally relies on using the nativeApplyScroll to
// scroll the element; however, the rootScroller may need to execute actions
// both before and after the native scroll which is currently unsupported.
// Because of this, the ViewportScrollCallback can scroll the Element directly.
-// This is accomplished by descendant classes implementing the setScroller
-// method which RootScrollerController will call to fill the callback with the
-// appropriate ScrollableArea to use.
+// This is accomplished by passing the ScrollableArea directly using
+// setScroller() which RootScrollerController will call to set the appropriate
+// ScrollableArea to use.
class ViewportScrollCallback : public ScrollStateCallback {
public:
- virtual ~ViewportScrollCallback() {}
+ // The TopControls and OverscrollController are given to the
+ // ViewportScrollCallback but are not owned or kept alive by it.
+ static ViewportScrollCallback* create(
+ TopControls* topControls,
+ OverscrollController* overscrollController,
+ RootFrameViewport& rootFrameViewport)
+ {
+ return new ViewportScrollCallback(
+ topControls, overscrollController, rootFrameViewport);
+ }
- virtual void setScroller(ScrollableArea*) = 0;
+ virtual ~ViewportScrollCallback();
- DEFINE_INLINE_VIRTUAL_TRACE() {
- ScrollStateCallback::trace(visitor);
- }
-protected:
- ScrollResult performNativeScroll(ScrollState&, ScrollableArea&);
+ void handleEvent(ScrollState*) override;
+ void setScroller(ScrollableArea*);
+
+ DECLARE_VIRTUAL_TRACE();
+
+private:
+ // ViewportScrollCallback does not assume ownership of TopControls or of
+ // OverscrollController.
+ ViewportScrollCallback(TopControls*, OverscrollController*, RootFrameViewport&);
+
+ bool shouldScrollTopControls(const FloatSize&, ScrollGranularity) const;
+ bool scrollTopControls(ScrollState&);
+
+ ScrollResult performNativeScroll(ScrollState&);
+
+ WeakMember<TopControls> m_topControls;
+ WeakMember<OverscrollController> m_overscrollController;
+ WeakMember<RootFrameViewport> m_rootFrameViewport;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698