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

Unified Diff: cc/input/scrollbar_animation_controller.h

Issue 2692243005: Merge Compositor's ScrollbarAnimationControllers into single class (Closed)
Patch Set: fix confict constant Created 3 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: cc/input/scrollbar_animation_controller.h
diff --git a/cc/input/scrollbar_animation_controller.h b/cc/input/scrollbar_animation_controller.h
index 25e129661251541c4145002a6c0bfe16c543cd4e..17d07d0dfd73bb4c5f0297c1e7d0d8f8ae3f86d1 100644
--- a/cc/input/scrollbar_animation_controller.h
+++ b/cc/input/scrollbar_animation_controller.h
@@ -29,24 +29,44 @@ class CC_EXPORT ScrollbarAnimationControllerClient {
virtual ~ScrollbarAnimationControllerClient() {}
};
-// This abstract class represents the compositor-side analogy of
-// ScrollbarAnimator. Individual platforms should subclass it to provide
-// specialized implementation.
+// This class fade in scrollbars when scroll and fade out after an idle delay.
+// The fade animations works on both scrollbars and is controlled in this class
// This class also passes the mouse state to each
// SingleScrollbarAnimationControllerThinning. The thinning animations are
// independent between vertical/horizontal and are managed by the
// SingleScrollbarAnimationControllerThinnings.
class CC_EXPORT ScrollbarAnimationController {
public:
- virtual ~ScrollbarAnimationController();
+ // ScrollbarAnimationController for Android. It only has fade in/out
+ // animation.
+ static std::unique_ptr<ScrollbarAnimationController>
+ CreateScrollbarAnimationControllerAndroid(
+ int scroll_layer_id,
+ ScrollbarAnimationControllerClient* client,
+ base::TimeDelta delay_before_starting,
+ base::TimeDelta resize_delay_before_starting,
+ base::TimeDelta fade_duration);
+
+ // ScrollbarAnimationController for Desktop Overlay Scrollbar. It has fade in/
+ // out animation and thinning animation.
+ static std::unique_ptr<ScrollbarAnimationController>
+ CreateScrollbarAnimationControllerAuraOverlay(
+ int scroll_layer_id,
+ ScrollbarAnimationControllerClient* client,
+ base::TimeDelta delay_before_starting,
+ base::TimeDelta resize_delay_before_starting,
+ base::TimeDelta fade_duration,
+ base::TimeDelta thinning_duration);
+
+ ~ScrollbarAnimationController();
+
+ bool ScrollbarsHidden() const;
bool Animate(base::TimeTicks now);
- virtual void DidScrollBegin();
- virtual void DidScrollUpdate(bool on_resize);
- virtual void DidScrollEnd();
- virtual bool ScrollbarsHidden() const;
- virtual bool NeedThinningAnimation() const;
+ void DidScrollBegin();
+ void DidScrollUpdate(bool on_resize);
+ void DidScrollEnd();
void DidMouseDown();
void DidMouseUp();
@@ -57,44 +77,39 @@ class CC_EXPORT ScrollbarAnimationController {
bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const;
bool mouse_is_near_any_scrollbar() const;
- void set_mouse_move_distance_for_test(float distance);
+ private:
+ ScrollbarAnimationController(int scroll_layer_id,
+ ScrollbarAnimationControllerClient* client,
+ base::TimeDelta delay_before_starting,
+ base::TimeDelta resize_delay_before_starting,
+ base::TimeDelta fade_duration);
- protected:
ScrollbarAnimationController(int scroll_layer_id,
ScrollbarAnimationControllerClient* client,
base::TimeDelta delay_before_starting,
- base::TimeDelta resize_delay_before_starting);
+ base::TimeDelta resize_delay_before_starting,
+ base::TimeDelta fade_duration,
+ base::TimeDelta thinning_duration);
- virtual void RunAnimationFrame(float progress) = 0;
- virtual const base::TimeDelta& Duration() = 0;
- virtual void ApplyOpacityToScrollbars(float opacity) = 0;
+ ScrollbarSet Scrollbars() const;
+ SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
+ ScrollbarOrientation) const;
+
+ // Returns how far through the animation we are as a progress value from
+ // 0 to 1.
+ float AnimationProgressAtTime(base::TimeTicks now);
+ void RunAnimationFrame(float progress);
void StartAnimation();
void StopAnimation();
- ScrollbarSet Scrollbars() const;
ScrollbarAnimationControllerClient* client_;
void PostDelayedAnimationTask(bool on_resize);
- int scroll_layer_id() const { return scroll_layer_id_; }
-
- bool animating_fade() const { return is_animating_; }
-
bool Captured() const;
- std::unique_ptr<SingleScrollbarAnimationControllerThinning>
- vertical_controller_;
- std::unique_ptr<SingleScrollbarAnimationControllerThinning>
- horizontal_controller_;
-
- private:
- // Returns how far through the animation we are as a progress value from
- // 0 to 1.
- float AnimationProgressAtTime(base::TimeTicks now);
-
- SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
- ScrollbarOrientation) const;
+ void ApplyOpacityToScrollbars(float opacity);
base::TimeTicks last_awaken_time_;
base::TimeDelta delay_before_starting_;
@@ -102,10 +117,19 @@ class CC_EXPORT ScrollbarAnimationController {
bool is_animating_;
- int scroll_layer_id_;
+ const int scroll_layer_id_;
bool currently_scrolling_;
bool scroll_gesture_has_scrolled_;
+
base::CancelableClosure delayed_scrollbar_fade_;
+ float opacity_;
+ base::TimeDelta fade_duration_;
+
+ const bool need_thinning_animation_;
+ std::unique_ptr<SingleScrollbarAnimationControllerThinning>
+ vertical_controller_;
+ std::unique_ptr<SingleScrollbarAnimationControllerThinning>
+ horizontal_controller_;
base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
};

Powered by Google App Engine
This is Rietveld 408576698