Chromium Code Reviews| 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 int scroll_layer_id, | 16 int scroll_layer_id, |
| 17 ScrollbarAnimationControllerClient* client, | 17 ScrollbarAnimationControllerClient* client, |
| 18 base::TimeDelta fade_out_delay, | 18 base::TimeDelta fade_out_delay, |
| 19 base::TimeDelta fade_out_resize_delay, | 19 base::TimeDelta fade_out_resize_delay, |
| 20 base::TimeDelta fade_out_duration) { | 20 base::TimeDelta fade_out_duration) { |
| 21 return base::WrapUnique(new ScrollbarAnimationController( | 21 return base::WrapUnique(new ScrollbarAnimationController( |
| 22 scroll_layer_id, client, fade_out_delay, fade_out_resize_delay, | 22 scroll_layer_id, client, fade_out_delay, fade_out_resize_delay, |
| 23 fade_out_duration)); | 23 fade_out_duration)); |
| 24 } | 24 } |
| 25 | 25 |
| 26 std::unique_ptr<ScrollbarAnimationController> | 26 std::unique_ptr<ScrollbarAnimationController> |
| 27 ScrollbarAnimationController::CreateScrollbarAnimationControllerAuraOverlay( | 27 ScrollbarAnimationController::CreateScrollbarAnimationControllerAuraOverlay( |
| 28 int scroll_layer_id, | 28 int scroll_layer_id, |
| 29 ScrollbarAnimationControllerClient* client, | 29 ScrollbarAnimationControllerClient* client, |
| 30 base::TimeDelta show_delay, | 30 base::TimeDelta fade_in_delay, |
| 31 base::TimeDelta fade_out_delay, | 31 base::TimeDelta fade_out_delay, |
| 32 base::TimeDelta fade_out_resize_delay, | 32 base::TimeDelta fade_out_resize_delay, |
| 33 base::TimeDelta fade_in_duration, | |
| 33 base::TimeDelta fade_out_duration, | 34 base::TimeDelta fade_out_duration, |
| 34 base::TimeDelta thinning_duration) { | 35 base::TimeDelta thinning_duration) { |
| 35 return base::WrapUnique(new ScrollbarAnimationController( | 36 return base::WrapUnique(new ScrollbarAnimationController( |
| 36 scroll_layer_id, client, show_delay, fade_out_delay, | 37 scroll_layer_id, client, fade_in_delay, fade_out_delay, |
| 37 fade_out_resize_delay, fade_out_duration, thinning_duration)); | 38 fade_out_resize_delay, fade_in_duration, fade_out_duration, |
| 39 thinning_duration)); | |
| 38 } | 40 } |
| 39 | 41 |
| 40 ScrollbarAnimationController::ScrollbarAnimationController( | 42 ScrollbarAnimationController::ScrollbarAnimationController( |
| 41 int scroll_layer_id, | 43 int scroll_layer_id, |
| 42 ScrollbarAnimationControllerClient* client, | 44 ScrollbarAnimationControllerClient* client, |
| 43 base::TimeDelta fade_out_delay, | 45 base::TimeDelta fade_out_delay, |
| 44 base::TimeDelta fade_out_resize_delay, | 46 base::TimeDelta fade_out_resize_delay, |
| 45 base::TimeDelta fade_out_duration) | 47 base::TimeDelta fade_out_duration) |
| 46 : client_(client), | 48 : client_(client), |
| 47 fade_out_delay_(fade_out_delay), | 49 fade_out_delay_(fade_out_delay), |
| 48 fade_out_resize_delay_(fade_out_resize_delay), | 50 fade_out_resize_delay_(fade_out_resize_delay), |
| 51 fade_out_duration_(fade_out_duration), | |
| 49 need_trigger_scrollbar_show_(false), | 52 need_trigger_scrollbar_show_(false), |
| 50 is_animating_(false), | 53 is_animating_(false), |
| 54 animation_change_(NONE), | |
| 51 scroll_layer_id_(scroll_layer_id), | 55 scroll_layer_id_(scroll_layer_id), |
| 52 currently_scrolling_(false), | 56 currently_scrolling_(false), |
| 53 show_in_fast_scroll_(false), | 57 show_in_fast_scroll_(false), |
| 54 opacity_(0.0f), | 58 opacity_(0.0f), |
| 55 fade_out_duration_(fade_out_duration), | |
| 56 show_scrollbars_on_scroll_gesture_(false), | 59 show_scrollbars_on_scroll_gesture_(false), |
| 57 need_thinning_animation_(false), | 60 need_thinning_animation_(false), |
| 58 weak_factory_(this) { | 61 weak_factory_(this) { |
| 59 ApplyOpacityToScrollbars(0.0f); | 62 ApplyOpacityToScrollbars(0.0f); |
| 60 } | 63 } |
| 61 | 64 |
| 62 ScrollbarAnimationController::ScrollbarAnimationController( | 65 ScrollbarAnimationController::ScrollbarAnimationController( |
| 63 int scroll_layer_id, | 66 int scroll_layer_id, |
| 64 ScrollbarAnimationControllerClient* client, | 67 ScrollbarAnimationControllerClient* client, |
| 65 base::TimeDelta show_delay, | 68 base::TimeDelta fade_in_delay, |
| 66 base::TimeDelta fade_out_delay, | 69 base::TimeDelta fade_out_delay, |
| 67 base::TimeDelta fade_out_resize_delay, | 70 base::TimeDelta fade_out_resize_delay, |
| 71 base::TimeDelta fade_in_duration, | |
| 68 base::TimeDelta fade_out_duration, | 72 base::TimeDelta fade_out_duration, |
| 69 base::TimeDelta thinning_duration) | 73 base::TimeDelta thinning_duration) |
| 70 : client_(client), | 74 : client_(client), |
| 71 show_delay_(show_delay), | 75 fade_in_delay_(fade_in_delay), |
| 72 fade_out_delay_(fade_out_delay), | 76 fade_out_delay_(fade_out_delay), |
| 73 fade_out_resize_delay_(fade_out_resize_delay), | 77 fade_out_resize_delay_(fade_out_resize_delay), |
| 78 fade_in_duration_(fade_in_duration), | |
| 79 fade_out_duration_(fade_out_duration), | |
| 74 need_trigger_scrollbar_show_(false), | 80 need_trigger_scrollbar_show_(false), |
| 75 is_animating_(false), | 81 is_animating_(false), |
| 82 animation_change_(NONE), | |
| 76 scroll_layer_id_(scroll_layer_id), | 83 scroll_layer_id_(scroll_layer_id), |
| 77 currently_scrolling_(false), | 84 currently_scrolling_(false), |
| 78 show_in_fast_scroll_(false), | 85 show_in_fast_scroll_(false), |
| 79 opacity_(0.0f), | 86 opacity_(0.0f), |
| 80 fade_out_duration_(fade_out_duration), | |
| 81 show_scrollbars_on_scroll_gesture_(true), | 87 show_scrollbars_on_scroll_gesture_(true), |
| 82 need_thinning_animation_(true), | 88 need_thinning_animation_(true), |
| 83 weak_factory_(this) { | 89 weak_factory_(this) { |
| 84 vertical_controller_ = SingleScrollbarAnimationControllerThinning::Create( | 90 vertical_controller_ = SingleScrollbarAnimationControllerThinning::Create( |
| 85 scroll_layer_id, ScrollbarOrientation::VERTICAL, client, | 91 scroll_layer_id, ScrollbarOrientation::VERTICAL, client, |
| 86 thinning_duration); | 92 thinning_duration); |
| 87 horizontal_controller_ = SingleScrollbarAnimationControllerThinning::Create( | 93 horizontal_controller_ = SingleScrollbarAnimationControllerThinning::Create( |
| 88 scroll_layer_id, ScrollbarOrientation::HORIZONTAL, client, | 94 scroll_layer_id, ScrollbarOrientation::HORIZONTAL, client, |
| 89 thinning_duration); | 95 thinning_duration); |
| 90 ApplyOpacityToScrollbars(0.0f); | 96 ApplyOpacityToScrollbars(0.0f); |
| 91 } | 97 } |
| 92 | 98 |
| 93 ScrollbarAnimationController::~ScrollbarAnimationController() {} | 99 ScrollbarAnimationController::~ScrollbarAnimationController() {} |
| 94 | 100 |
| 95 ScrollbarSet ScrollbarAnimationController::Scrollbars() const { | 101 ScrollbarSet ScrollbarAnimationController::Scrollbars() const { |
| 96 return client_->ScrollbarsFor(scroll_layer_id_); | 102 return client_->ScrollbarsFor(scroll_layer_id_); |
| 97 } | 103 } |
| 98 | 104 |
| 99 SingleScrollbarAnimationControllerThinning& | 105 SingleScrollbarAnimationControllerThinning& |
| 100 ScrollbarAnimationController::GetScrollbarAnimationController( | 106 ScrollbarAnimationController::GetScrollbarAnimationController( |
| 101 ScrollbarOrientation orientation) const { | 107 ScrollbarOrientation orientation) const { |
| 102 DCHECK(need_thinning_animation_); | 108 DCHECK(need_thinning_animation_); |
| 103 if (orientation == ScrollbarOrientation::VERTICAL) | 109 if (orientation == ScrollbarOrientation::VERTICAL) |
| 104 return *(vertical_controller_.get()); | 110 return *(vertical_controller_.get()); |
| 105 else | 111 else |
| 106 return *(horizontal_controller_.get()); | 112 return *(horizontal_controller_.get()); |
| 107 } | 113 } |
| 108 | 114 |
| 109 void ScrollbarAnimationController::StartAnimation() { | 115 void ScrollbarAnimationController::StartAnimation() { |
| 110 delayed_scrollbar_show_.Cancel(); | 116 DCHECK(animation_change_ != NONE); |
| 117 delayed_scrollbar_fade_in_.Cancel(); | |
| 111 delayed_scrollbar_fade_out_.Cancel(); | 118 delayed_scrollbar_fade_out_.Cancel(); |
| 112 is_animating_ = true; | 119 is_animating_ = true; |
| 113 last_awaken_time_ = base::TimeTicks(); | 120 last_awaken_time_ = base::TimeTicks(); |
| 114 client_->SetNeedsAnimateForScrollbarAnimation(); | 121 client_->SetNeedsAnimateForScrollbarAnimation(); |
| 115 } | 122 } |
| 116 | 123 |
| 117 void ScrollbarAnimationController::StopAnimation() { | 124 void ScrollbarAnimationController::StopAnimation() { |
| 118 delayed_scrollbar_show_.Cancel(); | 125 delayed_scrollbar_fade_in_.Cancel(); |
| 119 delayed_scrollbar_fade_out_.Cancel(); | 126 delayed_scrollbar_fade_out_.Cancel(); |
| 120 is_animating_ = false; | 127 is_animating_ = false; |
| 128 animation_change_ = NONE; | |
| 121 } | 129 } |
| 122 | 130 |
| 123 void ScrollbarAnimationController::PostDelayedShow() { | 131 void ScrollbarAnimationController::PostDelayedFadeIn() { |
| 124 DCHECK(delayed_scrollbar_fade_out_.IsCancelled()); | 132 DCHECK(delayed_scrollbar_fade_out_.IsCancelled()); |
|
weiliangc
2017/04/18 16:45:21
Could this happen in the middle of FadeOut animati
| |
| 125 delayed_scrollbar_show_.Cancel(); | 133 animation_change_ = FADE_IN; |
| 126 delayed_scrollbar_show_.Reset(base::Bind(&ScrollbarAnimationController::Show, | 134 delayed_scrollbar_fade_in_.Cancel(); |
| 127 weak_factory_.GetWeakPtr())); | 135 delayed_scrollbar_fade_in_.Reset( |
| 128 client_->PostDelayedScrollbarAnimationTask(delayed_scrollbar_show_.callback(), | 136 base::Bind(&ScrollbarAnimationController::StartAnimation, |
| 129 show_delay_); | 137 weak_factory_.GetWeakPtr())); |
| 138 client_->PostDelayedScrollbarAnimationTask( | |
| 139 delayed_scrollbar_fade_in_.callback(), fade_in_delay_); | |
| 130 } | 140 } |
| 131 | 141 |
| 132 void ScrollbarAnimationController::PostDelayedFadeOut(bool on_resize) { | 142 void ScrollbarAnimationController::PostDelayedFadeOut(bool on_resize) { |
| 133 DCHECK(delayed_scrollbar_show_.IsCancelled()); | 143 DCHECK(delayed_scrollbar_fade_in_.IsCancelled()); |
| 144 animation_change_ = FADE_OUT; | |
| 134 base::TimeDelta delay = on_resize ? fade_out_resize_delay_ : fade_out_delay_; | 145 base::TimeDelta delay = on_resize ? fade_out_resize_delay_ : fade_out_delay_; |
| 135 delayed_scrollbar_fade_out_.Cancel(); | 146 delayed_scrollbar_fade_out_.Cancel(); |
| 136 delayed_scrollbar_fade_out_.Reset( | 147 delayed_scrollbar_fade_out_.Reset( |
| 137 base::Bind(&ScrollbarAnimationController::StartAnimation, | 148 base::Bind(&ScrollbarAnimationController::StartAnimation, |
| 138 weak_factory_.GetWeakPtr())); | 149 weak_factory_.GetWeakPtr())); |
| 139 client_->PostDelayedScrollbarAnimationTask( | 150 client_->PostDelayedScrollbarAnimationTask( |
| 140 delayed_scrollbar_fade_out_.callback(), delay); | 151 delayed_scrollbar_fade_out_.callback(), delay); |
| 141 } | 152 } |
| 142 | 153 |
| 143 bool ScrollbarAnimationController::Animate(base::TimeTicks now) { | 154 bool ScrollbarAnimationController::Animate(base::TimeTicks now) { |
| 144 bool animated = false; | 155 bool animated = false; |
| 145 | 156 |
| 146 if (is_animating_) { | 157 if (is_animating_) { |
| 158 DCHECK(animation_change_ != NONE); | |
| 147 if (last_awaken_time_.is_null()) | 159 if (last_awaken_time_.is_null()) |
| 148 last_awaken_time_ = now; | 160 last_awaken_time_ = now; |
| 149 | 161 |
| 150 float progress = AnimationProgressAtTime(now); | 162 float progress = AnimationProgressAtTime(now); |
| 151 RunAnimationFrame(progress); | 163 RunAnimationFrame(progress); |
| 152 | 164 |
| 153 if (is_animating_) | 165 if (is_animating_) |
| 154 client_->SetNeedsAnimateForScrollbarAnimation(); | 166 client_->SetNeedsAnimateForScrollbarAnimation(); |
| 155 animated = true; | 167 animated = true; |
| 156 } | 168 } |
| 157 | 169 |
| 158 if (need_thinning_animation_) { | 170 if (need_thinning_animation_) { |
| 159 animated |= vertical_controller_->Animate(now); | 171 animated |= vertical_controller_->Animate(now); |
| 160 animated |= horizontal_controller_->Animate(now); | 172 animated |= horizontal_controller_->Animate(now); |
| 161 } | 173 } |
| 162 | 174 |
| 163 return animated; | 175 return animated; |
| 164 } | 176 } |
| 165 | 177 |
| 166 float ScrollbarAnimationController::AnimationProgressAtTime( | 178 float ScrollbarAnimationController::AnimationProgressAtTime( |
| 167 base::TimeTicks now) { | 179 base::TimeTicks now) { |
| 168 base::TimeDelta delta = now - last_awaken_time_; | 180 base::TimeDelta delta = now - last_awaken_time_; |
| 169 float progress = delta.InSecondsF() / fade_out_duration_.InSecondsF(); | 181 base::TimeDelta duration = |
| 182 animation_change_ == FADE_IN ? fade_in_duration_ : fade_out_duration_; | |
| 183 float progress = delta.InSecondsF() / duration.InSecondsF(); | |
| 170 return std::max(std::min(progress, 1.f), 0.f); | 184 return std::max(std::min(progress, 1.f), 0.f); |
| 171 } | 185 } |
| 172 | 186 |
| 173 void ScrollbarAnimationController::RunAnimationFrame(float progress) { | 187 void ScrollbarAnimationController::RunAnimationFrame(float progress) { |
| 174 ApplyOpacityToScrollbars(1.f - progress); | 188 float opacity; |
| 189 | |
| 190 DCHECK(animation_change_ != NONE); | |
| 191 if (animation_change_ == FADE_IN) { | |
| 192 opacity = std::max(progress, opacity_); | |
| 193 } else { | |
| 194 opacity = std::min(1.f - progress, opacity_); | |
| 195 } | |
| 196 | |
| 197 ApplyOpacityToScrollbars(opacity); | |
| 175 if (progress == 1.f) | 198 if (progress == 1.f) |
| 176 StopAnimation(); | 199 StopAnimation(); |
| 177 } | 200 } |
| 178 | 201 |
| 179 void ScrollbarAnimationController::DidScrollBegin() { | 202 void ScrollbarAnimationController::DidScrollBegin() { |
| 180 currently_scrolling_ = true; | 203 currently_scrolling_ = true; |
| 181 } | 204 } |
| 182 | 205 |
| 183 void ScrollbarAnimationController::DidScrollEnd() { | 206 void ScrollbarAnimationController::DidScrollEnd() { |
| 184 bool has_scrolled = show_in_fast_scroll_; | 207 bool has_scrolled = show_in_fast_scroll_; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 PostDelayedFadeOut(false); | 284 PostDelayedFadeOut(false); |
| 262 } | 285 } |
| 263 | 286 |
| 264 void ScrollbarAnimationController::DidMouseLeave() { | 287 void ScrollbarAnimationController::DidMouseLeave() { |
| 265 if (!need_thinning_animation_) | 288 if (!need_thinning_animation_) |
| 266 return; | 289 return; |
| 267 | 290 |
| 268 vertical_controller_->DidMouseLeave(); | 291 vertical_controller_->DidMouseLeave(); |
| 269 horizontal_controller_->DidMouseLeave(); | 292 horizontal_controller_->DidMouseLeave(); |
| 270 | 293 |
| 271 delayed_scrollbar_show_.Cancel(); | 294 delayed_scrollbar_fade_in_.Cancel(); |
| 272 need_trigger_scrollbar_show_ = false; | 295 need_trigger_scrollbar_show_ = false; |
| 273 | 296 |
| 274 if (ScrollbarsHidden() || Captured()) | 297 if (ScrollbarsHidden() || Captured()) |
| 275 return; | 298 return; |
| 276 | 299 |
| 277 PostDelayedFadeOut(false); | 300 PostDelayedFadeOut(false); |
| 278 } | 301 } |
| 279 | 302 |
| 280 void ScrollbarAnimationController::DidMouseMoveNear( | 303 void ScrollbarAnimationController::DidMouseMoveNear( |
| 281 ScrollbarOrientation orientation, | 304 ScrollbarOrientation orientation, |
| 282 float distance) { | 305 float distance) { |
| 283 if (!need_thinning_animation_) | 306 if (!need_thinning_animation_) |
| 284 return; | 307 return; |
| 285 | 308 |
| 286 bool need_trigger_scrollbar_show_before = need_trigger_scrollbar_show_; | 309 bool need_trigger_scrollbar_show_before = need_trigger_scrollbar_show_; |
| 287 | 310 |
| 288 GetScrollbarAnimationController(orientation).DidMouseMoveNear(distance); | 311 GetScrollbarAnimationController(orientation).DidMouseMoveNear(distance); |
| 289 | 312 |
| 290 need_trigger_scrollbar_show_ = | 313 need_trigger_scrollbar_show_ = |
| 291 CalcNeedTriggerScrollbarShow(orientation, distance); | 314 CalcNeedTriggerScrollbarShow(orientation, distance); |
| 292 | 315 |
| 293 if (Captured()) | 316 if (Captured()) |
| 294 return; | 317 return; |
| 295 | 318 |
| 296 if (ScrollbarsHidden()) { | 319 if (ScrollbarsHidden()) { |
| 297 if (need_trigger_scrollbar_show_before != need_trigger_scrollbar_show_) { | 320 if (need_trigger_scrollbar_show_before != need_trigger_scrollbar_show_) { |
| 298 if (need_trigger_scrollbar_show_) { | 321 if (need_trigger_scrollbar_show_) { |
| 299 PostDelayedShow(); | 322 PostDelayedFadeIn(); |
| 300 } else { | 323 } else { |
| 301 delayed_scrollbar_show_.Cancel(); | 324 delayed_scrollbar_fade_in_.Cancel(); |
| 302 } | 325 } |
| 303 } | 326 } |
| 304 } else { | 327 } else { |
| 305 if (MouseIsNearAnyScrollbar()) { | 328 if (MouseIsNearAnyScrollbar()) { |
| 306 Show(); | 329 Show(); |
| 307 StopAnimation(); | 330 StopAnimation(); |
| 308 } else if (!is_animating_) { | 331 } else if (!is_animating_) { |
| 309 PostDelayedFadeOut(false); | 332 PostDelayedFadeOut(false); |
| 310 } | 333 } |
| 311 } | 334 } |
| 312 } | 335 } |
| 313 | 336 |
| 314 bool ScrollbarAnimationController::CalcNeedTriggerScrollbarShow( | 337 bool ScrollbarAnimationController::CalcNeedTriggerScrollbarShow( |
| 315 ScrollbarOrientation orientation, | 338 ScrollbarOrientation orientation, |
| 316 float distance) const { | 339 float distance) const { |
| 317 DCHECK(need_thinning_animation_); | 340 DCHECK(need_thinning_animation_); |
| 318 | 341 |
| 319 if (vertical_controller_->mouse_is_over_scrollbar() || | 342 if (vertical_controller_->mouse_is_over_scrollbar() || |
| 320 horizontal_controller_->mouse_is_over_scrollbar()) | 343 horizontal_controller_->mouse_is_over_scrollbar()) |
| 321 return true; | 344 return true; |
| 322 | 345 |
| 323 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 346 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
| 324 if (scrollbar->orientation() != orientation) | 347 if (scrollbar->orientation() != orientation) |
| 325 continue; | 348 continue; |
| 326 | 349 |
| 327 if (distance < kMouseMoveDistanceToTriggerShow) | 350 if (distance < kMouseMoveDistanceToTriggerFadeIn) |
| 328 return true; | 351 return true; |
| 329 } | 352 } |
| 330 | 353 |
| 331 return false; | 354 return false; |
| 332 } | 355 } |
| 333 | 356 |
| 334 bool ScrollbarAnimationController::MouseIsOverScrollbar( | 357 bool ScrollbarAnimationController::MouseIsOverScrollbar( |
| 335 ScrollbarOrientation orientation) const { | 358 ScrollbarOrientation orientation) const { |
| 336 DCHECK(need_thinning_animation_); | 359 DCHECK(need_thinning_animation_); |
| 337 return GetScrollbarAnimationController(orientation).mouse_is_over_scrollbar(); | 360 return GetScrollbarAnimationController(orientation).mouse_is_over_scrollbar(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 352 bool ScrollbarAnimationController::ScrollbarsHidden() const { | 375 bool ScrollbarAnimationController::ScrollbarsHidden() const { |
| 353 return opacity_ == 0.0f; | 376 return opacity_ == 0.0f; |
| 354 } | 377 } |
| 355 | 378 |
| 356 bool ScrollbarAnimationController::Captured() const { | 379 bool ScrollbarAnimationController::Captured() const { |
| 357 DCHECK(need_thinning_animation_); | 380 DCHECK(need_thinning_animation_); |
| 358 return vertical_controller_->captured() || horizontal_controller_->captured(); | 381 return vertical_controller_->captured() || horizontal_controller_->captured(); |
| 359 } | 382 } |
| 360 | 383 |
| 361 void ScrollbarAnimationController::Show() { | 384 void ScrollbarAnimationController::Show() { |
| 362 delayed_scrollbar_show_.Cancel(); | 385 delayed_scrollbar_fade_in_.Cancel(); |
| 363 ApplyOpacityToScrollbars(1.0f); | 386 ApplyOpacityToScrollbars(1.0f); |
| 364 } | 387 } |
| 365 | 388 |
| 366 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { | 389 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { |
| 367 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 390 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
| 368 if (!scrollbar->is_overlay_scrollbar()) | 391 if (!scrollbar->is_overlay_scrollbar()) |
| 369 continue; | 392 continue; |
| 370 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; | 393 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; |
| 371 scrollbar->SetOverlayScrollbarLayerOpacityAnimated(effective_opacity); | 394 scrollbar->SetOverlayScrollbarLayerOpacityAnimated(effective_opacity); |
| 372 } | 395 } |
| 373 | 396 |
| 374 bool previouslyVisible = opacity_ > 0.0f; | 397 bool previouslyVisible = opacity_ > 0.0f; |
| 375 bool currentlyVisible = opacity > 0.0f; | 398 bool currentlyVisible = opacity > 0.0f; |
| 376 | 399 |
| 377 if (opacity_ != opacity) | 400 if (opacity_ != opacity) |
| 378 client_->SetNeedsRedrawForScrollbarAnimation(); | 401 client_->SetNeedsRedrawForScrollbarAnimation(); |
| 379 | 402 |
| 380 opacity_ = opacity; | 403 opacity_ = opacity; |
| 381 | 404 |
| 382 if (previouslyVisible != currentlyVisible) | 405 if (previouslyVisible != currentlyVisible) |
| 383 client_->DidChangeScrollbarVisibility(); | 406 client_->DidChangeScrollbarVisibility(); |
| 384 } | 407 } |
| 385 | 408 |
| 386 } // namespace cc | 409 } // namespace cc |
| OLD | NEW |