| 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" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 | 13 |
| 14 std::unique_ptr<ScrollbarAnimationController> | 14 std::unique_ptr<ScrollbarAnimationController> |
| 15 ScrollbarAnimationController::CreateScrollbarAnimationControllerAndroid( | 15 ScrollbarAnimationController::CreateScrollbarAnimationControllerAndroid( |
| 16 ElementId scroll_element_id, | 16 ElementId scroll_element_id, |
| 17 ScrollbarAnimationControllerClient* client, | 17 ScrollbarAnimationControllerClient* client, |
| 18 base::TimeDelta fade_delay, | 18 base::TimeDelta fade_delay, |
| 19 base::TimeDelta fade_duration) { | 19 base::TimeDelta fade_duration, |
| 20 float initial_opacity) { |
| 20 return base::WrapUnique(new ScrollbarAnimationController( | 21 return base::WrapUnique(new ScrollbarAnimationController( |
| 21 scroll_element_id, client, fade_delay, fade_duration)); | 22 scroll_element_id, client, fade_delay, fade_duration, initial_opacity)); |
| 22 } | 23 } |
| 23 | 24 |
| 24 std::unique_ptr<ScrollbarAnimationController> | 25 std::unique_ptr<ScrollbarAnimationController> |
| 25 ScrollbarAnimationController::CreateScrollbarAnimationControllerAuraOverlay( | 26 ScrollbarAnimationController::CreateScrollbarAnimationControllerAuraOverlay( |
| 26 ElementId scroll_element_id, | 27 ElementId scroll_element_id, |
| 27 ScrollbarAnimationControllerClient* client, | 28 ScrollbarAnimationControllerClient* client, |
| 28 base::TimeDelta fade_delay, | 29 base::TimeDelta fade_delay, |
| 29 base::TimeDelta fade_duration, | 30 base::TimeDelta fade_duration, |
| 30 base::TimeDelta thinning_duration) { | 31 base::TimeDelta thinning_duration, |
| 32 float initial_opacity) { |
| 31 return base::WrapUnique(new ScrollbarAnimationController( | 33 return base::WrapUnique(new ScrollbarAnimationController( |
| 32 scroll_element_id, client, fade_delay, fade_duration, thinning_duration)); | 34 scroll_element_id, client, fade_delay, fade_duration, thinning_duration, |
| 35 initial_opacity)); |
| 33 } | 36 } |
| 34 | 37 |
| 35 ScrollbarAnimationController::ScrollbarAnimationController( | 38 ScrollbarAnimationController::ScrollbarAnimationController( |
| 36 ElementId scroll_element_id, | 39 ElementId scroll_element_id, |
| 37 ScrollbarAnimationControllerClient* client, | 40 ScrollbarAnimationControllerClient* client, |
| 38 base::TimeDelta fade_delay, | 41 base::TimeDelta fade_delay, |
| 39 base::TimeDelta fade_duration) | 42 base::TimeDelta fade_duration, |
| 43 float initial_opacity) |
| 40 : client_(client), | 44 : client_(client), |
| 41 fade_delay_(fade_delay), | 45 fade_delay_(fade_delay), |
| 42 fade_duration_(fade_duration), | 46 fade_duration_(fade_duration), |
| 43 need_trigger_scrollbar_fade_in_(false), | 47 need_trigger_scrollbar_fade_in_(false), |
| 44 is_animating_(false), | 48 is_animating_(false), |
| 45 animation_change_(NONE), | 49 animation_change_(NONE), |
| 46 scroll_element_id_(scroll_element_id), | 50 scroll_element_id_(scroll_element_id), |
| 47 currently_scrolling_(false), | 51 currently_scrolling_(false), |
| 48 show_in_fast_scroll_(false), | 52 show_in_fast_scroll_(false), |
| 49 opacity_(0.0f), | 53 opacity_(initial_opacity), |
| 50 show_scrollbars_on_scroll_gesture_(false), | 54 show_scrollbars_on_scroll_gesture_(false), |
| 51 need_thinning_animation_(false), | 55 need_thinning_animation_(false), |
| 52 weak_factory_(this) { | 56 weak_factory_(this) {} |
| 53 ApplyOpacityToScrollbars(0.0f); | |
| 54 } | |
| 55 | 57 |
| 56 ScrollbarAnimationController::ScrollbarAnimationController( | 58 ScrollbarAnimationController::ScrollbarAnimationController( |
| 57 ElementId scroll_element_id, | 59 ElementId scroll_element_id, |
| 58 ScrollbarAnimationControllerClient* client, | 60 ScrollbarAnimationControllerClient* client, |
| 59 base::TimeDelta fade_delay, | 61 base::TimeDelta fade_delay, |
| 60 base::TimeDelta fade_duration, | 62 base::TimeDelta fade_duration, |
| 61 base::TimeDelta thinning_duration) | 63 base::TimeDelta thinning_duration, |
| 64 float initial_opacity) |
| 62 : client_(client), | 65 : client_(client), |
| 63 fade_delay_(fade_delay), | 66 fade_delay_(fade_delay), |
| 64 fade_duration_(fade_duration), | 67 fade_duration_(fade_duration), |
| 65 need_trigger_scrollbar_fade_in_(false), | 68 need_trigger_scrollbar_fade_in_(false), |
| 66 is_animating_(false), | 69 is_animating_(false), |
| 67 animation_change_(NONE), | 70 animation_change_(NONE), |
| 68 scroll_element_id_(scroll_element_id), | 71 scroll_element_id_(scroll_element_id), |
| 69 currently_scrolling_(false), | 72 currently_scrolling_(false), |
| 70 show_in_fast_scroll_(false), | 73 show_in_fast_scroll_(false), |
| 71 opacity_(0.0f), | 74 opacity_(initial_opacity), |
| 72 show_scrollbars_on_scroll_gesture_(true), | 75 show_scrollbars_on_scroll_gesture_(true), |
| 73 need_thinning_animation_(true), | 76 need_thinning_animation_(true), |
| 74 weak_factory_(this) { | 77 weak_factory_(this) { |
| 75 vertical_controller_ = SingleScrollbarAnimationControllerThinning::Create( | 78 vertical_controller_ = SingleScrollbarAnimationControllerThinning::Create( |
| 76 scroll_element_id, ScrollbarOrientation::VERTICAL, client, | 79 scroll_element_id, ScrollbarOrientation::VERTICAL, client, |
| 77 thinning_duration); | 80 thinning_duration); |
| 78 horizontal_controller_ = SingleScrollbarAnimationControllerThinning::Create( | 81 horizontal_controller_ = SingleScrollbarAnimationControllerThinning::Create( |
| 79 scroll_element_id, ScrollbarOrientation::HORIZONTAL, client, | 82 scroll_element_id, ScrollbarOrientation::HORIZONTAL, client, |
| 80 thinning_duration); | 83 thinning_duration); |
| 81 | |
| 82 ApplyOpacityToScrollbars(0.0f); | |
| 83 } | 84 } |
| 84 | 85 |
| 85 ScrollbarAnimationController::~ScrollbarAnimationController() {} | 86 ScrollbarAnimationController::~ScrollbarAnimationController() {} |
| 86 | 87 |
| 87 ScrollbarSet ScrollbarAnimationController::Scrollbars() const { | 88 ScrollbarSet ScrollbarAnimationController::Scrollbars() const { |
| 88 return client_->ScrollbarsFor(scroll_element_id_); | 89 return client_->ScrollbarsFor(scroll_element_id_); |
| 89 } | 90 } |
| 90 | 91 |
| 91 SingleScrollbarAnimationControllerThinning& | 92 SingleScrollbarAnimationControllerThinning& |
| 92 ScrollbarAnimationController::GetScrollbarAnimationController( | 93 ScrollbarAnimationController::GetScrollbarAnimationController( |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (opacity_ != opacity) | 347 if (opacity_ != opacity) |
| 347 client_->SetNeedsRedrawForScrollbarAnimation(); | 348 client_->SetNeedsRedrawForScrollbarAnimation(); |
| 348 | 349 |
| 349 opacity_ = opacity; | 350 opacity_ = opacity; |
| 350 | 351 |
| 351 if (previouslyVisible != currentlyVisible) | 352 if (previouslyVisible != currentlyVisible) |
| 352 client_->DidChangeScrollbarVisibility(); | 353 client_->DidChangeScrollbarVisibility(); |
| 353 } | 354 } |
| 354 | 355 |
| 355 } // namespace cc | 356 } // namespace cc |
| OLD | NEW |