| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/input/scrollbar_animation_controller.h" | 5 #include "cc/input/scrollbar_animation_controller.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/trees/layer_tree_impl.h" | 10 #include "cc/trees/layer_tree_impl.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 void ScrollbarAnimationController::RunAnimationFrame(float progress) { | 157 void ScrollbarAnimationController::RunAnimationFrame(float progress) { |
| 158 float opacity; | 158 float opacity; |
| 159 | 159 |
| 160 DCHECK(animation_change_ != NONE); | 160 DCHECK(animation_change_ != NONE); |
| 161 if (animation_change_ == FADE_IN) { | 161 if (animation_change_ == FADE_IN) { |
| 162 opacity = std::max(progress, opacity_); | 162 opacity = std::max(progress, opacity_); |
| 163 } else { | 163 } else { |
| 164 opacity = std::min(1.f - progress, opacity_); | 164 opacity = std::min(1.f - progress, opacity_); |
| 165 } | 165 } |
| 166 | 166 |
| 167 NotifyScrollbarLayersOfOpacityAnimation(opacity); |
| 167 ApplyOpacityToScrollbars(opacity); | 168 ApplyOpacityToScrollbars(opacity); |
| 168 if (progress == 1.f) | 169 if (progress == 1.f) |
| 169 StopAnimation(); | 170 StopAnimation(); |
| 170 } | 171 } |
| 171 | 172 |
| 172 void ScrollbarAnimationController::DidScrollBegin() { | 173 void ScrollbarAnimationController::DidScrollBegin() { |
| 173 currently_scrolling_ = true; | 174 currently_scrolling_ = true; |
| 174 } | 175 } |
| 175 | 176 |
| 176 void ScrollbarAnimationController::DidScrollEnd() { | 177 void ScrollbarAnimationController::DidScrollEnd() { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 324 } |
| 324 | 325 |
| 325 bool ScrollbarAnimationController::Captured() const { | 326 bool ScrollbarAnimationController::Captured() const { |
| 326 DCHECK(need_thinning_animation_); | 327 DCHECK(need_thinning_animation_); |
| 327 return GetScrollbarAnimationController(VERTICAL).captured() || | 328 return GetScrollbarAnimationController(VERTICAL).captured() || |
| 328 GetScrollbarAnimationController(HORIZONTAL).captured(); | 329 GetScrollbarAnimationController(HORIZONTAL).captured(); |
| 329 } | 330 } |
| 330 | 331 |
| 331 void ScrollbarAnimationController::Show() { | 332 void ScrollbarAnimationController::Show() { |
| 332 delayed_scrollbar_animation_.Cancel(); | 333 delayed_scrollbar_animation_.Cancel(); |
| 334 NotifyScrollbarLayersOfOpacityAnimation(1.0f); |
| 333 ApplyOpacityToScrollbars(1.0f); | 335 ApplyOpacityToScrollbars(1.0f); |
| 334 } | 336 } |
| 335 | 337 |
| 336 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { | 338 void ScrollbarAnimationController::NotifyScrollbarLayersOfOpacityAnimation( |
| 339 float opacity) { |
| 337 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 340 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
| 338 DCHECK(scrollbar->is_overlay_scrollbar()); | 341 DCHECK(scrollbar->is_overlay_scrollbar()); |
| 339 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; | 342 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; |
| 340 scrollbar->SetOverlayScrollbarLayerOpacityAnimated(effective_opacity); | 343 scrollbar->SetOverlayScrollbarLayerOpacityAnimated(effective_opacity); |
| 341 } | 344 } |
| 345 } |
| 342 | 346 |
| 347 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { |
| 343 bool previouslyVisible = opacity_ > 0.0f; | 348 bool previouslyVisible = opacity_ > 0.0f; |
| 344 bool currentlyVisible = opacity > 0.0f; | 349 bool currentlyVisible = opacity > 0.0f; |
| 345 | 350 |
| 346 if (opacity_ != opacity) | 351 if (opacity_ != opacity) |
| 347 client_->SetNeedsRedrawForScrollbarAnimation(); | 352 client_->SetNeedsRedrawForScrollbarAnimation(); |
| 348 | 353 |
| 349 opacity_ = opacity; | 354 opacity_ = opacity; |
| 350 | 355 |
| 351 if (previouslyVisible != currentlyVisible) | 356 if (previouslyVisible != currentlyVisible) |
| 352 client_->DidChangeScrollbarVisibility(); | 357 client_->DidChangeScrollbarVisibility(); |
| 353 } | 358 } |
| 354 | 359 |
| 355 } // namespace cc | 360 } // namespace cc |
| OLD | NEW |