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

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

Issue 2382913003: Revert of Fix scroll chaining for non-descendants of root scroller. (Closed)
Patch Set: Created 4 years, 2 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/layers/layer_impl.cc ('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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 2549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 } 2560 }
2561 2561
2562 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && 2562 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD &&
2563 !potentially_scrolling_layer_impl) { 2563 !potentially_scrolling_layer_impl) {
2564 potentially_scrolling_layer_impl = 2564 potentially_scrolling_layer_impl =
2565 active_tree_->LayerById(scroll_node->owner_id); 2565 active_tree_->LayerById(scroll_node->owner_id);
2566 } 2566 }
2567 } 2567 }
2568 } 2568 }
2569 2569
2570 // The outer viewport layer represents the viewport. 2570 // Falling back to the root scroll layer ensures generation of root overscroll
2571 if (potentially_scrolling_layer_impl == InnerViewportScrollLayer()) 2571 // notifications. The inner viewport layer represents the viewport during
2572 potentially_scrolling_layer_impl = OuterViewportScrollLayer(); 2572 // scrolling.
2573 if (!potentially_scrolling_layer_impl)
2574 potentially_scrolling_layer_impl = InnerViewportScrollLayer();
2573 2575
2574 // Falling back to the root scroll layer ensures generation of root overscroll 2576 // The inner viewport layer represents the viewport.
2575 // notifications. 2577 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer())
2576 if (!potentially_scrolling_layer_impl) 2578 potentially_scrolling_layer_impl = InnerViewportScrollLayer();
2577 potentially_scrolling_layer_impl = OuterViewportScrollLayer();
2578 2579
2579 if (potentially_scrolling_layer_impl) { 2580 if (potentially_scrolling_layer_impl) {
2580 // Ensure that final layer scrolls on impl thread (crbug.com/625100) 2581 // Ensure that final layer scrolls on impl thread (crbug.com/625100)
2581 ScrollNode* scroll_node = 2582 ScrollNode* scroll_node =
2582 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index()); 2583 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index());
2583 ScrollStatus status = 2584 ScrollStatus status =
2584 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); 2585 TryScroll(device_viewport_point, type, scroll_tree, scroll_node);
2585 if (IsMainThreadScrolling(status, scroll_node)) { 2586 if (IsMainThreadScrolling(status, scroll_node)) {
2586 *scroll_on_main_thread = true; 2587 *scroll_on_main_thread = true;
2587 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2588 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 // that can scroll and set up an animation of its scroll offset. Note that 2841 // that can scroll and set up an animation of its scroll offset. Note that
2841 // this does not currently go through the scroll customization machinery 2842 // this does not currently go through the scroll customization machinery
2842 // that ScrollBy uses for non-animated wheel scrolls. 2843 // that ScrollBy uses for non-animated wheel scrolls.
2843 scroll_status = ScrollBegin(&scroll_state, WHEEL); 2844 scroll_status = ScrollBegin(&scroll_state, WHEEL);
2844 scroll_node = scroll_tree.CurrentlyScrollingNode(); 2845 scroll_node = scroll_tree.CurrentlyScrollingNode();
2845 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { 2846 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) {
2846 gfx::Vector2dF pending_delta = scroll_delta; 2847 gfx::Vector2dF pending_delta = scroll_delta;
2847 if (scroll_node) { 2848 if (scroll_node) {
2848 for (; scroll_tree.parent(scroll_node); 2849 for (; scroll_tree.parent(scroll_node);
2849 scroll_node = scroll_tree.parent(scroll_node)) { 2850 scroll_node = scroll_tree.parent(scroll_node)) {
2850 if (!scroll_node->scrollable) 2851 if (!scroll_node->scrollable ||
2852 scroll_node->is_outer_viewport_scroll_layer)
2851 continue; 2853 continue;
2852 2854
2853 if (scroll_node->is_outer_viewport_scroll_layer || 2855 if (scroll_node->is_inner_viewport_scroll_layer) {
2854 scroll_node->is_inner_viewport_scroll_layer) {
2855 gfx::Vector2dF scrolled = 2856 gfx::Vector2dF scrolled =
2856 viewport()->ScrollAnimated(pending_delta, delayed_by); 2857 viewport()->ScrollAnimated(pending_delta, delayed_by);
2857 // Viewport::ScrollAnimated returns pending_delta as long as it 2858 // Viewport::ScrollAnimated returns pending_delta as long as it
2858 // starts an animation. 2859 // starts an animation.
2859 if (scrolled == pending_delta) 2860 if (scrolled == pending_delta)
2860 return scroll_status; 2861 return scroll_status;
2861 break; 2862 pending_delta -= scrolled;
2863 continue;
2862 } 2864 }
2863 2865
2864 gfx::Vector2dF scroll_delta = 2866 gfx::Vector2dF scroll_delta =
2865 ComputeScrollDelta(scroll_node, pending_delta); 2867 ComputeScrollDelta(scroll_node, pending_delta);
2866 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) 2868 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by))
2867 return scroll_status; 2869 return scroll_status;
2868 2870
2869 pending_delta -= scroll_delta; 2871 pending_delta -= scroll_delta;
2870 } 2872 }
2871 } 2873 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 ScrollState* scroll_state) { 2996 ScrollState* scroll_state) {
2995 DCHECK(scroll_state); 2997 DCHECK(scroll_state);
2996 gfx::Point viewport_point(scroll_state->position_x(), 2998 gfx::Point viewport_point(scroll_state->position_x(),
2997 scroll_state->position_y()); 2999 scroll_state->position_y());
2998 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); 3000 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y());
2999 gfx::Vector2dF applied_delta; 3001 gfx::Vector2dF applied_delta;
3000 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for 3002 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for
3001 // details. 3003 // details.
3002 const float kEpsilon = 0.1f; 3004 const float kEpsilon = 0.1f;
3003 3005
3004 if (scroll_node->is_outer_viewport_scroll_layer) { 3006 if (scroll_node->is_inner_viewport_scroll_layer) {
3005 bool affect_top_controls = !wheel_scrolling_; 3007 bool affect_top_controls = !wheel_scrolling_;
3006 Viewport::ScrollResult result = viewport()->ScrollBy( 3008 Viewport::ScrollResult result = viewport()->ScrollBy(
3007 delta, viewport_point, scroll_state->is_direct_manipulation(), 3009 delta, viewport_point, scroll_state->is_direct_manipulation(),
3008 affect_top_controls); 3010 affect_top_controls);
3009 applied_delta = result.consumed_delta; 3011 applied_delta = result.consumed_delta;
3010 scroll_state->set_caused_scroll( 3012 scroll_state->set_caused_scroll(
3011 std::abs(result.content_scrolled_delta.x()) > kEpsilon, 3013 std::abs(result.content_scrolled_delta.x()) > kEpsilon,
3012 std::abs(result.content_scrolled_delta.y()) > kEpsilon); 3014 std::abs(result.content_scrolled_delta.y()) > kEpsilon);
3013 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); 3015 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y());
3014 } else { 3016 } else {
3015 applied_delta = ScrollSingleNode( 3017 applied_delta = ScrollSingleNode(
3016 scroll_node, delta, viewport_point, 3018 scroll_node, delta, viewport_point,
3017 scroll_state->is_direct_manipulation(), 3019 scroll_state->is_direct_manipulation(),
3018 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree); 3020 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree);
3019 } 3021 }
3020 3022
3021 // If the layer wasn't able to move, try the next one in the hierarchy. 3023 // If the layer wasn't able to move, try the next one in the hierarchy.
3022 bool scrolled = std::abs(applied_delta.x()) > kEpsilon; 3024 bool scrolled = std::abs(applied_delta.x()) > kEpsilon;
3023 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon; 3025 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon;
3024 3026
3025 if (scrolled && !scroll_node->is_outer_viewport_scroll_layer) { 3027 if (scrolled && !scroll_node->is_inner_viewport_scroll_layer) {
3026 // If the applied delta is within 45 degrees of the input 3028 // If the applied delta is within 45 degrees of the input
3027 // delta, bail out to make it easier to scroll just one layer 3029 // delta, bail out to make it easier to scroll just one layer
3028 // in one direction without affecting any of its parents. 3030 // in one direction without affecting any of its parents.
3029 float angle_threshold = 45; 3031 float angle_threshold = 45;
3030 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) < 3032 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) <
3031 angle_threshold) { 3033 angle_threshold) {
3032 applied_delta = delta; 3034 applied_delta = delta;
3033 } else { 3035 } else {
3034 // Allow further movement only on an axis perpendicular to the direction 3036 // Allow further movement only on an axis perpendicular to the direction
3035 // in which the layer moved. 3037 // in which the layer moved.
(...skipping 16 matching lines...) Expand all
3052 // sides but it may become a non issue if we get rid of scroll chaining (see 3054 // sides but it may become a non issue if we get rid of scroll chaining (see
3053 // crbug.com/526462) 3055 // crbug.com/526462)
3054 std::list<const ScrollNode*> current_scroll_chain; 3056 std::list<const ScrollNode*> current_scroll_chain;
3055 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 3057 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
3056 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); 3058 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
3057 if (scroll_node) { 3059 if (scroll_node) {
3058 for (; scroll_tree.parent(scroll_node); 3060 for (; scroll_tree.parent(scroll_node);
3059 scroll_node = scroll_tree.parent(scroll_node)) { 3061 scroll_node = scroll_tree.parent(scroll_node)) {
3060 if (scroll_node->is_outer_viewport_scroll_layer) { 3062 if (scroll_node->is_outer_viewport_scroll_layer) {
3061 // Don't chain scrolls past the outer viewport scroll layer. Once we 3063 // Don't chain scrolls past the outer viewport scroll layer. Once we
3062 // reach that, we're viewport scrolling which is special and handled by 3064 // reach that, we should scroll the viewport, which is represented by
3063 // cc's Viewport class. 3065 // the inner viewport scroll layer.
3064 current_scroll_chain.push_front(scroll_node); 3066 ScrollNode* inner_viewport_scroll_node =
3067 scroll_tree.Node(InnerViewportScrollLayer()->scroll_tree_index());
3068 current_scroll_chain.push_front(inner_viewport_scroll_node);
3065 break; 3069 break;
3066 } 3070 }
3067 3071
3068 if (!scroll_node->scrollable) 3072 if (!scroll_node->scrollable)
3069 continue; 3073 continue;
3070 3074
3071 current_scroll_chain.push_front(scroll_node); 3075 current_scroll_chain.push_front(scroll_node);
3072 } 3076 }
3073 } 3077 }
3074 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, 3078 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3228 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 3232 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
3229 HandleMouseOverScrollbar(layer_impl); 3233 HandleMouseOverScrollbar(layer_impl);
3230 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) 3234 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID)
3231 return; 3235 return;
3232 3236
3233 bool scroll_on_main_thread = false; 3237 bool scroll_on_main_thread = false;
3234 uint32_t main_thread_scrolling_reasons; 3238 uint32_t main_thread_scrolling_reasons;
3235 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( 3239 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint(
3236 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, 3240 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl,
3237 &scroll_on_main_thread, &main_thread_scrolling_reasons); 3241 &scroll_on_main_thread, &main_thread_scrolling_reasons);
3242 if (scroll_layer_impl == InnerViewportScrollLayer())
3243 scroll_layer_impl = OuterViewportScrollLayer();
3238 if (scroll_on_main_thread || !scroll_layer_impl) 3244 if (scroll_on_main_thread || !scroll_layer_impl)
3239 return; 3245 return;
3240 3246
3241 ScrollbarAnimationController* animation_controller = 3247 ScrollbarAnimationController* animation_controller =
3242 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); 3248 ScrollbarAnimationControllerForId(scroll_layer_impl->id());
3243 if (!animation_controller) 3249 if (!animation_controller)
3244 return; 3250 return;
3245 3251
3246 float distance_to_scrollbar = std::numeric_limits<float>::max(); 3252 float distance_to_scrollbar = std::numeric_limits<float>::max();
3247 for (ScrollbarLayerImplBase* scrollbar : 3253 for (ScrollbarLayerImplBase* scrollbar :
(...skipping 27 matching lines...) Expand all
3275 scroll_layer_id_when_mouse_over_scrollbar_); 3281 scroll_layer_id_when_mouse_over_scrollbar_);
3276 if (new_animation_controller) 3282 if (new_animation_controller)
3277 new_animation_controller->DidMouseMoveNear(0); 3283 new_animation_controller->DidMouseMoveNear(0);
3278 } 3284 }
3279 3285
3280 void LayerTreeHostImpl::PinchGestureBegin() { 3286 void LayerTreeHostImpl::PinchGestureBegin() {
3281 pinch_gesture_active_ = true; 3287 pinch_gesture_active_ = true;
3282 client_->RenewTreePriority(); 3288 client_->RenewTreePriority();
3283 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); 3289 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer();
3284 active_tree_->SetCurrentlyScrollingLayer( 3290 active_tree_->SetCurrentlyScrollingLayer(
3285 active_tree_->OuterViewportScrollLayer()); 3291 active_tree_->InnerViewportScrollLayer());
3286 top_controls_manager_->PinchBegin(); 3292 top_controls_manager_->PinchBegin();
3287 } 3293 }
3288 3294
3289 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 3295 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
3290 const gfx::Point& anchor) { 3296 const gfx::Point& anchor) {
3291 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); 3297 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate");
3292 if (!InnerViewportScrollLayer()) 3298 if (!InnerViewportScrollLayer())
3293 return; 3299 return;
3294 viewport()->PinchUpdate(magnify_delta, anchor); 3300 viewport()->PinchUpdate(magnify_delta, anchor);
3295 client_->SetNeedsCommitOnImplThread(); 3301 client_->SetNeedsCommitOnImplThread();
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
4147 if (is_visible) { 4153 if (is_visible) {
4148 worker_context_visibility_ = 4154 worker_context_visibility_ =
4149 worker_context->CacheController()->ClientBecameVisible(); 4155 worker_context->CacheController()->ClientBecameVisible();
4150 } else { 4156 } else {
4151 worker_context->CacheController()->ClientBecameNotVisible( 4157 worker_context->CacheController()->ClientBecameNotVisible(
4152 std::move(worker_context_visibility_)); 4158 std::move(worker_context_visibility_));
4153 } 4159 }
4154 } 4160 }
4155 4161
4156 } // namespace cc 4162 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698