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

Side by Side Diff: cc/input/scrollbar_animation_controller.h

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: fix for test Created 3 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 5 #ifndef CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
7 7
8 #include "base/cancelable_callback.h" 8 #include "base/cancelable_callback.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/input/scrollbar.h"
bokan 2016/12/21 15:56:02 Not used.
12 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
13 #include "cc/layers/scrollbar_layer_impl_base.h" 14 #include "cc/layers/scrollbar_layer_impl_base.h"
14 #include "ui/gfx/geometry/vector2d_f.h" 15 #include "ui/gfx/geometry/vector2d_f.h"
15 16
16 namespace cc { 17 namespace cc {
17 18
18 class ScrollbarAnimationController; 19 class ScrollbarAnimationController;
19 20
20 class CC_EXPORT ScrollbarAnimationControllerClient { 21 class CC_EXPORT ScrollbarAnimationControllerClient {
21 public: 22 public:
22 virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task, 23 virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task,
23 base::TimeDelta delay) = 0; 24 base::TimeDelta delay) = 0;
24 virtual void SetNeedsRedrawForScrollbarAnimation() = 0; 25 virtual void SetNeedsRedrawForScrollbarAnimation() = 0;
25 virtual void SetNeedsAnimateForScrollbarAnimation() = 0; 26 virtual void SetNeedsAnimateForScrollbarAnimation() = 0;
26 virtual void DidChangeScrollbarVisibility() = 0; 27 virtual void DidChangeScrollbarVisibility() = 0;
27 virtual ScrollbarSet ScrollbarsFor(int scroll_layer_id) const = 0; 28 virtual ScrollbarSet ScrollbarsFor(int scroll_layer_id) const = 0;
28 29
29 protected: 30 protected:
30 virtual ~ScrollbarAnimationControllerClient() {} 31 virtual ~ScrollbarAnimationControllerClient() {}
31 }; 32 };
32 33
33 // This abstract class represents the compositor-side analogy of 34 // This abstract class represents the compositor-side analogy of
34 // ScrollbarAnimator. Individual platforms should subclass it to provide 35 // ScrollbarAnimator. Individual platforms should subclass it to provide
35 // specialized implementation. 36 // specialized implementation.
36 class CC_EXPORT ScrollbarAnimationController { 37 class CC_EXPORT ScrollbarAnimationController {
37 public: 38 public:
38 virtual ~ScrollbarAnimationController(); 39 virtual ~ScrollbarAnimationController();
39 40
40 bool Animate(base::TimeTicks now); 41 virtual bool Animate(base::TimeTicks now);
41 42
42 virtual void DidScrollBegin(); 43 virtual void DidScrollBegin();
43 virtual void DidScrollUpdate(bool on_resize); 44 virtual void DidScrollUpdate(bool on_resize);
44 virtual void DidScrollEnd(); 45 virtual void DidScrollEnd();
45 virtual void DidMouseDown() {} 46 virtual void DidMouseDown() {}
46 virtual void DidMouseUp() {} 47 virtual void DidMouseUp() {}
47 virtual void DidMouseLeave() {} 48 virtual void DidMouseLeave() {}
48 virtual void DidMouseMoveNear(float distance) {} 49 virtual void DidMouseMoveNear(ScrollbarOrientation, float) {}
49 virtual bool ScrollbarsHidden() const; 50 virtual bool ScrollbarsHidden() const;
50 51
51 protected: 52 protected:
52 ScrollbarAnimationController(int scroll_layer_id, 53 ScrollbarAnimationController(int scroll_layer_id,
53 ScrollbarAnimationControllerClient* client, 54 ScrollbarAnimationControllerClient* client,
54 base::TimeDelta delay_before_starting, 55 base::TimeDelta delay_before_starting,
55 base::TimeDelta resize_delay_before_starting); 56 base::TimeDelta resize_delay_before_starting);
56 57
57 virtual void RunAnimationFrame(float progress) = 0; 58 virtual void RunAnimationFrame(float progress) = 0;
58 virtual const base::TimeDelta& Duration() = 0; 59 virtual const base::TimeDelta& Duration() = 0;
59 60
60 void StartAnimation(); 61 void StartAnimation();
61 void StopAnimation(); 62 void StopAnimation();
63
62 ScrollbarSet Scrollbars() const; 64 ScrollbarSet Scrollbars() const;
63 65
64 ScrollbarAnimationControllerClient* client_; 66 ScrollbarAnimationControllerClient* client_;
65 67
66 void PostDelayedAnimationTask(bool on_resize); 68 void PostDelayedAnimationTask(bool on_resize);
67 69
68 int scroll_layer_id() const { return scroll_layer_id_; } 70 int scroll_layer_id() const { return scroll_layer_id_; }
69 71
72 bool animating() const { return is_animating_; }
bokan 2016/12/21 15:56:02 this is confusing when used in the child class. Re
73
74 bool currently_scrolling() const { return currently_scrolling_; }
75
70 private: 76 private:
71 // Returns how far through the animation we are as a progress value from 77 // Returns how far through the animation we are as a progress value from
72 // 0 to 1. 78 // 0 to 1.
73 float AnimationProgressAtTime(base::TimeTicks now); 79 float AnimationProgressAtTime(base::TimeTicks now);
74 80
75 base::TimeTicks last_awaken_time_; 81 base::TimeTicks last_awaken_time_;
76 base::TimeDelta delay_before_starting_; 82 base::TimeDelta delay_before_starting_;
77 base::TimeDelta resize_delay_before_starting_; 83 base::TimeDelta resize_delay_before_starting_;
78 84
79 bool is_animating_; 85 bool is_animating_;
80 86
81 int scroll_layer_id_; 87 int scroll_layer_id_;
82 bool currently_scrolling_; 88 bool currently_scrolling_;
83 bool scroll_gesture_has_scrolled_; 89 bool scroll_gesture_has_scrolled_;
84 base::CancelableClosure delayed_scrollbar_fade_; 90 base::CancelableClosure delayed_scrollbar_fade_;
85 91
86 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 92 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
87 }; 93 };
88 94
89 } // namespace cc 95 } // namespace cc
90 96
91 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 97 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698