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

Side by Side Diff: content/browser/renderer_host/overscroll_controller.cc

Issue 52263006: Put vertical overscroll behind kScrollEndEffect flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed failures in content_unittest Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/overscroll_controller.h" 5 #include "content/browser/renderer_host/overscroll_controller.h"
6 6
7 #include "base/command_line.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "content/browser/renderer_host/overscroll_controller_delegate.h" 9 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
9 #include "content/public/browser/overscroll_configuration.h" 10 #include "content/public/browser/overscroll_configuration.h"
11 #include "content/public/common/content_switches.h"
10 12
11 using WebKit::WebInputEvent; 13 using WebKit::WebInputEvent;
12 14
15 namespace {
16
17 bool IsScrollEndEffectEnabled() {
18 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
19 switches::kScrollEndEffect) == "1";
20 }
21
22 } // namespace
23
13 namespace content { 24 namespace content {
14 25
15 OverscrollController::OverscrollController() 26 OverscrollController::OverscrollController()
16 : overscroll_mode_(OVERSCROLL_NONE), 27 : overscroll_mode_(OVERSCROLL_NONE),
17 scroll_state_(STATE_UNKNOWN), 28 scroll_state_(STATE_UNKNOWN),
18 overscroll_delta_x_(0.f), 29 overscroll_delta_x_(0.f),
19 overscroll_delta_y_(0.f), 30 overscroll_delta_y_(0.f),
20 delegate_(NULL) { 31 delegate_(NULL) {
21 } 32 }
22 33
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // to make sure that subsequent scroll events go through to the page first. 306 // to make sure that subsequent scroll events go through to the page first.
296 OverscrollMode new_mode = OVERSCROLL_NONE; 307 OverscrollMode new_mode = OVERSCROLL_NONE;
297 const float kMinRatio = 2.5; 308 const float kMinRatio = 2.5;
298 if (fabs(overscroll_delta_x_) > horiz_threshold && 309 if (fabs(overscroll_delta_x_) > horiz_threshold &&
299 fabs(overscroll_delta_x_) > fabs(overscroll_delta_y_) * kMinRatio) 310 fabs(overscroll_delta_x_) > fabs(overscroll_delta_y_) * kMinRatio)
300 new_mode = overscroll_delta_x_ > 0.f ? OVERSCROLL_EAST : OVERSCROLL_WEST; 311 new_mode = overscroll_delta_x_ > 0.f ? OVERSCROLL_EAST : OVERSCROLL_WEST;
301 else if (fabs(overscroll_delta_y_) > vert_threshold && 312 else if (fabs(overscroll_delta_y_) > vert_threshold &&
302 fabs(overscroll_delta_y_) > fabs(overscroll_delta_x_) * kMinRatio) 313 fabs(overscroll_delta_y_) > fabs(overscroll_delta_x_) * kMinRatio)
303 new_mode = overscroll_delta_y_ > 0.f ? OVERSCROLL_SOUTH : OVERSCROLL_NORTH; 314 new_mode = overscroll_delta_y_ > 0.f ? OVERSCROLL_SOUTH : OVERSCROLL_NORTH;
304 315
316 // The vertical oversrcoll currently does not have any UX effects other then
317 // for the scroll end effect, so testing if it is enabled.
318 if ((new_mode == OVERSCROLL_SOUTH || new_mode == OVERSCROLL_NORTH) &&
319 !IsScrollEndEffectEnabled())
320 new_mode = OVERSCROLL_NONE;
321
305 if (overscroll_mode_ == OVERSCROLL_NONE) 322 if (overscroll_mode_ == OVERSCROLL_NONE)
306 SetOverscrollMode(new_mode); 323 SetOverscrollMode(new_mode);
307 else if (new_mode != overscroll_mode_) 324 else if (new_mode != overscroll_mode_)
308 SetOverscrollMode(OVERSCROLL_NONE); 325 SetOverscrollMode(OVERSCROLL_NONE);
309 326
310 if (overscroll_mode_ == OVERSCROLL_NONE) 327 if (overscroll_mode_ == OVERSCROLL_NONE)
311 return; 328 return;
312 329
313 // Tell the delegate about the overscroll update so that it can update 330 // Tell the delegate about the overscroll update so that it can update
314 // the display accordingly (e.g. show history preview etc.). 331 // the display accordingly (e.g. show history preview etc.).
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 overscroll_mode_ = mode; 369 overscroll_mode_ = mode;
353 if (overscroll_mode_ == OVERSCROLL_NONE) 370 if (overscroll_mode_ == OVERSCROLL_NONE)
354 overscroll_delta_x_ = overscroll_delta_y_ = 0.f; 371 overscroll_delta_x_ = overscroll_delta_y_ = 0.f;
355 else 372 else
356 scroll_state_ = STATE_OVERSCROLLING; 373 scroll_state_ = STATE_OVERSCROLLING;
357 if (delegate_) 374 if (delegate_)
358 delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_); 375 delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_);
359 } 376 }
360 377
361 } // namespace content 378 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698