OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 if (!wheel_scrolling_) { | 2262 if (!wheel_scrolling_) { |
2263 float scale_from_viewport_to_screen_space = device_scale_factor_; | 2263 float scale_from_viewport_to_screen_space = device_scale_factor_; |
2264 applied_delta = | 2264 applied_delta = |
2265 ScrollLayerWithViewportSpaceDelta(layer_impl, | 2265 ScrollLayerWithViewportSpaceDelta(layer_impl, |
2266 scale_from_viewport_to_screen_space, | 2266 scale_from_viewport_to_screen_space, |
2267 viewport_point, pending_delta); | 2267 viewport_point, pending_delta); |
2268 } else { | 2268 } else { |
2269 applied_delta = ScrollLayerWithLocalDelta(layer_impl, pending_delta); | 2269 applied_delta = ScrollLayerWithLocalDelta(layer_impl, pending_delta); |
2270 } | 2270 } |
2271 | 2271 |
| 2272 const float kEpsilon = 0.1f; |
2272 if (layer_impl == InnerViewportScrollLayer()) { | 2273 if (layer_impl == InnerViewportScrollLayer()) { |
2273 unused_root_delta.Subtract(applied_delta); | 2274 unused_root_delta.Subtract(applied_delta); |
2274 const float kOverscrollEpsilon = 0.01f; | 2275 if (std::abs(unused_root_delta.x()) < kEpsilon) |
2275 if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon) | |
2276 unused_root_delta.set_x(0.0f); | 2276 unused_root_delta.set_x(0.0f); |
2277 if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon) | 2277 if (std::abs(unused_root_delta.y()) < kEpsilon) |
2278 unused_root_delta.set_y(0.0f); | 2278 unused_root_delta.set_y(0.0f); |
2279 } | 2279 } |
2280 | 2280 |
2281 // If the layer wasn't able to move, try the next one in the hierarchy. | 2281 // If the layer wasn't able to move, try the next one in the hierarchy. |
2282 float move_threshold = 0.1f; | 2282 bool did_move_layer_x = std::abs(applied_delta.x()) > kEpsilon; |
2283 bool did_move_layer_x = std::abs(applied_delta.x()) > move_threshold; | 2283 bool did_move_layer_y = std::abs(applied_delta.y()) > kEpsilon; |
2284 bool did_move_layer_y = std::abs(applied_delta.y()) > move_threshold; | |
2285 did_scroll_x |= did_move_layer_x; | 2284 did_scroll_x |= did_move_layer_x; |
2286 did_scroll_y |= did_move_layer_y; | 2285 did_scroll_y |= did_move_layer_y; |
2287 if (!did_move_layer_x && !did_move_layer_y) { | 2286 if (!did_move_layer_x && !did_move_layer_y) { |
2288 // Scrolls should always bubble between the outer and inner viewports | 2287 // Scrolls should always bubble between the outer and inner viewports |
2289 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || | 2288 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || |
2290 layer_impl == OuterViewportScrollLayer()) | 2289 layer_impl == OuterViewportScrollLayer()) |
2291 continue; | 2290 continue; |
2292 else | 2291 else |
2293 break; | 2292 break; |
2294 } | 2293 } |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 swap_promise_monitor_.erase(monitor); | 3030 swap_promise_monitor_.erase(monitor); |
3032 } | 3031 } |
3033 | 3032 |
3034 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3033 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3035 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3034 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3036 for (; it != swap_promise_monitor_.end(); it++) | 3035 for (; it != swap_promise_monitor_.end(); it++) |
3037 (*it)->OnSetNeedsRedrawOnImpl(); | 3036 (*it)->OnSetNeedsRedrawOnImpl(); |
3038 } | 3037 } |
3039 | 3038 |
3040 } // namespace cc | 3039 } // namespace cc |
OLD | NEW |