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 delayed_scrollbar_fade_in_.Cancel(); |
| 111 delayed_scrollbar_fade_out_.Cancel(); | 117 delayed_scrollbar_fade_out_.Cancel(); |
| 112 is_animating_ = true; | 118 is_animating_ = true; |
| 113 last_awaken_time_ = base::TimeTicks(); | 119 last_awaken_time_ = base::TimeTicks(); |
| 114 client_->SetNeedsAnimateForScrollbarAnimation(); | 120 client_->SetNeedsAnimateForScrollbarAnimation(); |
| 115 } | 121 } |
| 116 | 122 |
| 117 void ScrollbarAnimationController::StopAnimation() { | 123 void ScrollbarAnimationController::StopAnimation() { |
| 118 delayed_scrollbar_show_.Cancel(); | 124 delayed_scrollbar_fade_in_.Cancel(); |
| 119 delayed_scrollbar_fade_out_.Cancel(); | 125 delayed_scrollbar_fade_out_.Cancel(); |
| 120 is_animating_ = false; | 126 is_animating_ = false; |
| 127 animation_change_ = NONE; | |
| 121 } | 128 } |
| 122 | 129 |
| 123 void ScrollbarAnimationController::PostDelayedShow() { | 130 void ScrollbarAnimationController::PostDelayedFadeIn() { |
| 124 DCHECK(delayed_scrollbar_fade_out_.IsCancelled()); | 131 DCHECK(delayed_scrollbar_fade_out_.IsCancelled()); |
| 125 delayed_scrollbar_show_.Cancel(); | 132 animation_change_ = FADE_IN; |
| 126 delayed_scrollbar_show_.Reset(base::Bind(&ScrollbarAnimationController::Show, | 133 delayed_scrollbar_fade_in_.Cancel(); |
| 127 weak_factory_.GetWeakPtr())); | 134 delayed_scrollbar_fade_in_.Reset( |
| 128 client_->PostDelayedScrollbarAnimationTask(delayed_scrollbar_show_.callback(), | 135 base::Bind(&ScrollbarAnimationController::StartAnimation, |
| 129 show_delay_); | 136 weak_factory_.GetWeakPtr())); |
| 137 client_->PostDelayedScrollbarAnimationTask( | |
| 138 delayed_scrollbar_fade_in_.callback(), fade_in_delay_); | |
| 130 } | 139 } |
| 131 | 140 |
| 132 void ScrollbarAnimationController::PostDelayedFadeOut(bool on_resize) { | 141 void ScrollbarAnimationController::PostDelayedFadeOut(bool on_resize) { |
| 133 DCHECK(delayed_scrollbar_show_.IsCancelled()); | 142 DCHECK(delayed_scrollbar_fade_in_.IsCancelled()); |
| 143 animation_change_ = FADE_OUT; | |
| 134 base::TimeDelta delay = on_resize ? fade_out_resize_delay_ : fade_out_delay_; | 144 base::TimeDelta delay = on_resize ? fade_out_resize_delay_ : fade_out_delay_; |
| 135 delayed_scrollbar_fade_out_.Cancel(); | 145 delayed_scrollbar_fade_out_.Cancel(); |
| 136 delayed_scrollbar_fade_out_.Reset( | 146 delayed_scrollbar_fade_out_.Reset( |
| 137 base::Bind(&ScrollbarAnimationController::StartAnimation, | 147 base::Bind(&ScrollbarAnimationController::StartAnimation, |
| 138 weak_factory_.GetWeakPtr())); | 148 weak_factory_.GetWeakPtr())); |
| 139 client_->PostDelayedScrollbarAnimationTask( | 149 client_->PostDelayedScrollbarAnimationTask( |
| 140 delayed_scrollbar_fade_out_.callback(), delay); | 150 delayed_scrollbar_fade_out_.callback(), delay); |
| 141 } | 151 } |
| 142 | 152 |
| 143 bool ScrollbarAnimationController::Animate(base::TimeTicks now) { | 153 bool ScrollbarAnimationController::Animate(base::TimeTicks now) { |
| 144 bool animated = false; | 154 bool animated = false; |
| 145 | 155 |
| 146 if (is_animating_) { | 156 if (is_animating_) { |
|
bokan
2017/04/13 15:31:40
Why'd you lose the `&& animation_change_ != NONE`
chaopeng
2017/04/13 15:56:08
animation_change_ must not be NONE if is_animating
bokan
2017/04/13 16:04:54
Ah, got it. Thanks.
| |
| 147 if (last_awaken_time_.is_null()) | 157 if (last_awaken_time_.is_null()) |
| 148 last_awaken_time_ = now; | 158 last_awaken_time_ = now; |
| 149 | 159 |
| 150 float progress = AnimationProgressAtTime(now); | 160 float progress = AnimationProgressAtTime(now); |
| 151 RunAnimationFrame(progress); | 161 RunAnimationFrame(progress); |
| 152 | 162 |
| 153 if (is_animating_) | 163 if (is_animating_) |
| 154 client_->SetNeedsAnimateForScrollbarAnimation(); | 164 client_->SetNeedsAnimateForScrollbarAnimation(); |
| 155 animated = true; | 165 animated = true; |
| 156 } | 166 } |
| 157 | 167 |
| 158 if (need_thinning_animation_) { | 168 if (need_thinning_animation_) { |
| 159 animated |= vertical_controller_->Animate(now); | 169 animated |= vertical_controller_->Animate(now); |
| 160 animated |= horizontal_controller_->Animate(now); | 170 animated |= horizontal_controller_->Animate(now); |
| 161 } | 171 } |
| 162 | 172 |
| 163 return animated; | 173 return animated; |
| 164 } | 174 } |
| 165 | 175 |
| 166 float ScrollbarAnimationController::AnimationProgressAtTime( | 176 float ScrollbarAnimationController::AnimationProgressAtTime( |
| 167 base::TimeTicks now) { | 177 base::TimeTicks now) { |
| 168 base::TimeDelta delta = now - last_awaken_time_; | 178 base::TimeDelta delta = now - last_awaken_time_; |
| 169 float progress = delta.InSecondsF() / fade_out_duration_.InSecondsF(); | 179 base::TimeDelta duration = |
| 180 animation_change_ == FADE_IN ? fade_in_duration_ : fade_out_duration_; | |
| 181 float progress = delta.InSecondsF() / duration.InSecondsF(); | |
| 170 return std::max(std::min(progress, 1.f), 0.f); | 182 return std::max(std::min(progress, 1.f), 0.f); |
| 171 } | 183 } |
| 172 | 184 |
| 173 void ScrollbarAnimationController::RunAnimationFrame(float progress) { | 185 void ScrollbarAnimationController::RunAnimationFrame(float progress) { |
| 174 ApplyOpacityToScrollbars(1.f - progress); | 186 DCHECK(animation_change_ != NONE); |
| 187 float opacity; | |
| 188 | |
| 189 if (animation_change_ == FADE_IN) { | |
| 190 opacity = std::max(progress, opacity_); | |
| 191 } else { | |
| 192 opacity = std::min(1.f - progress, opacity_); | |
| 193 } | |
| 194 | |
| 195 ApplyOpacityToScrollbars(opacity); | |
| 175 if (progress == 1.f) | 196 if (progress == 1.f) |
| 176 StopAnimation(); | 197 StopAnimation(); |
| 177 } | 198 } |
| 178 | 199 |
| 179 void ScrollbarAnimationController::DidScrollBegin() { | 200 void ScrollbarAnimationController::DidScrollBegin() { |
| 180 currently_scrolling_ = true; | 201 currently_scrolling_ = true; |
| 181 } | 202 } |
| 182 | 203 |
| 183 void ScrollbarAnimationController::DidScrollEnd() { | 204 void ScrollbarAnimationController::DidScrollEnd() { |
| 184 bool has_scrolled = show_in_fast_scroll_; | 205 bool has_scrolled = show_in_fast_scroll_; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 PostDelayedFadeOut(false); | 282 PostDelayedFadeOut(false); |
| 262 } | 283 } |
| 263 | 284 |
| 264 void ScrollbarAnimationController::DidMouseLeave() { | 285 void ScrollbarAnimationController::DidMouseLeave() { |
| 265 if (!need_thinning_animation_) | 286 if (!need_thinning_animation_) |
| 266 return; | 287 return; |
| 267 | 288 |
| 268 vertical_controller_->DidMouseLeave(); | 289 vertical_controller_->DidMouseLeave(); |
| 269 horizontal_controller_->DidMouseLeave(); | 290 horizontal_controller_->DidMouseLeave(); |
| 270 | 291 |
| 271 delayed_scrollbar_show_.Cancel(); | 292 delayed_scrollbar_fade_in_.Cancel(); |
| 272 need_trigger_scrollbar_show_ = false; | 293 need_trigger_scrollbar_show_ = false; |
| 273 | 294 |
| 274 if (ScrollbarsHidden() || Captured()) | 295 if (ScrollbarsHidden() || Captured()) |
| 275 return; | 296 return; |
| 276 | 297 |
| 277 PostDelayedFadeOut(false); | 298 PostDelayedFadeOut(false); |
| 278 } | 299 } |
| 279 | 300 |
| 280 void ScrollbarAnimationController::DidMouseMoveNear( | 301 void ScrollbarAnimationController::DidMouseMoveNear( |
| 281 ScrollbarOrientation orientation, | 302 ScrollbarOrientation orientation, |
| 282 float distance) { | 303 float distance) { |
| 283 if (!need_thinning_animation_) | 304 if (!need_thinning_animation_) |
| 284 return; | 305 return; |
| 285 | 306 |
| 286 bool need_trigger_scrollbar_show_before = need_trigger_scrollbar_show_; | 307 bool need_trigger_scrollbar_show_before = need_trigger_scrollbar_show_; |
| 287 | 308 |
| 288 GetScrollbarAnimationController(orientation).DidMouseMoveNear(distance); | 309 GetScrollbarAnimationController(orientation).DidMouseMoveNear(distance); |
| 289 | 310 |
| 290 need_trigger_scrollbar_show_ = | 311 need_trigger_scrollbar_show_ = |
| 291 CalcNeedTriggerScrollbarShow(orientation, distance); | 312 CalcNeedTriggerScrollbarShow(orientation, distance); |
| 292 | 313 |
| 293 if (Captured()) | 314 if (Captured()) |
| 294 return; | 315 return; |
| 295 | 316 |
| 296 if (ScrollbarsHidden()) { | 317 if (ScrollbarsHidden()) { |
| 297 if (need_trigger_scrollbar_show_before != need_trigger_scrollbar_show_) { | 318 if (need_trigger_scrollbar_show_before != need_trigger_scrollbar_show_) { |
| 298 if (need_trigger_scrollbar_show_) { | 319 if (need_trigger_scrollbar_show_) { |
| 299 PostDelayedShow(); | 320 PostDelayedFadeIn(); |
| 300 } else { | 321 } else { |
| 301 delayed_scrollbar_show_.Cancel(); | 322 delayed_scrollbar_fade_in_.Cancel(); |
| 302 } | 323 } |
| 303 } | 324 } |
| 304 } else { | 325 } else { |
| 305 if (MouseIsNearAnyScrollbar()) { | 326 if (MouseIsNearAnyScrollbar()) { |
| 306 Show(); | 327 Show(); |
| 307 StopAnimation(); | 328 StopAnimation(); |
| 308 } else if (!is_animating_) { | 329 } else if (!is_animating_) { |
| 309 PostDelayedFadeOut(false); | 330 PostDelayedFadeOut(false); |
| 310 } | 331 } |
| 311 } | 332 } |
| 312 } | 333 } |
| 313 | 334 |
| 314 bool ScrollbarAnimationController::CalcNeedTriggerScrollbarShow( | 335 bool ScrollbarAnimationController::CalcNeedTriggerScrollbarShow( |
| 315 ScrollbarOrientation orientation, | 336 ScrollbarOrientation orientation, |
| 316 float distance) const { | 337 float distance) const { |
| 317 DCHECK(need_thinning_animation_); | 338 DCHECK(need_thinning_animation_); |
| 318 | 339 |
| 319 if (vertical_controller_->mouse_is_over_scrollbar() || | 340 if (vertical_controller_->mouse_is_over_scrollbar() || |
| 320 horizontal_controller_->mouse_is_over_scrollbar()) | 341 horizontal_controller_->mouse_is_over_scrollbar()) |
| 321 return true; | 342 return true; |
| 322 | 343 |
| 323 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 344 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
| 324 if (scrollbar->orientation() != orientation) | 345 if (scrollbar->orientation() != orientation) |
| 325 continue; | 346 continue; |
| 326 | 347 |
| 327 if (distance < kMouseMoveDistanceToTriggerShow) | 348 if (distance < kMouseMoveDistanceToTriggerFadeIn) |
| 328 return true; | 349 return true; |
| 329 } | 350 } |
| 330 | 351 |
| 331 return false; | 352 return false; |
| 332 } | 353 } |
| 333 | 354 |
| 334 bool ScrollbarAnimationController::MouseIsOverScrollbar( | 355 bool ScrollbarAnimationController::MouseIsOverScrollbar( |
| 335 ScrollbarOrientation orientation) const { | 356 ScrollbarOrientation orientation) const { |
| 336 DCHECK(need_thinning_animation_); | 357 DCHECK(need_thinning_animation_); |
| 337 return GetScrollbarAnimationController(orientation).mouse_is_over_scrollbar(); | 358 return GetScrollbarAnimationController(orientation).mouse_is_over_scrollbar(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 352 bool ScrollbarAnimationController::ScrollbarsHidden() const { | 373 bool ScrollbarAnimationController::ScrollbarsHidden() const { |
| 353 return opacity_ == 0.0f; | 374 return opacity_ == 0.0f; |
| 354 } | 375 } |
| 355 | 376 |
| 356 bool ScrollbarAnimationController::Captured() const { | 377 bool ScrollbarAnimationController::Captured() const { |
| 357 DCHECK(need_thinning_animation_); | 378 DCHECK(need_thinning_animation_); |
| 358 return vertical_controller_->captured() || horizontal_controller_->captured(); | 379 return vertical_controller_->captured() || horizontal_controller_->captured(); |
| 359 } | 380 } |
| 360 | 381 |
| 361 void ScrollbarAnimationController::Show() { | 382 void ScrollbarAnimationController::Show() { |
| 362 delayed_scrollbar_show_.Cancel(); | 383 delayed_scrollbar_fade_in_.Cancel(); |
| 363 ApplyOpacityToScrollbars(1.0f); | 384 ApplyOpacityToScrollbars(1.0f); |
| 364 } | 385 } |
| 365 | 386 |
| 366 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { | 387 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { |
| 367 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 388 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
| 368 if (!scrollbar->is_overlay_scrollbar()) | 389 if (!scrollbar->is_overlay_scrollbar()) |
| 369 continue; | 390 continue; |
| 370 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; | 391 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; |
| 371 scrollbar->SetOverlayScrollbarLayerOpacityAnimated(effective_opacity); | 392 scrollbar->SetOverlayScrollbarLayerOpacityAnimated(effective_opacity); |
| 372 } | 393 } |
| 373 | 394 |
| 374 bool previouslyVisible = opacity_ > 0.0f; | 395 bool previouslyVisible = opacity_ > 0.0f; |
| 375 bool currentlyVisible = opacity > 0.0f; | 396 bool currentlyVisible = opacity > 0.0f; |
| 376 | 397 |
| 377 if (opacity_ != opacity) | 398 if (opacity_ != opacity) |
| 378 client_->SetNeedsRedrawForScrollbarAnimation(); | 399 client_->SetNeedsRedrawForScrollbarAnimation(); |
| 379 | 400 |
| 380 opacity_ = opacity; | 401 opacity_ = opacity; |
| 381 | 402 |
| 382 if (previouslyVisible != currentlyVisible) | 403 if (previouslyVisible != currentlyVisible) |
| 383 client_->DidChangeScrollbarVisibility(); | 404 client_->DidChangeScrollbarVisibility(); |
| 384 } | 405 } |
| 385 | 406 |
| 386 } // namespace cc | 407 } // namespace cc |
| OLD | NEW |