| 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 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2625 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); | 2625 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); |
| 2626 if (!CurrentlyScrollingLayer()) | 2626 if (!CurrentlyScrollingLayer()) |
| 2627 return InputHandlerScrollResult(); | 2627 return InputHandlerScrollResult(); |
| 2628 | 2628 |
| 2629 gfx::Vector2dF pending_delta = scroll_delta; | 2629 gfx::Vector2dF pending_delta = scroll_delta; |
| 2630 gfx::Vector2dF unused_root_delta; | 2630 gfx::Vector2dF unused_root_delta; |
| 2631 bool did_scroll_x = false; | 2631 bool did_scroll_x = false; |
| 2632 bool did_scroll_y = false; | 2632 bool did_scroll_y = false; |
| 2633 bool did_scroll_top_controls = false; | 2633 bool did_scroll_top_controls = false; |
| 2634 | 2634 |
| 2635 if (pinch_gesture_active_ && settings().viewport_scroll_order_experiment) { |
| 2636 // Scrolls during a pinch gesture should pan the visual viewport, rather |
| 2637 // than a typical bubbling scroll. |
| 2638 viewport()->Pan(pending_delta); |
| 2639 return InputHandlerScrollResult(); |
| 2640 } |
| 2641 |
| 2635 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); | 2642 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); |
| 2636 layer_impl; | 2643 layer_impl; |
| 2637 layer_impl = layer_impl->parent()) { | 2644 layer_impl = layer_impl->parent()) { |
| 2638 // Skip the outer viewport scroll layer so that we try to scroll the | 2645 // Skip the outer viewport scroll layer so that we try to scroll the |
| 2639 // viewport only once. i.e. The inner viewport layer represents the | 2646 // viewport only once. i.e. The inner viewport layer represents the |
| 2640 // viewport. | 2647 // viewport. |
| 2641 if (!layer_impl->scrollable() || layer_impl == OuterViewportScrollLayer()) | 2648 if (!layer_impl->scrollable() || layer_impl == OuterViewportScrollLayer()) |
| 2642 continue; | 2649 continue; |
| 2643 | 2650 |
| 2644 gfx::Vector2dF applied_delta; | 2651 gfx::Vector2dF applied_delta; |
| 2645 if (layer_impl == InnerViewportScrollLayer()) { | 2652 if (layer_impl == InnerViewportScrollLayer()) { |
| 2653 bool affect_top_controls = true; |
| 2646 Viewport::ScrollResult result = viewport()->ScrollBy(pending_delta, | 2654 Viewport::ScrollResult result = viewport()->ScrollBy(pending_delta, |
| 2647 viewport_point, | 2655 viewport_point, |
| 2648 wheel_scrolling_); | 2656 wheel_scrolling_, |
| 2657 affect_top_controls); |
| 2649 applied_delta = result.applied_delta; | 2658 applied_delta = result.applied_delta; |
| 2650 unused_root_delta = result.unused_scroll_delta; | 2659 unused_root_delta = result.unused_scroll_delta; |
| 2651 did_scroll_top_controls = result.top_controls_applied_delta.y() != 0; | 2660 did_scroll_top_controls = result.top_controls_applied_delta.y() != 0; |
| 2652 } else { | 2661 } else { |
| 2653 applied_delta = ScrollLayer(layer_impl, | 2662 applied_delta = ScrollLayer(layer_impl, |
| 2654 pending_delta, | 2663 pending_delta, |
| 2655 viewport_point, | 2664 viewport_point, |
| 2656 wheel_scrolling_); | 2665 wheel_scrolling_); |
| 2657 } | 2666 } |
| 2658 | 2667 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2927 | 2936 |
| 2928 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 2937 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
| 2929 // position over the course of the magnify. | 2938 // position over the course of the magnify. |
| 2930 float page_scale = active_tree_->current_page_scale_factor(); | 2939 float page_scale = active_tree_->current_page_scale_factor(); |
| 2931 gfx::PointF previous_scale_anchor = gfx::ScalePoint(anchor, 1.f / page_scale); | 2940 gfx::PointF previous_scale_anchor = gfx::ScalePoint(anchor, 1.f / page_scale); |
| 2932 active_tree_->SetPageScaleOnActiveTree(page_scale * magnify_delta); | 2941 active_tree_->SetPageScaleOnActiveTree(page_scale * magnify_delta); |
| 2933 page_scale = active_tree_->current_page_scale_factor(); | 2942 page_scale = active_tree_->current_page_scale_factor(); |
| 2934 gfx::PointF new_scale_anchor = gfx::ScalePoint(anchor, 1.f / page_scale); | 2943 gfx::PointF new_scale_anchor = gfx::ScalePoint(anchor, 1.f / page_scale); |
| 2935 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; | 2944 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; |
| 2936 | 2945 |
| 2946 // Scale back to viewport space since that's the coordinate space ScrollBy |
| 2947 // uses. |
| 2948 move.Scale(page_scale); |
| 2949 |
| 2937 previous_pinch_anchor_ = anchor; | 2950 previous_pinch_anchor_ = anchor; |
| 2938 | 2951 |
| 2939 // If clamping the inner viewport scroll offset causes a change, it should | 2952 // If clamping the inner viewport scroll offset causes a change, it should |
| 2940 // be accounted for from the intended move. | 2953 // be accounted for from the intended move. |
| 2941 move -= InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); | 2954 move -= InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); |
| 2942 | 2955 |
| 2943 // We manually manage the bubbling behaviour here as it is different to that | 2956 if (settings().viewport_scroll_order_experiment) { |
| 2944 // implemented in LayerTreeHostImpl::ScrollBy(). Specifically: | 2957 viewport()->Pan(move); |
| 2945 // 1) we want to explicit limit the bubbling to the outer/inner viewports, | 2958 } else { |
| 2946 // 2) we don't want the directional limitations on the unused parts that | 2959 gfx::Point viewport_point; |
| 2947 // ScrollBy() implements, and | 2960 bool is_wheel_event = false; |
| 2948 // 3) pinching should not engage the top controls manager. | 2961 bool affect_top_controls = false; |
| 2949 gfx::Vector2dF unused = OuterViewportScrollLayer() | 2962 viewport()->ScrollBy(move, |
| 2950 ? OuterViewportScrollLayer()->ScrollBy(move) | 2963 viewport_point, |
| 2951 : move; | 2964 is_wheel_event, |
| 2952 | 2965 affect_top_controls); |
| 2953 if (!unused.IsZero()) { | |
| 2954 InnerViewportScrollLayer()->ScrollBy(unused); | |
| 2955 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); | |
| 2956 } | 2966 } |
| 2957 | 2967 |
| 2958 active_tree_->SetRootLayerScrollOffsetDelegate( | 2968 active_tree_->SetRootLayerScrollOffsetDelegate( |
| 2959 root_layer_scroll_offset_delegate_); | 2969 root_layer_scroll_offset_delegate_); |
| 2960 | 2970 |
| 2961 client_->SetNeedsCommitOnImplThread(); | 2971 client_->SetNeedsCommitOnImplThread(); |
| 2962 SetNeedsRedraw(); | 2972 SetNeedsRedraw(); |
| 2963 client_->RenewTreePriority(); | 2973 client_->RenewTreePriority(); |
| 2964 } | 2974 } |
| 2965 | 2975 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3440 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3450 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
| 3441 | 3451 |
| 3442 curve->UpdateTarget( | 3452 curve->UpdateTarget( |
| 3443 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3453 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
| 3444 .InSecondsF(), | 3454 .InSecondsF(), |
| 3445 new_target); | 3455 new_target); |
| 3446 | 3456 |
| 3447 return true; | 3457 return true; |
| 3448 } | 3458 } |
| 3449 } // namespace cc | 3459 } // namespace cc |
| OLD | NEW |