Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: cc/input/top_controls_manager.cc

Issue 986433004: Revert of Always create top controls manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/base/switches.cc ('k') | cc/input/top_controls_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
107 if (pinch_gesture_active_) 104 if (pinch_gesture_active_)
108 return pending_delta; 105 return pending_delta;
109 106
110 if (permitted_state_ == SHOWN && pending_delta.y() > 0) 107 if (permitted_state_ == SHOWN && pending_delta.y() > 0)
111 return pending_delta; 108 return pending_delta;
112 else if (permitted_state_ == HIDDEN && pending_delta.y() < 0) 109 else if (permitted_state_ == HIDDEN && pending_delta.y() < 0)
113 return pending_delta; 110 return pending_delta;
114 111
115 accumulated_scroll_delta_ += pending_delta.y(); 112 accumulated_scroll_delta_ += pending_delta.y();
116 113
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 173 }
177 174
178 void TopControlsManager::SetupAnimation(AnimationDirection direction) { 175 void TopControlsManager::SetupAnimation(AnimationDirection direction) {
179 DCHECK_NE(NO_ANIMATION, direction); 176 DCHECK_NE(NO_ANIMATION, direction);
180 DCHECK_IMPLIES(direction == HIDING_CONTROLS, TopControlsShownRatio() > 0.f); 177 DCHECK_IMPLIES(direction == HIDING_CONTROLS, TopControlsShownRatio() > 0.f);
181 DCHECK_IMPLIES(direction == SHOWING_CONTROLS, TopControlsShownRatio() < 1.f); 178 DCHECK_IMPLIES(direction == SHOWING_CONTROLS, TopControlsShownRatio() < 1.f);
182 179
183 if (top_controls_animation_ && animation_direction_ == direction) 180 if (top_controls_animation_ && animation_direction_ == direction)
184 return; 181 return;
185 182
186 if (!TopControlsHeight()) {
187 client_->SetCurrentTopControlsShownRatio(
188 direction == HIDING_CONTROLS ? 0.f : 1.f);
189 return;
190 }
191
192 top_controls_animation_ = KeyframedFloatAnimationCurve::Create(); 183 top_controls_animation_ = KeyframedFloatAnimationCurve::Create();
193 base::TimeDelta start_time = gfx::FrameTime::Now() - base::TimeTicks(); 184 base::TimeDelta start_time = gfx::FrameTime::Now() - base::TimeTicks();
194 top_controls_animation_->AddKeyframe( 185 top_controls_animation_->AddKeyframe(
195 FloatKeyframe::Create(start_time, TopControlsShownRatio(), nullptr)); 186 FloatKeyframe::Create(start_time, TopControlsShownRatio(), nullptr));
196 float max_ending_ratio = (direction == SHOWING_CONTROLS ? 1 : -1); 187 float max_ending_ratio = (direction == SHOWING_CONTROLS ? 1 : -1);
197 top_controls_animation_->AddKeyframe(FloatKeyframe::Create( 188 top_controls_animation_->AddKeyframe(FloatKeyframe::Create(
198 start_time + base::TimeDelta::FromMilliseconds(kShowHideMaxDurationMs), 189 start_time + base::TimeDelta::FromMilliseconds(kShowHideMaxDurationMs),
199 TopControlsShownRatio() + max_ending_ratio, 190 TopControlsShownRatio() + max_ending_ratio,
200 EaseTimingFunction::Create())); 191 EaseTimingFunction::Create()));
201 animation_direction_ = direction; 192 animation_direction_ = direction;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 225 }
235 return false; 226 return false;
236 } 227 }
237 228
238 void TopControlsManager::ResetBaseline() { 229 void TopControlsManager::ResetBaseline() {
239 accumulated_scroll_delta_ = 0.f; 230 accumulated_scroll_delta_ = 0.f;
240 baseline_content_offset_ = ContentTopOffset(); 231 baseline_content_offset_ = ContentTopOffset();
241 } 232 }
242 233
243 } // namespace cc 234 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/switches.cc ('k') | cc/input/top_controls_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698