| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 void TopControlsManager::SetTopControlsHeight(float top_controls_height) { | 161 void TopControlsManager::SetTopControlsHeight(float top_controls_height) { |
| 162 DCHECK_GE(top_controls_height, 0); | 162 DCHECK_GE(top_controls_height, 0); |
| 163 | 163 |
| 164 if (top_controls_height == top_controls_height_) | 164 if (top_controls_height == top_controls_height_) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 ResetAnimations(); | 167 ResetAnimations(); |
| 168 float top_controls_offset = client_->ControlsTopOffset(); | 168 float top_controls_offset = client_->ControlsTopOffset(); |
| 169 top_controls_height_ = top_controls_height; | 169 top_controls_height_ = top_controls_height; |
| 170 |
| 171 // Stay hidden if only HIDDEN state is permitted. |
| 172 if (permitted_state_ == HIDDEN) |
| 173 top_controls_offset = -top_controls_height_; |
| 174 |
| 170 SetControlsTopOffset(top_controls_offset); | 175 SetControlsTopOffset(top_controls_offset); |
| 171 StartAnimationIfNecessary(); | 176 StartAnimationIfNecessary(); |
| 172 } | 177 } |
| 173 | 178 |
| 174 gfx::Vector2dF TopControlsManager::Animate(base::TimeTicks monotonic_time) { | 179 gfx::Vector2dF TopControlsManager::Animate(base::TimeTicks monotonic_time) { |
| 175 if (!top_controls_animation_ || !client_->HaveRootScrollLayer()) | 180 if (!top_controls_animation_ || !client_->HaveRootScrollLayer()) |
| 176 return gfx::Vector2dF(); | 181 return gfx::Vector2dF(); |
| 177 | 182 |
| 178 base::TimeDelta time = monotonic_time - base::TimeTicks(); | 183 base::TimeDelta time = monotonic_time - base::TimeTicks(); |
| 179 | 184 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 262 |
| 258 if ((animation_direction_ == SHOWING_CONTROLS && new_offset >= 0) || | 263 if ((animation_direction_ == SHOWING_CONTROLS && new_offset >= 0) || |
| 259 (animation_direction_ == HIDING_CONTROLS | 264 (animation_direction_ == HIDING_CONTROLS |
| 260 && new_offset <= -top_controls_height_)) { | 265 && new_offset <= -top_controls_height_)) { |
| 261 return true; | 266 return true; |
| 262 } | 267 } |
| 263 return false; | 268 return false; |
| 264 } | 269 } |
| 265 | 270 |
| 266 } // namespace cc | 271 } // namespace cc |
| OLD | NEW |