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

Unified Diff: content/browser/renderer_host/overscroll_controller.cc

Issue 18603008: Seperate horizontal and vertical overscrolling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed broken unit test Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/overscroll_controller.cc
diff --git a/content/browser/renderer_host/overscroll_controller.cc b/content/browser/renderer_host/overscroll_controller.cc
index 37f9e378c35e1848ac0c13a78f5f6fa0eee13bf1..3fed4c332a7d9acd381d31bd94c47b25dded194c 100644
--- a/content/browser/renderer_host/overscroll_controller.cc
+++ b/content/browser/renderer_host/overscroll_controller.cc
@@ -277,14 +277,16 @@ void OverscrollController::ProcessEventForOverscroll(
}
void OverscrollController::ProcessOverscroll(float delta_x, float delta_y) {
- if (scroll_state_ == STATE_CONTENT_SCROLLING)
- return;
- overscroll_delta_x_ += delta_x;
+ if (scroll_state_ != STATE_CONTENT_SCROLLING)
+ overscroll_delta_x_ += delta_x;
overscroll_delta_y_ += delta_y;
- float threshold = GetOverscrollConfig(OVERSCROLL_CONFIG_MIN_THRESHOLD_START);
- if (fabs(overscroll_delta_x_) < threshold &&
- fabs(overscroll_delta_y_) < threshold) {
+ float horiz_threshold = GetOverscrollConfig(
+ OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START);
+ float vert_threshold = GetOverscrollConfig(
+ OVERSCROLL_CONFIG_VERT_THRESHOLD_START);
+ if (fabs(overscroll_delta_x_) <= horiz_threshold &&
+ fabs(overscroll_delta_y_) <= vert_threshold) {
SetOverscrollMode(OVERSCROLL_NONE);
return;
}
@@ -294,17 +296,20 @@ void OverscrollController::ProcessOverscroll(float delta_x, float delta_y) {
// to make sure that subsequent scroll events go through to the page first.
OverscrollMode new_mode = OVERSCROLL_NONE;
const float kMinRatio = 2.5;
- if (fabs(overscroll_delta_x_) > fabs(overscroll_delta_y_) * kMinRatio)
+ if (fabs(overscroll_delta_x_) > horiz_threshold &&
+ fabs(overscroll_delta_x_) > fabs(overscroll_delta_y_) * kMinRatio)
new_mode = overscroll_delta_x_ > 0.f ? OVERSCROLL_EAST : OVERSCROLL_WEST;
- else if (fabs(overscroll_delta_y_) > fabs(overscroll_delta_x_) * kMinRatio)
+ else if (fabs(overscroll_delta_y_) > vert_threshold &&
+ fabs(overscroll_delta_y_) > fabs(overscroll_delta_x_) * kMinRatio)
new_mode = overscroll_delta_y_ > 0.f ? OVERSCROLL_SOUTH : OVERSCROLL_NORTH;
- if (overscroll_mode_ == OVERSCROLL_NONE) {
+ if (overscroll_mode_ == OVERSCROLL_NONE)
SetOverscrollMode(new_mode);
- } else if (new_mode != overscroll_mode_) {
+ else if (new_mode != overscroll_mode_)
SetOverscrollMode(OVERSCROLL_NONE);
+
+ if (overscroll_mode_ == OVERSCROLL_NONE)
return;
- }
// Tell the delegate about the overscroll update so that it can update
// the display accordingly (e.g. show history preview etc.).
@@ -312,21 +317,21 @@ void OverscrollController::ProcessOverscroll(float delta_x, float delta_y) {
// Do not include the threshold amount when sending the deltas to the
// delegate.
float delegate_delta_x = overscroll_delta_x_;
- if (fabs(delegate_delta_x) > threshold) {
+ if (fabs(delegate_delta_x) > horiz_threshold) {
if (delegate_delta_x < 0)
- delegate_delta_x += threshold;
+ delegate_delta_x += horiz_threshold;
else
- delegate_delta_x -= threshold;
+ delegate_delta_x -= horiz_threshold;
} else {
delegate_delta_x = 0.f;
}
float delegate_delta_y = overscroll_delta_y_;
- if (fabs(delegate_delta_y) > threshold) {
+ if (fabs(delegate_delta_y) > vert_threshold) {
if (delegate_delta_y < 0)
- delegate_delta_y += threshold;
+ delegate_delta_y += vert_threshold;
else
- delegate_delta_y -= threshold;
+ delegate_delta_y -= vert_threshold;
} else {
delegate_delta_y = 0.f;
}

Powered by Google App Engine
This is Rietveld 408576698