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 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 if (!wheel_scrolling_) { | 2245 if (!wheel_scrolling_) { |
2246 float scale_from_viewport_to_screen_space = device_scale_factor_; | 2246 float scale_from_viewport_to_screen_space = device_scale_factor_; |
2247 applied_delta = | 2247 applied_delta = |
2248 ScrollLayerWithViewportSpaceDelta(layer_impl, | 2248 ScrollLayerWithViewportSpaceDelta(layer_impl, |
2249 scale_from_viewport_to_screen_space, | 2249 scale_from_viewport_to_screen_space, |
2250 viewport_point, pending_delta); | 2250 viewport_point, pending_delta); |
2251 } else { | 2251 } else { |
2252 applied_delta = ScrollLayerWithLocalDelta(layer_impl, pending_delta); | 2252 applied_delta = ScrollLayerWithLocalDelta(layer_impl, pending_delta); |
2253 } | 2253 } |
2254 | 2254 |
| 2255 if (layer_impl == InnerViewportScrollLayer()) { |
| 2256 unused_root_delta.Subtract(applied_delta); |
| 2257 const float kOverscrollEpsilon = 0.01f; |
| 2258 if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon) |
| 2259 unused_root_delta.set_x(0.0f); |
| 2260 if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon) |
| 2261 unused_root_delta.set_y(0.0f); |
| 2262 } |
| 2263 |
2255 // If the layer wasn't able to move, try the next one in the hierarchy. | 2264 // If the layer wasn't able to move, try the next one in the hierarchy. |
2256 float move_threshold = 0.1f; | 2265 float move_threshold = 0.1f; |
2257 bool did_move_layer_x = std::abs(applied_delta.x()) > move_threshold; | 2266 bool did_move_layer_x = std::abs(applied_delta.x()) > move_threshold; |
2258 bool did_move_layer_y = std::abs(applied_delta.y()) > move_threshold; | 2267 bool did_move_layer_y = std::abs(applied_delta.y()) > move_threshold; |
2259 did_scroll_x |= did_move_layer_x; | 2268 did_scroll_x |= did_move_layer_x; |
2260 did_scroll_y |= did_move_layer_y; | 2269 did_scroll_y |= did_move_layer_y; |
2261 if (!did_move_layer_x && !did_move_layer_y) { | 2270 if (!did_move_layer_x && !did_move_layer_y) { |
2262 // Scrolls should always bubble between the outer and inner viewports | 2271 // Scrolls should always bubble between the outer and inner viewports |
2263 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || | 2272 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || |
2264 layer_impl == OuterViewportScrollLayer()) | 2273 layer_impl == OuterViewportScrollLayer()) |
2265 continue; | 2274 continue; |
2266 else | 2275 else |
2267 break; | 2276 break; |
2268 } | 2277 } |
2269 | 2278 |
2270 if (layer_impl == InnerViewportScrollLayer()) { | |
2271 unused_root_delta.Subtract(applied_delta); | |
2272 const float kOverscrollEpsilon = 0.01f; | |
2273 if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon) | |
2274 unused_root_delta.set_x(0.0f); | |
2275 if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon) | |
2276 unused_root_delta.set_y(0.0f); | |
2277 } | |
2278 | |
2279 did_lock_scrolling_layer_ = true; | 2279 did_lock_scrolling_layer_ = true; |
2280 if (!should_bubble_scrolls_) { | 2280 if (!should_bubble_scrolls_) { |
2281 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2281 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
2282 break; | 2282 break; |
2283 } | 2283 } |
2284 | 2284 |
2285 // If the applied delta is within 45 degrees of the input delta, bail out to | 2285 // If the applied delta is within 45 degrees of the input delta, bail out to |
2286 // make it easier to scroll just one layer in one direction without | 2286 // make it easier to scroll just one layer in one direction without |
2287 // affecting any of its parents. | 2287 // affecting any of its parents. |
2288 float angle_threshold = 45; | 2288 float angle_threshold = 45; |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3019 swap_promise_monitor_.erase(monitor); | 3019 swap_promise_monitor_.erase(monitor); |
3020 } | 3020 } |
3021 | 3021 |
3022 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3022 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3023 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3023 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3024 for (; it != swap_promise_monitor_.end(); it++) | 3024 for (; it != swap_promise_monitor_.end(); it++) |
3025 (*it)->OnSetNeedsRedrawOnImpl(); | 3025 (*it)->OnSetNeedsRedrawOnImpl(); |
3026 } | 3026 } |
3027 | 3027 |
3028 } // namespace cc | 3028 } // namespace cc |
OLD | NEW |