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 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 | 2327 |
2328 // Scrolling along an axis resets accumulated root overscroll for that axis. | 2328 // Scrolling along an axis resets accumulated root overscroll for that axis. |
2329 if (did_scroll_x) | 2329 if (did_scroll_x) |
2330 accumulated_root_overscroll_.set_x(0); | 2330 accumulated_root_overscroll_.set_x(0); |
2331 if (did_scroll_y) | 2331 if (did_scroll_y) |
2332 accumulated_root_overscroll_.set_y(0); | 2332 accumulated_root_overscroll_.set_y(0); |
2333 | 2333 |
2334 accumulated_root_overscroll_ += unused_root_delta; | 2334 accumulated_root_overscroll_ += unused_root_delta; |
2335 bool did_overscroll = !unused_root_delta.IsZero(); | 2335 bool did_overscroll = !unused_root_delta.IsZero(); |
2336 if (did_overscroll && input_handler_client_) { | 2336 if (did_overscroll && input_handler_client_) { |
2337 DidOverscrollParams params; | 2337 input_handler_client_->DidOverscroll(accumulated_root_overscroll_, |
2338 params.accumulated_overscroll = accumulated_root_overscroll_; | 2338 unused_root_delta); |
2339 params.latest_overscroll_delta = unused_root_delta; | |
2340 params.current_fling_velocity = current_fling_velocity_; | |
2341 input_handler_client_->DidOverscroll(params); | |
2342 } | 2339 } |
2343 | 2340 |
2344 return did_scroll_content || did_scroll_top_controls; | 2341 return did_scroll_content || did_scroll_top_controls; |
2345 } | 2342 } |
2346 | 2343 |
2347 // This implements scrolling by page as described here: | 2344 // This implements scrolling by page as described here: |
2348 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel | 2345 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel |
2349 // for events with WHEEL_PAGESCROLL set. | 2346 // for events with WHEEL_PAGESCROLL set. |
2350 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | 2347 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, |
2351 ScrollDirection direction) { | 2348 ScrollDirection direction) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2395 void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { | 2392 void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { |
2396 DCHECK(root_layer_scroll_offset_delegate_ != NULL); | 2393 DCHECK(root_layer_scroll_offset_delegate_ != NULL); |
2397 client_->SetNeedsCommitOnImplThread(); | 2394 client_->SetNeedsCommitOnImplThread(); |
2398 } | 2395 } |
2399 | 2396 |
2400 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { | 2397 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { |
2401 active_tree_->ClearCurrentlyScrollingLayer(); | 2398 active_tree_->ClearCurrentlyScrollingLayer(); |
2402 did_lock_scrolling_layer_ = false; | 2399 did_lock_scrolling_layer_ = false; |
2403 scroll_affects_scroll_handler_ = false; | 2400 scroll_affects_scroll_handler_ = false; |
2404 accumulated_root_overscroll_ = gfx::Vector2dF(); | 2401 accumulated_root_overscroll_ = gfx::Vector2dF(); |
2405 current_fling_velocity_ = gfx::Vector2dF(); | |
2406 } | 2402 } |
2407 | 2403 |
2408 void LayerTreeHostImpl::ScrollEnd() { | 2404 void LayerTreeHostImpl::ScrollEnd() { |
2409 if (top_controls_manager_) | 2405 if (top_controls_manager_) |
2410 top_controls_manager_->ScrollEnd(); | 2406 top_controls_manager_->ScrollEnd(); |
2411 ClearCurrentlyScrollingLayer(); | 2407 ClearCurrentlyScrollingLayer(); |
2412 StartScrollbarAnimation(); | 2408 StartScrollbarAnimation(); |
2413 } | 2409 } |
2414 | 2410 |
2415 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2411 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
(...skipping 10 matching lines...) Expand all Loading... |
2426 if (!wheel_scrolling_) { | 2422 if (!wheel_scrolling_) { |
2427 // Allow the fling to lock to the first layer that moves after the initial | 2423 // Allow the fling to lock to the first layer that moves after the initial |
2428 // fling |ScrollBy()| event. | 2424 // fling |ScrollBy()| event. |
2429 did_lock_scrolling_layer_ = false; | 2425 did_lock_scrolling_layer_ = false; |
2430 should_bubble_scrolls_ = false; | 2426 should_bubble_scrolls_ = false; |
2431 } | 2427 } |
2432 | 2428 |
2433 return ScrollStarted; | 2429 return ScrollStarted; |
2434 } | 2430 } |
2435 | 2431 |
2436 void LayerTreeHostImpl::NotifyCurrentFlingVelocity( | |
2437 const gfx::Vector2dF& velocity) { | |
2438 current_fling_velocity_ = velocity; | |
2439 } | |
2440 | |
2441 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( | 2432 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( |
2442 const gfx::PointF& device_viewport_point, | 2433 const gfx::PointF& device_viewport_point, |
2443 LayerImpl* layer_impl) { | 2434 LayerImpl* layer_impl) { |
2444 if (!layer_impl) | 2435 if (!layer_impl) |
2445 return std::numeric_limits<float>::max(); | 2436 return std::numeric_limits<float>::max(); |
2446 | 2437 |
2447 gfx::Rect layer_impl_bounds( | 2438 gfx::Rect layer_impl_bounds( |
2448 layer_impl->content_bounds()); | 2439 layer_impl->content_bounds()); |
2449 | 2440 |
2450 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( | 2441 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3040 swap_promise_monitor_.erase(monitor); | 3031 swap_promise_monitor_.erase(monitor); |
3041 } | 3032 } |
3042 | 3033 |
3043 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3034 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3044 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3035 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3045 for (; it != swap_promise_monitor_.end(); it++) | 3036 for (; it != swap_promise_monitor_.end(); it++) |
3046 (*it)->OnSetNeedsRedrawOnImpl(); | 3037 (*it)->OnSetNeedsRedrawOnImpl(); |
3047 } | 3038 } |
3048 | 3039 |
3049 } // namespace cc | 3040 } // namespace cc |
OLD | NEW |