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

Unified Diff: cc/animation/scrollbar_animation_controller.cc

Issue 960873002: Update from https://crrev.com/318214 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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/animation/scrollbar_animation_controller.cc
diff --git a/cc/animation/scrollbar_animation_controller.cc b/cc/animation/scrollbar_animation_controller.cc
index ffb22870825618a4a9e6e4bff1b58c5eeebb0c1e..48b199d6e665388e0021dd80dd4c97f84c5a5d4f 100644
--- a/cc/animation/scrollbar_animation_controller.cc
+++ b/cc/animation/scrollbar_animation_controller.cc
@@ -7,15 +7,18 @@
#include <algorithm>
#include "base/time/time.h"
+#include "cc/trees/layer_tree_impl.h"
namespace cc {
ScrollbarAnimationController::ScrollbarAnimationController(
+ LayerImpl* scroll_layer,
ScrollbarAnimationControllerClient* client,
base::TimeDelta delay_before_starting,
base::TimeDelta resize_delay_before_starting,
base::TimeDelta duration)
- : client_(client),
+ : scroll_layer_(scroll_layer),
+ client_(client),
delay_before_starting_(delay_before_starting),
resize_delay_before_starting_(resize_delay_before_starting),
duration_(duration),
@@ -26,6 +29,8 @@ ScrollbarAnimationController::ScrollbarAnimationController(
}
ScrollbarAnimationController::~ScrollbarAnimationController() {
+ if (is_animating_)
+ client_->StopAnimatingScrollbarAnimationController(this);
}
void ScrollbarAnimationController::Animate(base::TimeTicks now) {
@@ -37,11 +42,6 @@ void ScrollbarAnimationController::Animate(base::TimeTicks now) {
float progress = AnimationProgressAtTime(now);
RunAnimationFrame(progress);
-
- if (is_animating_) {
- delayed_scrollbar_fade_.Cancel();
- client_->SetNeedsScrollbarAnimationFrame();
- }
}
float ScrollbarAnimationController::AnimationProgressAtTime(
@@ -62,38 +62,40 @@ void ScrollbarAnimationController::DidScrollUpdate(bool on_resize) {
// As an optimization, we avoid spamming fade delay tasks during active fast
// scrolls. But if we're not within one, we need to post every scroll update.
if (!currently_scrolling_)
- PostDelayedFade(on_resize);
+ PostDelayedAnimationTask(on_resize);
else
scroll_gesture_has_scrolled_ = true;
}
void ScrollbarAnimationController::DidScrollEnd() {
if (scroll_gesture_has_scrolled_) {
- PostDelayedFade(false);
+ PostDelayedAnimationTask(false);
scroll_gesture_has_scrolled_ = false;
}
currently_scrolling_ = false;
}
-void ScrollbarAnimationController::PostDelayedFade(bool on_resize) {
+void ScrollbarAnimationController::PostDelayedAnimationTask(bool on_resize) {
base::TimeDelta delay =
on_resize ? resize_delay_before_starting_ : delay_before_starting_;
delayed_scrollbar_fade_.Reset(
base::Bind(&ScrollbarAnimationController::StartAnimation,
weak_factory_.GetWeakPtr()));
- client_->PostDelayedScrollbarFade(delayed_scrollbar_fade_.callback(), delay);
+ client_->PostDelayedScrollbarAnimationTask(delayed_scrollbar_fade_.callback(),
+ delay);
}
void ScrollbarAnimationController::StartAnimation() {
delayed_scrollbar_fade_.Cancel();
is_animating_ = true;
last_awaken_time_ = base::TimeTicks();
- client_->SetNeedsScrollbarAnimationFrame();
+ client_->StartAnimatingScrollbarAnimationController(this);
}
void ScrollbarAnimationController::StopAnimation() {
is_animating_ = false;
+ client_->StopAnimatingScrollbarAnimationController(this);
}
} // namespace cc
« no previous file with comments | « cc/animation/scrollbar_animation_controller.h ('k') | cc/animation/scrollbar_animation_controller_linear_fade.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698