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 if (layer_impl == InnerViewportScrollLayer()) { |
| 2273 unused_root_delta.Subtract(applied_delta); |
| 2274 const float kOverscrollEpsilon = 0.01f; |
| 2275 if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon) |
| 2276 unused_root_delta.set_x(0.0f); |
| 2277 if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon) |
| 2278 unused_root_delta.set_y(0.0f); |
| 2279 } |
| 2280 |
2272 // 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. |
2273 float move_threshold = 0.1f; | 2282 float move_threshold = 0.1f; |
2274 bool did_move_layer_x = std::abs(applied_delta.x()) > move_threshold; | 2283 bool did_move_layer_x = std::abs(applied_delta.x()) > move_threshold; |
2275 bool did_move_layer_y = std::abs(applied_delta.y()) > move_threshold; | 2284 bool did_move_layer_y = std::abs(applied_delta.y()) > move_threshold; |
2276 did_scroll_x |= did_move_layer_x; | 2285 did_scroll_x |= did_move_layer_x; |
2277 did_scroll_y |= did_move_layer_y; | 2286 did_scroll_y |= did_move_layer_y; |
2278 if (!did_move_layer_x && !did_move_layer_y) { | 2287 if (!did_move_layer_x && !did_move_layer_y) { |
2279 // Scrolls should always bubble between the outer and inner viewports | 2288 // Scrolls should always bubble between the outer and inner viewports |
2280 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || | 2289 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || |
2281 layer_impl == OuterViewportScrollLayer()) | 2290 layer_impl == OuterViewportScrollLayer()) |
2282 continue; | 2291 continue; |
2283 else | 2292 else |
2284 break; | 2293 break; |
2285 } | 2294 } |
2286 | 2295 |
2287 if (layer_impl == InnerViewportScrollLayer()) { | |
2288 unused_root_delta.Subtract(applied_delta); | |
2289 const float kOverscrollEpsilon = 0.01f; | |
2290 if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon) | |
2291 unused_root_delta.set_x(0.0f); | |
2292 if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon) | |
2293 unused_root_delta.set_y(0.0f); | |
2294 } | |
2295 | |
2296 did_lock_scrolling_layer_ = true; | 2296 did_lock_scrolling_layer_ = true; |
2297 if (!should_bubble_scrolls_) { | 2297 if (!should_bubble_scrolls_) { |
2298 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2298 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
2299 break; | 2299 break; |
2300 } | 2300 } |
2301 | 2301 |
2302 // If the applied delta is within 45 degrees of the input delta, bail out to | 2302 // If the applied delta is within 45 degrees of the input delta, bail out to |
2303 // make it easier to scroll just one layer in one direction without | 2303 // make it easier to scroll just one layer in one direction without |
2304 // affecting any of its parents. | 2304 // affecting any of its parents. |
2305 float angle_threshold = 45; | 2305 float angle_threshold = 45; |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3040 swap_promise_monitor_.erase(monitor); | 3040 swap_promise_monitor_.erase(monitor); |
3041 } | 3041 } |
3042 | 3042 |
3043 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3043 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3044 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3044 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3045 for (; it != swap_promise_monitor_.end(); it++) | 3045 for (; it != swap_promise_monitor_.end(); it++) |
3046 (*it)->OnSetNeedsRedrawOnImpl(); | 3046 (*it)->OnSetNeedsRedrawOnImpl(); |
3047 } | 3047 } |
3048 | 3048 |
3049 } // namespace cc | 3049 } // namespace cc |
OLD | NEW |