| OLD | NEW |
| 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 "ui/app_list/pagination_controller.h" | 5 #include "ui/app_list/pagination_controller.h" |
| 6 | 6 |
| 7 #include "ui/app_list/pagination_model.h" | 7 #include "ui/app_list/pagination_model.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/gfx/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/gfx/geometry/vector2d.h" | 10 #include "ui/gfx/geometry/vector2d.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 if (scroll_axis_ == SCROLL_AXIS_HORIZONTAL) { | 32 if (scroll_axis_ == SCROLL_AXIS_HORIZONTAL) { |
| 33 // If the view scrolls horizontally, both horizontal and vertical scroll | 33 // If the view scrolls horizontally, both horizontal and vertical scroll |
| 34 // events are valid (since most mouse wheels only have vertical scrolling). | 34 // events are valid (since most mouse wheels only have vertical scrolling). |
| 35 offset_magnitude = | 35 offset_magnitude = |
| 36 abs(offset.x()) > abs(offset.y()) ? offset.x() : offset.y(); | 36 abs(offset.x()) > abs(offset.y()) ? offset.x() : offset.y(); |
| 37 } else { | 37 } else { |
| 38 // If the view scrolls vertically, only vertical scroll events are valid. | 38 // If the view scrolls vertically, only vertical scroll events are valid. |
| 39 offset_magnitude = offset.y(); | 39 offset_magnitude = offset.y(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Do not scroll on very small touchpad events. Mouse wheel events should | 42 // Do not scroll on very small events. |
| 43 // scroll, no matter how small the value change. | 43 // TODO(calamity): This should only apply on touchpad scroll but touchpad |
| 44 if (type == SCROLL_MOUSE_WHEEL || | 44 // events are coming in as mousewheel events. See https://crbug.com/594264. |
| 45 abs(offset_magnitude) > kMinScrollToSwitchPage) { | 45 if (abs(offset_magnitude) > kMinScrollToSwitchPage) { |
| 46 if (!pagination_model_->has_transition()) { | 46 if (!pagination_model_->has_transition()) { |
| 47 pagination_model_->SelectPageRelative(offset_magnitude > 0 ? -1 : 1, | 47 pagination_model_->SelectPageRelative(offset_magnitude > 0 ? -1 : 1, |
| 48 true); | 48 true); |
| 49 } | 49 } |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 | 52 |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 83 if (fabs(velocity) > kMinHorizVelocityToSwitchPage) | 83 if (fabs(velocity) > kMinHorizVelocityToSwitchPage) |
| 84 pagination_model_->SelectPageRelative(velocity < 0 ? 1 : -1, true); | 84 pagination_model_->SelectPageRelative(velocity < 0 ? 1 : -1, true); |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 default: | 87 default: |
| 88 return false; | 88 return false; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace app_list | 92 } // namespace app_list |
| OLD | NEW |