| 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/input/top_controls_manager.h" | 5 #include "cc/input/top_controls_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "cc/animation/keyframed_animation_curve.h" | 10 #include "cc/animation/keyframed_animation_curve.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 void TopControlsManager::ScrollBegin() { | 96 void TopControlsManager::ScrollBegin() { |
| 97 DCHECK(!pinch_gesture_active_); | 97 DCHECK(!pinch_gesture_active_); |
| 98 ResetAnimations(); | 98 ResetAnimations(); |
| 99 ResetBaseline(); | 99 ResetBaseline(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 gfx::Vector2dF TopControlsManager::ScrollBy( | 102 gfx::Vector2dF TopControlsManager::ScrollBy( |
| 103 const gfx::Vector2dF& pending_delta) { | 103 const gfx::Vector2dF& pending_delta) { |
| 104 if (!TopControlsHeight()) |
| 105 return pending_delta; |
| 106 |
| 104 if (pinch_gesture_active_) | 107 if (pinch_gesture_active_) |
| 105 return pending_delta; | 108 return pending_delta; |
| 106 | 109 |
| 107 if (permitted_state_ == SHOWN && pending_delta.y() > 0) | 110 if (permitted_state_ == SHOWN && pending_delta.y() > 0) |
| 108 return pending_delta; | 111 return pending_delta; |
| 109 else if (permitted_state_ == HIDDEN && pending_delta.y() < 0) | 112 else if (permitted_state_ == HIDDEN && pending_delta.y() < 0) |
| 110 return pending_delta; | 113 return pending_delta; |
| 111 | 114 |
| 112 accumulated_scroll_delta_ += pending_delta.y(); | 115 accumulated_scroll_delta_ += pending_delta.y(); |
| 113 | 116 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 176 } |
| 174 | 177 |
| 175 void TopControlsManager::SetupAnimation(AnimationDirection direction) { | 178 void TopControlsManager::SetupAnimation(AnimationDirection direction) { |
| 176 DCHECK_NE(NO_ANIMATION, direction); | 179 DCHECK_NE(NO_ANIMATION, direction); |
| 177 DCHECK_IMPLIES(direction == HIDING_CONTROLS, TopControlsShownRatio() > 0.f); | 180 DCHECK_IMPLIES(direction == HIDING_CONTROLS, TopControlsShownRatio() > 0.f); |
| 178 DCHECK_IMPLIES(direction == SHOWING_CONTROLS, TopControlsShownRatio() < 1.f); | 181 DCHECK_IMPLIES(direction == SHOWING_CONTROLS, TopControlsShownRatio() < 1.f); |
| 179 | 182 |
| 180 if (top_controls_animation_ && animation_direction_ == direction) | 183 if (top_controls_animation_ && animation_direction_ == direction) |
| 181 return; | 184 return; |
| 182 | 185 |
| 186 if (!TopControlsHeight()) { |
| 187 client_->SetCurrentTopControlsShownRatio( |
| 188 direction == HIDING_CONTROLS ? 0.f : 1.f); |
| 189 return; |
| 190 } |
| 191 |
| 183 top_controls_animation_ = KeyframedFloatAnimationCurve::Create(); | 192 top_controls_animation_ = KeyframedFloatAnimationCurve::Create(); |
| 184 base::TimeDelta start_time = gfx::FrameTime::Now() - base::TimeTicks(); | 193 base::TimeDelta start_time = gfx::FrameTime::Now() - base::TimeTicks(); |
| 185 top_controls_animation_->AddKeyframe( | 194 top_controls_animation_->AddKeyframe( |
| 186 FloatKeyframe::Create(start_time, TopControlsShownRatio(), nullptr)); | 195 FloatKeyframe::Create(start_time, TopControlsShownRatio(), nullptr)); |
| 187 float max_ending_ratio = (direction == SHOWING_CONTROLS ? 1 : -1); | 196 float max_ending_ratio = (direction == SHOWING_CONTROLS ? 1 : -1); |
| 188 top_controls_animation_->AddKeyframe(FloatKeyframe::Create( | 197 top_controls_animation_->AddKeyframe(FloatKeyframe::Create( |
| 189 start_time + base::TimeDelta::FromMilliseconds(kShowHideMaxDurationMs), | 198 start_time + base::TimeDelta::FromMilliseconds(kShowHideMaxDurationMs), |
| 190 TopControlsShownRatio() + max_ending_ratio, | 199 TopControlsShownRatio() + max_ending_ratio, |
| 191 EaseTimingFunction::Create())); | 200 EaseTimingFunction::Create())); |
| 192 animation_direction_ = direction; | 201 animation_direction_ = direction; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 234 } |
| 226 return false; | 235 return false; |
| 227 } | 236 } |
| 228 | 237 |
| 229 void TopControlsManager::ResetBaseline() { | 238 void TopControlsManager::ResetBaseline() { |
| 230 accumulated_scroll_delta_ = 0.f; | 239 accumulated_scroll_delta_ = 0.f; |
| 231 baseline_content_offset_ = ContentTopOffset(); | 240 baseline_content_offset_ = ContentTopOffset(); |
| 232 } | 241 } |
| 233 | 242 |
| 234 } // namespace cc | 243 } // namespace cc |
| OLD | NEW |