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

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

Issue 2611013002: Show Overlay Scrollbar when GestureScrollUpdate (Closed)
Patch Set: ScrollingGestureUpdate should only effect Aura Overlay Scrollbar Created 3 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
OLDNEW
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"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return animated; 159 return animated;
160 } 160 }
161 161
162 float ScrollbarAnimationController::AnimationProgressAtTime( 162 float ScrollbarAnimationController::AnimationProgressAtTime(
163 base::TimeTicks now) { 163 base::TimeTicks now) {
164 base::TimeDelta delta = now - last_awaken_time_; 164 base::TimeDelta delta = now - last_awaken_time_;
165 float progress = delta.InSecondsF() / fade_out_duration_.InSecondsF(); 165 float progress = delta.InSecondsF() / fade_out_duration_.InSecondsF();
166 return std::max(std::min(progress, 1.f), 0.f); 166 return std::max(std::min(progress, 1.f), 0.f);
167 } 167 }
168 168
169 void ScrollbarAnimationController::DidScrollBegin() {
170 currently_scrolling_ = true;
171 }
172
173 void ScrollbarAnimationController::RunAnimationFrame(float progress) { 169 void ScrollbarAnimationController::RunAnimationFrame(float progress) {
174 ApplyOpacityToScrollbars(1.f - progress); 170 ApplyOpacityToScrollbars(1.f - progress);
175 client_->SetNeedsRedrawForScrollbarAnimation(); 171 client_->SetNeedsRedrawForScrollbarAnimation();
176 if (progress == 1.f) 172 if (progress == 1.f)
177 StopAnimation(); 173 StopAnimation();
178 } 174 }
179 175
180 void ScrollbarAnimationController::DidScrollUpdate(bool on_resize) { 176 void ScrollbarAnimationController::DidScrollBegin() {
177 currently_scrolling_ = true;
178 }
179
180 void ScrollbarAnimationController::DidScrollEnd() {
181 bool has_scrolled = scroll_gesture_has_scrolled_;
182 scroll_gesture_has_scrolled_ = false;
183
184 currently_scrolling_ = false;
185
186 // We don't fade out scrollbar if they need thinning animation and mouse is
187 // near.
188 if (need_thinning_animation_ && MouseIsNearAnyScrollbar())
189 return;
190
191 if (has_scrolled)
192 PostDelayedFadeOut(false);
193 }
194
195 void ScrollbarAnimationController::DidScrollUpdate() {
181 if (need_thinning_animation_ && Captured()) 196 if (need_thinning_animation_ && Captured())
182 return; 197 return;
183 198
184 StopAnimation(); 199 StopAnimation();
185 200
186 // As an optimization, we avoid spamming fade delay tasks during active fast 201 // As an optimization, we avoid spamming fade delay tasks during active fast
187 // scrolls. But if we're not within one, we need to post every scroll update. 202 // scrolls. But if we're not within one, we need to post every scroll update.
188 if (!currently_scrolling_) { 203 if (!currently_scrolling_) {
189 // We don't fade out scrollbar if they need thinning animation and mouse is 204 // We don't fade out scrollbar if they need thinning animation and mouse is
190 // near. 205 // near.
191 if (!need_thinning_animation_ || !MouseIsNearAnyScrollbar()) 206 if (!need_thinning_animation_ || !MouseIsNearAnyScrollbar())
192 PostDelayedFadeOut(on_resize); 207 PostDelayedFadeOut(false);
193 } else { 208 } else {
194 scroll_gesture_has_scrolled_ = true; 209 scroll_gesture_has_scrolled_ = true;
195 } 210 }
196 211
197 Show(); 212 Show();
198 213
199 if (need_thinning_animation_) { 214 if (need_thinning_animation_) {
200 vertical_controller_->UpdateThumbThicknessScale(); 215 vertical_controller_->UpdateThumbThicknessScale();
201 horizontal_controller_->UpdateThumbThicknessScale(); 216 horizontal_controller_->UpdateThumbThicknessScale();
202 } 217 }
203 } 218 }
204 219
205 void ScrollbarAnimationController::DidScrollEnd() { 220 void ScrollbarAnimationController::WillUpdateScroll() {
206 bool has_scrolled = scroll_gesture_has_scrolled_; 221 if (need_thinning_animation_)
bokan 2017/03/09 15:57:58 Instead of using need_thinning_animation_, add a b
207 scroll_gesture_has_scrolled_ = false; 222 DidScrollUpdate();
223 }
208 224
209 currently_scrolling_ = false; 225 void ScrollbarAnimationController::DidResize() {
210 226 StopAnimation();
211 // We don't fade out scrollbar if they need thinning animation and mouse is 227 Show();
212 // near. 228 // We should use the gesture delay rather than the resize delay if we're in a
213 if (need_thinning_animation_ && MouseIsNearAnyScrollbar()) 229 // gesture scroll, even if it is resizing.
214 return; 230 PostDelayedFadeOut(!currently_scrolling_);
215
216 if (has_scrolled)
217 PostDelayedFadeOut(false);
218 } 231 }
219 232
220 void ScrollbarAnimationController::DidMouseDown() { 233 void ScrollbarAnimationController::DidMouseDown() {
221 if (!need_thinning_animation_ || ScrollbarsHidden()) 234 if (!need_thinning_animation_ || ScrollbarsHidden())
222 return; 235 return;
223 236
224 vertical_controller_->DidMouseDown(); 237 vertical_controller_->DidMouseDown();
225 horizontal_controller_->DidMouseDown(); 238 horizontal_controller_->DidMouseDown();
226 } 239 }
227 240
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 bool previouslyVisible = opacity_ > 0.0f; 375 bool previouslyVisible = opacity_ > 0.0f;
363 bool currentlyVisible = opacity > 0.0f; 376 bool currentlyVisible = opacity > 0.0f;
364 377
365 opacity_ = opacity; 378 opacity_ = opacity;
366 379
367 if (previouslyVisible != currentlyVisible) 380 if (previouslyVisible != currentlyVisible)
368 client_->DidChangeScrollbarVisibility(); 381 client_->DidChangeScrollbarVisibility();
369 } 382 }
370 383
371 } // namespace cc 384 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698