Simplify web_view.js
[chromium-blink-merge.git] / cc / animation / scrollbar_animation_controller_linear_fade.cc
blob1b5dfd933daf117cdacc272b4d9cdb11c26d2def
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
3 // found in the LICENSE file.
5 #include "cc/animation/scrollbar_animation_controller_linear_fade.h"
7 #include "base/time/time.h"
8 #include "cc/layers/layer_impl.h"
9 #include "cc/layers/scrollbar_layer_impl_base.h"
11 namespace cc {
13 scoped_ptr<ScrollbarAnimationControllerLinearFade>
14 ScrollbarAnimationControllerLinearFade::Create(
15 LayerImpl* scroll_layer,
16 ScrollbarAnimationControllerClient* client,
17 base::TimeDelta delay_before_starting,
18 base::TimeDelta resize_delay_before_starting,
19 base::TimeDelta duration) {
20 return make_scoped_ptr(
21 new ScrollbarAnimationControllerLinearFade(scroll_layer,
22 client,
23 delay_before_starting,
24 resize_delay_before_starting,
25 duration));
28 ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade(
29 LayerImpl* scroll_layer,
30 ScrollbarAnimationControllerClient* client,
31 base::TimeDelta delay_before_starting,
32 base::TimeDelta resize_delay_before_starting,
33 base::TimeDelta duration)
34 : ScrollbarAnimationController(client,
35 delay_before_starting,
36 resize_delay_before_starting,
37 duration),
38 scroll_layer_(scroll_layer) {
41 ScrollbarAnimationControllerLinearFade::
42 ~ScrollbarAnimationControllerLinearFade() {}
44 void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress) {
45 ApplyOpacityToScrollbars(1.f - progress);
46 if (progress == 1.f)
47 StopAnimation();
50 void ScrollbarAnimationControllerLinearFade::DidScrollUpdate(bool on_resize) {
51 ScrollbarAnimationController::DidScrollUpdate(on_resize);
52 ApplyOpacityToScrollbars(1.f);
55 void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars(
56 float opacity) {
57 if (!scroll_layer_->scrollbars())
58 return;
60 LayerImpl::ScrollbarSet* scrollbars = scroll_layer_->scrollbars();
61 for (LayerImpl::ScrollbarSet::iterator it = scrollbars->begin();
62 it != scrollbars->end();
63 ++it) {
64 ScrollbarLayerImplBase* scrollbar = *it;
66 if (scrollbar->is_overlay_scrollbar())
67 scrollbar->SetOpacity(scrollbar->CanScrollOrientation() ? opacity : 0);
71 } // namespace cc