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

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

Issue 2931703002: Don't fade in overlay scrollbar when user interacting the content under scrollbar. (Closed)
Patch Set: Created 3 years, 6 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 DCHECK(need_thinning_animation_); 95 DCHECK(need_thinning_animation_);
96 if (orientation == ScrollbarOrientation::VERTICAL) 96 if (orientation == ScrollbarOrientation::VERTICAL)
97 return *(vertical_controller_.get()); 97 return *(vertical_controller_.get());
98 else 98 else
99 return *(horizontal_controller_.get()); 99 return *(horizontal_controller_.get());
100 } 100 }
101 101
102 void ScrollbarAnimationController::StartAnimation() { 102 void ScrollbarAnimationController::StartAnimation() {
103 DCHECK(animation_change_ != NONE); 103 DCHECK(animation_change_ != NONE);
104 delayed_scrollbar_animation_.Cancel(); 104 delayed_scrollbar_animation_.Cancel();
105 need_trigger_scrollbar_fade_in_ = false;
105 is_animating_ = true; 106 is_animating_ = true;
106 last_awaken_time_ = base::TimeTicks(); 107 last_awaken_time_ = base::TimeTicks();
107 client_->SetNeedsAnimateForScrollbarAnimation(); 108 client_->SetNeedsAnimateForScrollbarAnimation();
108 } 109 }
109 110
110 void ScrollbarAnimationController::StopAnimation() { 111 void ScrollbarAnimationController::StopAnimation() {
111 delayed_scrollbar_animation_.Cancel(); 112 delayed_scrollbar_animation_.Cancel();
113 need_trigger_scrollbar_fade_in_ = false;
112 is_animating_ = false; 114 is_animating_ = false;
113 animation_change_ = NONE; 115 animation_change_ = NONE;
114 } 116 }
115 117
116 void ScrollbarAnimationController::PostDelayedAnimation( 118 void ScrollbarAnimationController::PostDelayedAnimation(
117 AnimationChange animation_change) { 119 AnimationChange animation_change) {
118 animation_change_ = animation_change; 120 animation_change_ = animation_change;
119 delayed_scrollbar_animation_.Cancel(); 121 delayed_scrollbar_animation_.Cancel();
120 delayed_scrollbar_animation_.Reset( 122 delayed_scrollbar_animation_.Reset(
121 base::Bind(&ScrollbarAnimationController::StartAnimation, 123 base::Bind(&ScrollbarAnimationController::StartAnimation,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void ScrollbarAnimationController::WillUpdateScroll() { 219 void ScrollbarAnimationController::WillUpdateScroll() {
218 if (show_scrollbars_on_scroll_gesture_) 220 if (show_scrollbars_on_scroll_gesture_)
219 DidScrollUpdate(); 221 DidScrollUpdate();
220 } 222 }
221 223
222 void ScrollbarAnimationController::DidRequestShowFromMainThread() { 224 void ScrollbarAnimationController::DidRequestShowFromMainThread() {
223 DidScrollUpdate(); 225 DidScrollUpdate();
224 } 226 }
225 227
226 void ScrollbarAnimationController::DidMouseDown() { 228 void ScrollbarAnimationController::DidMouseDown() {
227 if (!need_thinning_animation_ || ScrollbarsHidden()) 229 if (!need_thinning_animation_)
228 return; 230 return;
229 231
232 if (ScrollbarsHidden()) {
233 if (need_trigger_scrollbar_fade_in_) {
234 delayed_scrollbar_animation_.Cancel();
235 need_trigger_scrollbar_fade_in_ = false;
236 }
237 return;
238 }
239
230 vertical_controller_->DidMouseDown(); 240 vertical_controller_->DidMouseDown();
231 horizontal_controller_->DidMouseDown(); 241 horizontal_controller_->DidMouseDown();
232 } 242 }
233 243
234 void ScrollbarAnimationController::DidMouseUp() { 244 void ScrollbarAnimationController::DidMouseUp() {
235 if (!need_thinning_animation_ || !Captured()) 245 if (!need_thinning_animation_)
236 return; 246 return;
237 247
248 if (!Captured()) {
249 if (MouseIsNearAnyScrollbar() && ScrollbarsHidden()) {
250 PostDelayedAnimation(FADE_IN);
251 need_trigger_scrollbar_fade_in_ = true;
252 }
253 return;
254 }
255
238 vertical_controller_->DidMouseUp(); 256 vertical_controller_->DidMouseUp();
239 horizontal_controller_->DidMouseUp(); 257 horizontal_controller_->DidMouseUp();
240 258
241 if (!MouseIsNearAnyScrollbar()) 259 if (!MouseIsNearAnyScrollbar() && !ScrollbarsHidden()) {
bokan 2017/06/08 14:02:38 Nit: no braces
242 PostDelayedAnimation(FADE_OUT); 260 PostDelayedAnimation(FADE_OUT);
261 }
243 } 262 }
244 263
245 void ScrollbarAnimationController::DidMouseLeave() { 264 void ScrollbarAnimationController::DidMouseLeave() {
246 if (!need_thinning_animation_) 265 if (!need_thinning_animation_)
247 return; 266 return;
248 267
249 vertical_controller_->DidMouseLeave(); 268 vertical_controller_->DidMouseLeave();
250 horizontal_controller_->DidMouseLeave(); 269 horizontal_controller_->DidMouseLeave();
251 270
252 delayed_scrollbar_animation_.Cancel(); 271 delayed_scrollbar_animation_.Cancel();
253 need_trigger_scrollbar_fade_in_ = false; 272 need_trigger_scrollbar_fade_in_ = false;
254 273
255 if (ScrollbarsHidden() || Captured()) 274 if (ScrollbarsHidden() || Captured())
256 return; 275 return;
257 276
258 PostDelayedAnimation(FADE_OUT); 277 PostDelayedAnimation(FADE_OUT);
259 } 278 }
260 279
261 void ScrollbarAnimationController::DidMouseMove( 280 void ScrollbarAnimationController::DidMouseMove(
262 const gfx::PointF& device_viewport_point) { 281 const gfx::PointF& device_viewport_point,
282 bool is_mouse_down) {
263 if (!need_thinning_animation_) 283 if (!need_thinning_animation_)
264 return; 284 return;
265 285
266 bool need_trigger_scrollbar_fade_in_before = need_trigger_scrollbar_fade_in_; 286 bool need_trigger_scrollbar_fade_in_before = need_trigger_scrollbar_fade_in_;
267 287
268 vertical_controller_->DidMouseMove(device_viewport_point); 288 vertical_controller_->DidMouseMove(device_viewport_point);
269 horizontal_controller_->DidMouseMove(device_viewport_point); 289 horizontal_controller_->DidMouseMove(device_viewport_point);
270 290
271 need_trigger_scrollbar_fade_in_ = MouseIsNearAnyScrollbar();
272
273 if (Captured()) 291 if (Captured())
bokan 2017/06/08 14:02:38 Could you add a DCHECK that if we're Captured() th
274 return; 292 return;
275 293
276 if (ScrollbarsHidden()) { 294 if (ScrollbarsHidden()) {
295 // Do not fade in scrollbar when user interacting with the content below
296 // scrollbar.
297 if (is_mouse_down)
298 return;
299 need_trigger_scrollbar_fade_in_ = MouseIsNearAnyScrollbar();
277 if (need_trigger_scrollbar_fade_in_before != 300 if (need_trigger_scrollbar_fade_in_before !=
278 need_trigger_scrollbar_fade_in_) { 301 need_trigger_scrollbar_fade_in_) {
279 if (need_trigger_scrollbar_fade_in_) { 302 if (need_trigger_scrollbar_fade_in_) {
280 PostDelayedAnimation(FADE_IN); 303 PostDelayedAnimation(FADE_IN);
281 } else { 304 } else {
282 delayed_scrollbar_animation_.Cancel(); 305 delayed_scrollbar_animation_.Cancel();
283 } 306 }
284 } 307 }
285 } else { 308 } else {
286 if (MouseIsNearAnyScrollbar()) { 309 if (MouseIsNearAnyScrollbar()) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 if (opacity_ != opacity) 370 if (opacity_ != opacity)
348 client_->SetNeedsRedrawForScrollbarAnimation(); 371 client_->SetNeedsRedrawForScrollbarAnimation();
349 372
350 opacity_ = opacity; 373 opacity_ = opacity;
351 374
352 if (previouslyVisible != currentlyVisible) 375 if (previouslyVisible != currentlyVisible)
353 client_->DidChangeScrollbarVisibility(); 376 client_->DidChangeScrollbarVisibility();
354 } 377 }
355 378
356 } // namespace cc 379 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698