summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/animation/scrollbar_animation_controller.h25
-rw-r--r--cc/animation/scrollbar_animation_controller_linear_fade.cc123
-rw-r--r--cc/animation/scrollbar_animation_controller_linear_fade.h52
-rw-r--r--cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc254
-rw-r--r--cc/layers/layer_impl.cc6
-rw-r--r--cc/trees/layer_tree_host_impl.cc8
-rw-r--r--cc/trees/layer_tree_impl.cc6
7 files changed, 239 insertions, 235 deletions
diff --git a/cc/animation/scrollbar_animation_controller.h b/cc/animation/scrollbar_animation_controller.h
index 8c7aafe..aa106cf 100644
--- a/cc/animation/scrollbar_animation_controller.h
+++ b/cc/animation/scrollbar_animation_controller.h
@@ -11,22 +11,23 @@
namespace cc {
-// This abstract class represents the compositor-side analogy of ScrollbarAnimator.
-// Individual platforms should subclass it to provide specialized implementation.
+// This abstract class represents the compositor-side analogy of
+// ScrollbarAnimator. Individual platforms should subclass it to provide
+// specialized implementation.
class CC_EXPORT ScrollbarAnimationController {
-public:
- virtual ~ScrollbarAnimationController() {}
+ public:
+ virtual ~ScrollbarAnimationController() {}
- virtual bool isScrollGestureInProgress() const = 0;
- virtual bool isAnimating() const = 0;
- virtual base::TimeDelta delayBeforeStart(base::TimeTicks now) const = 0;
+ virtual bool IsScrollGestureInProgress() const = 0;
+ virtual bool IsAnimating() const = 0;
+ virtual base::TimeDelta DelayBeforeStart(base::TimeTicks now) const = 0;
- virtual bool animate(base::TimeTicks) = 0;
- virtual void didScrollGestureBegin() = 0;
- virtual void didScrollGestureEnd(base::TimeTicks now) = 0;
- virtual void didProgrammaticallyUpdateScroll(base::TimeTicks now) = 0;
+ virtual bool Animate(base::TimeTicks now) = 0;
+ virtual void DidScrollGestureBegin() = 0;
+ virtual void DidScrollGestureEnd(base::TimeTicks now) = 0;
+ virtual void DidProgrammaticallyUpdateScroll(base::TimeTicks now) = 0;
};
-} // namespace cc
+} // namespace cc
#endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
diff --git a/cc/animation/scrollbar_animation_controller_linear_fade.cc b/cc/animation/scrollbar_animation_controller_linear_fade.cc
index 88804b8..e22207d 100644
--- a/cc/animation/scrollbar_animation_controller_linear_fade.cc
+++ b/cc/animation/scrollbar_animation_controller_linear_fade.cc
@@ -9,86 +9,87 @@
namespace cc {
-scoped_ptr<ScrollbarAnimationControllerLinearFade> ScrollbarAnimationControllerLinearFade::create(LayerImpl* scrollLayer, base::TimeDelta fadeoutDelay, base::TimeDelta fadeoutLength)
-{
- return make_scoped_ptr(new ScrollbarAnimationControllerLinearFade(scrollLayer, fadeoutDelay, fadeoutLength));
+scoped_ptr<ScrollbarAnimationControllerLinearFade>
+ScrollbarAnimationControllerLinearFade::Create(LayerImpl* scroll_layer,
+ base::TimeDelta fadeout_delay,
+ base::TimeDelta fadeout_length) {
+ return make_scoped_ptr(new ScrollbarAnimationControllerLinearFade(
+ scroll_layer, fadeout_delay, fadeout_length));
}
-ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade(LayerImpl* scrollLayer, base::TimeDelta fadeoutDelay, base::TimeDelta fadeoutLength)
- : ScrollbarAnimationController()
- , m_scrollLayer(scrollLayer)
- , m_scrollGestureInProgress(false)
- , m_fadeoutDelay(fadeoutDelay)
- , m_fadeoutLength(fadeoutLength)
-{
+ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade(
+ LayerImpl* scroll_layer,
+ base::TimeDelta fadeout_delay,
+ base::TimeDelta fadeout_length)
+ : ScrollbarAnimationController(),
+ scroll_layer_(scroll_layer),
+ scroll_gesture_in_progress_(false),
+ fadeout_delay_(fadeout_delay),
+ fadeout_length_(fadeout_length) {}
+
+ScrollbarAnimationControllerLinearFade::
+ ~ScrollbarAnimationControllerLinearFade() {}
+
+bool ScrollbarAnimationControllerLinearFade::IsScrollGestureInProgress() const {
+ return scroll_gesture_in_progress_;
}
-ScrollbarAnimationControllerLinearFade::~ScrollbarAnimationControllerLinearFade()
-{
+bool ScrollbarAnimationControllerLinearFade::IsAnimating() const {
+ return !last_awaken_time_.is_null();
}
-bool ScrollbarAnimationControllerLinearFade::isScrollGestureInProgress() const
-{
- return m_scrollGestureInProgress;
+base::TimeDelta ScrollbarAnimationControllerLinearFade::DelayBeforeStart(
+ base::TimeTicks now) const {
+ if (now > last_awaken_time_ + fadeout_delay_)
+ return base::TimeDelta();
+ return fadeout_delay_ - (now - last_awaken_time_);
}
-bool ScrollbarAnimationControllerLinearFade::isAnimating() const
-{
- return !m_lastAwakenTime.is_null();
+bool ScrollbarAnimationControllerLinearFade::Animate(base::TimeTicks now) {
+ float opacity = OpacityAtTime(now);
+ scroll_layer_->SetScrollbarOpacity(opacity);
+ if (!opacity)
+ last_awaken_time_ = base::TimeTicks();
+ return IsAnimating() && DelayBeforeStart(now) == base::TimeDelta();
}
-base::TimeDelta ScrollbarAnimationControllerLinearFade::delayBeforeStart(base::TimeTicks now) const
-{
- if (now > m_lastAwakenTime + m_fadeoutDelay)
- return base::TimeDelta();
- return m_fadeoutDelay - (now - m_lastAwakenTime);
+void ScrollbarAnimationControllerLinearFade::DidScrollGestureBegin() {
+ scroll_layer_->SetScrollbarOpacity(1.0f);
+ scroll_gesture_in_progress_ = true;
+ last_awaken_time_ = base::TimeTicks();
}
-bool ScrollbarAnimationControllerLinearFade::animate(base::TimeTicks now)
-{
- float opacity = opacityAtTime(now);
- m_scrollLayer->SetScrollbarOpacity(opacity);
- if (!opacity)
- m_lastAwakenTime = base::TimeTicks();
- return isAnimating() && delayBeforeStart(now) == base::TimeDelta();
+void ScrollbarAnimationControllerLinearFade::DidScrollGestureEnd(
+ base::TimeTicks now) {
+ scroll_gesture_in_progress_ = false;
+ last_awaken_time_ = now;
}
-void ScrollbarAnimationControllerLinearFade::didScrollGestureBegin()
-{
- m_scrollLayer->SetScrollbarOpacity(1);
- m_scrollGestureInProgress = true;
- m_lastAwakenTime = base::TimeTicks();
+void ScrollbarAnimationControllerLinearFade::DidProgrammaticallyUpdateScroll(
+ base::TimeTicks now) {
+ // Don't set scroll_gesture_in_progress_ as this scroll is not from a gesture
+ // and we won't receive ScrollEnd.
+ scroll_layer_->SetScrollbarOpacity(1.0f);
+ last_awaken_time_ = now;
}
-void ScrollbarAnimationControllerLinearFade::didScrollGestureEnd(base::TimeTicks now)
-{
- m_scrollGestureInProgress = false;
- m_lastAwakenTime = now;
-}
-
-void ScrollbarAnimationControllerLinearFade::didProgrammaticallyUpdateScroll(base::TimeTicks now)
-{
- // Don't set m_scrollGestureInProgress as this scroll is not from a gesture
- // and we won't receive ScrollEnd.
- m_scrollLayer->SetScrollbarOpacity(1);
- m_lastAwakenTime = now;
-}
-
-float ScrollbarAnimationControllerLinearFade::opacityAtTime(base::TimeTicks now)
-{
- if (m_scrollGestureInProgress)
- return 1;
+float ScrollbarAnimationControllerLinearFade::OpacityAtTime(
+ base::TimeTicks now) {
+ if (scroll_gesture_in_progress_)
+ return 1.0f;
- if (m_lastAwakenTime.is_null())
- return 0;
+ if (last_awaken_time_.is_null())
+ return 0.0f;
- base::TimeDelta delta = now - m_lastAwakenTime;
+ base::TimeDelta delta = now - last_awaken_time_;
- if (delta <= m_fadeoutDelay)
- return 1;
- if (delta < m_fadeoutDelay + m_fadeoutLength)
- return (m_fadeoutDelay + m_fadeoutLength - delta).InSecondsF() / m_fadeoutLength.InSecondsF();
- return 0;
+ if (delta <= fadeout_delay_)
+ return 1.0f;
+ if (delta < fadeout_delay_ + fadeout_length_) {
+ return (fadeout_delay_ + fadeout_length_ - delta).InSecondsF() /
+ fadeout_length_.InSecondsF();
+ }
+ return 0.0f;
}
} // namespace cc
diff --git a/cc/animation/scrollbar_animation_controller_linear_fade.h b/cc/animation/scrollbar_animation_controller_linear_fade.h
index a126306..19a94d8 100644
--- a/cc/animation/scrollbar_animation_controller_linear_fade.h
+++ b/cc/animation/scrollbar_animation_controller_linear_fade.h
@@ -12,39 +12,43 @@
namespace cc {
class LayerImpl;
-class CC_EXPORT ScrollbarAnimationControllerLinearFade : public ScrollbarAnimationController {
-public:
- static scoped_ptr<ScrollbarAnimationControllerLinearFade> create(LayerImpl* scrollLayer, base::TimeDelta fadeoutDelay, base::TimeDelta fadeoutLength);
+class CC_EXPORT ScrollbarAnimationControllerLinearFade :
+ public ScrollbarAnimationController {
+ public:
+ static scoped_ptr<ScrollbarAnimationControllerLinearFade> Create(
+ LayerImpl* scroll_layer,
+ base::TimeDelta fadeout_delay,
+ base::TimeDelta fadeout_length);
- virtual ~ScrollbarAnimationControllerLinearFade();
+ virtual ~ScrollbarAnimationControllerLinearFade();
- // ScrollbarAnimationController overrides.
- virtual bool isScrollGestureInProgress() const OVERRIDE;
- virtual bool isAnimating() const OVERRIDE;
- virtual base::TimeDelta delayBeforeStart(base::TimeTicks now) const OVERRIDE;
+ // ScrollbarAnimationController overrides.
+ virtual bool IsScrollGestureInProgress() const OVERRIDE;
+ virtual bool IsAnimating() const OVERRIDE;
+ virtual base::TimeDelta DelayBeforeStart(base::TimeTicks now) const OVERRIDE;
- virtual bool animate(base::TimeTicks) OVERRIDE;
- virtual void didScrollGestureBegin() OVERRIDE;
- virtual void didScrollGestureEnd(base::TimeTicks now) OVERRIDE;
- virtual void didProgrammaticallyUpdateScroll(base::TimeTicks now) OVERRIDE;
+ virtual bool Animate(base::TimeTicks now) OVERRIDE;
+ virtual void DidScrollGestureBegin() OVERRIDE;
+ virtual void DidScrollGestureEnd(base::TimeTicks now) OVERRIDE;
+ virtual void DidProgrammaticallyUpdateScroll(base::TimeTicks now) OVERRIDE;
-protected:
- ScrollbarAnimationControllerLinearFade(LayerImpl* scrollLayer, base::TimeDelta fadeoutDelay, base::TimeDelta fadeoutLength);
+ protected:
+ ScrollbarAnimationControllerLinearFade(LayerImpl* scroll_layer,
+ base::TimeDelta fadeout_delay,
+ base::TimeDelta fadeout_length);
-private:
- float opacityAtTime(base::TimeTicks);
+ private:
+ float OpacityAtTime(base::TimeTicks now);
- LayerImpl* m_scrollLayer;
+ LayerImpl* scroll_layer_;
- base::TimeTicks m_lastAwakenTime;
- bool m_scrollGestureInProgress;
+ base::TimeTicks last_awaken_time_;
+ bool scroll_gesture_in_progress_;
- base::TimeDelta m_fadeoutDelay;
- base::TimeDelta m_fadeoutLength;
-
- double m_currentTimeForTesting;
+ base::TimeDelta fadeout_delay_;
+ base::TimeDelta fadeout_length_;
};
-} // namespace cc
+} // namespace cc
#endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_LINEAR_FADE_H_
diff --git a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
index ca92b70..b791f39 100644
--- a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
+++ b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
@@ -15,153 +15,151 @@ namespace cc {
namespace {
class ScrollbarAnimationControllerLinearFadeTest : public testing::Test {
-public:
- ScrollbarAnimationControllerLinearFadeTest()
- : m_hostImpl(&m_proxy)
- {
- }
-
-protected:
- virtual void SetUp()
- {
- m_scrollLayer = LayerImpl::Create(m_hostImpl.active_tree(), 1);
- scoped_ptr<ScrollbarGeometryFixedThumb> geometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollbarThemeGeometry::create(false)));
- m_scrollbarLayer = ScrollbarLayerImpl::Create(m_hostImpl.active_tree(), 2, geometry.Pass());
-
- m_scrollLayer->SetMaxScrollOffset(gfx::Vector2d(50, 50));
- m_scrollLayer->SetBounds(gfx::Size(50, 50));
- m_scrollLayer->SetHorizontalScrollbarLayer(m_scrollbarLayer.get());
-
- m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m_scrollLayer.get(), base::TimeDelta::FromSeconds(2), base::TimeDelta::FromSeconds(3));
- }
-
- FakeImplProxy m_proxy;
- FakeLayerTreeHostImpl m_hostImpl;
- scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController;
- scoped_ptr<LayerImpl> m_scrollLayer;
- scoped_ptr<ScrollbarLayerImpl> m_scrollbarLayer;
-
+ public:
+ ScrollbarAnimationControllerLinearFadeTest() : host_impl_(&proxy_) {}
+
+ protected:
+ virtual void SetUp() {
+ scroll_layer_ = LayerImpl::Create(host_impl_.active_tree(), 1);
+ scoped_ptr<ScrollbarGeometryFixedThumb> geometry(
+ ScrollbarGeometryFixedThumb::create(
+ FakeWebScrollbarThemeGeometry::create(false)));
+ scrollbar_layer_ = ScrollbarLayerImpl::Create(
+ host_impl_.active_tree(), 2, geometry.Pass());
+
+ scroll_layer_->SetMaxScrollOffset(gfx::Vector2d(50, 50));
+ scroll_layer_->SetBounds(gfx::Size(50, 50));
+ scroll_layer_->SetHorizontalScrollbarLayer(scrollbar_layer_.get());
+
+ scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create(
+ scroll_layer_.get(),
+ base::TimeDelta::FromSeconds(2),
+ base::TimeDelta::FromSeconds(3));
+ }
+
+ FakeImplProxy proxy_;
+ FakeLayerTreeHostImpl host_impl_;
+ scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_;
+ scoped_ptr<LayerImpl> scroll_layer_;
+ scoped_ptr<ScrollbarLayerImpl> scrollbar_layer_;
};
-TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin)
-{
- m_scrollbarController->animate(base::TimeTicks());
- EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
+TEST_F(ScrollbarAnimationControllerLinearFadeTest, HiddenInBegin) {
+ scrollbar_controller_->Animate(base::TimeTicks());
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
}
-TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScrollGesture)
-{
- base::TimeTicks time;
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->didScrollGestureBegin();
- EXPECT_TRUE(m_scrollbarController->isScrollGestureInProgress());
- EXPECT_FALSE(m_scrollbarController->isAnimating());
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByScrollGesture) {
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollGestureBegin();
+ EXPECT_TRUE(scrollbar_controller_->IsScrollGestureInProgress());
+ EXPECT_FALSE(scrollbar_controller_->IsAnimating());
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(100);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
- m_scrollbarController->didScrollGestureEnd(time);
+ time += base::TimeDelta::FromSeconds(100);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+ scrollbar_controller_->DidScrollGestureEnd(time);
- EXPECT_FALSE(m_scrollbarController->isScrollGestureInProgress());
- EXPECT_TRUE(m_scrollbarController->isAnimating());
- EXPECT_EQ(2, m_scrollbarController->delayBeforeStart(time).InSeconds());
+ EXPECT_FALSE(scrollbar_controller_->IsScrollGestureInProgress());
+ EXPECT_TRUE(scrollbar_controller_->IsAnimating());
+ EXPECT_EQ(2, scrollbar_controller_->DelayBeforeStart(time).InSeconds());
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(1);
+ time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->didScrollGestureBegin();
- m_scrollbarController->didScrollGestureEnd(time);
+ scrollbar_controller_->DidScrollGestureBegin();
+ scrollbar_controller_->DidScrollGestureEnd(time);
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity());
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
}
-TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByProgrammaticScroll)
-{
- base::TimeTicks time;
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->didProgrammaticallyUpdateScroll(time);
- EXPECT_FALSE(m_scrollbarController->isScrollGestureInProgress());
- EXPECT_TRUE(m_scrollbarController->isAnimating());
- EXPECT_EQ(2, m_scrollbarController->delayBeforeStart(time).InSeconds());
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
- m_scrollbarController->didProgrammaticallyUpdateScroll(time);
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->didProgrammaticallyUpdateScroll(time);
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
-
- time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
+TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByProgrammaticScroll) {
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidProgrammaticallyUpdateScroll(time);
+ EXPECT_FALSE(scrollbar_controller_->IsScrollGestureInProgress());
+ EXPECT_TRUE(scrollbar_controller_->IsAnimating());
+ EXPECT_EQ(2, scrollbar_controller_->DelayBeforeStart(time).InSeconds());
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+ scrollbar_controller_->DidProgrammaticallyUpdateScroll(time);
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidProgrammaticallyUpdateScroll(time);
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
}
} // namespace
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index 36c31c0..46e59ed 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -816,8 +816,8 @@ void LayerImpl::UpdateScrollbarPositions() {
last_scroll_offset_ = current_offset;
if (scrollbar_animation_controller_ &&
- !scrollbar_animation_controller_->isScrollGestureInProgress()) {
- scrollbar_animation_controller_->didProgrammaticallyUpdateScroll(
+ !scrollbar_animation_controller_->IsScrollGestureInProgress()) {
+ scrollbar_animation_controller_->DidProgrammaticallyUpdateScroll(
base::TimeTicks::Now());
}
@@ -909,7 +909,7 @@ inline scoped_ptr<ScrollbarAnimationController>
CreateScrollbarAnimationControllerWithFade(LayerImpl* layer) {
base::TimeDelta fadeout_delay = base::TimeDelta::FromMilliseconds(300);
base::TimeDelta fadeout_length = base::TimeDelta::FromMilliseconds(300);
- return ScrollbarAnimationControllerLinearFade::create(
+ return ScrollbarAnimationControllerLinearFade::Create(
layer, fadeout_delay, fadeout_length)
.PassAs<ScrollbarAnimationController>();
}
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 990c32b..008cbab 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1844,7 +1844,7 @@ void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer,
ScrollbarAnimationController* scrollbar_controller =
layer->scrollbar_animation_controller();
- if (scrollbar_controller && scrollbar_controller->animate(time)) {
+ if (scrollbar_controller && scrollbar_controller->Animate(time)) {
TRACE_EVENT_INSTANT0(
"cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars");
client_->SetNeedsRedrawOnImplThread();
@@ -1866,11 +1866,11 @@ void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer,
ScrollbarAnimationController* scrollbar_controller =
layer->scrollbar_animation_controller();
- if (scrollbar_controller && scrollbar_controller->isAnimating()) {
- base::TimeDelta delay = scrollbar_controller->delayBeforeStart(time);
+ if (scrollbar_controller && scrollbar_controller->IsAnimating()) {
+ base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time);
if (delay > base::TimeDelta())
client_->RequestScrollbarAnimationOnImplThread(delay);
- else if (scrollbar_controller->animate(time))
+ else if (scrollbar_controller->Animate(time))
client_->SetNeedsRedrawOnImplThread();
}
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index a426d5a..28cdc0c 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -152,11 +152,11 @@ void LayerTreeImpl::SetCurrentlyScrollingLayer(LayerImpl* layer) {
if (currently_scrolling_layer_ &&
currently_scrolling_layer_->scrollbar_animation_controller())
- currently_scrolling_layer_->scrollbar_animation_controller()
- ->didScrollGestureEnd(base::TimeTicks::Now());
+ currently_scrolling_layer_->scrollbar_animation_controller()->
+ DidScrollGestureEnd(base::TimeTicks::Now());
currently_scrolling_layer_ = layer;
if (layer && layer->scrollbar_animation_controller())
- layer->scrollbar_animation_controller()->didScrollGestureBegin();
+ layer->scrollbar_animation_controller()->DidScrollGestureBegin();
}
void LayerTreeImpl::ClearCurrentlyScrollingLayer() {