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 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 static gfx::Vector2dF ScrollLayerWithLocalDelta( | 2577 static gfx::Vector2dF ScrollLayerWithLocalDelta( |
2578 LayerImpl* layer_impl, | 2578 LayerImpl* layer_impl, |
2579 const gfx::Vector2dF& local_delta, | 2579 const gfx::Vector2dF& local_delta, |
2580 float page_scale_factor) { | 2580 float page_scale_factor) { |
2581 gfx::ScrollOffset previous_offset = layer_impl->CurrentScrollOffset(); | 2581 gfx::ScrollOffset previous_offset = layer_impl->CurrentScrollOffset(); |
2582 gfx::Vector2dF delta = local_delta; | 2582 gfx::Vector2dF delta = local_delta; |
2583 delta.Scale(1.f / page_scale_factor); | 2583 delta.Scale(1.f / page_scale_factor); |
2584 layer_impl->ScrollBy(delta); | 2584 layer_impl->ScrollBy(delta); |
2585 gfx::ScrollOffset scrolled = | 2585 gfx::ScrollOffset scrolled = |
2586 layer_impl->CurrentScrollOffset() - previous_offset; | 2586 layer_impl->CurrentScrollOffset() - previous_offset; |
2587 return gfx::Vector2dF(scrolled.x(), scrolled.y()); | 2587 gfx::Vector2dF consumed_scroll(scrolled.x(), scrolled.y()); |
| 2588 consumed_scroll.Scale(page_scale_factor); |
| 2589 |
| 2590 return consumed_scroll; |
2588 } | 2591 } |
2589 | 2592 |
2590 gfx::Vector2dF LayerTreeHostImpl::ScrollLayer(LayerImpl* layer_impl, | 2593 gfx::Vector2dF LayerTreeHostImpl::ScrollLayer(LayerImpl* layer_impl, |
2591 const gfx::Vector2dF& delta, | 2594 const gfx::Vector2dF& delta, |
2592 const gfx::Point& viewport_point, | 2595 const gfx::Point& viewport_point, |
2593 bool is_wheel_scroll) { | 2596 bool is_wheel_scroll) { |
2594 // Gesture events need to be transformed from viewport coordinates to | 2597 // Gesture events need to be transformed from viewport coordinates to |
2595 // local layer coordinates so that the scrolling contents exactly follow | 2598 // local layer coordinates so that the scrolling contents exactly follow |
2596 // the user's finger. In contrast, wheel events represent a fixed amount | 2599 // the user's finger. In contrast, wheel events represent a fixed amount |
2597 // of scrolling so we can just apply them directly, but the page scale | 2600 // of scrolling so we can just apply them directly, but the page scale |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3433 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3436 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3434 | 3437 |
3435 curve->UpdateTarget( | 3438 curve->UpdateTarget( |
3436 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3439 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3437 .InSecondsF(), | 3440 .InSecondsF(), |
3438 new_target); | 3441 new_target); |
3439 | 3442 |
3440 return true; | 3443 return true; |
3441 } | 3444 } |
3442 } // namespace cc | 3445 } // namespace cc |
OLD | NEW |