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

Unified Diff: Source/platform/scroll/ScrollableArea.h

Issue 134443003: Implement CSSOM Smooth Scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 10 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: Source/platform/scroll/ScrollableArea.h
diff --git a/Source/platform/scroll/ScrollableArea.h b/Source/platform/scroll/ScrollableArea.h
index f39f2e558a3618bbd454f27526800df6af13a5dc..82a5e2824d5f3684c61724c688b01ed589accbbe 100644
--- a/Source/platform/scroll/ScrollableArea.h
+++ b/Source/platform/scroll/ScrollableArea.h
@@ -39,6 +39,7 @@ class GraphicsContext;
class GraphicsLayer;
class PlatformGestureEvent;
class PlatformWheelEvent;
+class ProgrammaticScrollAnimator;
class ScrollAnimator;
enum ScrollBehavior {
@@ -58,6 +59,8 @@ public:
void scrollToOffsetWithoutAnimation(const FloatPoint&);
void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset);
+ void programmaticallyScrollSmoothlyToOffset(const FloatPoint&);
+
// Should be called when the scroll position changes externally, for example if the scroll layer position
// is updated on the scrolling thread and we need to notify the main thread.
void notifyScrollPositionChanged(const IntPoint&);
@@ -106,6 +109,12 @@ public:
// This getter will return null if the ScrollAnimator hasn't been created yet.
ScrollAnimator* existingScrollAnimator() const { return m_scrollAnimator.get(); }
+ ProgrammaticScrollAnimator* programmaticScrollAnimator() const;
+ ProgrammaticScrollAnimator* existingProgrammaticScrollAnimator() const
+ {
+ return m_programmaticScrollAnimator.get();
+ }
+
const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
bool scrollOriginChanged() const { return m_scrollOriginChanged; }
@@ -177,8 +186,11 @@ public:
// Let subclasses provide a way of asking for and servicing scroll
// animations.
+ virtual bool registerForAnimation() { return false; }
+ virtual void deregisterForAnimation() { }
virtual bool scheduleAnimation() { return false; }
- void serviceScrollAnimations();
+ virtual void serviceScrollAnimations(double monotonicTime);
+
virtual bool usesCompositedScrolling() const { return false; }
virtual void updateNeedsCompositedScrolling() { }
@@ -187,6 +199,14 @@ public:
virtual bool userInputScrollable(ScrollbarOrientation) const = 0;
virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0;
+ // Notifications for compositor-driven animations.
+ void notifyAnimationStarted(double monotonicTime);
+ void notifyAnimationFinished(double monotonicTime);
+
+ void layerForScrollingDidChange();
+ void requiresMainThreadScrollingDidChange();
+ bool canUseCompositedScrollAnimations() const;
+
// Convenience functions
int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); }
int minimumScrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPosition().y(); }
@@ -225,6 +245,7 @@ protected:
virtual void invalidateScrollCornerRect(const IntRect&) = 0;
friend class ScrollingCoordinator;
+ friend class ProgrammaticScrollAnimator;
virtual GraphicsLayer* layerForScrolling() const { return 0; }
virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; }
virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; }
@@ -233,6 +254,9 @@ protected:
bool hasLayerForVerticalScrollbar() const;
bool hasLayerForScrollCorner() const;
+ void cancelProgrammaticScrollAnimation();
+ virtual bool compositedScrollAnimationsEnabled() const { return false; }
+
// For repaint after layout, stores the damage to be repainted for the
// scrollbars.
unsigned m_hasHorizontalBarDamage : 1;
@@ -247,6 +271,9 @@ private:
friend class ScrollAnimator;
void setScrollOffsetFromAnimation(const IntPoint&);
+ // Only called from ProgrammaticScrollAnimator.
+ void setScrollOffsetFromProgrammaticAnimation(const IntPoint&);
+
// This function should be overriden by subclasses to perform the actual
// scroll of the content.
virtual void setScrollOffset(const IntPoint&) = 0;
@@ -257,6 +284,7 @@ private:
virtual float pixelStep(ScrollbarOrientation) const;
mutable OwnPtr<ScrollAnimator> m_scrollAnimator;
+ mutable OwnPtr<ProgrammaticScrollAnimator> m_programmaticScrollAnimator;
unsigned m_constrainsScrollingToContentEdge : 1;
unsigned m_inLiveResize : 1;

Powered by Google App Engine
This is Rietveld 408576698