Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 1227823005: Revert of Cleanup viewport scrolling for future scroll customization work. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 layer_impl->CurrentScrollOffset() - previous_offset; 2603 layer_impl->CurrentScrollOffset() - previous_offset;
2604 gfx::Vector2dF consumed_scroll(scrolled.x(), scrolled.y()); 2604 gfx::Vector2dF consumed_scroll(scrolled.x(), scrolled.y());
2605 consumed_scroll.Scale(page_scale_factor); 2605 consumed_scroll.Scale(page_scale_factor);
2606 2606
2607 return consumed_scroll; 2607 return consumed_scroll;
2608 } 2608 }
2609 2609
2610 gfx::Vector2dF LayerTreeHostImpl::ScrollLayer(LayerImpl* layer_impl, 2610 gfx::Vector2dF LayerTreeHostImpl::ScrollLayer(LayerImpl* layer_impl,
2611 const gfx::Vector2dF& delta, 2611 const gfx::Vector2dF& delta,
2612 const gfx::Point& viewport_point, 2612 const gfx::Point& viewport_point,
2613 bool is_direct_manipulation) { 2613 bool is_wheel_scroll) {
2614 // Events representing direct manipulation of the screen (such as gesture 2614 // Gesture events need to be transformed from viewport coordinates to
2615 // events) need to be transformed from viewport coordinates to local layer 2615 // local layer coordinates so that the scrolling contents exactly follow
2616 // coordinates so that the scrolling contents exactly follow the user's 2616 // the user's finger. In contrast, wheel events represent a fixed amount
2617 // finger. In contrast, events not representing direct manipulation of the 2617 // of scrolling so we can just apply them directly, but the page scale
2618 // screen (such as wheel events) represent a fixed amount of scrolling so we 2618 // factor is applied to the scroll delta.
2619 // can just apply them directly, but the page scale factor is applied to the 2619 if (is_wheel_scroll) {
2620 // scroll delta. 2620 float scale_factor = active_tree()->current_page_scale_factor();
2621 if (is_direct_manipulation) 2621 return ScrollLayerWithLocalDelta(layer_impl,
2622 return ScrollLayerWithViewportSpaceDelta(layer_impl, viewport_point, delta); 2622 delta,
2623 float scale_factor = active_tree()->current_page_scale_factor(); 2623 scale_factor);
2624 return ScrollLayerWithLocalDelta(layer_impl, delta, scale_factor); 2624 }
2625
2626 return ScrollLayerWithViewportSpaceDelta(layer_impl,
2627 viewport_point,
2628 delta);
2625 } 2629 }
2626 2630
2627 static LayerImpl* nextLayerInScrollOrder(LayerImpl* layer) { 2631 static LayerImpl* nextLayerInScrollOrder(LayerImpl* layer) {
2628 if (layer->scroll_parent()) 2632 if (layer->scroll_parent())
2629 return layer->scroll_parent(); 2633 return layer->scroll_parent();
2630 2634
2631 return layer->parent(); 2635 return layer->parent();
2632 } 2636 }
2633 2637
2634 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( 2638 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
2635 const gfx::Point& viewport_point, 2639 const gfx::Point& viewport_point,
2636 const gfx::Vector2dF& scroll_delta) { 2640 const gfx::Vector2dF& scroll_delta) {
2637 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); 2641 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy");
2638 if (!CurrentlyScrollingLayer()) 2642 if (!CurrentlyScrollingLayer())
2639 return InputHandlerScrollResult(); 2643 return InputHandlerScrollResult();
2640 2644
2641 gfx::Vector2dF pending_delta = scroll_delta; 2645 gfx::Vector2dF pending_delta = scroll_delta;
2642 gfx::Vector2dF unused_root_delta; 2646 gfx::Vector2dF unused_root_delta;
2643 bool did_scroll_x = false; 2647 bool did_scroll_x = false;
2644 bool did_scroll_y = false; 2648 bool did_scroll_y = false;
2649 bool did_scroll_top_controls = false;
2645 2650
2646 if (pinch_gesture_active_ && settings().invert_viewport_scroll_order) { 2651 if (pinch_gesture_active_ && settings().invert_viewport_scroll_order) {
2647 // Scrolls during a pinch gesture should pan the visual viewport, rather 2652 // Scrolls during a pinch gesture should pan the visual viewport, rather
2648 // than a typical bubbling scroll. 2653 // than a typical bubbling scroll.
2649 viewport()->Pan(pending_delta); 2654 viewport()->Pan(pending_delta);
2650 return InputHandlerScrollResult(); 2655 return InputHandlerScrollResult();
2651 } 2656 }
2652 2657
2653 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); 2658 for (LayerImpl* layer_impl = CurrentlyScrollingLayer();
2654 layer_impl; 2659 layer_impl;
2655 layer_impl = nextLayerInScrollOrder(layer_impl)) { 2660 layer_impl = nextLayerInScrollOrder(layer_impl)) {
2656 // Skip the outer viewport scroll layer so that we try to scroll the 2661 // Skip the outer viewport scroll layer so that we try to scroll the
2657 // viewport only once. i.e. The inner viewport layer represents the 2662 // viewport only once. i.e. The inner viewport layer represents the
2658 // viewport. 2663 // viewport.
2659 if (!layer_impl->scrollable() || layer_impl == OuterViewportScrollLayer()) 2664 if (!layer_impl->scrollable() || layer_impl == OuterViewportScrollLayer())
2660 continue; 2665 continue;
2661 2666
2662 gfx::Vector2dF applied_delta; 2667 gfx::Vector2dF applied_delta;
2663 if (layer_impl == InnerViewportScrollLayer()) { 2668 if (layer_impl == InnerViewportScrollLayer()) {
2664 bool affect_top_controls = true; 2669 bool affect_top_controls = true;
2665 applied_delta = 2670 Viewport::ScrollResult result = viewport()->ScrollBy(pending_delta,
2666 viewport()->ScrollBy(pending_delta, viewport_point, !wheel_scrolling_, 2671 viewport_point,
2667 affect_top_controls); 2672 wheel_scrolling_,
2668 unused_root_delta = pending_delta - applied_delta; 2673 affect_top_controls);
2674 applied_delta = result.applied_delta;
2675 unused_root_delta = result.unused_scroll_delta;
2676 did_scroll_top_controls = result.top_controls_applied_delta.y() != 0;
2669 } else { 2677 } else {
2670 applied_delta = ScrollLayer(layer_impl, pending_delta, viewport_point, 2678 applied_delta = ScrollLayer(layer_impl,
2671 !wheel_scrolling_); 2679 pending_delta,
2680 viewport_point,
2681 wheel_scrolling_);
2672 } 2682 }
2673 2683
2674 // If the layer wasn't able to move, try the next one in the hierarchy. 2684 // If the layer wasn't able to move, try the next one in the hierarchy.
2675 const float kEpsilon = 0.1f; 2685 const float kEpsilon = 0.1f;
2676 bool did_layer_consume_delta_x = std::abs(applied_delta.x()) > kEpsilon; 2686 bool did_move_layer_x = std::abs(applied_delta.x()) > kEpsilon;
2677 bool did_layer_consume_delta_y = std::abs(applied_delta.y()) > kEpsilon; 2687 bool did_move_layer_y = std::abs(applied_delta.y()) > kEpsilon;
2688 did_scroll_x |= did_move_layer_x;
2689 did_scroll_y |= did_move_layer_y;
2678 2690
2679 did_scroll_x |= did_layer_consume_delta_x; 2691 if (did_move_layer_x || did_move_layer_y) {
2680 did_scroll_y |= did_layer_consume_delta_y;
2681
2682 if (did_layer_consume_delta_x || did_layer_consume_delta_y) {
2683 did_lock_scrolling_layer_ = true; 2692 did_lock_scrolling_layer_ = true;
2684 2693
2685 // When scrolls are allowed to bubble, it's important that the original 2694 // When scrolls are allowed to bubble, it's important that the original
2686 // scrolling layer be preserved. This ensures that, after a scroll 2695 // scrolling layer be preserved. This ensures that, after a scroll
2687 // bubbles, the user can reverse scroll directions and immediately resume 2696 // bubbles, the user can reverse scroll directions and immediately resume
2688 // scrolling the original layer that scrolled. 2697 // scrolling the original layer that scrolled.
2689 if (!should_bubble_scrolls_) { 2698 if (!should_bubble_scrolls_) {
2690 active_tree_->SetCurrentlyScrollingLayer(layer_impl); 2699 active_tree_->SetCurrentlyScrollingLayer(layer_impl);
2691 break; 2700 break;
2692 } 2701 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 } 2735 }
2727 2736
2728 // Scrolling along an axis resets accumulated root overscroll for that axis. 2737 // Scrolling along an axis resets accumulated root overscroll for that axis.
2729 if (did_scroll_x) 2738 if (did_scroll_x)
2730 accumulated_root_overscroll_.set_x(0); 2739 accumulated_root_overscroll_.set_x(0);
2731 if (did_scroll_y) 2740 if (did_scroll_y)
2732 accumulated_root_overscroll_.set_y(0); 2741 accumulated_root_overscroll_.set_y(0);
2733 accumulated_root_overscroll_ += unused_root_delta; 2742 accumulated_root_overscroll_ += unused_root_delta;
2734 2743
2735 InputHandlerScrollResult scroll_result; 2744 InputHandlerScrollResult scroll_result;
2736 scroll_result.did_scroll = did_scroll_content; 2745 scroll_result.did_scroll = did_scroll_content || did_scroll_top_controls;
2737 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); 2746 scroll_result.did_overscroll_root = !unused_root_delta.IsZero();
2738 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; 2747 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_;
2739 scroll_result.unused_scroll_delta = unused_root_delta; 2748 scroll_result.unused_scroll_delta = unused_root_delta;
2740 return scroll_result; 2749 return scroll_result;
2741 } 2750 }
2742 2751
2743 // This implements scrolling by page as described here: 2752 // This implements scrolling by page as described here:
2744 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel 2753 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel
2745 // for events with WHEEL_PAGESCROLL set. 2754 // for events with WHEEL_PAGESCROLL set.
2746 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, 2755 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point,
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
3426 new_target.SetToMin(layer_impl->MaxScrollOffset()); 3435 new_target.SetToMin(layer_impl->MaxScrollOffset());
3427 3436
3428 curve->UpdateTarget( 3437 curve->UpdateTarget(
3429 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) 3438 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time)
3430 .InSecondsF(), 3439 .InSecondsF(),
3431 new_target); 3440 new_target);
3432 3441
3433 return true; 3442 return true;
3434 } 3443 }
3435 } // namespace cc 3444 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698