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