| 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 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2265 did_scroll_y |= did_move_layer_y; | 2265 did_scroll_y |= did_move_layer_y; |
| 2266 if (!did_move_layer_x && !did_move_layer_y) { | 2266 if (!did_move_layer_x && !did_move_layer_y) { |
| 2267 // Scrolls should always bubble between the outer and inner viewports | 2267 // Scrolls should always bubble between the outer and inner viewports |
| 2268 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || | 2268 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || |
| 2269 layer_impl == OuterViewportScrollLayer()) | 2269 layer_impl == OuterViewportScrollLayer()) |
| 2270 continue; | 2270 continue; |
| 2271 else | 2271 else |
| 2272 break; | 2272 break; |
| 2273 } | 2273 } |
| 2274 | 2274 |
| 2275 if (layer_impl == InnerViewportScrollLayer()) | 2275 if (layer_impl == InnerViewportScrollLayer()) { |
| 2276 unused_root_delta.Subtract(applied_delta); | 2276 unused_root_delta.Subtract(applied_delta); |
| 2277 const float kOverscrollEpsilon = 0.01f; |
| 2278 if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon) |
| 2279 unused_root_delta.set_x(0.0f); |
| 2280 if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon) |
| 2281 unused_root_delta.set_y(0.0f); |
| 2282 } |
| 2277 | 2283 |
| 2278 did_lock_scrolling_layer_ = true; | 2284 did_lock_scrolling_layer_ = true; |
| 2279 if (!should_bubble_scrolls_) { | 2285 if (!should_bubble_scrolls_) { |
| 2280 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2286 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
| 2281 break; | 2287 break; |
| 2282 } | 2288 } |
| 2283 | 2289 |
| 2284 // If the applied delta is within 45 degrees of the input delta, bail out to | 2290 // If the applied delta is within 45 degrees of the input delta, bail out to |
| 2285 // make it easier to scroll just one layer in one direction without | 2291 // make it easier to scroll just one layer in one direction without |
| 2286 // affecting any of its parents. | 2292 // affecting any of its parents. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2307 client_->RenewTreePriority(); | 2313 client_->RenewTreePriority(); |
| 2308 } | 2314 } |
| 2309 | 2315 |
| 2310 // Scrolling along an axis resets accumulated root overscroll for that axis. | 2316 // Scrolling along an axis resets accumulated root overscroll for that axis. |
| 2311 if (did_scroll_x) | 2317 if (did_scroll_x) |
| 2312 accumulated_root_overscroll_.set_x(0); | 2318 accumulated_root_overscroll_.set_x(0); |
| 2313 if (did_scroll_y) | 2319 if (did_scroll_y) |
| 2314 accumulated_root_overscroll_.set_y(0); | 2320 accumulated_root_overscroll_.set_y(0); |
| 2315 | 2321 |
| 2316 accumulated_root_overscroll_ += unused_root_delta; | 2322 accumulated_root_overscroll_ += unused_root_delta; |
| 2317 bool did_overscroll = !gfx::ToRoundedVector2d(unused_root_delta).IsZero(); | 2323 bool did_overscroll = !unused_root_delta.IsZero(); |
| 2318 if (did_overscroll && input_handler_client_) { | 2324 if (did_overscroll && input_handler_client_) { |
| 2319 DidOverscrollParams params; | 2325 DidOverscrollParams params; |
| 2320 params.accumulated_overscroll = accumulated_root_overscroll_; | 2326 params.accumulated_overscroll = accumulated_root_overscroll_; |
| 2321 params.latest_overscroll_delta = unused_root_delta; | 2327 params.latest_overscroll_delta = unused_root_delta; |
| 2322 params.current_fling_velocity = current_fling_velocity_; | 2328 params.current_fling_velocity = current_fling_velocity_; |
| 2323 input_handler_client_->DidOverscroll(params); | 2329 input_handler_client_->DidOverscroll(params); |
| 2324 } | 2330 } |
| 2325 | 2331 |
| 2326 return did_scroll_content || did_scroll_top_controls; | 2332 return did_scroll_content || did_scroll_top_controls; |
| 2327 } | 2333 } |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 swap_promise_monitor_.erase(monitor); | 3026 swap_promise_monitor_.erase(monitor); |
| 3021 } | 3027 } |
| 3022 | 3028 |
| 3023 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3029 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
| 3024 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3030 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3025 for (; it != swap_promise_monitor_.end(); it++) | 3031 for (; it != swap_promise_monitor_.end(); it++) |
| 3026 (*it)->OnSetNeedsRedrawOnImpl(); | 3032 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3027 } | 3033 } |
| 3028 | 3034 |
| 3029 } // namespace cc | 3035 } // namespace cc |
| OLD | NEW |