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 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 | 2310 |
2311 // Scrolling along an axis resets accumulated root overscroll for that axis. | 2311 // Scrolling along an axis resets accumulated root overscroll for that axis. |
2312 if (did_scroll_x) | 2312 if (did_scroll_x) |
2313 accumulated_root_overscroll_.set_x(0); | 2313 accumulated_root_overscroll_.set_x(0); |
2314 if (did_scroll_y) | 2314 if (did_scroll_y) |
2315 accumulated_root_overscroll_.set_y(0); | 2315 accumulated_root_overscroll_.set_y(0); |
2316 | 2316 |
2317 accumulated_root_overscroll_ += unused_root_delta; | 2317 accumulated_root_overscroll_ += unused_root_delta; |
2318 bool did_overscroll = !unused_root_delta.IsZero(); | 2318 bool did_overscroll = !unused_root_delta.IsZero(); |
2319 if (did_overscroll && input_handler_client_) { | 2319 if (did_overscroll && input_handler_client_) { |
2320 input_handler_client_->DidOverscroll(accumulated_root_overscroll_, | 2320 DidOverscrollParams params; |
2321 unused_root_delta); | 2321 params.accumulated_overscroll = accumulated_root_overscroll_; |
| 2322 params.latest_overscroll_delta = unused_root_delta; |
| 2323 params.current_fling_velocity = current_fling_velocity_; |
| 2324 input_handler_client_->DidOverscroll(params); |
2322 } | 2325 } |
2323 | 2326 |
2324 return did_scroll_content || did_scroll_top_controls; | 2327 return did_scroll_content || did_scroll_top_controls; |
2325 } | 2328 } |
2326 | 2329 |
2327 // This implements scrolling by page as described here: | 2330 // This implements scrolling by page as described here: |
2328 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel | 2331 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel |
2329 // for events with WHEEL_PAGESCROLL set. | 2332 // for events with WHEEL_PAGESCROLL set. |
2330 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | 2333 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, |
2331 ScrollDirection direction) { | 2334 ScrollDirection direction) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2374 | 2377 |
2375 void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { | 2378 void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { |
2376 DCHECK(root_layer_scroll_offset_delegate_ != NULL); | 2379 DCHECK(root_layer_scroll_offset_delegate_ != NULL); |
2377 client_->SetNeedsCommitOnImplThread(); | 2380 client_->SetNeedsCommitOnImplThread(); |
2378 } | 2381 } |
2379 | 2382 |
2380 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { | 2383 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { |
2381 active_tree_->ClearCurrentlyScrollingLayer(); | 2384 active_tree_->ClearCurrentlyScrollingLayer(); |
2382 did_lock_scrolling_layer_ = false; | 2385 did_lock_scrolling_layer_ = false; |
2383 accumulated_root_overscroll_ = gfx::Vector2dF(); | 2386 accumulated_root_overscroll_ = gfx::Vector2dF(); |
| 2387 current_fling_velocity_ = gfx::Vector2dF(); |
2384 } | 2388 } |
2385 | 2389 |
2386 void LayerTreeHostImpl::ScrollEnd() { | 2390 void LayerTreeHostImpl::ScrollEnd() { |
2387 if (top_controls_manager_) | 2391 if (top_controls_manager_) |
2388 top_controls_manager_->ScrollEnd(); | 2392 top_controls_manager_->ScrollEnd(); |
2389 ClearCurrentlyScrollingLayer(); | 2393 ClearCurrentlyScrollingLayer(); |
2390 StartScrollbarAnimation(); | 2394 StartScrollbarAnimation(); |
2391 } | 2395 } |
2392 | 2396 |
2393 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2397 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
(...skipping 10 matching lines...) Expand all Loading... |
2404 if (!wheel_scrolling_) { | 2408 if (!wheel_scrolling_) { |
2405 // Allow the fling to lock to the first layer that moves after the initial | 2409 // Allow the fling to lock to the first layer that moves after the initial |
2406 // fling |ScrollBy()| event. | 2410 // fling |ScrollBy()| event. |
2407 did_lock_scrolling_layer_ = false; | 2411 did_lock_scrolling_layer_ = false; |
2408 should_bubble_scrolls_ = false; | 2412 should_bubble_scrolls_ = false; |
2409 } | 2413 } |
2410 | 2414 |
2411 return ScrollStarted; | 2415 return ScrollStarted; |
2412 } | 2416 } |
2413 | 2417 |
| 2418 void LayerTreeHostImpl::NotifyCurrentFlingVelocity( |
| 2419 const gfx::Vector2dF& velocity) { |
| 2420 current_fling_velocity_ = velocity; |
| 2421 } |
| 2422 |
2414 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( | 2423 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( |
2415 const gfx::PointF& device_viewport_point, | 2424 const gfx::PointF& device_viewport_point, |
2416 LayerImpl* layer_impl) { | 2425 LayerImpl* layer_impl) { |
2417 if (!layer_impl) | 2426 if (!layer_impl) |
2418 return std::numeric_limits<float>::max(); | 2427 return std::numeric_limits<float>::max(); |
2419 | 2428 |
2420 gfx::Rect layer_impl_bounds( | 2429 gfx::Rect layer_impl_bounds( |
2421 layer_impl->content_bounds()); | 2430 layer_impl->content_bounds()); |
2422 | 2431 |
2423 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( | 2432 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3010 swap_promise_monitor_.erase(monitor); | 3019 swap_promise_monitor_.erase(monitor); |
3011 } | 3020 } |
3012 | 3021 |
3013 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3022 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3014 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3023 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3015 for (; it != swap_promise_monitor_.end(); it++) | 3024 for (; it != swap_promise_monitor_.end(); it++) |
3016 (*it)->OnSetNeedsRedrawOnImpl(); | 3025 (*it)->OnSetNeedsRedrawOnImpl(); |
3017 } | 3026 } |
3018 | 3027 |
3019 } // namespace cc | 3028 } // namespace cc |
OLD | NEW |