| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 5 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 float | 131 float |
| 132 ScrollbarAnimationControllerThinning::ThumbThicknessScaleAtAnimationProgress( | 132 ScrollbarAnimationControllerThinning::ThumbThicknessScaleAtAnimationProgress( |
| 133 float progress) { | 133 float progress) { |
| 134 const float kIdleThicknessScale = 0.4f; | 134 const float kIdleThicknessScale = 0.4f; |
| 135 | 135 |
| 136 return ((1.f - kIdleThicknessScale) * (1.f - progress)) + kIdleThicknessScale; | 136 return ((1.f - kIdleThicknessScale) * (1.f - progress)) + kIdleThicknessScale; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void ScrollbarAnimationControllerThinning::ApplyOpacityAndThumbThicknessScale( | 139 void ScrollbarAnimationControllerThinning::ApplyOpacityAndThumbThicknessScale( |
| 140 float opacity, float thumb_thickness_scale) { | 140 float opacity, float thumb_thickness_scale) { |
| 141 ScrollbarLayerImplBase* horizontal_scrollbar = | 141 if (!scroll_layer_->scrollbars()) |
| 142 scroll_layer_->horizontal_scrollbar_layer(); | 142 return; |
| 143 if (horizontal_scrollbar) { | |
| 144 horizontal_scrollbar->SetOpacity(opacity); | |
| 145 horizontal_scrollbar->set_thumb_thickness_scale_factor( | |
| 146 thumb_thickness_scale); | |
| 147 } | |
| 148 | 143 |
| 149 ScrollbarLayerImplBase* vertical_scrollbar = | 144 LayerImpl::ScrollbarSet* scrollbars = scroll_layer_->scrollbars(); |
| 150 scroll_layer_->vertical_scrollbar_layer(); | 145 for (LayerImpl::ScrollbarSet::iterator it = scrollbars->begin(); |
| 151 if (vertical_scrollbar) { | 146 it != scrollbars->end(); |
| 152 vertical_scrollbar->SetOpacity(opacity); | 147 ++it) { |
| 153 vertical_scrollbar->set_thumb_thickness_scale_factor(thumb_thickness_scale); | 148 ScrollbarLayerImplBase* scrollbar = *it; |
| 149 if (scrollbar->opacity_can_animate()) { |
| 150 scrollbar->SetOpacity(opacity); |
| 151 scrollbar->set_thumb_thickness_scale_factor(thumb_thickness_scale); |
| 152 } |
| 154 } | 153 } |
| 155 } | 154 } |
| 156 | 155 |
| 157 } // namespace cc | 156 } // namespace cc |
| OLD | NEW |